update getSymbolInfo

This commit is contained in:
Mohamed Hegazy 2014-08-21 00:13:29 -07:00
parent e0ffc47acc
commit bbeeb8df7f
4 changed files with 53 additions and 14 deletions

View File

@ -6849,6 +6849,11 @@ module ts {
}
function getSymbolInfo(node: Node) {
if (isDeclarationOrFunctionExpressionOrCatchVariableName(node)) {
// In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration
return getSymbolOfNode(node.parent);
}
switch (node.kind) {
case SyntaxKind.Identifier:
case SyntaxKind.PropertyAccess:
@ -6890,18 +6895,6 @@ module ts {
return moduleType ? moduleType.symbol : undefined;
}
break;
// External module name in an ambient declaration
case SyntaxKind.ModuleDeclaration:
// Property with name as string or numeric literal
case SyntaxKind.Property:
case SyntaxKind.PropertyAssignment:
// Enum member with string or numeric literal name
case SyntaxKind.EnumMember:
if ((<Declaration>node.parent).name === node) {
return getSymbolOfNode(node.parent);
}
break;
}
break;
}

View File

@ -2761,12 +2761,28 @@ module ts {
/// Classifier
export function createClassifier(host: Logger): Classifier {
var scanner: Scanner;
var noRegexTable: boolean[];
var noRegexTable: boolean[];
/// We do not have a full parser support to know when we should parse a regex or not
/// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where
/// we have a series of divide operator. this list allows us to be more accurate by ruling out
/// locations where a regexp cannot exist.
if (!noRegexTable) { noRegexTable = []; noRegexTable[SyntaxKind.Identifier] = true; noRegexTable[SyntaxKind.StringLiteral] = true; noRegexTable[SyntaxKind.NumericLiteral] = true; noRegexTable[SyntaxKind.RegularExpressionLiteral] = true; noRegexTable[SyntaxKind.ThisKeyword] = true; noRegexTable[SyntaxKind.PlusPlusToken] = true; noRegexTable[SyntaxKind.MinusMinusToken] = true; noRegexTable[SyntaxKind.CloseParenToken] = true; noRegexTable[SyntaxKind.CloseBracketToken] = true; noRegexTable[SyntaxKind.CloseBraceToken] = true; noRegexTable[SyntaxKind.TrueKeyword] = true; noRegexTable[SyntaxKind.FalseKeyword] = true; }
if (!noRegexTable) {
noRegexTable = [];
noRegexTable[SyntaxKind.Identifier] = true;
noRegexTable[SyntaxKind.StringLiteral] = true;
noRegexTable[SyntaxKind.NumericLiteral] = true;
noRegexTable[SyntaxKind.RegularExpressionLiteral] = true;
noRegexTable[SyntaxKind.ThisKeyword] = true;
noRegexTable[SyntaxKind.PlusPlusToken] = true;
noRegexTable[SyntaxKind.MinusMinusToken] = true;
noRegexTable[SyntaxKind.CloseParenToken] = true;
noRegexTable[SyntaxKind.CloseBracketToken] = true;
noRegexTable[SyntaxKind.CloseBraceToken] = true;
noRegexTable[SyntaxKind.TrueKeyword] = true;
noRegexTable[SyntaxKind.FalseKeyword] = true;
}
function getClassificationsForLine(text: string, lexState: EndOfLineState): ClassificationResult {
var offset = 0;
var lastTokenOrCommentEnd = 0;

View File

@ -0,0 +1,15 @@
/// <reference path='fourslash.ts'/>
////class Foo {
//// /*1*/"blah"() { return 0; }
////}
////
////var x: Foo;
////x./*2*/blah;
goTo.marker("1");
verify.referencesCountIs(2);
goTo.marker("2");
verify.referencesCountIs(2);

View File

@ -0,0 +1,15 @@
/// <reference path='fourslash.ts'/>
////class Foo2 {
//// get /*1*/"42"() { return 0; }
//// set /*2*/42(n) { }
////}
////
////var y: Foo2;
////y[42];
goTo.marker("1");
verify.referencesCountIs(3);
goTo.marker("2");
verify.referencesCountIs(3);