mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Merge pull request #817 from Microsoft/renameEnumMember
Fixes the name displayed in the rename dialog to be just symbol name instead of qualified path
This commit is contained in:
commit
c40f02a248
@ -413,10 +413,14 @@ module FourSlash {
|
||||
}
|
||||
|
||||
private raiseError(message: string) {
|
||||
message = "Marker: " + currentTestState.lastKnownMarker + "\n" + message;
|
||||
message = this.messageAtLastKnownMarker(message);
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
private messageAtLastKnownMarker(message: string) {
|
||||
return "Marker: " + currentTestState.lastKnownMarker + "\n" + message;
|
||||
}
|
||||
|
||||
private getDiagnostics(fileName: string): ts.Diagnostic[] {
|
||||
var syntacticErrors = this.languageService.getSyntacticDiagnostics(fileName);
|
||||
var semanticErrors = this.languageService.getSemanticDiagnostics(fileName);
|
||||
@ -778,29 +782,29 @@ module FourSlash {
|
||||
|
||||
if (negative) {
|
||||
if (expectedTypeName !== undefined) {
|
||||
assert.notEqual(actualQuickInfoMemberName, expectedTypeName, this.assertionMessage("quick info member name", actualQuickInfoMemberName, expectedTypeName));
|
||||
assert.notEqual(actualQuickInfoMemberName, expectedTypeName, this.messageAtLastKnownMarker("quick info member name"));
|
||||
}
|
||||
if (docComment != undefined) {
|
||||
assert.notEqual(actualQuickInfoDocComment, docComment, this.assertionMessage("quick info doc comment", actualQuickInfoDocComment, docComment));
|
||||
assert.notEqual(actualQuickInfoDocComment, docComment, this.messageAtLastKnownMarker("quick info doc comment"));
|
||||
}
|
||||
if (symbolName !== undefined) {
|
||||
assert.notEqual(actualQuickInfoSymbolName, symbolName, this.assertionMessage("quick info symbol name", actualQuickInfoSymbolName, symbolName));
|
||||
assert.notEqual(actualQuickInfoSymbolName, symbolName, this.messageAtLastKnownMarker("quick info symbol name"));
|
||||
}
|
||||
if (kind !== undefined) {
|
||||
assert.notEqual(actualQuickInfoKind, kind, this.assertionMessage("quick info kind", actualQuickInfoKind, kind));
|
||||
assert.notEqual(actualQuickInfoKind, kind, this.messageAtLastKnownMarker("quick info kind"));
|
||||
}
|
||||
} else {
|
||||
if (expectedTypeName !== undefined) {
|
||||
assert.equal(actualQuickInfoMemberName, expectedTypeName, this.assertionMessage("quick info member", actualQuickInfoMemberName, expectedTypeName));
|
||||
assert.equal(actualQuickInfoMemberName, expectedTypeName, this.messageAtLastKnownMarker("quick info member"));
|
||||
}
|
||||
if (docComment != undefined) {
|
||||
assert.equal(actualQuickInfoDocComment, docComment, this.assertionMessage("quick info doc", actualQuickInfoDocComment, docComment));
|
||||
assert.equal(actualQuickInfoDocComment, docComment, this.messageAtLastKnownMarker("quick info doc"));
|
||||
}
|
||||
if (symbolName !== undefined) {
|
||||
assert.equal(actualQuickInfoSymbolName, symbolName, this.assertionMessage("quick info symbol name", actualQuickInfoSymbolName, symbolName));
|
||||
assert.equal(actualQuickInfoSymbolName, symbolName, this.messageAtLastKnownMarker("quick info symbol name"));
|
||||
}
|
||||
if (kind !== undefined) {
|
||||
assert.equal(actualQuickInfoKind, kind, this.assertionMessage("quick info kind", actualQuickInfoKind, kind));
|
||||
assert.equal(actualQuickInfoKind, kind, this.messageAtLastKnownMarker("quick info kind"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1480,6 +1484,21 @@ module FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyDefinitionsName(negative: boolean, expectedName: string, expectedContainerName: string) {
|
||||
this.taoInvalidReason = 'verifyDefinititionsInfo NYI';
|
||||
|
||||
var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
var actualDefinitionName = definitions && definitions.length ? definitions[0].name : "";
|
||||
var actualDefinitionContainerName = definitions && definitions.length ? definitions[0].containerName : "";
|
||||
if (negative) {
|
||||
assert.notEqual(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
|
||||
assert.notEqual(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Container Name"));
|
||||
} else {
|
||||
assert.equal(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
|
||||
assert.equal(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Container Name"));
|
||||
}
|
||||
}
|
||||
|
||||
public getMarkers(): Marker[] {
|
||||
// Return a copy of the list
|
||||
return this.testData.markers.slice(0);
|
||||
|
||||
@ -2606,7 +2606,7 @@ module ts {
|
||||
var result: DefinitionInfo[] = [];
|
||||
|
||||
var declarations = symbol.getDeclarations();
|
||||
var symbolName = typeInfoResolver.symbolToString(symbol, node);
|
||||
var symbolName = typeInfoResolver.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
||||
var symbolKind = getSymbolKind(symbol);
|
||||
var containerSymbol = symbol.parent;
|
||||
var containerName = containerSymbol ? typeInfoResolver.symbolToString(containerSymbol, node) : "";
|
||||
|
||||
11
tests/cases/fourslash/definitionNameOnEnumMember.ts
Normal file
11
tests/cases/fourslash/definitionNameOnEnumMember.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////enum e {
|
||||
//// firstMember,
|
||||
//// secondMember,
|
||||
//// thirdMember
|
||||
////}
|
||||
////var enumMember = e./*1*/thirdMember;
|
||||
|
||||
goTo.marker("1");
|
||||
verify.verifyDefinitionsName("thirdMember", "e");
|
||||
@ -237,6 +237,10 @@ module FourSlashInterface {
|
||||
public definitionLocationExists() {
|
||||
FourSlash.currentTestState.verifyDefinitionLocationExists(this.negative);
|
||||
}
|
||||
|
||||
public verifyDefinitionsName(name: string, containerName: string) {
|
||||
FourSlash.currentTestState.verifyDefinitionsName(this.negative, name, containerName);
|
||||
}
|
||||
}
|
||||
|
||||
export class verify extends verifyNegatable {
|
||||
|
||||
11
tests/cases/fourslash/renameNameOnEnumMember.ts
Normal file
11
tests/cases/fourslash/renameNameOnEnumMember.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////enum e {
|
||||
//// firstMember,
|
||||
//// secondMember,
|
||||
//// thirdMember
|
||||
////}
|
||||
////var enumMember = e.[|/**/thirdMember|];
|
||||
|
||||
goTo.marker("");
|
||||
verify.renameInfoSucceeded("thirdMember", "e.thirdMember");
|
||||
Loading…
x
Reference in New Issue
Block a user