Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 593f56d

Browse files
committedJun 12, 2024
Add support for SymbolInformation.signature
Companion PRs: * sourcegraph/scip#231 * sourcegraph/cody#3142 Previously, scip-typescript didn't emit any structured information about signatures. This PR solves that problem, which unblocks new exciting use-cases for SCIP. Keeping this PR open for a while since we are not planning to merge signature support to SCIP just yet. For now, the Cody repo can use this branch instead.
1 parent ea22136 commit 593f56d

33 files changed

+7397
-157
lines changed
 

‎.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"editor.formatOnSave": true
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "esbenp.prettier-vscode"
34
}

‎snapshots/input/syntax/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
},
99
"author": "",
1010
"license": "ISC",
11-
"private": true
11+
"private": true,
12+
"devDependencies": {
13+
"@types/vscode": "1.86.0"
14+
}
1215
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// format-options: showSignatures
2+
export namespace minimized {
3+
export enum NumericLiteralEnum {
4+
One = 1,
5+
TwoThousand = 2_000,
6+
}
7+
8+
export const doubleConstant = 3.14
9+
10+
export enum StringLiteralEnum {
11+
Saturday = 'saturday',
12+
Sunday = 'sunday',
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// format-options: showSignatures
2+
3+
export type CompletionItemID = string & { _opaque: typeof CompletionItemID }
4+
declare const CompletionItemID: unique symbol
+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// format-options: showSignatures
2+
3+
export type Requests = {
4+
'workspace/edit': [WorkspaceEditParams, boolean]
5+
'chat/submitMessage': [WorkspaceEditParams, boolean]
6+
}
7+
8+
export type Notifications = {
9+
'workspace/edit': [WorkspaceEditParams]
10+
}
11+
12+
export type Intersection = { uri: string } & { size: number }
13+
export type Union = { uri: string } | { size: number }
14+
export type Builtin = Pick<WorkspaceEditParams, 'changes'>
15+
export type Builtin2 = Partial<WorkspaceEditParams>
16+
export interface WorkspaceEditParams {
17+
changes: { uri: string }[]
18+
}
19+
20+
export interface ExampleSuperInterface<T> {
21+
a: T
22+
b: string
23+
}
24+
export interface ExampleInterface<T> extends ExampleSuperInterface<T> {
25+
c: number
26+
}
27+
export class ExampleSuperClass<T> {
28+
constructor(
29+
public a: T,
30+
public b: string
31+
) {}
32+
}
33+
34+
export class ExampleClass<T>
35+
extends ExampleSuperClass<T>
36+
implements ExampleSuperInterface<T>, ExampleInterface<T>
37+
{
38+
public d: Record<string, any>
39+
40+
#e = true
41+
42+
constructor(
43+
public a: T,
44+
public b: string,
45+
public c: number,
46+
d: Record<string, any>
47+
) {
48+
super(a, b)
49+
this.d = d
50+
}
51+
public getC(): number {
52+
return this.c
53+
}
54+
55+
get e(): boolean {
56+
return this.#e
57+
}
58+
59+
set setB(b: string) {
60+
this.#e = true
61+
this.b = b
62+
}
63+
}
64+
65+
export function basicFunction<T>(a: T, b: number): string {
66+
return `${a}${b}`
67+
}
68+
export const constant = 42
69+
export const variable: <T>(a: T, b: number) => string = (a, b) => `${a}${b}`
70+
71+
export interface User {
72+
name: string
73+
age: number
74+
customHeaders: Record<string, string>
75+
}
76+
77+
export interface ChatHistory {
78+
chatID: User
79+
[a: number]: User
80+
[_: string]: User
81+
}
82+
83+
export class ModelProvider {
84+
default = true
85+
}
86+
87+
export enum NumericLiteralEnum {
88+
MinusOne = -1,
89+
Expression = 1 + 23 - 2,
90+
One = 1,
91+
TwoThousand = 2_000,
92+
}
93+
94+
export const doubleConstant = 3.14
95+
96+
export enum StringLiteralEnum {
97+
Saturday = 'saturday',
98+
Sunday = 'sunday',
99+
}

‎snapshots/input/syntax/src/structural-type.ts

+3
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ export function bar2(): Promise<number> {
1010

1111
type OptionsFlags<Type> = { [Property in keyof Type]: boolean }
1212
type FeatureFlags = { darkMode: () => void }
13+
export type PropertySignature = {
14+
'chat/submit': [{ text: { value: string } }]
15+
}
1316
export type FeatureOptions = OptionsFlags<FeatureFlags> // implicitly // type FeatureOptions = { // darkMode: boolean; // } const fo: FeatureOptions = { darkMode: true }; // ^ go to def
1417
export const fo: FeatureOptions = { darkMode: true }

‎snapshots/output/enclosing-ranges-ts/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
interface Foo {
88
// ^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Foo#
99
bar: string
10-
//^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Foo#bar.
10+
//^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/bar0:
1111
test: () => void
12-
//^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Foo#test.
12+
//^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/test0:
1313
}
1414
// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/Foo#
1515

@@ -18,7 +18,7 @@ interface Single<T> {
1818
// ^^^^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Single#
1919
// ^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Single#[T]
2020
t: T
21-
//^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Single#t.
21+
//^ definition enclosing-ranges-ts 1.0.0 `index.ts`/t0:
2222
// ^ reference enclosing-ranges-ts 1.0.0 `index.ts`/Single#[T]
2323
}
2424
// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/Single#

‎snapshots/output/pure-js/src/main.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ function print_fib(a) {
2020
console.log(fib(a))
2121
//^^^^^^^ reference typescript 5.3.3 lib/`lib.dom.d.ts`/console.
2222
//^^^^^^^ reference @types/node 20.10.5 `globals.d.ts`/global/console.
23-
//^^^^^^^ reference @types/node 20.10.5 `console.d.ts`/`"node:console"`/global/console/
24-
//^^^^^^^ reference @types/node 20.10.5 `console.d.ts`/`"node:console"`/global/console.
23+
//^^^^^^^ reference @types/node 20.10.5 `console.d.ts`/`node:console`/global/console/
24+
//^^^^^^^ reference @types/node 20.10.5 `console.d.ts`/`node:console`/global/console.
2525
// ^^^ reference typescript 5.3.3 lib/`lib.dom.d.ts`/Console#log().
26-
// ^^^ reference @types/node 20.10.5 `console.d.ts`/`"node:console"`/global/Console#log().
26+
// ^^^ reference @types/node 20.10.5 `console.d.ts`/`node:console`/global/Console#log().
2727
// ^^^ reference pure-js 1.0.0 src/`main.js`/fib().
2828
// ^ reference pure-js 1.0.0 src/`main.js`/print_fib().(a)
2929
}
@@ -42,12 +42,12 @@ const capture_lambda = () => {
4242
}
4343

4444
for (var i = 0; i <= 10; i++) {}
45-
// ^ definition local 2
46-
// ^ reference local 2
47-
// ^ reference local 2
45+
// ^ definition local 4
46+
// ^ reference local 4
47+
// ^ reference local 4
4848

4949
for (const x of [1, 2, 3]) {
50-
// ^ definition local 5
50+
// ^ definition local 7
5151
}
5252

5353
var a = 0
@@ -68,32 +68,32 @@ function use_before_def() {
6868
// ^^^^^^^^^^^^^^ definition pure-js 1.0.0 src/`main.js`/use_before_def().
6969
print_fib(n)
7070
//^^^^^^^^^ reference pure-js 1.0.0 src/`main.js`/print_fib().
71-
// ^ reference local 8
71+
// ^ reference local 10
7272
var n = 10
73-
// ^ definition local 8
73+
// ^ definition local 10
7474

7575
if (forever()) {
7676
// ^^^^^^^ reference pure-js 1.0.0 src/`main.js`/forever().
7777
var m = 10
78-
// ^ definition local 11
78+
// ^ definition local 13
7979
}
8080
print_fib(m)
8181
//^^^^^^^^^ reference pure-js 1.0.0 src/`main.js`/print_fib().
82-
// ^ reference local 11
82+
// ^ reference local 13
8383
}
8484

8585
function var_function_scope() {
8686
// ^^^^^^^^^^^^^^^^^^ definition pure-js 1.0.0 src/`main.js`/var_function_scope().
8787
var k = 0
88-
// ^ definition local 14
88+
// ^ definition local 16
8989
if (forever()) {
9090
// ^^^^^^^ reference pure-js 1.0.0 src/`main.js`/forever().
9191
var k = 1
92-
// ^ definition local 17
92+
// ^ definition local 19
9393
}
9494
print_fib(k)
9595
//^^^^^^^^^ reference pure-js 1.0.0 src/`main.js`/print_fib().
96-
// ^ reference local 14
97-
// ^ reference local 17
96+
// ^ reference local 16
97+
// ^ reference local 19
9898
}
9999

‎snapshots/output/react/src/LoaderInput.tsx

+19-19
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import React from 'react'
88
interface Props {
99
// ^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#
1010
loading: boolean
11-
//^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#loading.
11+
//^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/loading0:
1212
children: React.ReactNode
13-
//^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
13+
//^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/children0:
1414
// ^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/
1515
// ^^^^^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/ReactNode#
1616
}
@@ -21,37 +21,37 @@ export const LoaderInput: React.FunctionComponent<Props> = ({
2121
// ^^^^^^^^^^^^^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/FunctionComponent#
2222
// ^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#
2323
loading,
24-
//^^^^^^^ definition local 3
25-
//^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#loading.
24+
//^^^^^^^ definition local 4
25+
//^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/loading0:
2626
children,
27-
//^^^^^^^^ definition local 4
28-
//^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
27+
//^^^^^^^^ definition local 5
28+
//^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/children0:
2929
}) => (
3030
<div className="hello">
31-
// ^^^ reference @types/react 18.2.39 `index.d.ts`/global/JSX/IntrinsicElements#div.
32-
// ^^^^^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/HTMLAttributes#className.
31+
// ^^^ reference @types/react 18.2.39 `index.d.ts`/div0:
32+
// ^^^^^^^^^ reference @types/react 18.2.39 `index.d.ts`/className0:
3333
{children}
34-
// ^^^^^^^^ reference local 4
34+
// ^^^^^^^^ reference local 5
3535
{loading && <p>spinner</p>}
36-
// ^^^^^^^ reference local 3
37-
// ^ reference @types/react 18.2.39 `index.d.ts`/global/JSX/IntrinsicElements#p.
38-
// ^ reference @types/react 18.2.39 `index.d.ts`/global/JSX/IntrinsicElements#p.
36+
// ^^^^^^^ reference local 4
37+
// ^ reference @types/react 18.2.39 `index.d.ts`/p0:
38+
// ^ reference @types/react 18.2.39 `index.d.ts`/p0:
3939
</div>
40-
// ^^^ reference @types/react 18.2.39 `index.d.ts`/global/JSX/IntrinsicElements#div.
40+
// ^^^ reference @types/react 18.2.39 `index.d.ts`/div0:
4141
)
4242

4343
export const LoaderInput2: React.FunctionComponent<Props> = props => {
4444
// ^^^^^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput2.
4545
// ^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/
4646
// ^^^^^^^^^^^^^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/FunctionComponent#
4747
// ^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#
48-
// ^^^^^ definition local 6
48+
// ^^^^^ definition local 705
4949
return <LoaderInput loading={true} key="key" children={props.children} />
5050
// ^^^^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput.
51-
// ^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#loading.
52-
// ^^^ reference local 10
53-
// ^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
54-
// ^^^^^ reference local 6
55-
// ^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
51+
// ^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/loading0:
52+
// ^^^ reference local 709
53+
// ^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/children0:
54+
// ^^^^^ reference local 705
55+
// ^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/children0:
5656
}
5757

‎snapshots/output/react/src/MyTSXElement.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export const MyTSXElement: React.FunctionComponent<MyProps> = ({}) => (<p></p>)
1212
// ^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/
1313
// ^^^^^^^^^^^^^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/FunctionComponent#
1414
// ^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
15-
// ^ reference @types/react 18.2.39 `index.d.ts`/global/JSX/IntrinsicElements#p.
16-
// ^ reference @types/react 18.2.39 `index.d.ts`/global/JSX/IntrinsicElements#p.
15+
// ^ reference @types/react 18.2.39 `index.d.ts`/p0:
16+
// ^ reference @types/react 18.2.39 `index.d.ts`/p0:

‎snapshots/output/syntax/src/accessors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ function f() {
115115
g(D.length)
116116
//^ reference syntax 1.0.0 src/`accessors.ts`/g().
117117
// ^ reference syntax 1.0.0 src/`accessors.ts`/D#
118-
// ^^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Function#length.
118+
// ^^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/length0:
119119
}
120120

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
// < definition syntax 1.0.0 src/`definition-file-signatures.d.ts`/
2+
3+
// format-options: showSignatures
4+
export namespace minimized {
5+
// ^^^^^^^^^ definition syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/
6+
// info {
7+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/",
8+
// | "documentation": [
9+
// | "```ts\nminimized: typeof minimized\n```"
10+
// | ],
11+
// | "relationships": [],
12+
// | "kind": 0,
13+
// | "display_name": "minimized",
14+
// | "enclosing_symbol": "",
15+
// | "signature": {}
16+
// | }
17+
export enum NumericLiteralEnum {
18+
// ^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/NumericLiteralEnum#
19+
// info {
20+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/NumericLiteralEnum#",
21+
// | "documentation": [
22+
// | "```ts\nenum NumericLiteralEnum\n```"
23+
// | ],
24+
// | "relationships": [],
25+
// | "kind": 11,
26+
// | "display_name": "NumericLiteralEnum",
27+
// | "enclosing_symbol": "",
28+
// | "signature": {
29+
// | "class_signature": {
30+
// | "parents": [],
31+
// | "declarations": {
32+
// | "symlinks": [
33+
// | "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/NumericLiteralEnum#One.",
34+
// | "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/NumericLiteralEnum#TwoThousand."
35+
// | ],
36+
// | "hardlinks": []
37+
// | }
38+
// | }
39+
// | }
40+
// | }
41+
One = 1,
42+
// ^^^ definition syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/NumericLiteralEnum#One.
43+
// info {
44+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/NumericLiteralEnum#One.",
45+
// | "documentation": [
46+
// | "```ts\n(enum member) One = 1\n```"
47+
// | ],
48+
// | "relationships": [],
49+
// | "kind": 12,
50+
// | "display_name": "One",
51+
// | "enclosing_symbol": "",
52+
// | "signature": {
53+
// | "value_signature": {
54+
// | "tpe": {
55+
// | "constant_type": {
56+
// | "constant": {
57+
// | "int_constant": {
58+
// | "value": 1
59+
// | }
60+
// | }
61+
// | }
62+
// | }
63+
// | }
64+
// | }
65+
// | }
66+
TwoThousand = 2_000,
67+
// ^^^^^^^^^^^ definition syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/NumericLiteralEnum#TwoThousand.
68+
// info {
69+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/NumericLiteralEnum#TwoThousand.",
70+
// | "documentation": [
71+
// | "```ts\n(enum member) TwoThousand = 2000\n```"
72+
// | ],
73+
// | "relationships": [],
74+
// | "kind": 12,
75+
// | "display_name": "TwoThousand",
76+
// | "enclosing_symbol": "",
77+
// | "signature": {
78+
// | "value_signature": {
79+
// | "tpe": {
80+
// | "constant_type": {
81+
// | "constant": {
82+
// | "int_constant": {
83+
// | "value": 2000
84+
// | }
85+
// | }
86+
// | }
87+
// | }
88+
// | }
89+
// | }
90+
// | }
91+
}
92+
93+
export const doubleConstant = 3.14
94+
// ^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/doubleConstant.
95+
// info {
96+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/doubleConstant.",
97+
// | "documentation": [
98+
// | "```ts\nvar doubleConstant: 3.14\n```"
99+
// | ],
100+
// | "relationships": [],
101+
// | "kind": 61,
102+
// | "display_name": "doubleConstant",
103+
// | "enclosing_symbol": "",
104+
// | "signature": {
105+
// | "value_signature": {
106+
// | "tpe": {
107+
// | "constant_type": {
108+
// | "constant": {
109+
// | "double_constant": {
110+
// | "value": 3.14
111+
// | }
112+
// | }
113+
// | }
114+
// | }
115+
// | }
116+
// | }
117+
// | }
118+
119+
export enum StringLiteralEnum {
120+
// ^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/StringLiteralEnum#
121+
// info {
122+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/StringLiteralEnum#",
123+
// | "documentation": [
124+
// | "```ts\nenum StringLiteralEnum\n```"
125+
// | ],
126+
// | "relationships": [],
127+
// | "kind": 11,
128+
// | "display_name": "StringLiteralEnum",
129+
// | "enclosing_symbol": "",
130+
// | "signature": {
131+
// | "class_signature": {
132+
// | "parents": [],
133+
// | "declarations": {
134+
// | "symlinks": [
135+
// | "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/StringLiteralEnum#Saturday.",
136+
// | "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/StringLiteralEnum#Sunday."
137+
// | ],
138+
// | "hardlinks": []
139+
// | }
140+
// | }
141+
// | }
142+
// | }
143+
Saturday = 'saturday',
144+
// ^^^^^^^^ definition syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/StringLiteralEnum#Saturday.
145+
// info {
146+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/StringLiteralEnum#Saturday.",
147+
// | "documentation": [
148+
// | "```ts\n(enum member) Saturday = saturday\n```"
149+
// | ],
150+
// | "relationships": [],
151+
// | "kind": 12,
152+
// | "display_name": "Saturday",
153+
// | "enclosing_symbol": "",
154+
// | "signature": {
155+
// | "value_signature": {
156+
// | "tpe": {
157+
// | "constant_type": {
158+
// | "constant": {
159+
// | "string_constant": {
160+
// | "value": "saturday"
161+
// | }
162+
// | }
163+
// | }
164+
// | }
165+
// | }
166+
// | }
167+
// | }
168+
Sunday = 'sunday',
169+
// ^^^^^^ definition syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/StringLiteralEnum#Sunday.
170+
// info {
171+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`definition-file-signatures.d.ts`/minimized/StringLiteralEnum#Sunday.",
172+
// | "documentation": [
173+
// | "```ts\n(enum member) Sunday = sunday\n```"
174+
// | ],
175+
// | "relationships": [],
176+
// | "kind": 12,
177+
// | "display_name": "Sunday",
178+
// | "enclosing_symbol": "",
179+
// | "signature": {
180+
// | "value_signature": {
181+
// | "tpe": {
182+
// | "constant_type": {
183+
// | "constant": {
184+
// | "string_constant": {
185+
// | "value": "sunday"
186+
// | }
187+
// | }
188+
// | }
189+
// | }
190+
// | }
191+
// | }
192+
// | }
193+
}
194+
}
195+

‎snapshots/output/syntax/src/destructuring.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
interface Props {
44
// ^^^^^ definition syntax 1.0.0 src/`destructuring.ts`/Props#
55
a: number
6-
//^ definition syntax 1.0.0 src/`destructuring.ts`/Props#a.
6+
//^ definition syntax 1.0.0 src/`destructuring.ts`/a0:
77
}
88
const props: Props = { a: 42 }
99
// ^^^^^ definition syntax 1.0.0 src/`destructuring.ts`/props.
1010
// ^^^^^ reference syntax 1.0.0 src/`destructuring.ts`/Props#
11-
// ^ definition syntax 1.0.0 src/`destructuring.ts`/a0:
12-
// relationship implementation reference syntax 1.0.0 src/`destructuring.ts`/Props#a.
11+
// ^ definition syntax 1.0.0 src/`destructuring.ts`/a1:
12+
// relationship implementation reference syntax 1.0.0 src/`destructuring.ts`/a0:
1313

1414
export function objectDestructuring(): number[] {
1515
// ^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`destructuring.ts`/objectDestructuring().
1616
const { a: b } = props
17-
// ^ reference syntax 1.0.0 src/`destructuring.ts`/Props#a.
17+
// ^ reference syntax 1.0.0 src/`destructuring.ts`/a0:
1818
// ^ definition local 4
1919
// ^^^^^ reference syntax 1.0.0 src/`destructuring.ts`/props.
2020
return [props].map(({ a }) => a + b)
2121
// ^^^^^ reference syntax 1.0.0 src/`destructuring.ts`/props.
2222
// ^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Array#map().
2323
// ^ definition local 10
24-
// ^ reference syntax 1.0.0 src/`destructuring.ts`/Props#a.
24+
// ^ reference syntax 1.0.0 src/`destructuring.ts`/a0:
2525
// ^ reference local 10
2626
// ^ reference local 4
2727
}
@@ -36,7 +36,7 @@ export function arrayDestructuring(): number[] {
3636
// ^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Array#map().
3737
// ^ definition local 21
3838
// ^ reference local 21
39-
// ^ reference syntax 1.0.0 src/`destructuring.ts`/Props#a.
39+
// ^ reference syntax 1.0.0 src/`destructuring.ts`/a0:
4040
}
4141

4242
export function nestedDestructuring(): number[] {
@@ -48,17 +48,17 @@ export function nestedDestructuring(): number[] {
4848
// ^^^^^ reference syntax 1.0.0 src/`destructuring.ts`/props.
4949
// ^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Array#map().
5050
// ^ definition local 36
51-
// ^ reference syntax 1.0.0 src/`destructuring.ts`/Props#a.
51+
// ^ reference syntax 1.0.0 src/`destructuring.ts`/a0:
5252
// ^ reference local 36
5353
// ^ reference local 28
54-
// ^ reference syntax 1.0.0 src/`destructuring.ts`/Props#a.
54+
// ^ reference syntax 1.0.0 src/`destructuring.ts`/a0:
5555
}
5656

5757
export function forLoopObjectDestructuring(): number {
5858
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`destructuring.ts`/forLoopObjectDestructuring().
5959
for (const { a } of [props]) {
6060
// ^ definition local 41
61-
// ^ reference syntax 1.0.0 src/`destructuring.ts`/Props#a.
61+
// ^ reference syntax 1.0.0 src/`destructuring.ts`/a0:
6262
// ^^^^^ reference syntax 1.0.0 src/`destructuring.ts`/props.
6363
return a
6464
// ^ reference local 41
@@ -70,7 +70,7 @@ export function forLoopArrayDestructuring(): number {
7070
// ^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`destructuring.ts`/forLoopArrayDestructuring().
7171
for (const [{ a }] of [[props]]) {
7272
// ^ definition local 48
73-
// ^ reference syntax 1.0.0 src/`destructuring.ts`/Props#a.
73+
// ^ reference syntax 1.0.0 src/`destructuring.ts`/a0:
7474
// ^^^^^ reference syntax 1.0.0 src/`destructuring.ts`/props.
7575
return a
7676
// ^ reference local 48
@@ -81,7 +81,7 @@ export function forLoopArrayDestructuring(): number {
8181
export function parameterDestructuring({ a }: Props): number {
8282
// ^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`destructuring.ts`/parameterDestructuring().
8383
// ^ definition local 50
84-
// ^ reference syntax 1.0.0 src/`destructuring.ts`/Props#a.
84+
// ^ reference syntax 1.0.0 src/`destructuring.ts`/a0:
8585
// ^^^^^ reference syntax 1.0.0 src/`destructuring.ts`/Props#
8686
return a
8787
// ^ reference local 50

‎snapshots/output/syntax/src/infer-relationship.ts

+21-21
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
interface Configuration {
44
// ^^^^^^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/Configuration#
55
property: number
6-
//^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
6+
//^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property0:
77
}
88

99
function random(): number {
@@ -22,8 +22,8 @@ export function returnStatement(): Configuration {
2222
// ^^^^^^ reference syntax 1.0.0 src/`infer-relationship.ts`/random().
2323
return {
2424
property: 41,
25-
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property0:
26-
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
25+
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property1:
26+
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/property0:
2727
}
2828
}
2929
for (let i = 0; i < 9; i++) {
@@ -35,8 +35,8 @@ export function returnStatement(): Configuration {
3535
// ^ reference local 2
3636
return {
3737
property: 41,
38-
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property1:
39-
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
38+
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property2:
39+
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/property0:
4040
}
4141
}
4242
}
@@ -47,14 +47,14 @@ export function returnStatement(): Configuration {
4747
// ^ reference local 5
4848
return {
4949
property: 41,
50-
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property2:
51-
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
50+
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property3:
51+
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/property0:
5252
}
5353
}
5454
}
5555
for (const i in { '1': 2 }) {
5656
// ^ definition local 8
57-
// ^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/`'1'0`:
57+
// ^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/10:
5858
if (random() > Number.parseInt(i)) {
5959
// ^^^^^^ reference syntax 1.0.0 src/`infer-relationship.ts`/random().
6060
// ^^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Number#
@@ -65,35 +65,35 @@ export function returnStatement(): Configuration {
6565
// ^ reference local 8
6666
return {
6767
property: 41,
68-
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property3:
69-
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
68+
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property4:
69+
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/property0:
7070
}
7171
}
7272
}
7373
while (random() < 0) {
7474
// ^^^^^^ reference syntax 1.0.0 src/`infer-relationship.ts`/random().
7575
return {
7676
property: 41,
77-
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property4:
78-
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
77+
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property5:
78+
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/property0:
7979
}
8080
}
8181
do {
8282
if (random() > 0) {
8383
// ^^^^^^ reference syntax 1.0.0 src/`infer-relationship.ts`/random().
8484
return {
8585
property: 41,
86-
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property5:
87-
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
86+
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property6:
87+
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/property0:
8888
}
8989
}
9090
} while (random() < 0)
9191
// ^^^^^^ reference syntax 1.0.0 src/`infer-relationship.ts`/random().
9292

9393
return {
9494
property: 42,
95-
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property6:
96-
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
95+
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property7:
96+
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/property0:
9797
}
9898
}
9999

@@ -103,14 +103,14 @@ export function returnStatementInsideArgumentExpression(): Configuration[] {
103103
return [1].map<Configuration>(number => {
104104
// ^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Array#map().
105105
// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#
106-
// ^^^^^^ definition local 12
106+
// ^^^^^^ definition local 14
107107
const incremented = number + 1
108-
// ^^^^^^^^^^^ definition local 15
109-
// ^^^^^^ reference local 12
108+
// ^^^^^^^^^^^ definition local 17
109+
// ^^^^^^ reference local 14
110110
return {
111111
property: incremented,
112-
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property7:
113-
// ^^^^^^^^^^^ reference local 15
112+
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property8:
113+
// ^^^^^^^^^^^ reference local 17
114114
}
115115
})
116116
}

‎snapshots/output/syntax/src/inheritance.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Overloader } from './overload'
77
export interface Superinterface {
88
// ^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Superinterface#
99
property: string
10-
//^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
10+
//^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/property0:
1111
interfaceMethod(): string
1212
//^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Superinterface#interfaceMethod().
1313
}
@@ -58,7 +58,7 @@ export class Subclass
5858
}
5959
property = 'property'
6060
//^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#property.
61-
//relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
61+
//relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/property0:
6262
public overrideMethod(): string {
6363
// ^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#overrideMethod().
6464
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#overrideMethod().
@@ -93,8 +93,8 @@ export const objectLiteralImplementation: Superinterface = {
9393
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/objectLiteralImplementation.
9494
// ^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#
9595
property: 'property',
96-
//^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/property0:
97-
//relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
96+
//^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/property1:
97+
//relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/property0:
9898
interfaceMethod: (): string => {
9999
//^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/interfaceMethod0:
100100
//relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#interfaceMethod().
@@ -115,8 +115,8 @@ export function infersInterface(): void {
115115
// ^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/interfaceMethod1:
116116
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#interfaceMethod().
117117
property: 'inferred',
118-
// ^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/property1:
119-
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
118+
// ^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/property2:
119+
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/property0:
120120
})
121121
}
122122

‎snapshots/output/syntax/src/interface.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
export interface Interface {
44
// ^^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/Interface#
55
property: string
6-
//^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/Interface#property.
6+
//^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/property0:
77
methodSignature(param: string): string
88
//^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/Interface#methodSignature().
99
// ^^^^^ definition syntax 1.0.0 src/`interface.ts`/Interface#methodSignature().(param)
1010
methodSignature2: (param: string) => string
11-
//^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/Interface#methodSignature2.
11+
//^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/methodSignature20:
1212
// ^^^^^ definition local 1
1313
}
1414

@@ -17,8 +17,8 @@ export function newInterface(): Interface {
1717
// ^^^^^^^^^ reference syntax 1.0.0 src/`interface.ts`/Interface#
1818
return {
1919
property: 'a',
20-
// ^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/property0:
21-
// relationship implementation reference syntax 1.0.0 src/`interface.ts`/Interface#property.
20+
// ^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/property1:
21+
// relationship implementation reference syntax 1.0.0 src/`interface.ts`/property0:
2222
methodSignature(param: string): string {
2323
// ^^^^^^^^^^^^^^^ definition local 4
2424
// relationship implementation reference syntax 1.0.0 src/`interface.ts`/Interface#methodSignature().
@@ -27,11 +27,11 @@ export function newInterface(): Interface {
2727
// ^^^^^ reference local 5
2828
},
2929
methodSignature2: (param: string): string => {
30-
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/methodSignature20:
31-
// relationship implementation reference syntax 1.0.0 src/`interface.ts`/Interface#methodSignature2.
32-
// ^^^^^ definition local 7
30+
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/methodSignature21:
31+
// relationship implementation reference syntax 1.0.0 src/`interface.ts`/methodSignature20:
32+
// ^^^^^ definition local 8
3333
return param
34-
// ^^^^^ reference local 7
34+
// ^^^^^ reference local 8
3535
},
3636
}
3737
}

‎snapshots/output/syntax/src/local.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ export function local(): string {
1717
// ^ definition local 12
1818
// ^ reference local 12
1919
// ^ reference local 8
20-
// ^^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/String#length.
20+
// ^^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/length0:
2121
// ^ reference local 12
2222
c += d
2323
// ^ reference local 8
2424
// ^ reference local 12
2525
c2 += c.length
2626
// ^^ reference local 9
2727
// ^ reference local 8
28-
// ^^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/String#length.
28+
// ^^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/length0:
2929
}
3030
return [c, c2].reduce((previousValue, currentValue, currentIndex) => {
3131
// ^ reference local 8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// < definition syntax 1.0.0 src/`minimized-signatures.ts`/
2+
3+
// format-options: showSignatures
4+
5+
export type CompletionItemID = string & { _opaque: typeof CompletionItemID }
6+
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`minimized-signatures.ts`/CompletionItemID#
7+
// info {
8+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`minimized-signatures.ts`/CompletionItemID#",
9+
// | "documentation": [
10+
// | "```ts\ntype CompletionItemID\n```"
11+
// | ],
12+
// | "relationships": [],
13+
// | "kind": 55,
14+
// | "display_name": "CompletionItemID",
15+
// | "enclosing_symbol": "",
16+
// | "signature": {
17+
// | "type_signature": {
18+
// | "type_parameters": {
19+
// | "symlinks": [],
20+
// | "hardlinks": []
21+
// | },
22+
// | "lower_bound": {
23+
// | "intersection_type": {
24+
// | "types": [
25+
// | {
26+
// | "type_ref": {
27+
// | "symbol": "scip-typescript npm typescript . string#",
28+
// | "type_arguments": []
29+
// | }
30+
// | },
31+
// | {
32+
// | "structural_type": {
33+
// | "declarations": {
34+
// | "symlinks": [
35+
// | "scip-typescript npm syntax 1.0.0 src/`minimized-signatures.ts`/_opaque0:"
36+
// | ],
37+
// | "hardlinks": []
38+
// | }
39+
// | }
40+
// | }
41+
// | ]
42+
// | }
43+
// | }
44+
// | }
45+
// | }
46+
// | }
47+
// ^^^^^^^ definition syntax 1.0.0 src/`minimized-signatures.ts`/_opaque0:
48+
// info {
49+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`minimized-signatures.ts`/_opaque0:",
50+
// | "documentation": [
51+
// | "```ts\n(property) _opaque: unique symbol\n```"
52+
// | ],
53+
// | "relationships": [],
54+
// | "kind": 41,
55+
// | "display_name": "_opaque",
56+
// | "enclosing_symbol": "",
57+
// | "signature": {
58+
// | "value_signature": {
59+
// | "tpe": {}
60+
// | }
61+
// | }
62+
// | }
63+
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`minimized-signatures.ts`/CompletionItemID#
64+
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`minimized-signatures.ts`/CompletionItemID.
65+
declare const CompletionItemID: unique symbol
66+
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`minimized-signatures.ts`/CompletionItemID.
67+
// info {
68+
// | "symbol": "scip-typescript npm syntax 1.0.0 src/`minimized-signatures.ts`/CompletionItemID.",
69+
// | "documentation": [
70+
// | "```ts\nvar CompletionItemID: unique symbol\n```"
71+
// | ],
72+
// | "relationships": [],
73+
// | "kind": 61,
74+
// | "display_name": "CompletionItemID",
75+
// | "enclosing_symbol": "",
76+
// | "signature": {
77+
// | "value_signature": {
78+
// | "tpe": {
79+
// | "type_ref": {
80+
// | "symbol": "scip-typescript npm typescript . symbol#",
81+
// | "type_arguments": []
82+
// | }
83+
// | }
84+
// | }
85+
// | }
86+
// | }
87+
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// < definition syntax 1.0.0 src/`module.d.ts`/
22

33
declare module 'a:b' {
4-
// ^^^^^ definition syntax 1.0.0 src/`module.d.ts`/`'a:b'`/
4+
// ^^^^^ definition syntax 1.0.0 src/`module.d.ts`/`a:b`/
55
function hello(): string
6-
// ^^^^^ definition syntax 1.0.0 src/`module.d.ts`/`'a:b'`/hello().
6+
// ^^^^^ definition syntax 1.0.0 src/`module.d.ts`/`a:b`/hello().
77
}
88

‎snapshots/output/syntax/src/namespace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export declare namespace a {
77
interface Interface {
88
// ^^^^^^^^^ definition syntax 1.0.0 src/`namespace.ts`/a/Interface#
99
hello: string
10-
// ^^^^^ definition syntax 1.0.0 src/`namespace.ts`/a/Interface#hello.
10+
// ^^^^^ definition syntax 1.0.0 src/`namespace.ts`/hello0:
1111
}
1212
var i: Interface
1313
// ^ definition syntax 1.0.0 src/`namespace.ts`/a/i.

‎snapshots/output/syntax/src/signatures.ts

+1,981
Large diffs are not rendered by default.

‎snapshots/output/syntax/src/string-literals.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
interface SomeInterface {
44
// ^^^^^^^^^^^^^ definition syntax 1.0.0 src/`string-literals.ts`/SomeInterface#
55
a: number
6-
//^ definition syntax 1.0.0 src/`string-literals.ts`/SomeInterface#a.
6+
//^ definition syntax 1.0.0 src/`string-literals.ts`/a0:
77
b: number
8-
//^ definition syntax 1.0.0 src/`string-literals.ts`/SomeInterface#b.
8+
//^ definition syntax 1.0.0 src/`string-literals.ts`/b0:
99
c: number
10-
//^ definition syntax 1.0.0 src/`string-literals.ts`/SomeInterface#c.
10+
//^ definition syntax 1.0.0 src/`string-literals.ts`/c0:
1111
}
1212
// "Go to definition" does not work for the 'a', 'b' and 'c' string literals
1313
// below when using tsserver so it's fine that scip-typescript does not emit

‎snapshots/output/syntax/src/structural-type.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ export function foo(): Promise<{ member: number }> {
77
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2015.promise.d.ts`/Promise.
88
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2015.symbol.wellknown.d.ts`/Promise#
99
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2018.promise.d.ts`/Promise#
10-
// ^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/foo().Promise:typeLiteral0:member.
10+
// ^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/member0:
1111
return Promise.resolve({ member: 42 })
1212
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Promise#
1313
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2015.iterable.d.ts`/Promise#
1414
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2015.promise.d.ts`/Promise.
1515
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2015.symbol.wellknown.d.ts`/Promise#
1616
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2018.promise.d.ts`/Promise#
1717
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2015.promise.d.ts`/PromiseConstructor#resolve().
18-
// ^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/member0:
18+
// ^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/member1:
1919
}
2020
export function bar(): Promise<number> {
2121
// ^^^ definition syntax 1.0.0 src/`structural-type.ts`/bar().
@@ -29,7 +29,7 @@ export function bar(): Promise<number> {
2929
// ^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Promise#then().
3030
// ^ definition local 4
3131
// ^ reference local 4
32-
// ^^^^^^ reference syntax 1.0.0 src/`structural-type.ts`/foo().Promise:typeLiteral0:member.
32+
// ^^^^^^ reference syntax 1.0.0 src/`structural-type.ts`/member0:
3333
}
3434
export function bar2(): Promise<number> {
3535
// ^^^^ definition syntax 1.0.0 src/`structural-type.ts`/bar2().
@@ -42,7 +42,7 @@ export function bar2(): Promise<number> {
4242
// ^^^ reference syntax 1.0.0 src/`structural-type.ts`/foo().
4343
// ^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Promise#then().
4444
// ^^^^^^ definition local 10
45-
// ^^^^^^ reference syntax 1.0.0 src/`structural-type.ts`/foo().Promise:typeLiteral0:member.
45+
// ^^^^^^ reference syntax 1.0.0 src/`structural-type.ts`/member0:
4646
// ^^^^^^ reference local 10
4747
}
4848

@@ -53,13 +53,20 @@ type OptionsFlags<Type> = { [Property in keyof Type]: boolean }
5353
// ^^^^ reference syntax 1.0.0 src/`structural-type.ts`/OptionsFlags#[Type]
5454
type FeatureFlags = { darkMode: () => void }
5555
// ^^^^^^^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/FeatureFlags#
56-
// ^^^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/FeatureFlags#typeLiteral13:darkMode.
56+
// ^^^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/darkMode0:
57+
export type PropertySignature = {
58+
// ^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/PropertySignature#
59+
'chat/submit': [{ text: { value: string } }]
60+
//^^^^^^^^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/`chat/submit0`:
61+
// ^^^^ definition syntax 1.0.0 src/`structural-type.ts`/text0:
62+
// ^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/value0:
63+
}
5764
export type FeatureOptions = OptionsFlags<FeatureFlags> // implicitly // type FeatureOptions = { // darkMode: boolean; // } const fo: FeatureOptions = { darkMode: true }; // ^ go to def
5865
// ^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/FeatureOptions#
5966
// ^^^^^^^^^^^^ reference syntax 1.0.0 src/`structural-type.ts`/OptionsFlags#
6067
// ^^^^^^^^^^^^ reference syntax 1.0.0 src/`structural-type.ts`/FeatureFlags#
6168
export const fo: FeatureOptions = { darkMode: true }
6269
// ^^ definition syntax 1.0.0 src/`structural-type.ts`/fo.
6370
// ^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`structural-type.ts`/FeatureOptions#
64-
// ^^^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/darkMode0:
71+
// ^^^^^^^^ definition syntax 1.0.0 src/`structural-type.ts`/darkMode1:
6572

‎snapshots/output/syntax/src/typings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export function process() {
55
return window.process
66
// ^^^^^^ reference typescript 5.3.3 lib/`lib.dom.d.ts`/window.
77
// ^^^^^^^ reference @types/node 20.10.5 `globals.d.ts`/global/process.
8-
// ^^^^^^^ reference @types/node 20.10.5 `process.d.ts`/`"process"`/global/process.
8+
// ^^^^^^^ reference @types/node 20.10.5 `process.d.ts`/process/global/process.
99
}
1010

‎snapshots/yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
2727
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==
2828

29+
"@types/vscode@1.86.0":
30+
version "1.86.0"
31+
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.86.0.tgz#5d5f233137b27e51d7ad1462600005741296357a"
32+
integrity sha512-DnIXf2ftWv+9LWOB5OJeIeaLigLHF7fdXF6atfc7X5g2w/wVZBgk0amP7b+ub5xAuW1q7qP5YcFvOcit/DtyCQ==
33+
2934
csstype@^3.0.2:
3035
version "3.0.11"
3136
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.11.tgz#d66700c5eacfac1940deb4e3ee5642792d85cd33"

‎src/CommandLineOptions.ts

+21
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export interface MultiProjectOptions {
1414
yarnBerryWorkspaces: boolean
1515
pnpmWorkspaces: boolean
1616
globalCaches: boolean
17+
emitSignatures: boolean
18+
followSourceMapping: boolean
19+
emitExternalSymbols: boolean
1720
maxFileByteSize?: string
1821
maxFileByteSizeNumber?: number
1922
cwd: string
@@ -35,6 +38,7 @@ export interface GlobalCache {
3538
[ts.SourceFile | undefined, ts.ScriptTarget | ts.CreateSourceFileOptions]
3639
>
3740
parsedCommandLines: Map<string, ts.ParsedCommandLine>
41+
externalSymbols: Map<string, scip.scip.SymbolInformation>
3842
}
3943

4044
export function mainCommand(
@@ -69,6 +73,23 @@ export function mainCommand(
6973
'--no-global-caches',
7074
'whether to disable global caches between TypeScript projects'
7175
)
76+
.option(
77+
'--emit-signatures',
78+
'whether to emit experimental `SymbolInformation.signatures`',
79+
false
80+
)
81+
.option(
82+
'--emit-external-symbols',
83+
'whether to emit `SymbolInformation` for external symbols (defined outside this project)',
84+
false
85+
)
86+
.option(
87+
'--follow-source-mapping',
88+
'if true, follow `sourceMappingURL` in declaration files. ' +
89+
'In multi-project workspaces, this option allows more accurate ' +
90+
'cross-project navigation.',
91+
true
92+
)
7293
.option(
7394
'--max-file-byte-size <value>',
7495
'skip files that have a larger byte size than the provided value. Supported formats: 1kb, 1mb, 1gb.',

‎src/FileIndexer.ts

+582-50
Large diffs are not rendered by default.

‎src/ProjectIndexer.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class ProjectIndexer {
7777
constructor(
7878
public readonly config: ts.ParsedCommandLine,
7979
public readonly options: ProjectOptions,
80-
cache: GlobalCache
80+
private readonly cache: GlobalCache
8181
) {
8282
const host = createCompilerHost(cache, config.options, options)
8383
this.program = ts.createProgram(config.fileNames, config.options, host)
@@ -141,6 +141,7 @@ export class ProjectIndexer {
141141
input,
142142
document,
143143
this.symbolCache,
144+
this.cache,
144145
this.hasConstructor,
145146
this.packages,
146147
sourceFile

‎src/ScipSymbol.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { descriptorString } from './Descriptor'
1+
import { descriptorString, typeDescriptor } from './Descriptor'
22
import * as scip from './scip'
33

44
export class ScipSymbol {
5-
private constructor(public readonly value: string) {}
5+
private constructor(
6+
public readonly value: string,
7+
private readonly descriptor?: scip.scip.Descriptor
8+
) {}
9+
10+
public get display_name(): string | undefined {
11+
return this.descriptor?.name
12+
}
613

714
public isEmpty(): boolean {
815
return this.value === ''
@@ -28,6 +35,13 @@ export class ScipSymbol {
2835
return ScipSymbol.package('.', '.')
2936
}
3037

38+
public static builtinType(value: string): ScipSymbol {
39+
return ScipSymbol.global(
40+
ScipSymbol.package('typescript', '.'),
41+
typeDescriptor(value)
42+
)
43+
}
44+
3145
public static global(
3246
owner: ScipSymbol,
3347
descriptor: scip.scip.Descriptor

‎src/SnapshotTesting.ts

+50
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ function getSymbolTable(
1919
function parseOptions(lines: string[]): {
2020
showDocs: boolean
2121
showRanges: boolean
22+
showSignatures: boolean
23+
showExternalSymbols: boolean
2224
} {
2325
const formatOptions = {
2426
showDocs: false,
2527
showRanges: false,
28+
showSignatures: false,
29+
showExternalSymbols: false,
2630
}
2731

2832
for (const line of lines) {
@@ -186,6 +190,37 @@ export function formatSnapshot(
186190
out.push('\n')
187191
}
188192

193+
const pushSignature = (
194+
range: Range,
195+
symbol: string,
196+
isDefinition: boolean
197+
): void => {
198+
if (!isDefinition) {
199+
return
200+
}
201+
if (!formatOptions.showSignatures) {
202+
return
203+
}
204+
const info = symbolTable.get(symbol)
205+
if (!info?.signature) {
206+
return
207+
}
208+
out.push(commentSyntax)
209+
const indent = ' '.repeat(Math.max(1, range.start.character - 2))
210+
out.push(indent)
211+
out.push('info ')
212+
const formatted = JSON.stringify(info.toObject(), null, 2)
213+
for (const [lineNumber, line] of formatted.split('\n').entries()) {
214+
if (lineNumber !== 0) {
215+
out.push(commentSyntax)
216+
out.push(indent)
217+
out.push('| ')
218+
}
219+
out.push(line)
220+
out.push('\n')
221+
}
222+
}
223+
189224
const pushEnclosingRange = (
190225
enclosingRange: {
191226
range: Range
@@ -295,13 +330,28 @@ export function formatSnapshot(
295330
out.push(symbol.replace('\n', '|'))
296331

297332
pushDoc(range, occurrence.symbol, isDefinition, isStartOfLine)
333+
pushSignature(range, occurrence.symbol, isDefinition)
298334
}
299335

300336
// Check if any enclosing ranges end on this line
301337
for (const enclosingRange of enclosingRangeEnds[lineNumber]) {
302338
pushEnclosingRange(enclosingRange, true)
303339
}
304340
}
341+
if (formatOptions.showExternalSymbols) {
342+
for (const symbol of externalSymbols) {
343+
out.push('\n')
344+
const lines = JSON.stringify(symbol.toObject(), null, 2).split('\n')
345+
out.push('// externalSymbol: ')
346+
for (const [index, line] of lines.entries()) {
347+
if (index !== 0) {
348+
out.push('// |')
349+
}
350+
out.push(line)
351+
out.push('\n')
352+
}
353+
}
354+
}
305355
return out.join('')
306356
}
307357

‎src/main.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ for (const snapshotDirectory of snapshotDirectories) {
6161
progressBar: false,
6262
indexedProjects: new Set(),
6363
globalCaches: true,
64+
emitSignatures: true,
65+
emitExternalSymbols: true,
66+
followSourceMapping: true,
6467
})
6568
if (inferTsconfig) {
6669
fs.rmSync(tsconfigJsonPath)
@@ -81,7 +84,7 @@ for (const snapshotDirectory of snapshotDirectories) {
8184
? fs.readFileSync(outputPath).toString()
8285
: ''
8386
const input = Input.fromFile(inputPath)
84-
const obtained = formatSnapshot(input, document)
87+
const obtained = formatSnapshot(input, document, index.external_symbols)
8588
if (obtained === expected) {
8689
// Test passed
8790
continue

‎src/main.ts

+9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function indexCommand(
5454
const cache: GlobalCache = {
5555
sources: new Map(),
5656
parsedCommandLines: new Map(),
57+
externalSymbols: new Map(),
5758
}
5859
try {
5960
writeIndex(
@@ -84,6 +85,14 @@ export function indexCommand(
8485
cache
8586
)
8687
}
88+
89+
if (cache.externalSymbols.size > 0) {
90+
writeIndex(
91+
new scip.scip.Index({
92+
external_symbols: [...cache.externalSymbols.values()],
93+
})
94+
)
95+
}
8796
} finally {
8897
fs.close(output)
8998
if (documentCount > 0) {

‎src/scip.ts

+4,211
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.