TypeScript/tests/baselines/reference/referencesForClassMembers.baseline.jsonc
Nathan Shively-Sanders f0fe1b88ca
Make isDefinition aware of declaring symbol (#45920)
* Make isDefinition aware of target symbol

Initial code, haven't fixed any tests yet.

* Update baselines

This commit includes a regression for commonjs aliases:

```js
// @filename: a.js
function f() { }
module.exports.f = f

// @filename: b.js
const { f } = require('./a')
f/**/
```

Now says that `f` in b.js has 1 reference --
the alias `module.exports.f = f`. This is not correct (or not exactly
correct), but correctly fixing will involve re-creating the ad-hoc
commonjs alias resolution code from the checker. I don't think it's
worth it for an edge case like this.

* update more unit tests

* Fix symbol lookup for constructors

* More baselines + two fixes

1. Fix `default` support.
2. Add a secondary declaration location for commonjs assignment
declarations.

* Update rest of baselines

* Switch a few more tests over to baselines
2021-09-22 13:43:52 -07:00

1091 lines
21 KiB
Plaintext

// === /tests/cases/fourslash/referencesForClassMembers.ts ===
// class Base {
// /*FIND ALL REFS*/[|a|]: number;
// method(): void { }
// }
// class MyClass extends Base {
// [|a|];
// method() { }
// }
//
// var c: MyClass;
// c.[|a|];
// c.method();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "property",
"name": "(property) Base.a: number",
"textSpan": {
"start": 17,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Base",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "a",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"contextSpan": {
"start": 17,
"length": 10
}
},
"references": [
{
"textSpan": {
"start": 17,
"length": 1
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 17,
"length": 10
},
"isWriteAccess": false,
"isDefinition": true
}
]
},
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "property",
"name": "(property) MyClass.a: any",
"textSpan": {
"start": 86,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "MyClass",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "a",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"contextSpan": {
"start": 86,
"length": 2
}
},
"references": [
{
"textSpan": {
"start": 86,
"length": 1
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 86,
"length": 2
},
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 127,
"length": 1
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/referencesForClassMembers.ts ===
// class Base {
// [|a|]: number;
// method(): void { }
// }
// class MyClass extends Base {
// /*FIND ALL REFS*/[|a|];
// method() { }
// }
//
// var c: MyClass;
// c.[|a|];
// c.method();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "property",
"name": "(property) Base.a: number",
"textSpan": {
"start": 17,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Base",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "a",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"contextSpan": {
"start": 17,
"length": 10
}
},
"references": [
{
"textSpan": {
"start": 17,
"length": 1
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 17,
"length": 10
},
"isWriteAccess": false,
"isDefinition": false
}
]
},
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "property",
"name": "(property) MyClass.a: any",
"textSpan": {
"start": 86,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "MyClass",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "a",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"contextSpan": {
"start": 86,
"length": 2
}
},
"references": [
{
"textSpan": {
"start": 86,
"length": 1
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 86,
"length": 2
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 127,
"length": 1
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/referencesForClassMembers.ts ===
// class Base {
// [|a|]: number;
// method(): void { }
// }
// class MyClass extends Base {
// [|a|];
// method() { }
// }
//
// var c: MyClass;
// c./*FIND ALL REFS*/[|a|];
// c.method();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "property",
"name": "(property) Base.a: number",
"textSpan": {
"start": 17,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Base",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "a",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"contextSpan": {
"start": 17,
"length": 10
}
},
"references": [
{
"textSpan": {
"start": 17,
"length": 1
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 17,
"length": 10
},
"isWriteAccess": false,
"isDefinition": false
}
]
},
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "property",
"name": "(property) MyClass.a: any",
"textSpan": {
"start": 86,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "MyClass",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "a",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"contextSpan": {
"start": 86,
"length": 2
}
},
"references": [
{
"textSpan": {
"start": 86,
"length": 1
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 86,
"length": 2
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 127,
"length": 1
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/referencesForClassMembers.ts ===
// class Base {
// a: number;
// /*FIND ALL REFS*/[|method|](): void { }
// }
// class MyClass extends Base {
// a;
// [|method|]() { }
// }
//
// var c: MyClass;
// c.a;
// c.[|method|]();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "method",
"name": "(method) Base.method(): void",
"textSpan": {
"start": 32,
"length": 6
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Base",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "method",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 32,
"length": 18
}
},
"references": [
{
"textSpan": {
"start": 32,
"length": 6
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 32,
"length": 18
},
"isWriteAccess": true,
"isDefinition": true
}
]
},
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "method",
"name": "(method) MyClass.method(): void",
"textSpan": {
"start": 93,
"length": 6
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "MyClass",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "method",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 93,
"length": 12
}
},
"references": [
{
"textSpan": {
"start": 93,
"length": 6
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 93,
"length": 12
},
"isWriteAccess": true,
"isDefinition": false
},
{
"textSpan": {
"start": 132,
"length": 6
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/referencesForClassMembers.ts ===
// class Base {
// a: number;
// [|method|](): void { }
// }
// class MyClass extends Base {
// a;
// /*FIND ALL REFS*/[|method|]() { }
// }
//
// var c: MyClass;
// c.a;
// c.[|method|]();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "method",
"name": "(method) Base.method(): void",
"textSpan": {
"start": 32,
"length": 6
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Base",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "method",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 32,
"length": 18
}
},
"references": [
{
"textSpan": {
"start": 32,
"length": 6
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 32,
"length": 18
},
"isWriteAccess": true,
"isDefinition": false
}
]
},
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "method",
"name": "(method) MyClass.method(): void",
"textSpan": {
"start": 93,
"length": 6
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "MyClass",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "method",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 93,
"length": 12
}
},
"references": [
{
"textSpan": {
"start": 93,
"length": 6
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 93,
"length": 12
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 132,
"length": 6
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/referencesForClassMembers.ts ===
// class Base {
// a: number;
// [|method|](): void { }
// }
// class MyClass extends Base {
// a;
// [|method|]() { }
// }
//
// var c: MyClass;
// c.a;
// c./*FIND ALL REFS*/[|method|]();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "method",
"name": "(method) Base.method(): void",
"textSpan": {
"start": 32,
"length": 6
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Base",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "method",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 32,
"length": 18
}
},
"references": [
{
"textSpan": {
"start": 32,
"length": 6
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 32,
"length": 18
},
"isWriteAccess": true,
"isDefinition": false
}
]
},
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"kind": "method",
"name": "(method) MyClass.method(): void",
"textSpan": {
"start": 93,
"length": 6
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "MyClass",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "method",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"contextSpan": {
"start": 93,
"length": 12
}
},
"references": [
{
"textSpan": {
"start": 93,
"length": 6
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"contextSpan": {
"start": 93,
"length": 12
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 132,
"length": 6
},
"fileName": "/tests/cases/fourslash/referencesForClassMembers.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]