feat(49834): Suggestion: filter enum member ids from their own jsdocs (#49843)

* feat(49834): omit self-referenced enum declaration in JsDoc

* change code style
This commit is contained in:
Oleksandr T
2022-08-09 15:02:45 -07:00
committed by GitHub
parent 6aa9b87f54
commit 19e2a310c0
26 changed files with 587 additions and 0 deletions
+6
View File
@@ -42548,6 +42548,12 @@ namespace ts {
return resolveJSDocMemberName(name, /*ignoreErrors*/ false, getSymbolOfNode(container));
}
}
if (result && isJSDoc) {
const container = getJSDocHost(name);
if (container && isEnumMember(container) && container === result.valueDeclaration) {
return resolveEntityName(name, meaning, /*ignoreErrors*/ true, /* dontResolveAlias */ true, getSourceFileOfNode(container)) || result;
}
}
return result;
}
else if (isPrivateIdentifier(name)) {
@@ -0,0 +1,85 @@
// === /tests/cases/fourslash/findAllReferencesFromLinkTagReference1.ts ===
// enum E {
// /** {@link /*FIND ALL REFS*/[|A|]} */
// [|A|]
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllReferencesFromLinkTagReference1.ts",
"kind": "enum member",
"name": "(enum member) E.A = 0",
"textSpan": {
"start": 34,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "enum member",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "E",
"kind": "enumName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "A",
"kind": "enumMemberName"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "0",
"kind": "numericLiteral"
}
]
},
"references": [
{
"textSpan": {
"start": 24,
"length": 1
},
"fileName": "/tests/cases/fourslash/findAllReferencesFromLinkTagReference1.ts",
"isWriteAccess": false
},
{
"textSpan": {
"start": 34,
"length": 1
},
"fileName": "/tests/cases/fourslash/findAllReferencesFromLinkTagReference1.ts",
"isWriteAccess": true
}
]
}
]
@@ -0,0 +1,64 @@
// === /a.ts ===
// enum E {
// /** {@link /*FIND ALL REFS*/[|Foo|]} */
// Foo
// }
// interface [|Foo|] {
// foo: E.Foo;
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/a.ts",
"kind": "interface",
"name": "interface Foo",
"textSpan": {
"start": 52,
"length": 3
},
"displayParts": [
{
"text": "interface",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Foo",
"kind": "interfaceName"
}
],
"contextSpan": {
"start": 42,
"length": 33
}
},
"references": [
{
"textSpan": {
"start": 24,
"length": 3
},
"fileName": "/a.ts",
"isWriteAccess": false
},
{
"textSpan": {
"start": 52,
"length": 3
},
"fileName": "/a.ts",
"contextSpan": {
"start": 42,
"length": 33
},
"isWriteAccess": true
}
]
}
]
@@ -0,0 +1,66 @@
// === /tests/cases/fourslash/a.ts ===
// interface [|Foo|] {
// foo: E.Foo;
// }
// === /tests/cases/fourslash/b.ts ===
// enum E {
// /** {@link /*FIND ALL REFS*/[|Foo|]} */
// Foo
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "interface",
"name": "interface Foo",
"textSpan": {
"start": 10,
"length": 3
},
"displayParts": [
{
"text": "interface",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Foo",
"kind": "interfaceName"
}
],
"contextSpan": {
"start": 0,
"length": 33
}
},
"references": [
{
"textSpan": {
"start": 10,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"contextSpan": {
"start": 0,
"length": 33
},
"isWriteAccess": true
},
{
"textSpan": {
"start": 24,
"length": 3
},
"fileName": "/tests/cases/fourslash/b.ts",
"isWriteAccess": false
}
]
}
]
@@ -0,0 +1,86 @@
// === /tests/cases/fourslash/findAllReferencesFromLinkTagReference4.ts ===
// enum E {
// /** {@link /*FIND ALL REFS*/[|B|]} */
// A,
// [|B|]
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllReferencesFromLinkTagReference4.ts",
"kind": "enum member",
"name": "(enum member) E.B = 1",
"textSpan": {
"start": 41,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "enum member",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "E",
"kind": "enumName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "B",
"kind": "enumMemberName"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "1",
"kind": "numericLiteral"
}
]
},
"references": [
{
"textSpan": {
"start": 24,
"length": 1
},
"fileName": "/tests/cases/fourslash/findAllReferencesFromLinkTagReference4.ts",
"isWriteAccess": false
},
{
"textSpan": {
"start": 41,
"length": 1
},
"fileName": "/tests/cases/fourslash/findAllReferencesFromLinkTagReference4.ts",
"isWriteAccess": true
}
]
}
]
@@ -0,0 +1,85 @@
// === /tests/cases/fourslash/findAllReferencesFromLinkTagReference5.ts ===
// enum E {
// /** {@link E./*FIND ALL REFS*/[|A|]} */
// [|A|]
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllReferencesFromLinkTagReference5.ts",
"kind": "enum member",
"name": "(enum member) E.A = 0",
"textSpan": {
"start": 36,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "enum member",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "E",
"kind": "enumName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "A",
"kind": "enumMemberName"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "0",
"kind": "numericLiteral"
}
]
},
"references": [
{
"textSpan": {
"start": 26,
"length": 1
},
"fileName": "/tests/cases/fourslash/findAllReferencesFromLinkTagReference5.ts",
"isWriteAccess": false
},
{
"textSpan": {
"start": 36,
"length": 1
},
"fileName": "/tests/cases/fourslash/findAllReferencesFromLinkTagReference5.ts",
"isWriteAccess": true
}
]
}
]
@@ -0,0 +1,6 @@
/*====== /tests/cases/fourslash/renameReferenceFromLinkTag1.ts ======*/
enum E {
/** {@link [|RENAME|]} */
RENAME
}
@@ -0,0 +1,9 @@
/*====== /a.ts ======*/
enum E {
/** {@link [|RENAME|]} */
Foo
}
interface RENAME {
foo: E.Foo;
}
@@ -0,0 +1,12 @@
/*====== /tests/cases/fourslash/a.ts ======*/
interface RENAME {
foo: E.Foo;
}
/*====== /tests/cases/fourslash/b.ts ======*/
enum E {
/** {@link RENAME} */
Foo
}
@@ -0,0 +1,7 @@
/*====== /tests/cases/fourslash/renameReferenceFromLinkTag4.ts ======*/
enum E {
/** {@link [|RENAME|]} */
A,
RENAME
}
@@ -0,0 +1,6 @@
/*====== /tests/cases/fourslash/renameReferenceFromLinkTag5.ts ======*/
enum E {
/** {@link E.[|RENAME|]} */
RENAME
}
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////enum E {
//// /** {@link /**/A} */
//// A
////}
verify.baselineFindAllReferences("");
@@ -0,0 +1,12 @@
/// <reference path="fourslash.ts" />
// @Filename: /a.ts
////enum E {
//// /** {@link /**/Foo} */
//// Foo
////}
////interface Foo {
//// foo: E.Foo;
////}
verify.baselineFindAllReferences("");
@@ -0,0 +1,14 @@
/// <reference path="fourslash.ts" />
// @filename: a.ts
////interface Foo {
//// foo: E.Foo;
////}
// @Filename: b.ts
////enum E {
//// /** {@link /**/Foo} */
//// Foo
////}
verify.baselineFindAllReferences("");
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////enum E {
//// /** {@link /**/B} */
//// A,
//// B
////}
verify.baselineFindAllReferences("");
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////enum E {
//// /** {@link E./**/A} */
//// A
////}
verify.baselineFindAllReferences("");
@@ -0,0 +1,9 @@
/// <reference path="fourslash.ts" />
////enum E {
//// /** {@link /*1*/[|A|]} */
//// [|/*2*/A|]
////}
goTo.marker("1");
verify.goToDefinitionIs("2");
@@ -0,0 +1,13 @@
/// <reference path="fourslash.ts" />
// @Filename: /a.ts
////enum E {
//// /** {@link /*1*/[|Foo|]} */
//// Foo
////}
////interface [|/*2*/Foo|] {
//// foo: E.Foo;
////}
goTo.marker("1");
verify.goToDefinitionIs("2");
@@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
// @filename: a.ts
////interface [|/*2*/Foo|] {
//// foo: E.Foo;
////}
// @Filename: b.ts
////enum E {
//// /** {@link /*1*/[|Foo|]} */
//// Foo
////}
goTo.marker("1");
verify.goToDefinitionIs("2");
@@ -0,0 +1,9 @@
/// <reference path="fourslash.ts" />
////enum E {
//// /** {@link /*1*/[|B|]} */
//// A,
//// [|/*2*/B|]
////}
goTo.marker("1");
verify.goToDefinitionIs("2");
@@ -0,0 +1,9 @@
/// <reference path="fourslash.ts" />
////enum E {
//// /** {@link E./*1*/[|A|]} */
//// [|/*2*/A|]
////}
goTo.marker("1");
verify.goToDefinitionIs("2");
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////enum E {
//// /** {@link /**/A} */
//// A
////}
verify.baselineRename("", {});
@@ -0,0 +1,12 @@
/// <reference path="fourslash.ts" />
// @Filename: /a.ts
////enum E {
//// /** {@link /**/Foo} */
//// Foo
////}
////interface Foo {
//// foo: E.Foo;
////}
verify.baselineRename("", {});
@@ -0,0 +1,14 @@
/// <reference path="fourslash.ts" />
// @filename: a.ts
////interface Foo {
//// foo: E.Foo;
////}
// @Filename: b.ts
////enum E {
//// /** {@link /**/Foo} */
//// Foo
////}
verify.baselineRename("", {});
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////enum E {
//// /** {@link /**/B} */
//// A,
//// B
////}
verify.baselineRename("", {});
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////enum E {
//// /** {@link E./**/A} */
//// A
////}
verify.baselineRename("", {});