|
| 1 | +import { performance } from 'perf_hooks' |
1 | 2 | import lodashGet from 'lodash.get'
|
2 | 3 | import { getCompletionsAtPosition, PrevCompletionMap, PrevCompletionsAdditionalData } from './completionsAtPosition'
|
3 | 4 | import { RequestInputTypes, TriggerCharacterCommand } from './ipcTypes'
|
@@ -115,6 +116,31 @@ export const decorateLanguageService = (
|
115 | 116 | }
|
116 | 117 | }
|
117 | 118 |
|
| 119 | + const readonlyModeDisableFeatures: Array<keyof ts.LanguageService> = [ |
| 120 | + 'getOutliningSpans', |
| 121 | + 'getSyntacticDiagnostics', |
| 122 | + 'getSemanticDiagnostics', |
| 123 | + 'getSuggestionDiagnostics', |
| 124 | + 'provideInlayHints', |
| 125 | + 'getLinkedEditingRangeAtPosition', |
| 126 | + 'getApplicableRefactors', |
| 127 | + 'getCompletionsAtPosition', |
| 128 | + 'getDefinitionAndBoundSpan', |
| 129 | + 'getFormattingEditsAfterKeystroke', |
| 130 | + 'getDocumentHighlights', |
| 131 | + ] |
| 132 | + for (const feature of readonlyModeDisableFeatures) { |
| 133 | + const orig = proxy[feature] |
| 134 | + proxy[feature] = (...args) => { |
| 135 | + const start = performance.now() |
| 136 | + //@ts-expect-error |
| 137 | + const result = orig(...args) |
| 138 | + const time = performance.now() - start |
| 139 | + if (time > 100) console.log(`[typescript-vscode-plugin perf warning] ${feature} took ${time}ms: ${args[0]} ${args[1]}`) |
| 140 | + return result |
| 141 | + } |
| 142 | + } |
| 143 | + |
118 | 144 | languageService[thisPluginMarker] = true
|
119 | 145 | return proxy
|
120 | 146 | }
|
0 commit comments