Skip to content
41 changes: 41 additions & 0 deletions packages/vscode-typescript/l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,47 @@
"{0} extensions contribute TypeScript server plugins that will not be loaded because TypeScript 7 is enabled globally: {1}": "{0} extensions contribute TypeScript server plugins that will not be loaded because TypeScript 7 is enabled globally: {1}",
"Disable Native Preview in Workspace": "Disable Native Preview in Workspace",
"Don't Show Again": "Don't Show Again",
"Open virtual documents to inspect diagnostic directives.": "Open virtual documents to inspect diagnostic directives.",
"{0} directive": "{0} directive",
"{0} directives": "{0} directives",
"Reveal Diagnostic Directive": "Reveal Diagnostic Directive",
"The current content-mapped file has no diagnostic directives.": "The current content-mapped file has no diagnostic directives.",
"Original range: {0}": "Original range: {0}",
"Virtual range: {0}": "Virtual range: {0}",
"Preview:": "Preview:",
"Unused diagnostic code: {0}": "Unused diagnostic code: {0}",
"Expect": "Expect",
"Unknown ({0})": "Unknown ({0})",
"Could not reveal diagnostic directive: {0}": "Could not reveal diagnostic directive: {0}",
"Open a content-mapped source file to show its virtual TypeScript documents.": "Open a content-mapped source file to show its virtual TypeScript documents.",
"The active file is not transformed by a TypeScript content mapper.": "The active file is not transformed by a TypeScript content mapper.",
"Content mapper inspector is unavailable: {0}": "Content mapper inspector is unavailable: {0}",
"Span kind: {0}": "Span kind: {0}",
"Features: {0}": "Features: {0}",
"None": "None",
"Verbatim": "Verbatim",
"Atom": "Atom",
"Alias": "Alias",
"Hover": "Hover",
"Signature Help": "Signature Help",
"Completion": "Completion",
"Definition": "Definition",
"Type Definition": "Type Definition",
"Implementation": "Implementation",
"References": "References",
"Document Highlights": "Document Highlights",
"Rename": "Rename",
"Call Hierarchy": "Call Hierarchy",
"Code Actions": "Code Actions",
"Formatting": "Formatting",
"Inlay Hints": "Inlay Hints",
"Semantic Tokens": "Semantic Tokens",
"Folding Ranges": "Folding Ranges",
"Selection Ranges": "Selection Ranges",
"Linked Editing": "Linked Editing",
"Auto Insert": "Auto Insert",
"Document Symbols": "Document Symbols",
"CodeLens": "CodeLens",
"Unexpected number of arguments.": "Unexpected number of arguments.",
"Starting language server...": "Starting language server...",
"Language client is not initialized": "Language client is not initialized",
Expand Down
30 changes: 29 additions & 1 deletion packages/vscode-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"onLanguage:javascript",
"onLanguage:javascriptreact",
"onLanguage:typescript",
"onLanguage:typescriptreact"
"onLanguage:typescriptreact",
"onFileSystem:typescript-content-mapper"
],
"contributes": {
"configuration": [
Expand Down Expand Up @@ -224,6 +225,16 @@
}
}
],
"views": {
"explorer": [
{
"id": "typescript.native-preview.contentMapperDiagnosticDirectives",
"name": "%native-preview.contentMapperDiagnosticDirectives.name%",
"icon": "$(list-tree)",
"when": "typescript.native-preview.serverRunning && typescript.native-preview.contentMapperInspectorEnabled"
}
]
},
"commands": [
{
"command": "typescript.native-preview.enable",
Expand Down Expand Up @@ -267,6 +278,12 @@
"enablement": "typescript.native-preview.serverRunning",
"category": "TypeScript"
},
{
"command": "typescript.native-preview.showContentMapperVirtualDocuments",
"title": "%native-preview.showContentMapperVirtualDocuments.title%",
"enablement": "typescript.native-preview.serverRunning && typescript.native-preview.activeEditorIsContentMapped",
"category": "TypeScript"
},
{
"command": "typescript.native-preview.sortImports",
"title": "%native-preview.sortImports.title%",
Expand Down Expand Up @@ -339,6 +356,10 @@
"command": "typescript.native-preview.goToSourceDefinition",
"when": "typescript.native-preview.serverRunning && tsSupportsSourceDefinition"
},
{
"command": "typescript.native-preview.showContentMapperVirtualDocuments",
"when": "typescript.native-preview.serverRunning && typescript.native-preview.activeEditorIsContentMapped"
},
{
"command": "typescript.native-preview.sortImports",
"when": "typescript.native-preview.serverRunning && supportedCodeAction =~ /(\\s|^)source\\.sortImports\\b/ && editorLangId =~ /^(typescript|javascript)(react)?$/"
Expand All @@ -354,6 +375,13 @@
"when": "typescript.native-preview.serverRunning && tsSupportsSourceDefinition && (resourceLangId == typescript || resourceLangId == typescriptreact || resourceLangId == javascript || resourceLangId == javascriptreact)",
"group": "navigation@1.41"
}
],
"editor/title/context": [
{
"command": "typescript.native-preview.showContentMapperVirtualDocuments",
"when": "typescript.native-preview.serverRunning && typescript.native-preview.activeEditorIsContentMapped",
"group": "navigation@1.5"
}
]
}
},
Expand Down
2 changes: 2 additions & 0 deletions packages/vscode-typescript/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"native-preview.reportIssue.title": "Report Issue",
"native-preview.selectVersion.title": "Select TypeScript Version...",
"native-preview.goToSourceDefinition.title": "Go to Source Definition",
"native-preview.showContentMapperVirtualDocuments.title": "Show Content Mapper Virtual Documents",
"native-preview.contentMapperDiagnosticDirectives.name": "Content Mapper Diagnostic Directives",
"native-preview.sortImports.title": "Sort Imports",
"native-preview.removeUnusedImports.title": "Remove Unused Imports",
"native-preview.codeLens.showLocations.title": "Show References of CodeLens",
Expand Down
27 changes: 27 additions & 0 deletions packages/vscode-typescript/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import {
sendNotificationMiddleware,
} from "./configurationMiddleware";
import type { SerializedContentMapperContribution } from "./contentMapperContributions";
import {
type ContentMapperVirtualFile,
type MappedOutput,
toMappedOutputs,
} from "./contentMapperVirtualFiles";
import { registerMultiDocumentHighlightFeature } from "./languageFeatures/documentHighlight";
import { registerHoverFeature } from "./languageFeatures/hover";
import { registerOnAutoInsertFeature } from "./languageFeatures/onAutoInsert";
Expand Down Expand Up @@ -436,6 +441,28 @@ export class Client implements vscode.Disposable {
return this.client.sendRequest<{ sessionId: string; pipe: string; }>("custom/initializeAPISession", { pipe });
}

async getContentMapperVirtualFiles(uri: vscode.Uri): Promise<readonly MappedOutput[]> {
if (!this.client) {
throw new Error(vscode.l10n.t("Language client is not initialized"));
}
const result = await this.client.sendRequest<{ files: ContentMapperVirtualFile[]; }>(
"custom/contentMapperVirtualFiles",
{ textDocument: { uri: uri.toString() } },
);
return toMappedOutputs(result.files);
}

async isContentMapped(uri: vscode.Uri): Promise<boolean> {
if (!this.client) {
throw new Error(vscode.l10n.t("Language client is not initialized"));
}
const result = await this.client.sendRequest<{ isContentMapped: boolean; }>(
"custom/isContentMapped",
{ textDocument: { uri: uri.toString() } },
);
return result.isContentMapped;
}

/**
* Restart the language server if the executable path has not changed.
* Returns true if a restart was performed.
Expand Down
Loading