MCPcopy
hub / github.com/microsoft/pyright / findNodeByPosition

Method findNodeByPosition

server/src/analyzer/parseTreeUtils.ts:20–29  ·  view source on GitHub ↗
(node: ParseNode, position: DiagnosticTextPosition,
            lines: TextRangeCollection<TextRange>)

Source from the content-addressed store, hash-verified

18export class ParseTreeUtils {
19 // Returns the deepest node that contains the specified position.
20 static findNodeByPosition(node: ParseNode, position: DiagnosticTextPosition,
21 lines: TextRangeCollection<TextRange>): ParseNode | undefined {
22
23 let offset = convertPositionToOffset(position, lines);
24 if (offset === undefined) {
25 return undefined;
26 }
27
28 return ParseTreeUtils.findNodeByOffset(node, offset);
29 }
30
31 // Returns the deepest node that contains the specified offset.
32 static findNodeByOffset(node: ParseNode, offset: number): ParseNode | undefined {

Callers

nothing calls this directly

Calls 2

convertPositionToOffsetFunction · 0.90
findNodeByOffsetMethod · 0.80

Tested by

no test coverage detected