Skip to content

Fix completion entry conversion to protocol format #59410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2469,6 +2469,7 @@ export class Session<TMessage = string> implements EventSender {
isPackageJsonImport,
isImportStatementCompletion,
data,
commitCharacters,
} = entry;
const convertedSpan = replacementSpan ? toProtocolTextSpan(replacementSpan, scriptInfo) : undefined;
// Use `hasAction || undefined` to avoid serializing `false`.
Expand All @@ -2489,6 +2490,7 @@ export class Session<TMessage = string> implements EventSender {
isPackageJsonImport,
isImportStatementCompletion,
data,
commitCharacters,
};
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// === Completions ===
=== /src/index.ts ===
// const a: "aa" | "bb" = "";
// ^
// | ----------------------------------------------------------------------
// | aa
// | bb
// | ----------------------------------------------------------------------

[
{
"marker": {
"fileName": "/src/index.ts",
"position": 24,
"name": ""
},
"item": {
"isGlobalCompletion": false,
"isMemberCompletion": false,
"isNewIdentifierLocation": false,
"entries": [
{
"name": "aa",
"kind": "string",
"kindModifiers": "",
"sortText": "11",
"replacementSpan": {
"start": 24,
"length": 0
},
"commitCharacters": [],
"displayParts": [
{
"text": "aa",
"kind": "text"
}
],
"tags": []
},
{
"name": "bb",
"kind": "string",
"kindModifiers": "",
"sortText": "11",
"replacementSpan": {
"start": 24,
"length": 0
},
"commitCharacters": [],
"displayParts": [
{
"text": "bb",
"kind": "text"
}
],
"tags": []
}
],
"defaultCommitCharacters": [
".",
",",
";"
]
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,8 @@ Info seq [hh:mm:ss:mss] response:
"name": "BrowserRouter",
"kind": "warning",
"kindModifiers": "",
"sortText": "18"
"sortText": "18",
"commitCharacters": []
}
],
"defaultCommitCharacters": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,15 @@ Info seq [hh:mm:ss:mss] response:
"name": "exports",
"kind": "warning",
"kindModifiers": "",
"sortText": "18"
"sortText": "18",
"commitCharacters": []
},
{
"name": "p1",
"kind": "warning",
"kindModifiers": "",
"sortText": "18"
"sortText": "18",
"commitCharacters": []
},
{
"name": "escape",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,13 +719,15 @@ Info seq [hh:mm:ss:mss] response:
"name": "exports",
"kind": "warning",
"kindModifiers": "",
"sortText": "18"
"sortText": "18",
"commitCharacters": []
},
{
"name": "p1",
"kind": "warning",
"kindModifiers": "",
"sortText": "18"
"sortText": "18",
"commitCharacters": []
},
{
"name": "escape",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
currentDirectory:: / useCaseSensitiveFileNames: false
Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist
//// [/lib.d.ts]
lib.d.ts-Text

//// [/lib.decorators.d.ts]
lib.decorators.d.ts-Text

//// [/lib.decorators.legacy.d.ts]
lib.decorators.legacy.d.ts-Text

//// [/src/index.ts]
const a: "aa" | "bb" = "";


Info seq [hh:mm:ss:mss] request:
{
"seq": 0,
"type": "request",
"arguments": {
"file": "/src/index.ts"
},
"command": "open"
}
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /src/index.ts ProjectRootPath: undefined:: Result: undefined
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.d.ts 500 undefined WatchType: Closed Script info
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 500 undefined WatchType: Closed Script info
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred)
Info seq [hh:mm:ss:mss] Files (4)
/lib.d.ts Text-1 lib.d.ts-Text
/lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
/lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
/src/index.ts SVC-1-0 "const a: \"aa\" | \"bb\" = \"\";"


../lib.d.ts
Default library for target 'es5'
../lib.decorators.d.ts
Library referenced via 'decorators' from file '../lib.d.ts'
../lib.decorators.legacy.d.ts
Library referenced via 'decorators.legacy' from file '../lib.d.ts'
index.ts
Root file specified for compilation

Info seq [hh:mm:ss:mss] -----------------------------------------------
Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred)
Info seq [hh:mm:ss:mss] Files (4)

