Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getDefinitionForFragmentDefinition(
path: Uri,
text: string,
definition: FragmentDefinitionNode,
): Definition {
return {
path,
position: offsetToPosition(text, definition.name.loc.start),
range: locToRange(text, definition.loc),
name: definition.name.value,
language: LANGUAGE,
// This is a file inside the project root, good enough for now
projectRoot: path,
};
}
queryRange: definitions.map(_ => locToRange(text, fragment.loc)),
};
export function getDefinitionQueryResultForDefinitionNode(
path: Uri,
text: string,
definition: FragmentDefinitionNode,
): DefinitionQueryResult {
return {
definitions: [getDefinitionForFragmentDefinition(path, text, definition)],
queryRange: [locToRange(text, definition.name.loc)],
};
}
function getRange(text: string, node: ASTNode): Range {
const location = node.loc as Location;
invariant(location, 'Expected ASTNode to have a location.');
return locToRange(text, location);
}