Skip to content

Commit 5f9579f

Browse files
committed
wip
1 parent dacb28d commit 5f9579f

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/configurationType.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ScriptElementKind, ScriptKind } from 'typescript/lib/tsserverlibrary'
1+
import { ScriptElementKind, ScriptKind, LanguageService } from 'typescript/lib/tsserverlibrary'
22

33
type ReplaceRule = {
44
/**
@@ -647,6 +647,21 @@ export type Configuration = {
647647
typeAlias: string
648648
interface: string
649649
}
650+
customizeEnabledFeatures: {
651+
[path: string]:
652+
| 'disable-auto-invoked'
653+
| 'disable-heavy-features'
654+
| {
655+
/** @default true */
656+
[feature in keyof LanguageService]: boolean
657+
}
658+
}
659+
// bigFilesLimitFeatures: 'do-not-limit' | 'limit-auto-invoking' | 'force-limit-all-features'
660+
/**
661+
* in kb default is 1.5mb
662+
* @default 100000
663+
*/
664+
// bigFilesThreshold: number
650665
}
651666

652667
// scrapped using search editor. config: caseInsensitive, context lines: 0, regex: const fix\w+ = "[^ ]+"

typescript/src/decorateProxy.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { performance } from 'perf_hooks'
12
import lodashGet from 'lodash.get'
23
import { getCompletionsAtPosition, PrevCompletionMap, PrevCompletionsAdditionalData } from './completionsAtPosition'
34
import { RequestInputTypes, TriggerCharacterCommand } from './ipcTypes'
@@ -115,6 +116,31 @@ export const decorateLanguageService = (
115116
}
116117
}
117118

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+
118144
languageService[thisPluginMarker] = true
119145
return proxy
120146
}

0 commit comments

Comments
 (0)