Fixed navigation expansion for missing identifier nodes.

This commit is contained in:
Daniel Rosenwasser 2014-12-03 14:53:47 -08:00
parent 2178aec5e5
commit 4d0edb51b3
2 changed files with 14 additions and 2 deletions

View File

@ -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);
}

View File

@ -203,7 +203,6 @@ module ts.NavigationBar {
if ((node.flags & NodeFlags.Modifier) === 0) {
return undefined;
}
return createItem(node, getTextOfNode((<ParameterDeclaration>node).name), ts.ScriptElementKind.memberVariableElement);
case SyntaxKind.Method: