Skip to content

Commit f948f5d

Browse files
Re-added fourslash tests, corrected failures.
1 parent 144eb8d commit f948f5d

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

src/compiler/checker.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ module ts {
1111
var nextNodeId = 1;
1212
var nextMergeId = 1;
1313

14+
export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration {
15+
var declarations = symbol.declarations;
16+
for (var i = 0; i < declarations.length; i++) {
17+
var declaration = declarations[i];
18+
if (declaration.kind === kind) {
19+
return declaration;
20+
}
21+
}
22+
23+
return undefined;
24+
}
25+
1426
/// fullTypeCheck denotes if this instance of the typechecker will be used to get semantic diagnostics.
1527
/// If fullTypeCheck === true - then typechecker should do every possible check to produce all errors
1628
/// If fullTypeCheck === false - typechecker can shortcut and skip checks that only produce errors.
@@ -570,18 +582,6 @@ module ts {
570582
return false;
571583
}
572584

573-
function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration {
574-
var declarations = symbol.declarations;
575-
for (var i = 0; i < declarations.length; i++) {
576-
var declaration = declarations[i];
577-
if (declaration.kind === kind) {
578-
return declaration;
579-
}
580-
}
581-
582-
return undefined;
583-
}
584-
585585
function findConstructorDeclaration(node: ClassDeclaration): ConstructorDeclaration {
586586
var members = node.members;
587587
for (var i = 0; i < members.length; i++) {

src/harness/fourslash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ module FourSlash {
607607

608608
for (var i = 0; i < references.length; i++) {
609609
var reference = references[i];
610-
if (reference && reference.fileName === fileName && reference.minChar === start && reference.limChar === end) {
610+
if (reference && reference.fileName === fileName && reference.textSpan.start() === start && reference.textSpan.end() === end) {
611611
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
612612
throw new Error('verifyReferencesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.');
613613
}

src/services/services.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,7 @@ module ts {
22242224
var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), symbol.getDeclarations());
22252225

22262226
// Get the text to search for, we need to normalize it as external module names will have quote
2227-
var symbolName = getNormalizedSymbolName(symbol.getName());
2227+
var symbolName = getNormalizedSymbolName(symbol);
22282228

22292229
var scope = getSymbolScope(symbol);
22302230

@@ -2245,7 +2245,17 @@ module ts {
22452245

22462246
return result;
22472247

2248-
function getNormalizedSymbolName(name: string): string {
2248+
function getNormalizedSymbolName(symbol: Symbol): string {
2249+
// Special case for function expressions, whose names are solely local to their bodies.
2250+
var functionExpression = getDeclarationOfKind(symbol, SyntaxKind.FunctionExpression);
2251+
2252+
if (functionExpression && functionExpression.name) {
2253+
var name = functionExpression.name.text;
2254+
}
2255+
else {
2256+
var name = symbol.name;
2257+
}
2258+
22492259
var length = name.length;
22502260
if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) {
22512261
return name.substring(1, length - 1);

0 commit comments

Comments
 (0)