Skip to content

Commit

Permalink
wire up to tsc, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhit committed Feb 11, 2025
1 parent 81f4ad0 commit 3b421f4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
7 changes: 1 addition & 6 deletions cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3334,7 +3334,6 @@ impl Inner {
}

#[tracing::instrument(skip_all)]

async fn semantic_tokens_range(
&self,
params: SemanticTokensRangeParams,
Expand Down Expand Up @@ -3400,7 +3399,6 @@ impl Inner {
}

#[tracing::instrument(skip_all)]

async fn signature_help(
&self,
params: SignatureHelpParams,
Expand Down Expand Up @@ -3476,7 +3474,6 @@ impl Inner {
}

#[tracing::instrument(skip_all)]

async fn will_rename_files(
&self,
params: RenameFilesParams,
Expand Down Expand Up @@ -3539,7 +3536,6 @@ impl Inner {
}

#[tracing::instrument(skip_all)]

async fn symbol(
&self,
params: WorkspaceSymbolParams,
Expand Down Expand Up @@ -4484,7 +4480,6 @@ impl Inner {
}

#[tracing::instrument(skip_all)]

async fn post_cache(&mut self) {
self.resolver.did_cache();
self.refresh_dep_info().await;
Expand Down Expand Up @@ -4526,7 +4521,6 @@ impl Inner {
}

#[tracing::instrument(skip_all)]

async fn post_did_change_workspace_folders(&mut self) {
self.refresh_workspace_files();
self.refresh_config_tree().await;
Expand Down Expand Up @@ -4606,6 +4600,7 @@ impl Inner {
Ok(result)
}

#[tracing::instrument(skip_all)]
async fn inlay_hint(
&self,
params: InlayHintParams,
Expand Down
4 changes: 4 additions & 0 deletions cli/tsc/00_typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -165768,6 +165768,10 @@ function getDefaultCommitCharacters(isNewIdentifierLocation) {
return allCommitCharacters;
}
function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext, includeSymbol = false) {
return spanned("Tsc::getCompletionsAtPosition", () => getCompletionsAtPositionInner(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext, includeSymbol));
}

function getCompletionsAtPositionInner(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext, includeSymbol = false) {
var _a;
const { previousToken } = getRelevantTokens(position, sourceFile);
if (triggerCharacter && !isInString(sourceFile, position, previousToken) && !isValidTrigger(sourceFile, triggerCharacter, previousToken, position)) {
Expand Down
12 changes: 5 additions & 7 deletions cli/tsc/97_ts_host.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export function clearScriptNamesCache() {
* specific "bindings" to the Deno environment that tsc needs to work.
*
* @type {ts.CompilerHost & ts.LanguageServiceHost} */
const hosty = {
const hostImpl = {
fileExists(specifier) {
if (logDebug) {
debug(`host.fileExists("${specifier}")`);
Expand Down Expand Up @@ -732,11 +732,9 @@ const hosty = {
}
return scriptSnapshot;
},
// getModuleResolutionCache() {
// return resolutionCache;
// }
};
// resolutionCache = ts.createResolutionCache(host, host.getCurrentDirectory(), true);

// these host methods are super noisy (often thousands of calls per TSC request)
const excluded = new Set([
"getScriptVersion",
"fileExists",
Expand All @@ -748,13 +746,13 @@ const excluded = new Set([
"getGlobalTypingsCacheLocation",
"getSourceFile",
]);
/** @type {typeof hosty} */
/** @type {typeof hostImpl} */
export const host = {
log(msg) {
ops.op_log_event(msg);
},
};
for (const [key, value] of Object.entries(hosty)) {
for (const [key, value] of Object.entries(hostImpl)) {
if (typeof value === "function" && !excluded.has(key)) {
host[key] = (...args) => {
return spanned(key, () => value.bind(host)(...args));
Expand Down

0 comments on commit 3b421f4

Please sign in to comment.