@@ -24,118 +24,6 @@ export function registerEnablementCommands(context: vscode.ExtensionContext, tel
2424 } ) ) ;
2525}
2626
27- export function registerLanguageCommands (
28- context : vscode . ExtensionContext ,
29- client : Client ,
30- outputChannel : vscode . OutputChannel ,
31- traceOutputChannel : vscode . OutputChannel ,
32- telemetryReporter : tr . TelemetryReporter ,
33- ) : vscode . Disposable [ ] {
34- const disposables : vscode . Disposable [ ] = [ ] ;
35-
36- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.restart" , ( ) => {
37- telemetryReporter . sendTelemetryEvent ( "command.restartLanguageServer" ) ;
38- return client . restart ( context ) ;
39- } ) ) ;
40-
41- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.output.focus" , ( ) => {
42- outputChannel . show ( ) ;
43- } ) ) ;
44-
45- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.lsp-trace.focus" , ( ) => {
46- traceOutputChannel . show ( ) ;
47- } ) ) ;
48-
49- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.selectVersion" , async ( ) => {
50- } ) ) ;
51-
52- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.showMenu" , showCommands ) ) ;
53-
54- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.reportIssue" , ( ) => {
55- telemetryReporter . sendTelemetryEvent ( "command.reportIssue" ) ;
56- vscode . commands . executeCommand ( "workbench.action.openIssueReporter" , {
57- extensionId : "TypeScriptTeam.native-preview" ,
58- } ) ;
59- } ) ) ;
60-
61- // Developer/debugging commands
62- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.dev.runGC" , async ( ) => {
63- try {
64- await client . runGC ( ) ;
65- vscode . window . showInformationMessage ( "Garbage collection triggered" ) ;
66- }
67- catch ( error ) {
68- vscode . window . showErrorMessage ( `Failed to run GC: ${ error } ` ) ;
69- }
70- } ) ) ;
71-
72- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.dev.saveHeapProfile" , async ( ) => {
73- const dir = await promptForProfileDirectory ( ) ;
74- if ( ! dir ) return ;
75- try {
76- const file = await client . saveHeapProfile ( dir ) ;
77- vscode . window . showInformationMessage ( `Heap profile saved to: ${ file } ` ) ;
78- }
79- catch ( error ) {
80- vscode . window . showErrorMessage ( `Failed to save heap profile: ${ error } ` ) ;
81- }
82- } ) ) ;
83-
84- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.dev.saveAllocProfile" , async ( ) => {
85- const dir = await promptForProfileDirectory ( ) ;
86- if ( ! dir ) return ;
87- try {
88- const file = await client . saveAllocProfile ( dir ) ;
89- vscode . window . showInformationMessage ( `Allocation profile saved to: ${ file } ` ) ;
90- }
91- catch ( error ) {
92- vscode . window . showErrorMessage ( `Failed to save allocation profile: ${ error } ` ) ;
93- }
94- } ) ) ;
95-
96- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.dev.startCPUProfile" , async ( ) => {
97- const dir = await promptForProfileDirectory ( ) ;
98- if ( ! dir ) return ;
99- try {
100- await client . startCPUProfile ( dir ) ;
101- vscode . commands . executeCommand ( "setContext" , "typescript.native-preview.cpuProfileRunning" , true ) ;
102- vscode . window . showInformationMessage ( `CPU profiling started. Profile will be saved to: ${ dir } ` ) ;
103- }
104- catch ( error ) {
105- vscode . window . showErrorMessage ( `Failed to start CPU profile: ${ error } ` ) ;
106- vscode . commands . executeCommand ( "setContext" , "typescript.native-preview.cpuProfileRunning" , false ) ;
107- }
108- } ) ) ;
109-
110- disposables . push ( vscode . commands . registerCommand ( "typescript.native-preview.dev.stopCPUProfile" , async ( ) => {
111- try {
112- const file = await client . stopCPUProfile ( ) ;
113- vscode . commands . executeCommand ( "setContext" , "typescript.native-preview.cpuProfileRunning" , false ) ;
114- vscode . window . showInformationMessage ( `CPU profile saved to: ${ file } ` ) ;
115- }
116- catch ( error ) {
117- vscode . window . showErrorMessage ( `Failed to stop CPU profile: ${ error } ` ) ;
118- }
119- } ) ) ;
120-
121- return disposables ;
122- }
123-
124- async function promptForProfileDirectory ( ) : Promise < string | undefined > {
125- const defaultDir = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri . fsPath ?? "" ;
126- const dir = await vscode . window . showInputBox ( {
127- prompt : "Enter directory path for profile output" ,
128- value : defaultDir ,
129- validateInput : value => {
130- if ( ! value . trim ( ) ) {
131- return "Directory path is required" ;
132- }
133- return undefined ;
134- } ,
135- } ) ;
136- return dir ?. trim ( ) ;
137- }
138-
13927/**
14028 * Updates the TypeScript Native Preview setting and reloads extension host.
14129 */
@@ -153,47 +41,6 @@ async function updateUseTsgoSetting(enable: boolean): Promise<void> {
15341 await restartExtHostOnChangeIfNeeded ( ) ;
15442}
15543
156- /**
157- * Shows the quick pick menu for TypeScript Native Preview commands
158- */
159- async function showCommands ( ) : Promise < void > {
160- const commands : readonly { label : string ; description : string ; command : string ; } [ ] = [
161- {
162- label : "$(refresh) Restart Server" ,
163- description : "Restart the TypeScript Native Preview language server" ,
164- command : "typescript.native-preview.restart" ,
165- } ,
166- {
167- label : "$(output) Show TS Server Log" ,
168- description : "Show the TypeScript Native Preview server log" ,
169- command : "typescript.native-preview.output.focus" ,
170- } ,
171- {
172- label : "$(debug-console) Show LSP Messages" ,
173- description : "Show the LSP communication trace" ,
174- command : "typescript.native-preview.lsp-trace.focus" ,
175- } ,
176- {
177- label : "$(report) Report Issue" ,
178- description : "Report an issue with TypeScript Native Preview" ,
179- command : "typescript.native-preview.reportIssue" ,
180- } ,
181- {
182- label : "$(stop-circle) Disable TypeScript Native Preview" ,
183- description : "Switch back to the built-in TypeScript extension" ,
184- command : "typescript.native-preview.disable" ,
185- } ,
186- ] ;
187-
188- const selected = await vscode . window . showQuickPick ( commands , {
189- placeHolder : "TypeScript Native Preview Commands" ,
190- } ) ;
191-
192- if ( selected ) {
193- await vscode . commands . executeCommand ( selected . command ) ;
194- }
195- }
196-
19744export const codeLensShowLocationsCommandName = "typescript.native-preview.codeLens.showLocations" ;
19845export function registerCodeLensShowLocationsCommand ( ) : vscode . Disposable {
19946 return vscode . commands . registerCommand ( codeLensShowLocationsCommandName , showCodeLensLocations ) ;
0 commit comments