diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index de2d75286dc..73e96f4e7aa 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -43,21 +43,34 @@ module ts { return node.pos; } + export function isMissingNode(node: Node) { + return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken; + } + export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. - if (node.pos === node.end) { + if (isMissingNode(node)) { return node.pos; } + return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string { + if (isMissingNode(node)) { + return ""; + } + var text = sourceFile.text; return text.substring(skipTrivia(text, node.pos), node.end); } export function getTextOfNodeFromSourceText(sourceText: string, node: Node): string { + if (isMissingNode(node)) { + return ""; + } + return sourceText.substring(skipTrivia(sourceText, node.pos), node.end); } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index deb779bea2c..0ea5e3532ae 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -203,7 +203,6 @@ module ts.NavigationBar { if ((node.flags & NodeFlags.Modifier) === 0) { return undefined; } - return createItem(node, getTextOfNode((node).name), ts.ScriptElementKind.memberVariableElement); case SyntaxKind.Method: