Repository navigation
Description
π Search Terms
"no project for unknown script kind: no project found for URI", contentmapper, LSP
π Version & Regression Information
Compiled on the latest main (5e32f3249529c40a56011c583b416ad838ffb682)
β― Playground Link
No response
π» Code
// repro.mjs
import { spawn } from "node:child_process"
import { fileURLToPath } from "node:url"
import { createProtocolConnection } from "vscode-languageserver-protocol/node"
const server = spawn("tsc", [
"--lsp",
"--stdio",
])
const connection = createProtocolConnection(server.stdout, server.stdin)
connection.listen()
const textDocument = { uri: "file:///App.vue" }
const position = { line: 0, character: 0 }
const range = { start: position, end: position }
const options = { tabSize: 4, insertSpaces: true }
const item = {
...textDocument,
name: "stale",
kind: 12,
range,
selectionRange: range,
}
try {
await connection.sendRequest("initialize", {
processId: process.pid,
rootUri: null,
capabilities: {},
})
await connection.sendNotification("initialized", {})
await connection.sendNotification("textDocument/didOpen", {
textDocument: { ...textDocument, languageId: "vue", version: 1, text: "" },
})
for (const [method, params] of [
...[
["hover", { position }],
["diagnostic"],
["signatureHelp", { position }],
["definition", { position }],
["typeDefinition", { position }],
["implementation", { position }],
["references", { position, context: { includeDeclaration: true } }],
["documentHighlight", { position }],
["completion", { position }],
["rename", { position, newName: "renamed" }],
["codeAction", { range, context: { diagnostics: [] } }],
["semanticTokens/full"],
["semanticTokens/range", { range }],
["documentSymbol"],
["foldingRange"],
["selectionRange", { positions: [position] }],
["inlayHint", { range }],
["codeLens"],
["formatting", { options }],
["rangeFormatting", { range, options }],
["onTypeFormatting", { position, ch: ";", options }],
["linkedEditingRange", { position }],
["prepareCallHierarchy", { position }],
["prepareRename", { position }],
].map(([method, params]) => [
`textDocument/${method}`,
{ textDocument, ...params },
]),
["callHierarchy/incomingCalls", { item }],
["callHierarchy/outgoingCalls", { item }],
[
"completionItem/resolve",
{
label: "stale",
data: {
fileName: fileURLToPath(textDocument.uri),
position: 0,
name: "stale",
},
},
],
[
"codeLens/resolve",
{
range,
data: { uri: textDocument.uri, kind: "references", position: 0 },
},
],
]) {
try {
console.log(
`${method}:`,
JSON.stringify(await connection.sendRequest(method, params)),
)
} catch ({ code, message }) {
console.log(`${method}: ${code} ${message}`)
if (code !== -32801) process.exitCode = 1
}
}
} finally {
connection.dispose()
server.kill()
}And then node repro.mjs
π Actual behavior
> node repro.mjs
textDocument/hover: null
textDocument/diagnostic: {"kind":"full","items":[]}
textDocument/signatureHelp: null
textDocument/definition: null
textDocument/typeDefinition: null
textDocument/implementation: null
textDocument/references: null
textDocument/documentHighlight: null
textDocument/completion: null
textDocument/rename: null
textDocument/codeAction: null
textDocument/semanticTokens/full: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/semanticTokens/range: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/documentSymbol: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/foldingRange: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/selectionRange: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/inlayHint: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/codeLens: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/formatting: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/rangeFormatting: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/onTypeFormatting: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/linkedEditingRange: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/prepareCallHierarchy: -32603 no project for unknown script kind: no project found for URI file:///App.vue
textDocument/prepareRename: -32603 no project for unknown script kind: no project found for URI file:///App.vue
callHierarchy/incomingCalls: -32603 no project for unknown script kind: no project found for URI file:///App.vue
callHierarchy/outgoingCalls: -32603 no project for unknown script kind: no project found for URI file:///App.vue
completionItem/resolve: -32603 no project for unknown script kind: no project found for URI file:///App.vue
codeLens/resolve: -32801 ContentModified
π Expected behavior
All methods advertised through dynamic registration for content mapped files should return null as a fallback, not just some of them.
Additional information about the issue
The LSP server does dynamic registration for these features:
TypeScript/tsc/internal/lsp/server.go
Lines 364 to 386 in 5e32f32
| contentMapperDiagnosticRegistrationID = "content-mapper-diagnostic" | |
| contentMapperHoverRegistrationID = "content-mapper-hover" | |
| contentMapperSignatureHelpRegistrationID = "content-mapper-signature-help" | |
| contentMapperDefinitionRegistrationID = "content-mapper-definition" | |
| contentMapperTypeDefinitionRegistrationID = "content-mapper-type-definition" | |
| contentMapperImplementationRegistrationID = "content-mapper-implementation" | |
| contentMapperReferencesRegistrationID = "content-mapper-references" | |
| contentMapperDocumentHighlightRegistrationID = "content-mapper-document-highlight" | |
| contentMapperCompletionRegistrationID = "content-mapper-completion" | |
| contentMapperRenameRegistrationID = "content-mapper-rename" | |
| contentMapperSemanticTokensRegistrationID = "content-mapper-semantic-tokens" | |
| contentMapperDocumentSymbolRegistrationID = "content-mapper-document-symbol" | |
| contentMapperFoldingRangeRegistrationID = "content-mapper-folding-range" | |
| contentMapperSelectionRangeRegistrationID = "content-mapper-selection-range" | |
| contentMapperInlayHintRegistrationID = "content-mapper-inlay-hint" | |
| contentMapperCodeLensRegistrationID = "content-mapper-code-lens" | |
| contentMapperCodeActionRegistrationID = "content-mapper-code-action" | |
| contentMapperFormattingRegistrationID = "content-mapper-formatting" | |
| contentMapperRangeFormattingRegistrationID = "content-mapper-range-formatting" | |
| contentMapperOnTypeFormattingRegistrationID = "content-mapper-on-type-formatting" | |
| contentMapperLinkedEditingRegistrationID = "content-mapper-linked-editing" | |
| contentMapperCallHierarchyRegistrationID = "content-mapper-call-hierarchy" | |
| contentMapperWillRenameFilesRegistrationID = "content-mapper-will-rename-files" |
However, only a subset of them is handled in contentMapperFallbackResponse:
TypeScript/tsc/internal/lsp/server.go
Lines 1248 to 1276 in 5e32f32
| // contentMapperFallbackResponse returns an empty response for requests made for | |
| // unknown file types not handled by any content mapper. This typically serves a | |
| // short window in time between when the server has unregistered content mapper | |
| // extensions and when the client has stopped sending requests for those file types. | |
| func contentMapperFallbackResponse(method lsproto.Method, err error) (any, bool) { | |
| if !errors.Is(err, project.ErrNoProjectForUnknownScriptKind) { | |
| return nil, false | |
| } | |
| switch method { | |
| case lsproto.MethodTextDocumentDiagnostic: | |
| return lsproto.DocumentDiagnosticResponse{ | |
| FullDocumentDiagnosticReport: &lsproto.RelatedFullDocumentDiagnosticReport{ | |
| Items: []*lsproto.Diagnostic{}, | |
| }, | |
| }, true | |
| case lsproto.MethodTextDocumentHover, | |
| lsproto.MethodTextDocumentSignatureHelp, | |
| lsproto.MethodTextDocumentDefinition, | |
| lsproto.MethodTextDocumentTypeDefinition, | |
| lsproto.MethodTextDocumentImplementation, | |
| lsproto.MethodTextDocumentReferences, | |
| lsproto.MethodTextDocumentDocumentHighlight, | |
| lsproto.MethodTextDocumentCompletion, | |
| lsproto.MethodTextDocumentRename: | |
| return lsproto.Null{}, true | |
| default: | |
| return nil, false | |
| } | |
| } |
This means that, for example, a textDocument/hover request for a file whose content mapper was just removed returns null, while a textDocument/inlayHint for the same file returns -32603 no project for unknown script kind: no project found for URI file:///App.vue.
Activity