fix(48673): allow Find All References on access modifier for constructor (#48813)

This commit is contained in:
Oleksandr T 2022-05-10 00:56:56 +03:00 committed by GitHub
parent d6e483b8da
commit aa48a37e09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 296 additions and 0 deletions

View File

@ -806,6 +806,8 @@ namespace ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
return getAdjustedLocationForFunction(node as FunctionDeclaration | FunctionExpression);
case SyntaxKind.Constructor:
return node;
}
}
if (isNamedDeclaration(node)) {

View File

@ -0,0 +1,63 @@
// === /tests/cases/fourslash/constructorFindAllReferences1.ts ===
// export class C {
// /*FIND ALL REFS*/public [|constructor|]() { }
// public foo() { }
// }
//
// new [|C|]().foo();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/constructorFindAllReferences1.ts",
"kind": "class",
"name": "class C",
"textSpan": {
"start": 13,
"length": 1
},
"displayParts": [
{
"text": "class",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "C",
"kind": "className"
}
],
"contextSpan": {
"start": 0,
"length": 68
}
},
"references": [
{
"textSpan": {
"start": 28,
"length": 11
},
"fileName": "/tests/cases/fourslash/constructorFindAllReferences1.ts",
"contextSpan": {
"start": 21,
"length": 24
},
"isWriteAccess": false
},
{
"textSpan": {
"start": 74,
"length": 1
},
"fileName": "/tests/cases/fourslash/constructorFindAllReferences1.ts",
"isWriteAccess": false
}
]
}
]

View File

@ -0,0 +1,63 @@
// === /tests/cases/fourslash/constructorFindAllReferences2.ts ===
// export class C {
// /*FIND ALL REFS*/private [|constructor|]() { }
// public foo() { }
// }
//
// new [|C|]().foo();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/constructorFindAllReferences2.ts",
"kind": "class",
"name": "class C",
"textSpan": {
"start": 13,
"length": 1
},
"displayParts": [
{
"text": "class",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "C",
"kind": "className"
}
],
"contextSpan": {
"start": 0,
"length": 69
}
},
"references": [
{
"textSpan": {
"start": 29,
"length": 11
},
"fileName": "/tests/cases/fourslash/constructorFindAllReferences2.ts",
"contextSpan": {
"start": 21,
"length": 25
},
"isWriteAccess": false
},
{
"textSpan": {
"start": 75,
"length": 1
},
"fileName": "/tests/cases/fourslash/constructorFindAllReferences2.ts",
"isWriteAccess": false
}
]
}
]

View File

@ -0,0 +1,65 @@
// === /tests/cases/fourslash/constructorFindAllReferences3.ts ===
// export class C {
// /*FIND ALL REFS*/[|constructor|]() { }
// public foo() { }
// }
//
// new [|C|]().foo();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/constructorFindAllReferences3.ts",
"kind": "class",
"name": "class C",
"textSpan": {
"start": 13,
"length": 1
},
"displayParts": [
{
"text": "class",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "C",
"kind": "className"
}
],
"contextSpan": {
"start": 0,
"length": 61
}
},
"references": [
{
"textSpan": {
"start": 21,
"length": 11
},
"fileName": "/tests/cases/fourslash/constructorFindAllReferences3.ts",
"contextSpan": {
"start": 21,
"length": 17
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 67,
"length": 1
},
"fileName": "/tests/cases/fourslash/constructorFindAllReferences3.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]

View File

@ -0,0 +1,63 @@
// === /tests/cases/fourslash/constructorFindAllReferences4.ts ===
// export class C {
// /*FIND ALL REFS*/protected [|constructor|]() { }
// public foo() { }
// }
//
// new [|C|]().foo();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/constructorFindAllReferences4.ts",
"kind": "class",
"name": "class C",
"textSpan": {
"start": 13,
"length": 1
},
"displayParts": [
{
"text": "class",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "C",
"kind": "className"
}
],
"contextSpan": {
"start": 0,
"length": 71
}
},
"references": [
{
"textSpan": {
"start": 31,
"length": 11
},
"fileName": "/tests/cases/fourslash/constructorFindAllReferences4.ts",
"contextSpan": {
"start": 21,
"length": 27
},
"isWriteAccess": false
},
{
"textSpan": {
"start": 77,
"length": 1
},
"fileName": "/tests/cases/fourslash/constructorFindAllReferences4.ts",
"isWriteAccess": false
}
]
}
]

View File

@ -0,0 +1,10 @@
/// <reference path="fourslash.ts" />
////export class C {
//// /**/public constructor() { }
//// public foo() { }
////}
////
////new C().foo();
verify.baselineFindAllReferences("");

View File

@ -0,0 +1,10 @@
/// <reference path="fourslash.ts" />
////export class C {
//// /**/private constructor() { }
//// public foo() { }
////}
////
////new C().foo();
verify.baselineFindAllReferences("");

View File

@ -0,0 +1,10 @@
/// <reference path="fourslash.ts" />
////export class C {
//// /**/constructor() { }
//// public foo() { }
////}
////
////new C().foo();
verify.baselineFindAllReferences("");

View File

@ -0,0 +1,10 @@
/// <reference path="fourslash.ts" />
////export class C {
//// /**/protected constructor() { }
//// public foo() { }
////}
////
////new C().foo();
verify.baselineFindAllReferences("");