mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Respond to code review comments
This commit is contained in:
@@ -1573,7 +1573,8 @@ module FourSlash {
|
||||
public goToTypeDefinition(definitionIndex: number) {
|
||||
if (definitionIndex === 0) {
|
||||
this.scenarioActions.push('<GoToTypeDefinition />');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.taoInvalidReason = 'GoToTypeDefinition not supported for non-zero definition indices';
|
||||
}
|
||||
|
||||
@@ -1610,8 +1611,18 @@ module FourSlash {
|
||||
var assertFn = negative ? assert.notEqual : assert.equal;
|
||||
|
||||
var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
var actualCount = definitions && definitions.length || 0;
|
||||
|
||||
assertFn(definitions.length, expectedCount, this.messageAtLastKnownMarker("Definitions Count"));
|
||||
assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Definitions Count"));
|
||||
}
|
||||
|
||||
public verifyTypeDefinitionsCount(negative: boolean, expectedCount: number) {
|
||||
var assertFn = negative ? assert.notEqual : assert.equal;
|
||||
|
||||
var definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
var actualCount = definitions && definitions.length || 0;
|
||||
|
||||
assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Type definitions Count"));
|
||||
}
|
||||
|
||||
public verifyDefinitionsName(negative: boolean, expectedName: string, expectedContainerName: string) {
|
||||
|
||||
@@ -3876,7 +3876,7 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
function getDefintionFromSymbol(symbol: Symbol, node: Node): DefinitionInfo[]{
|
||||
function getDefinitionFromSymbol(symbol: Symbol, node: Node): DefinitionInfo[] {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
let result: DefinitionInfo[] = [];
|
||||
let declarations = symbol.getDeclarations();
|
||||
@@ -3939,7 +3939,6 @@ module ts {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Goto definition
|
||||
@@ -4016,7 +4015,7 @@ module ts {
|
||||
declaration => createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName));
|
||||
}
|
||||
|
||||
return getDefintionFromSymbol(symbol, node);
|
||||
return getDefinitionFromSymbol(symbol, node);
|
||||
}
|
||||
|
||||
/// Goto type
|
||||
@@ -4046,7 +4045,7 @@ module ts {
|
||||
var result: DefinitionInfo[] = [];
|
||||
forEach((<UnionType>type).types, t => {
|
||||
if (t.symbol) {
|
||||
result.push(...getDefintionFromSymbol(t.symbol, node));
|
||||
result.push(...getDefinitionFromSymbol(t.symbol, node));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
@@ -4056,7 +4055,7 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return getDefintionFromSymbol(type.symbol, node);
|
||||
return getDefinitionFromSymbol(type.symbol, node);
|
||||
}
|
||||
|
||||
function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
|
||||
@@ -561,7 +561,7 @@ module ts {
|
||||
return this.forwardJSONCall(
|
||||
"getDefinitionAtPosition('" + fileName + "', " + position + ")",
|
||||
() => {
|
||||
return this.languageService.getDefinitionAtPosition(fileName, position);
|
||||
return this.languageService.getTypeDefinitionAtPosition(fileName, position);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user