Info seq [hh:mm:ss:mss] -----------------------------------------------
Info seq [hh:mm:ss:mss] Open files:
Info seq [hh:mm:ss:mss] FileName: /src/index.ts ProjectRootPath: undefined
Info seq [hh:mm:ss:mss] Projects: /dev/null/inferredProject1*
Info seq [hh:mm:ss:mss] response:
{
"seq": 0,
"type": "response",
"command": "open",
"request_seq": 0,
"success": true,
"performanceData": {
"updateGraphDurationMs": *
}
}
After Request
watchedFiles::
/lib.d.ts: *new*
{"pollingInterval":500}
/lib.decorators.d.ts: *new*
{"pollingInterval":500}
/lib.decorators.legacy.d.ts: *new*
{"pollingInterval":500}

Projects::
/dev/null/inferredProject1* (Inferred) *new*
projectStateVersion: 1
projectProgramVersion: 1

ScriptInfos::
/lib.d.ts *new*
version: Text-1
containingProjects: 1
/dev/null/inferredProject1*
/lib.decorators.d.ts *new*
version: Text-1
containingProjects: 1
/dev/null/inferredProject1*
/lib.decorators.legacy.d.ts *new*
version: Text-1
containingProjects: 1
/dev/null/inferredProject1*
/src/index.ts (Open) *new*
version: SVC-1-0
containingProjects: 1
/dev/null/inferredProject1* *default*

Info seq [hh:mm:ss:mss] request:
{
"seq": 1,
"type": "request",
"arguments": {
"file": "/src/index.ts",
"line": 1,
"offset": 25
},
"command": "completionInfo"
}
Info seq [hh:mm:ss:mss] response:
{
"seq": 0,
"type": "response",
"command": "completionInfo",
"request_seq": 1,
"success": true,
"body": {
"isGlobalCompletion": false,
"isMemberCompletion": false,
"isNewIdentifierLocation": false,
"optionalReplacementSpan": {
"start": {
"line": 1,
"offset": 25
},
"end": {
"line": 1,
"offset": 25
}
},
"entries": [
{
"name": "aa",
"kind": "string",
"kindModifiers": "",
"sortText": "11",
"replacementSpan": {
"start": {
"line": 1,
"offset": 25
},
"end": {
"line": 1,
"offset": 25
}
},
"commitCharacters": []
},
{
"name": "bb",
"kind": "string",
"kindModifiers": "",
"sortText": "11",
"replacementSpan": {
"start": {
"line": 1,
"offset": 25
},
"end": {
"line": 1,
"offset": 25
}
},
"commitCharacters": []
}
],
"defaultCommitCharacters": [
".",
",",
";"
]
}
}
Info seq [hh:mm:ss:mss] request:
{
"seq": 2,
"type": "request",
"arguments": {
"file": "/src/index.ts",
"line": 1,
"offset": 25,
"entryNames": [
{
"name": "aa"
}
]
},
"command": "completionEntryDetails-full"
}
Info seq [hh:mm:ss:mss] response:
{
"seq": 0,
"type": "response",
"command": "completionEntryDetails-full",
"request_seq": 2,
"success": true,
"body": [
{
"name": "aa",
"kindModifiers": "",
"kind": "string",
"displayParts": [
{
"text": "aa",
"kind": "text"
}
],
"tags": []
}
]
}
Info seq [hh:mm:ss:mss] request:
{
"seq": 3,
"type": "request",
"arguments": {
"file": "/src/index.ts",
"line": 1,
"offset": 25,
"entryNames": [
{
"name": "bb"
}
]
},
"command": "completionEntryDetails-full"
}
Info seq [hh:mm:ss:mss] response:
{
"seq": 0,
"type": "response",
"command": "completionEntryDetails-full",
"request_seq": 3,
"success": true,
"body": [
{
"name": "bb",
"kindModifiers": "",
"kind": "string",
"displayParts": [
{
"text": "bb",
"kind": "text"
}
],
"tags": []
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,15 @@ Info seq [hh:mm:ss:mss] response:
"name": "test",
"kind": "warning",
"kindModifiers": "",
"sortText": "18"
"sortText": "18",
"commitCharacters": []
},
{
"name": "type",
"kind": "warning",
"kindModifiers": "",
"sortText": "18"
"sortText": "18",
"commitCharacters": []
},
{
"name": "substr",
Expand Down
Loading