Skip to content

Commit 6490a88

Browse files
committed
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 70bab97 commit 6490a88

40 files changed

+7361
-495
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

-51
This file was deleted.

snapshots/output/enclosing-ranges/range.js

-79
This file was deleted.

snapshots/output/invalid-package-json/packages/a/src/a.ts

-7
This file was deleted.

snapshots/output/multi-project/packages/a/src/index.ts

-15
This file was deleted.

snapshots/output/multi-project/packages/b/src/b.ts

-12
This file was deleted.

snapshots/output/pnpm-workspaces/packages/a/src/a.ts

-7
This file was deleted.

snapshots/output/pnpm-workspaces/packages/b/src/b.ts

-12
This file was deleted.

0 commit comments

Comments
 (0)