mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-13 23:48:54 -05:00
Merge pull request #13597 from Microsoft/enum_member
Set ScriptElementKind for enum members to "enum member" instead of "const"
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
namespace ts.SymbolDisplay {
|
||||
// TODO(drosen): use contextual SemanticMeaning.
|
||||
export function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): string {
|
||||
const flags = symbol.getFlags();
|
||||
const { flags } = symbol;
|
||||
|
||||
if (flags & SymbolFlags.Class) return getDeclarationOfKind(symbol, SyntaxKind.ClassExpression) ?
|
||||
ScriptElementKind.localClassElement : ScriptElementKind.classElement;
|
||||
@@ -11,10 +11,10 @@ namespace ts.SymbolDisplay {
|
||||
if (flags & SymbolFlags.Interface) return ScriptElementKind.interfaceElement;
|
||||
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
|
||||
|
||||
const result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location);
|
||||
const result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location);
|
||||
if (result === ScriptElementKind.unknown) {
|
||||
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
|
||||
if (flags & SymbolFlags.EnumMember) return ScriptElementKind.variableElement;
|
||||
if (flags & SymbolFlags.EnumMember) return ScriptElementKind.enumMemberElement;
|
||||
if (flags & SymbolFlags.Alias) return ScriptElementKind.alias;
|
||||
if (flags & SymbolFlags.Module) return ScriptElementKind.moduleElement;
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace ts.SymbolDisplay {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker: TypeChecker, symbol: Symbol, flags: SymbolFlags, location: Node) {
|
||||
function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker: TypeChecker, symbol: Symbol, location: Node) {
|
||||
if (typeChecker.isUndefinedSymbol(symbol)) {
|
||||
return ScriptElementKind.variableElement;
|
||||
}
|
||||
@@ -32,6 +32,7 @@ namespace ts.SymbolDisplay {
|
||||
if (location.kind === SyntaxKind.ThisKeyword && isExpression(location)) {
|
||||
return ScriptElementKind.parameterElement;
|
||||
}
|
||||
const { flags } = symbol;
|
||||
if (flags & SymbolFlags.Variable) {
|
||||
if (isFirstDeclarationOfSymbolParameter(symbol)) {
|
||||
return ScriptElementKind.parameterElement;
|
||||
@@ -93,7 +94,7 @@ namespace ts.SymbolDisplay {
|
||||
const displayParts: SymbolDisplayPart[] = [];
|
||||
let documentation: SymbolDisplayPart[];
|
||||
const symbolFlags = symbol.flags;
|
||||
let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location);
|
||||
let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location);
|
||||
let hasAddedSymbolInfo: boolean;
|
||||
const isThisExpression = location.kind === SyntaxKind.ThisKeyword && isExpression(location);
|
||||
let type: Type;
|
||||
@@ -319,6 +320,7 @@ namespace ts.SymbolDisplay {
|
||||
}
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.EnumMember) {
|
||||
symbolKind = ScriptElementKind.enumMemberElement;
|
||||
addPrefixForAnyFunctionOrVar(symbol, "enum member");
|
||||
const declaration = symbol.declarations[0];
|
||||
if (declaration.kind === SyntaxKind.EnumMember) {
|
||||
|
||||
@@ -706,8 +706,7 @@ namespace ts {
|
||||
|
||||
/** enum E */
|
||||
export const enumElement = "enum";
|
||||
// TODO: GH#9983
|
||||
export const enumMemberElement = "const";
|
||||
export const enumMemberElement = "enum member";
|
||||
|
||||
/**
|
||||
* Inside module and script only
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"position": 13
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 13,
|
||||
@@ -95,7 +95,7 @@
|
||||
"position": 21
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 21,
|
||||
@@ -156,7 +156,7 @@
|
||||
"position": 34
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 34,
|
||||
@@ -357,7 +357,7 @@
|
||||
"position": 71
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 71,
|
||||
@@ -488,7 +488,7 @@
|
||||
"position": 89
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 89,
|
||||
@@ -619,7 +619,7 @@
|
||||
"position": 107
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 107,
|
||||
@@ -717,7 +717,7 @@
|
||||
"position": 135
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 135,
|
||||
@@ -778,7 +778,7 @@
|
||||
"position": 143
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 143,
|
||||
@@ -839,7 +839,7 @@
|
||||
"position": 156
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 156,
|
||||
@@ -1056,7 +1056,7 @@
|
||||
"position": 205
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 205,
|
||||
@@ -1195,7 +1195,7 @@
|
||||
"position": 229
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 229,
|
||||
@@ -1334,7 +1334,7 @@
|
||||
"position": 253
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 253,
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"position": 13
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 13,
|
||||
@@ -99,7 +99,7 @@
|
||||
"position": 23
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 23,
|
||||
@@ -164,7 +164,7 @@
|
||||
"position": 38
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 38,
|
||||
@@ -369,7 +369,7 @@
|
||||
"position": 77
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 77,
|
||||
@@ -504,7 +504,7 @@
|
||||
"position": 95
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 95,
|
||||
@@ -639,7 +639,7 @@
|
||||
"position": 113
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 113,
|
||||
@@ -741,7 +741,7 @@
|
||||
"position": 141
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 141,
|
||||
@@ -806,7 +806,7 @@
|
||||
"position": 151
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 151,
|
||||
@@ -871,7 +871,7 @@
|
||||
"position": 166
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 166,
|
||||
@@ -1092,7 +1092,7 @@
|
||||
"position": 217
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 217,
|
||||
@@ -1235,7 +1235,7 @@
|
||||
"position": 241
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 241,
|
||||
@@ -1378,7 +1378,7 @@
|
||||
"position": 265
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 265,
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"position": 13
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 13,
|
||||
@@ -99,7 +99,7 @@
|
||||
"position": 23
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 23,
|
||||
@@ -164,7 +164,7 @@
|
||||
"position": 38
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 38,
|
||||
@@ -369,7 +369,7 @@
|
||||
"position": 77
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 77,
|
||||
@@ -504,7 +504,7 @@
|
||||
"position": 98
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 98,
|
||||
@@ -639,7 +639,7 @@
|
||||
"position": 119
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 119,
|
||||
@@ -741,7 +741,7 @@
|
||||
"position": 150
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 150,
|
||||
@@ -806,7 +806,7 @@
|
||||
"position": 160
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 160,
|
||||
@@ -871,7 +871,7 @@
|
||||
"position": 175
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 175,
|
||||
@@ -1092,7 +1092,7 @@
|
||||
"position": 226
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 226,
|
||||
@@ -1235,7 +1235,7 @@
|
||||
"position": 253
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 253,
|
||||
@@ -1378,7 +1378,7 @@
|
||||
"position": 280
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kind": "enum member",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 280,
|
||||
|
||||
@@ -16,15 +16,15 @@ verify.navigationTree({
|
||||
"childItems": [
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "b",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "c",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -48,15 +48,15 @@ verify.navigationBar([
|
||||
"childItems": [
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "b",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "c",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
|
||||
@@ -36,7 +36,7 @@ verify.navigationTree({
|
||||
"childItems": [
|
||||
{
|
||||
"text": "LocalEnumMemberInConstructor",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -64,7 +64,7 @@ verify.navigationTree({
|
||||
"childItems": [
|
||||
{
|
||||
"text": "LocalEnumMemberInMethod",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -144,7 +144,7 @@ verify.navigationBar([
|
||||
"childItems": [
|
||||
{
|
||||
"text": "LocalEnumMemberInConstructor",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
],
|
||||
"indent": 3
|
||||
@@ -184,7 +184,7 @@ verify.navigationBar([
|
||||
"childItems": [
|
||||
{
|
||||
"text": "LocalEnumMemberInMethod",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
],
|
||||
"indent": 3
|
||||
|
||||
@@ -130,15 +130,15 @@ verify.navigationTree({
|
||||
"childItems": [
|
||||
{
|
||||
"text": "value1",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "value2",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "value3",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -263,15 +263,15 @@ verify.navigationBar([
|
||||
"childItems": [
|
||||
{
|
||||
"text": "value1",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "value2",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "value3",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
|
||||
@@ -19,4 +19,6 @@
|
||||
/////*25*/eInstance1 = /*26*/constE./*27*/e2;
|
||||
/////*28*/eInstance1 = /*29*/constE./*30*/e3;
|
||||
|
||||
verify.baselineQuickInfo();
|
||||
//goTo.marker("2");
|
||||
//verify.verifyQuickInfoDisplayParts("enum member", "", { start: 0, length: 2 }, /*displayParts*/[], /*documentation*/[]);
|
||||
verify.baselineQuickInfo();
|
||||
|
||||
@@ -129,15 +129,15 @@ verify.navigationTree({
|
||||
"childItems": [
|
||||
{
|
||||
"text": "value1",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "value2",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "value3",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -262,15 +262,15 @@ verify.navigationBar([
|
||||
"childItems": [
|
||||
{
|
||||
"text": "value1",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "value2",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
},
|
||||
{
|
||||
"text": "value3",
|
||||
"kind": "const"
|
||||
"kind": "enum member"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
|
||||
Reference in New Issue
Block a user