How to use the graphql-language-service-utils.locToRange function in graphql-language-service-utils

To help you get started, we’ve selected a few graphql-language-service-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql / graphiql / src / interfaces / getDefinition.js View on Github external
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,
  };
}
github graphql / graphiql / src / interfaces / getDefinition.js View on Github external
    queryRange: definitions.map(_ => locToRange(text, fragment.loc)),
  };
github graphql / graphiql / src / interfaces / getDefinition.js View on Github external
export function getDefinitionQueryResultForDefinitionNode(
  path: Uri,
  text: string,
  definition: FragmentDefinitionNode,
): DefinitionQueryResult {
  return {
    definitions: [getDefinitionForFragmentDefinition(path, text, definition)],
    queryRange: [locToRange(text, definition.name.loc)],
  };
}
github graphql / graphiql / packages / graphql-language-service-interface / src / getDefinition.ts View on Github external
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);
}