mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Fixes the quickInfo and completion list details for let and adds test cases for let and const
Handles #1083
This commit is contained in:
parent
a390afb4f5
commit
49ae5c7117
@ -238,6 +238,9 @@ module ts.NavigationBar {
|
||||
if (node.flags & NodeFlags.Const) {
|
||||
return createItem(node, getTextOfNode((<VariableDeclaration>node).name), ts.ScriptElementKind.constantElement);
|
||||
}
|
||||
else if (node.flags & NodeFlags.Let) {
|
||||
return createItem(node, getTextOfNode((<VariableDeclaration>node).name), ts.ScriptElementKind.letElement);
|
||||
}
|
||||
else {
|
||||
return createItem(node, getTextOfNode((<VariableDeclaration>node).name), ts.ScriptElementKind.variableElement);
|
||||
}
|
||||
|
||||
@ -1225,6 +1225,8 @@ module ts {
|
||||
static alias = "alias";
|
||||
|
||||
static constantElement = "constant";
|
||||
|
||||
static letElement = "let";
|
||||
}
|
||||
|
||||
export class ScriptElementKindModifier {
|
||||
@ -2857,9 +2859,12 @@ module ts {
|
||||
if (isFirstDeclarationOfSymbolParameter(symbol)) {
|
||||
return ScriptElementKind.parameterElement;
|
||||
}
|
||||
else if(symbol.valueDeclaration && symbol.valueDeclaration.flags & NodeFlags.Const) {
|
||||
else if (symbol.valueDeclaration && symbol.valueDeclaration.flags & NodeFlags.Const) {
|
||||
return ScriptElementKind.constantElement;
|
||||
}
|
||||
else if (forEach(symbol.declarations, declaration => declaration.flags & NodeFlags.Let)) {
|
||||
return ScriptElementKind.letElement;
|
||||
}
|
||||
return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement;
|
||||
}
|
||||
if (flags & SymbolFlags.Function) return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement;
|
||||
@ -2915,7 +2920,11 @@ module ts {
|
||||
case SyntaxKind.InterfaceDeclaration: return ScriptElementKind.interfaceElement;
|
||||
case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement;
|
||||
case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement;
|
||||
case SyntaxKind.VariableDeclaration: return node.flags & NodeFlags.Const ? ScriptElementKind.constantElement: ScriptElementKind.variableElement;
|
||||
case SyntaxKind.VariableDeclaration: return node.flags & NodeFlags.Const ?
|
||||
ScriptElementKind.constantElement :
|
||||
node.flags & NodeFlags.Let ?
|
||||
ScriptElementKind.letElement :
|
||||
ScriptElementKind.variableElement;
|
||||
case SyntaxKind.FunctionDeclaration: return ScriptElementKind.functionElement;
|
||||
case SyntaxKind.GetAccessor: return ScriptElementKind.memberGetAccessorElement;
|
||||
case SyntaxKind.SetAccessor: return ScriptElementKind.memberSetAccessorElement;
|
||||
|
||||
37
tests/cases/fourslash/constQuickInfoAndCompletionList.ts
Normal file
37
tests/cases/fourslash/constQuickInfoAndCompletionList.ts
Normal file
@ -0,0 +1,37 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////const /*1*/a = 10;
|
||||
////var x = /*2*/a;
|
||||
/////*3*/
|
||||
////function foo() {
|
||||
//// const /*4*/b = 20;
|
||||
//// var y = /*5*/b;
|
||||
//// var z = /*6*/a;
|
||||
//// /*7*/
|
||||
////}
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs("(constant) a: number");
|
||||
|
||||
goTo.marker('2');
|
||||
verify.completionListContains("a", "(constant) a: number");
|
||||
verify.quickInfoIs("(constant) a: number");
|
||||
|
||||
goTo.marker('3');
|
||||
verify.completionListContains("a", "(constant) a: number");
|
||||
|
||||
goTo.marker('4');
|
||||
verify.quickInfoIs("(constant) b: number");
|
||||
|
||||
goTo.marker('5');
|
||||
verify.completionListContains("a", "(constant) a: number");
|
||||
verify.completionListContains("b", "(constant) b: number");
|
||||
verify.quickInfoIs("(constant) b: number");
|
||||
|
||||
goTo.marker('6');
|
||||
verify.completionListContains("a", "(constant) a: number");
|
||||
verify.completionListContains("b", "(constant) b: number");
|
||||
verify.quickInfoIs("(constant) a: number");
|
||||
|
||||
goTo.marker('7');
|
||||
verify.completionListContains("a", "(constant) a: number");
|
||||
verify.completionListContains("b", "(constant) b: number");
|
||||
28
tests/cases/fourslash/letQuickInfoAndCompletionList.ts
Normal file
28
tests/cases/fourslash/letQuickInfoAndCompletionList.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////let /*1*/a = 10;
|
||||
/////*2*/a = 30;
|
||||
////function foo() {
|
||||
//// let /*3*/b = 20;
|
||||
//// /*4*/b = /*5*/a;
|
||||
////}
|
||||
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs("(let) a: number");
|
||||
|
||||
goTo.marker('2');
|
||||
verify.completionListContains("a", "(let) a: number");
|
||||
verify.quickInfoIs("(let) a: number");
|
||||
|
||||
goTo.marker('3');
|
||||
verify.quickInfoIs("(let) b: number");
|
||||
|
||||
goTo.marker('4');
|
||||
verify.completionListContains("a", "(let) a: number");
|
||||
verify.completionListContains("b", "(let) b: number");
|
||||
verify.quickInfoIs("(let) b: number");
|
||||
|
||||
goTo.marker('5');
|
||||
verify.completionListContains("a", "(let) a: number");
|
||||
verify.completionListContains("b", "(let) b: number");
|
||||
verify.quickInfoIs("(let) a: number");
|
||||
13
tests/cases/fourslash/navbar_let.ts
Normal file
13
tests/cases/fourslash/navbar_let.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// {| "itemName": "c", "kind": "let", "parentName": "" |}let c = 0;
|
||||
|
||||
test.markers().forEach(marker => {
|
||||
verify.getScriptLexicalStructureListContains(
|
||||
marker.data.itemName,
|
||||
marker.data.kind,
|
||||
marker.fileName,
|
||||
marker.data.parentName,
|
||||
marker.data.isAdditionalRange,
|
||||
marker.position);
|
||||
});
|
||||
16
tests/cases/fourslash/navigateItemsConst.ts
Normal file
16
tests/cases/fourslash/navigateItemsConst.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////{| "itemName": "c", "kind": "constant", "parentName": "" |}const c = 10;
|
||||
////function foo() {
|
||||
//// {| "itemName": "d", "kind": "constant", "parentName": "foo" |}const d = 10;
|
||||
////}
|
||||
|
||||
test.markers().forEach(marker => {
|
||||
verify.navigationItemsListContains(
|
||||
marker.data.itemName,
|
||||
marker.data.kind,
|
||||
marker.data.itemName,
|
||||
"exact",
|
||||
marker.fileName,
|
||||
marker.data.parentName);
|
||||
});
|
||||
16
tests/cases/fourslash/navigateItemsLet.ts
Normal file
16
tests/cases/fourslash/navigateItemsLet.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////{| "itemName": "c", "kind": "let", "parentName": "" |}let c = 10;
|
||||
////function foo() {
|
||||
//// {| "itemName": "d", "kind": "let", "parentName": "foo" |}let d = 10;
|
||||
////}
|
||||
|
||||
test.markers().forEach(marker => {
|
||||
verify.navigationItemsListContains(
|
||||
marker.data.itemName,
|
||||
marker.data.kind,
|
||||
marker.data.itemName,
|
||||
"exact",
|
||||
marker.fileName,
|
||||
marker.data.parentName);
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user