typescript-language-server
Advanced tools
Comparing version 1.2.0 to 2.0.0
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
## [2.0.0](https://github.com/typescript-language-server/typescript-language-server/compare/v1.2.0...v2.0.0) (2022-09-28) | ||
### ⚠ BREAKING CHANGES | ||
* Replace the CLI argument `--tsserver-log-file` with `tsserver.logDirectory` option provided through `initializationOptions` of the `initialize` request. | ||
### Features | ||
* add `tsserver.logDirectory` to `initializationOptions` ([#588](https://github.com/typescript-language-server/typescript-language-server/issues/588)) ([114d430](https://github.com/typescript-language-server/typescript-language-server/commit/114d4309cb1450585f991604118d3eff3690237c)) | ||
* add `tsserver.trace` init option for tracing tsserver ([#586](https://github.com/typescript-language-server/typescript-language-server/issues/586)) ([e3e8930](https://github.com/typescript-language-server/typescript-language-server/commit/e3e893094e501e3d6a72148e05f11286d688d2bd)) | ||
### Bug Fixes | ||
* **completions:** don't create snippet kind without `completeFunctionCalls` ([#595](https://github.com/typescript-language-server/typescript-language-server/issues/595)) ([7f69c27](https://github.com/typescript-language-server/typescript-language-server/commit/7f69c27eb8cce71d3db006623757a74f93d76dd3)) | ||
* **completions:** remove filterText override for bracket accessor ([#593](https://github.com/typescript-language-server/typescript-language-server/issues/593)) ([1ed4e2e](https://github.com/typescript-language-server/typescript-language-server/commit/1ed4e2eccf0b52e10204b5c2617d4944ae513afd)) | ||
* wrong import completion when insert/replace supported ([#592](https://github.com/typescript-language-server/typescript-language-server/issues/592)) ([4fe902a](https://github.com/typescript-language-server/typescript-language-server/commit/4fe902a9e28ec4c3ccc14a9e75488efeb8079544)) | ||
## [1.2.0](https://github.com/typescript-language-server/typescript-language-server/compare/v1.1.2...v1.2.0) (2022-09-12) | ||
@@ -5,0 +24,0 @@ |
@@ -10,4 +10,5 @@ #!/usr/bin/env node | ||
import { Command } from 'commander'; | ||
import lsp from 'vscode-languageserver'; | ||
import { createLspConnection } from './lsp-connection.js'; | ||
import * as lsp from 'vscode-languageserver'; | ||
import { TsServerLogLevel } from './utils/configuration.js'; | ||
const DEFAULT_LOG_LEVEL = lsp.MessageType.Info; | ||
@@ -19,3 +20,2 @@ const { version } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), { encoding: 'utf8' })); | ||
.option('--log-level <logLevel>', 'A number indicating the log level (4 = log, 3 = info, 2 = warn, 1 = error). Defaults to `2`.') | ||
.option('--tsserver-log-file <tsserverLogFile>', 'Specify a tsserver log file. example: --tsserver-log-file ts-logs.txt') | ||
.option('--tsserver-log-verbosity <tsserverLogVerbosity>', 'Specify a tsserver log verbosity (terse, normal, verbose). Defaults to `normal`.' + | ||
@@ -26,4 +26,5 @@ ' example: --tsserver-log-verbosity verbose') | ||
const options = program.opts(); | ||
if (options.tsserverLogFile && !options.tsserverLogVerbosity) { | ||
options.tsserverLogVerbosity = 'normal'; | ||
let tsserverLogVerbosity = TsServerLogLevel.fromString(options.tsserverLogVerbosity); | ||
if (options.tsserverLogFile && tsserverLogVerbosity === TsServerLogLevel.Off) { | ||
tsserverLogVerbosity = TsServerLogLevel.Normal; | ||
} | ||
@@ -40,6 +41,5 @@ let logLevel = DEFAULT_LOG_LEVEL; | ||
tsserverPath: options.tsserverPath, | ||
tsserverLogFile: options.tsserverLogFile, | ||
tsserverLogVerbosity: options.tsserverLogVerbosity, | ||
tsserverLogVerbosity, | ||
showMessageLevel: logLevel, | ||
}).listen(); | ||
//# sourceMappingURL=cli.js.map |
@@ -7,6 +7,5 @@ import * as lsp from 'vscode-languageserver'; | ||
import type { WorkspaceConfigurationCompletionOptions } from './configuration-manager.js'; | ||
export declare function asCompletionItem(entry: tsp.CompletionEntry, optionalReplacementSpan: tsp.TextSpan | undefined, file: string, position: lsp.Position, document: LspDocument, features: SupportedFeatures): lsp.CompletionItem | null; | ||
export declare function asCompletionItem(entry: tsp.CompletionEntry, optionalReplacementSpan: tsp.TextSpan | undefined, file: string, position: lsp.Position, document: LspDocument, options: WorkspaceConfigurationCompletionOptions, features: SupportedFeatures): lsp.CompletionItem | null; | ||
export declare function asResolvedCompletionItem(item: lsp.CompletionItem, details: tsp.CompletionEntryDetails, client: TspClient, options: WorkspaceConfigurationCompletionOptions, features: SupportedFeatures): Promise<lsp.CompletionItem>; | ||
export declare function isValidFunctionCompletionContext(filepath: string, position: lsp.Position, client: TspClient): Promise<boolean>; | ||
export declare function getCompletionTriggerCharacter(character: string | undefined): tsp.CompletionsTriggerCharacter | undefined; | ||
//# sourceMappingURL=completion.d.ts.map |
@@ -14,3 +14,3 @@ /* | ||
import { Range, Position } from './utils/typeConverters.js'; | ||
export function asCompletionItem(entry, optionalReplacementSpan, file, position, document, features) { | ||
export function asCompletionItem(entry, optionalReplacementSpan, file, position, document, options, features) { | ||
const item = { | ||
@@ -41,7 +41,7 @@ label: entry.name, | ||
} | ||
const { isSnippet, sourceDisplay } = entry; | ||
const { isSnippet, replacementSpan, sourceDisplay } = entry; | ||
if (isSnippet && !features.completionSnippets) { | ||
return null; | ||
} | ||
if (features.completionSnippets && (isSnippet || entry.isImportStatementCompletion || item.kind === lsp.CompletionItemKind.Function || item.kind === lsp.CompletionItemKind.Method)) { | ||
if (features.completionSnippets && (isSnippet || canCreateSnippetOfFunctionCall(item.kind, options))) { | ||
// Import statements, Functions and Methods can result in a snippet completion when resolved. | ||
@@ -53,12 +53,3 @@ item.insertTextFormat = lsp.InsertTextFormat.Snippet; | ||
} | ||
let insertText = entry.insertText; | ||
const replacementSpan = entry.replacementSpan || (features.completionInsertReplaceSupport ? optionalReplacementSpan : undefined); | ||
let replacementRange = replacementSpan && Range.fromTextSpan(replacementSpan); | ||
// Make sure we only replace a single line at most | ||
if (replacementRange && replacementRange.start.line !== replacementRange.end.line) { | ||
replacementRange = lsp.Range.create(replacementRange.start, document.getLineEnd(replacementRange.start.line)); | ||
} | ||
if (insertText && replacementRange && insertText[0] === '[') { // o.x -> o['x'] | ||
item.filterText = '.' + item.label; | ||
} | ||
let { insertText } = entry; | ||
if (entry.kindModifiers) { | ||
@@ -95,13 +86,7 @@ const kindModifiers = new Set(entry.kindModifiers.split(/,|\s+/g)); | ||
} | ||
if (replacementRange) { | ||
if (!insertText) { | ||
insertText = item.label; | ||
} | ||
if (features.completionInsertReplaceSupport) { | ||
const insertRange = lsp.Range.create(replacementRange.start, position); | ||
item.textEdit = lsp.InsertReplaceEdit.create(insertText, insertRange, replacementRange); | ||
} | ||
else { | ||
item.textEdit = lsp.TextEdit.replace(replacementRange, insertText); | ||
} | ||
const range = getRangeFromReplacementSpan(replacementSpan, optionalReplacementSpan, position, document, features); | ||
if (range) { | ||
item.textEdit = range.insert | ||
? lsp.InsertReplaceEdit.create(insertText || item.label, range.insert, range.replace) | ||
: lsp.TextEdit.replace(range.replace, insertText || item.label); | ||
} | ||
@@ -113,2 +98,23 @@ else { | ||
} | ||
function getRangeFromReplacementSpan(replacementSpan, optionalReplacementSpan, position, document, features) { | ||
if (replacementSpan) { | ||
// If TS provides an explicit replacement span with an entry, we should use it and not provide an insert. | ||
return { | ||
replace: ensureRangeIsOnSingleLine(Range.fromTextSpan(replacementSpan), document), | ||
}; | ||
} | ||
if (features.completionInsertReplaceSupport && optionalReplacementSpan) { | ||
const range = ensureRangeIsOnSingleLine(Range.fromTextSpan(optionalReplacementSpan), document); | ||
return { | ||
insert: lsp.Range.create(range.start, position), | ||
replace: ensureRangeIsOnSingleLine(range, document), | ||
}; | ||
} | ||
} | ||
function ensureRangeIsOnSingleLine(range, document) { | ||
if (range.start.line !== range.end.line) { | ||
return lsp.Range.create(range.start, document.getLineEnd(range.start.line)); | ||
} | ||
return range; | ||
} | ||
function asCompletionItemKind(kind) { | ||
@@ -193,3 +199,3 @@ switch (kind) { | ||
} | ||
if (features.completionSnippets && options.completeFunctionCalls && (item.kind === lsp.CompletionItemKind.Function || item.kind === lsp.CompletionItemKind.Method)) { | ||
if (features.completionSnippets && canCreateSnippetOfFunctionCall(item.kind, options)) { | ||
const { line, offset } = item.data; | ||
@@ -204,3 +210,3 @@ const position = Position.fromLocation({ line, offset }); | ||
} | ||
export async function isValidFunctionCompletionContext(filepath, position, client) { | ||
async function isValidFunctionCompletionContext(filepath, position, client) { | ||
// Workaround for https://github.com/Microsoft/TypeScript/issues/12677 | ||
@@ -229,2 +235,5 @@ // Don't complete function calls inside of destructive assigments or imports | ||
} | ||
function canCreateSnippetOfFunctionCall(kind, options) { | ||
return options.completeFunctionCalls === true && (kind === lsp.CompletionItemKind.Function || kind === lsp.CompletionItemKind.Method); | ||
} | ||
function createSnippetOfFunctionCall(item, detail) { | ||
@@ -243,2 +252,5 @@ const { displayParts } = detail; | ||
item.insertTextFormat = lsp.InsertTextFormat.Snippet; | ||
if (item.textEdit) { | ||
item.textEdit.newText = snippet.value; | ||
} | ||
} | ||
@@ -245,0 +257,0 @@ function getParameterListParts(displayParts) { |
@@ -48,3 +48,3 @@ import deepmerge from 'deepmerge'; | ||
setWorkspaceConfiguration(configuration) { | ||
this.workspaceConfiguration = configuration; | ||
this.workspaceConfiguration = deepmerge({}, configuration); | ||
} | ||
@@ -51,0 +51,0 @@ async setAndConfigureTspClient(workspaceFolder, client, hostInfo) { |
import type tsp from 'typescript/lib/protocol.d.js'; | ||
import * as lsp from 'vscode-languageserver'; | ||
import { Logger } from './logger.js'; | ||
import { Logger } from './utils/logger.js'; | ||
import { EventTypes } from './tsp-command-types.js'; | ||
@@ -5,0 +5,0 @@ import { LspDocuments } from './document.js'; |
@@ -1,9 +0,9 @@ | ||
import * as lsp from 'vscode-languageserver/node.js'; | ||
export interface IServerOptions { | ||
import lsp from 'vscode-languageserver/node.js'; | ||
import type { TsServerLogLevel } from './utils/configuration.js'; | ||
export interface LspConnectionOptions { | ||
tsserverPath: string; | ||
tsserverLogFile?: string; | ||
tsserverLogVerbosity?: string; | ||
tsserverLogVerbosity: TsServerLogLevel; | ||
showMessageLevel: lsp.MessageType; | ||
} | ||
export declare function createLspConnection(options: IServerOptions): lsp.Connection; | ||
export declare function createLspConnection(options: LspConnectionOptions): lsp.Connection; | ||
//# sourceMappingURL=lsp-connection.d.ts.map |
@@ -7,6 +7,6 @@ /* | ||
*/ | ||
import * as lsp from 'vscode-languageserver/node.js'; | ||
import lsp from 'vscode-languageserver/node.js'; | ||
import * as lspcalls from './lsp-protocol.calls.proposed.js'; | ||
import * as lspinlayHints from './lsp-protocol.inlayHints.proposed.js'; | ||
import { LspClientLogger } from './logger.js'; | ||
import { LspClientLogger } from './utils/logger.js'; | ||
import { LspServer } from './lsp-server.js'; | ||
@@ -22,3 +22,2 @@ import { LspClientImpl } from './lsp-client.js'; | ||
tsserverPath: options.tsserverPath, | ||
tsserverLogFile: options.tsserverLogFile, | ||
tsserverLogVerbosity: options.tsserverLogVerbosity, | ||
@@ -25,0 +24,0 @@ }); |
@@ -6,4 +6,4 @@ import * as lsp from 'vscode-languageserver'; | ||
import { LspDocument } from './document.js'; | ||
import { TypeScriptInitializeParams, TypeScriptInitializeResult } from './ts-protocol.js'; | ||
import { IServerOptions } from './utils/configuration.js'; | ||
import { TypeScriptInitializeParams } from './ts-protocol.js'; | ||
import { TypeScriptServiceConfiguration } from './utils/configuration.js'; | ||
export declare class LspServer { | ||
@@ -20,3 +20,3 @@ private options; | ||
private readonly documents; | ||
constructor(options: IServerOptions); | ||
constructor(options: TypeScriptServiceConfiguration); | ||
closeAll(): void; | ||
@@ -26,5 +26,4 @@ shutdown(): void; | ||
private findTypescriptVersion; | ||
initialize(params: TypeScriptInitializeParams): Promise<TypeScriptInitializeResult>; | ||
protected getLogFile(logVerbosity: string | undefined): string | undefined; | ||
protected doGetLogFile(): string | undefined; | ||
initialize(params: TypeScriptInitializeParams): Promise<lsp.InitializeResult>; | ||
private getLogDirectoryPath; | ||
didChangeConfiguration(params: lsp.DidChangeConfigurationParams): void; | ||
@@ -31,0 +30,0 @@ protected diagnosticsTokenSource: lsp.CancellationTokenSource | undefined; |
@@ -10,3 +10,2 @@ /* | ||
import debounce from 'p-debounce'; | ||
import { temporaryFile } from 'tempy'; | ||
import * as lsp from 'vscode-languageserver'; | ||
@@ -16,3 +15,3 @@ import * as lspcalls from './lsp-protocol.calls.proposed.js'; | ||
import API from './utils/api.js'; | ||
import { PrefixingLogger } from './logger.js'; | ||
import { LogLevel, PrefixingLogger } from './utils/logger.js'; | ||
import { TspClient } from './tsp-client.js'; | ||
@@ -33,2 +32,4 @@ import { DiagnosticEventQueue } from './diagnostic-queue.js'; | ||
import { SourceDefinitionCommand } from './features/source-definition.js'; | ||
import { LogDirectoryProvider } from './tsServer/logDirectoryProvider.js'; | ||
import { Trace } from './tsServer/tracer.js'; | ||
import { TypeScriptVersionProvider } from './tsServer/versionProvider.js'; | ||
@@ -78,3 +79,3 @@ import { Position, Range } from './utils/typeConverters.js'; | ||
} | ||
this.logger.warn(`Typescript specified through --tsserver-path ignored due to invalid path "${userSettingVersion.path}"`); | ||
this.logger.logIgnoringVerbosity(LogLevel.Warning, `Typescript specified through --tsserver-path ignored due to invalid path "${userSettingVersion.path}"`); | ||
} | ||
@@ -104,8 +105,6 @@ // Workspace version. | ||
const userInitializationOptions = this.initializeParams.initializationOptions || {}; | ||
const { disableAutomaticTypingAcquisition, hostInfo, maxTsServerMemory, npmLocation, locale } = userInitializationOptions; | ||
const { logVerbosity, plugins } = { | ||
logVerbosity: userInitializationOptions.logVerbosity || this.options.tsserverLogVerbosity, | ||
const { disableAutomaticTypingAcquisition, hostInfo, maxTsServerMemory, npmLocation, locale, tsserver } = userInitializationOptions; | ||
const { plugins } = { | ||
plugins: userInitializationOptions.plugins || [], | ||
}; | ||
const logFile = this.getLogFile(logVerbosity); | ||
const globalPlugins = []; | ||
@@ -119,3 +118,3 @@ const pluginProbeLocations = []; | ||
if (typescriptVersion) { | ||
this.logger.info(`Using Typescript version (${typescriptVersion.source}) ${typescriptVersion.versionString} from path "${typescriptVersion.tsServerPath}"`); | ||
this.logger.logIgnoringVerbosity(LogLevel.Info, `Using Typescript version (${typescriptVersion.source}) ${typescriptVersion.versionString} from path "${typescriptVersion.tsServerPath}"`); | ||
} | ||
@@ -153,5 +152,6 @@ else { | ||
lspClient: this.options.lspClient, | ||
trace: Trace.fromString(tsserver?.trace || 'off'), | ||
typescriptVersion, | ||
logFile, | ||
logVerbosity, | ||
logDirectoryProvider: new LogDirectoryProvider(this.getLogDirectoryPath(userInitializationOptions)), | ||
logVerbosity: this.options.tsserverLogVerbosity, | ||
disableAutomaticTypingAcquisition, | ||
@@ -196,3 +196,2 @@ maxTsServerMemory, | ||
]); | ||
const logFileUri = logFile && pathToUri(logFile, undefined); | ||
const initializeResult = { | ||
@@ -271,3 +270,2 @@ capabilities: { | ||
}, | ||
logFileUri, | ||
}; | ||
@@ -278,22 +276,8 @@ initializeResult.capabilities.callsProvider = true; | ||
} | ||
getLogFile(logVerbosity) { | ||
if (logVerbosity === undefined || logVerbosity === 'off') { | ||
return undefined; | ||
getLogDirectoryPath(initializationOptions) { | ||
if (initializationOptions.tsserver?.logDirectory) { | ||
return initializationOptions.tsserver.logDirectory; | ||
} | ||
const logFile = this.doGetLogFile(); | ||
if (logFile) { | ||
fs.ensureFileSync(logFile); | ||
return logFile; | ||
} | ||
return temporaryFile({ name: 'tsserver.log' }); | ||
} | ||
doGetLogFile() { | ||
if (process.env.TSSERVER_LOG_FILE) { | ||
return process.env.TSSERVER_LOG_FILE; | ||
} | ||
if (this.options.tsserverLogFile) { | ||
return this.options.tsserverLogFile; | ||
} | ||
if (this.workspaceRoot) { | ||
return path.join(this.workspaceRoot, '.log/tsserver.log'); | ||
return path.join(this.workspaceRoot, '.log'); | ||
} | ||
@@ -551,2 +535,3 @@ return undefined; | ||
} | ||
const completionOptions = this.configurationManager.workspaceConfiguration.completions || {}; | ||
try { | ||
@@ -570,3 +555,3 @@ const result = await this.interuptDiagnostics(() => this.tspClient.request("completionInfo" /* CommandTypes.CompletionInfo */, { | ||
} | ||
const completion = asCompletionItem(entry, optionalReplacementSpan, file, params.position, document, this.features); | ||
const completion = asCompletionItem(entry, optionalReplacementSpan, file, params.position, document, completionOptions, this.features); | ||
if (!completion) { | ||
@@ -573,0 +558,0 @@ continue; |
import * as lsp from 'vscode-languageserver'; | ||
import { WorkspaceConfiguration } from './configuration-manager.js'; | ||
import { LspClient, WithProgressOptions } from './lsp-client.js'; | ||
import { LspServer } from './lsp-server.js'; | ||
import { ConsoleLogger } from './logger.js'; | ||
import { ConsoleLogger } from './utils/logger.js'; | ||
export declare const PACKAGE_ROOT: string; | ||
@@ -30,2 +31,3 @@ export declare function uri(...components: string[]): string; | ||
workspaceEdits: lsp.ApplyWorkspaceEditParams[]; | ||
updateWorkspaceSettings(settings: WorkspaceConfiguration): void; | ||
} | ||
@@ -32,0 +34,0 @@ interface TestLspServerOptions { |
@@ -16,5 +16,6 @@ /* | ||
import { LspServer } from './lsp-server.js'; | ||
import { ConsoleLogger } from './logger.js'; | ||
import { ConsoleLogger, LogLevel } from './utils/logger.js'; | ||
import { TypeScriptVersionProvider } from './tsServer/versionProvider.js'; | ||
const CONSOLE_LOG_LEVEL = ConsoleLogger.toMessageTypeLevel(process.env.CONSOLE_LOG_LEVEL); | ||
import { TsServerLogLevel } from './utils/configuration.js'; | ||
const CONSOLE_LOG_LEVEL = LogLevel.fromString(process.env.CONSOLE_LOG_LEVEL); | ||
export const PACKAGE_ROOT = fileURLToPath(new URL('..', import.meta.url)); | ||
@@ -62,2 +63,3 @@ const DEFAULT_TEST_CLIENT_CAPABILITIES = { | ||
}; | ||
const DEFAULT_WORKSPACE_SETTINGS = {}; | ||
export function uri(...components) { | ||
@@ -141,14 +143,22 @@ const resolved = filePath(...components); | ||
} | ||
updateWorkspaceSettings(settings) { | ||
const configuration = { | ||
settings: deepmerge(DEFAULT_WORKSPACE_SETTINGS, settings), | ||
}; | ||
this.didChangeConfiguration(configuration); | ||
} | ||
} | ||
export async function createServer(options) { | ||
const typescriptVersionProvider = new TypeScriptVersionProvider(); | ||
const bundled = typescriptVersionProvider.bundledVersion(); | ||
const logger = new ConsoleLogger(CONSOLE_LOG_LEVEL); | ||
const lspClient = new TestLspClient(options, logger); | ||
const serverOptions = { | ||
logger, | ||
lspClient, | ||
tsserverLogVerbosity: TsServerLogLevel.Off, | ||
}; | ||
const typescriptVersionProvider = new TypeScriptVersionProvider(serverOptions, logger); | ||
const bundled = typescriptVersionProvider.bundledVersion(); | ||
const server = new TestLspServer({ | ||
logger, | ||
...serverOptions, | ||
tsserverPath: bundled.tsServerPath, | ||
tsserverLogVerbosity: options.tsserverLogVerbosity, | ||
tsserverLogFile: path.resolve(PACKAGE_ROOT, 'tsserver.log'), | ||
lspClient, | ||
}); | ||
@@ -166,4 +176,5 @@ lspClient.addApplyWorkspaceEditListener(args => { | ||
}); | ||
server.updateWorkspaceSettings({}); | ||
return server; | ||
} | ||
//# sourceMappingURL=test-utils.js.map |
/** | ||
* **IMPORTANT** this module should not depend on `vscode-languageserver` only protocol and types | ||
*/ | ||
import * as lsp from 'vscode-languageserver-protocol'; | ||
import lsp from 'vscode-languageserver-protocol'; | ||
import type tsp from 'typescript/lib/protocol.d.js'; | ||
import type { TraceValue } from './tsServer/tracer.js'; | ||
export declare namespace TypeScriptRenameRequest { | ||
@@ -17,2 +18,7 @@ const type: lsp.RequestType<lsp.TextDocumentPositionParams, void, void>; | ||
} | ||
export declare enum SemicolonPreference { | ||
Ignore = "ignore", | ||
Insert = "insert", | ||
Remove = "remove" | ||
} | ||
export interface SupportedFeatures { | ||
@@ -32,16 +38,30 @@ codeActionDisabledSupport?: boolean; | ||
disableAutomaticTypingAcquisition?: boolean; | ||
logVerbosity?: string; | ||
hostInfo?: string; | ||
locale?: string; | ||
maxTsServerMemory?: number; | ||
npmLocation?: string; | ||
locale?: string; | ||
plugins: TypeScriptPlugin[]; | ||
preferences?: tsp.UserPreferences; | ||
hostInfo?: string; | ||
tsserver?: TsserverOptions; | ||
} | ||
interface TsserverOptions { | ||
/** | ||
* The path to the directory where the `tsserver` logs will be created. | ||
* If not provided, the log files will be created within the workspace, inside the `.log` directory. | ||
* If no workspace root is provided when initializating the server and no custom path is specified then | ||
* the logs will not be created. | ||
* @default undefined | ||
*/ | ||
logDirectory?: string; | ||
/** | ||
* The verbosity of logging the tsserver communication through the LSP messages. | ||
* This doesn't affect the file logging. | ||
* @default 'off' | ||
*/ | ||
trace?: TraceValue; | ||
} | ||
export declare type TypeScriptInitializeParams = lsp.InitializeParams & { | ||
initializationOptions?: Partial<TypeScriptInitializationOptions>; | ||
}; | ||
export interface TypeScriptInitializeResult extends lsp.InitializeResult { | ||
logFileUri?: string; | ||
} | ||
export {}; | ||
//# sourceMappingURL=ts-protocol.d.ts.map |
@@ -10,3 +10,3 @@ /* | ||
*/ | ||
import * as lsp from 'vscode-languageserver-protocol'; | ||
import lsp from 'vscode-languageserver-protocol'; | ||
export var TypeScriptRenameRequest; | ||
@@ -24,2 +24,8 @@ (function (TypeScriptRenameRequest) { | ||
DisplayPartKind.text = 'text'; | ||
export var SemicolonPreference; | ||
(function (SemicolonPreference) { | ||
SemicolonPreference["Ignore"] = "ignore"; | ||
SemicolonPreference["Insert"] = "insert"; | ||
SemicolonPreference["Remove"] = "remove"; | ||
})(SemicolonPreference = SemicolonPreference || (SemicolonPreference = {})); | ||
//# sourceMappingURL=ts-protocol.js.map |
@@ -5,13 +5,17 @@ /// <reference types="node" resolution-mode="require"/> | ||
import { CommandTypes } from './tsp-command-types.js'; | ||
import { Logger } from './logger.js'; | ||
import { Logger } from './utils/logger.js'; | ||
import API from './utils/api.js'; | ||
import type { ILogDirectoryProvider } from './tsServer/logDirectoryProvider.js'; | ||
import { ExecConfig, ServerResponse, TypeScriptRequestTypes } from './tsServer/requests.js'; | ||
import { Trace } from './tsServer/tracer.js'; | ||
import type { TypeScriptVersion } from './tsServer/versionProvider.js'; | ||
import type { LspClient } from './lsp-client.js'; | ||
import type { TsServerLogLevel } from './utils/configuration.js'; | ||
export interface TspClientOptions { | ||
lspClient: LspClient; | ||
trace: Trace; | ||
typescriptVersion: TypeScriptVersion; | ||
logger: Logger; | ||
logFile?: string; | ||
logVerbosity?: string; | ||
logVerbosity: TsServerLogLevel; | ||
logDirectoryProvider: ILogDirectoryProvider; | ||
disableAutomaticTypingAcquisition?: boolean; | ||
@@ -33,2 +37,3 @@ maxTsServerMemory?: number; | ||
private loadingIndicator; | ||
private tracer; | ||
constructor(options: TspClientOptions); | ||
@@ -35,0 +40,0 @@ start(): boolean; |
@@ -11,3 +11,3 @@ /*--------------------------------------------------------------------------------------------- | ||
*/ | ||
import { PrefixingLogger } from './logger.js'; | ||
import { PrefixingLogger } from './utils/logger.js'; | ||
import API from './utils/api.js'; | ||
@@ -17,2 +17,3 @@ import { ServerResponse } from './tsServer/requests.js'; | ||
import { TypeScriptServerSpawner } from './tsServer/spawner.js'; | ||
import Tracer from './tsServer/tracer.js'; | ||
class ServerInitializingIndicator { | ||
@@ -57,5 +58,6 @@ constructor(lspClient) { | ||
this.loadingIndicator = new ServerInitializingIndicator(options.lspClient); | ||
this.tracer = new Tracer(this.tsserverLogger, options.trace); | ||
} | ||
start() { | ||
const tsServerSpawner = new TypeScriptServerSpawner(this.apiVersion, this.logger); | ||
const tsServerSpawner = new TypeScriptServerSpawner(this.apiVersion, this.options.logDirectoryProvider, this.logger, this.tracer); | ||
const tsServer = tsServerSpawner.spawn(this.options.typescriptVersion, this.options); | ||
@@ -83,5 +85,2 @@ tsServer.onExit((data) => { | ||
} | ||
// private static isLoggingEnabled(configuration: TspClientOptions) { | ||
// return configuration.tsServerLogLevel !== TsServerLogLevel.Off; | ||
// } | ||
dispatchEvent(event) { | ||
@@ -88,0 +87,0 @@ switch (event.event) { |
@@ -9,8 +9,9 @@ /* | ||
import { TspClient } from './tsp-client.js'; | ||
import { ConsoleLogger } from './logger.js'; | ||
import { ConsoleLogger } from './utils/logger.js'; | ||
import { filePath, readContents, TestLspClient, uri } from './test-utils.js'; | ||
import { Trace } from './tsServer/tracer.js'; | ||
import { TypeScriptVersionProvider } from './tsServer/versionProvider.js'; | ||
import { TsServerLogLevel } from './utils/configuration.js'; | ||
import { noopLogDirectoryProvider } from './tsServer/logDirectoryProvider.js'; | ||
const assert = chai.assert; | ||
const typescriptVersionProvider = new TypeScriptVersionProvider(); | ||
const bundled = typescriptVersionProvider.bundledVersion(); | ||
const logger = new ConsoleLogger(); | ||
@@ -22,7 +23,16 @@ const lspClientOptions = { | ||
const lspClient = new TestLspClient(lspClientOptions, logger); | ||
const configuration = { | ||
logger, | ||
lspClient, | ||
tsserverLogVerbosity: TsServerLogLevel.Off, | ||
}; | ||
const typescriptVersionProvider = new TypeScriptVersionProvider(configuration, logger); | ||
const bundled = typescriptVersionProvider.bundledVersion(); | ||
let server; | ||
before(() => { | ||
server = new TspClient({ | ||
logger, | ||
lspClient, | ||
...configuration, | ||
logDirectoryProvider: noopLogDirectoryProvider, | ||
logVerbosity: configuration.tsserverLogVerbosity, | ||
trace: Trace.Off, | ||
typescriptVersion: bundled, | ||
@@ -29,0 +39,0 @@ }); |
@@ -0,1 +1,2 @@ | ||
import Tracer from './tracer.js'; | ||
export interface OngoingRequestCanceller { | ||
@@ -6,15 +7,17 @@ readonly cancellationPipeName: string | undefined; | ||
export interface OngoingRequestCancellerFactory { | ||
create(): OngoingRequestCanceller; | ||
create(serverId: string, tracer: Tracer): OngoingRequestCanceller; | ||
} | ||
export declare const noopRequestCancellerFactory: { | ||
create(): OngoingRequestCanceller; | ||
create(_serverId: string, _tracer: Tracer): OngoingRequestCanceller; | ||
}; | ||
export declare class NodeRequestCanceller implements OngoingRequestCanceller { | ||
private readonly _serverId; | ||
private readonly _tracer; | ||
readonly cancellationPipeName: string; | ||
constructor(); | ||
constructor(_serverId: string, _tracer: Tracer); | ||
tryCancelOngoingRequest(seq: number): boolean; | ||
} | ||
export declare const nodeRequestCancellerFactory: { | ||
create(): OngoingRequestCanceller; | ||
create(serverId: string, tracer: Tracer): OngoingRequestCanceller; | ||
}; | ||
//# sourceMappingURL=cancellation.d.ts.map |
@@ -22,3 +22,3 @@ /*--------------------------------------------------------------------------------------------- | ||
export const noopRequestCancellerFactory = new class { | ||
create( /*_serverId: string, _tracer: Tracer*/) { | ||
create(_serverId, _tracer) { | ||
return noopRequestCanceller; | ||
@@ -28,6 +28,5 @@ } | ||
export class NodeRequestCanceller { | ||
constructor( | ||
// private readonly _serverId: string, | ||
// private readonly _tracer: Tracer, | ||
) { | ||
constructor(_serverId, _tracer) { | ||
this._serverId = _serverId; | ||
this._tracer = _tracer; | ||
this.cancellationPipeName = temporaryFile({ name: 'tscancellation' }); | ||
@@ -39,3 +38,3 @@ } | ||
} | ||
// this._tracer.logTrace(this._serverId, `TypeScript Server: trying to cancel ongoing request with sequence number ${seq}`); | ||
this._tracer.logTrace(this._serverId, `TypeScript Server: trying to cancel ongoing request with sequence number ${seq}`); | ||
try { | ||
@@ -51,6 +50,6 @@ fs.writeFileSync(this.cancellationPipeName + String(seq), ''); | ||
export const nodeRequestCancellerFactory = new class { | ||
create( /*serverId: string, tracer: Tracer*/) { | ||
return new NodeRequestCanceller( /*serverId, tracer*/); | ||
create(serverId, tracer) { | ||
return new NodeRequestCanceller(serverId, tracer); | ||
} | ||
}; | ||
//# sourceMappingURL=cancellation.js.map |
@@ -7,2 +7,3 @@ /// <reference types="node" resolution-mode="require"/> | ||
import { OngoingRequestCanceller } from './cancellation.js'; | ||
import type Tracer from './tracer.js'; | ||
import type { TypeScriptVersion } from './versionProvider.js'; | ||
@@ -62,2 +63,3 @@ export declare enum ExecutionTarget { | ||
private readonly _version; | ||
private readonly _tracer; | ||
private readonly _requestQueue; | ||
@@ -69,3 +71,3 @@ private readonly _callbacks; | ||
private readonly _errorHandlers; | ||
constructor(_serverId: string, _serverSource: ServerType, _process: TsServerProcess, _tsServerLogFile: string | undefined, _requestCanceller: OngoingRequestCanceller, _version: TypeScriptVersion); | ||
constructor(_serverId: string, _serverSource: ServerType, _process: TsServerProcess, _tsServerLogFile: string | undefined, _requestCanceller: OngoingRequestCanceller, _version: TypeScriptVersion, _tracer: Tracer); | ||
onEvent(handler: OnEventHandler): void; | ||
@@ -72,0 +74,0 @@ onExit(handler: OnExitHandler): void; |
@@ -21,3 +21,3 @@ /*--------------------------------------------------------------------------------------------- | ||
export class ProcessBasedTsServer { | ||
constructor(_serverId, _serverSource, _process, _tsServerLogFile, _requestCanceller, _version) { | ||
constructor(_serverId, _serverSource, _process, _tsServerLogFile, _requestCanceller, _version, _tracer) { | ||
this._serverId = _serverId; | ||
@@ -29,2 +29,3 @@ this._serverSource = _serverSource; | ||
this._version = _version; | ||
this._tracer = _tracer; | ||
this._requestQueue = new RequestQueue(); | ||
@@ -93,3 +94,3 @@ this._callbacks = new CallbackMap(); | ||
if (callback) { | ||
// this._tracer.traceRequestCompleted(this._serverId, 'requestCompleted', seq, callback); | ||
this._tracer.traceRequestCompleted(this._serverId, 'requestCompleted', seq, callback); | ||
callback.onSuccess(undefined); | ||
@@ -99,3 +100,3 @@ } | ||
else { | ||
// this._tracer.traceEvent(this._serverId, event); | ||
this._tracer.traceEvent(this._serverId, event); | ||
this._eventHandlers.forEach(handler => handler(event)); | ||
@@ -135,3 +136,3 @@ } | ||
} | ||
// this._tracer.traceResponse(this._serverId, response, callback); | ||
this._tracer.traceResponse(this._serverId, response, callback); | ||
if (response.success) { | ||
@@ -182,3 +183,3 @@ callback.onSuccess(response); | ||
const serverRequest = requestItem.request; | ||
// this._tracer.traceRequest(this._serverId, serverRequest, requestItem.expectsResponse, this._requestQueue.length); | ||
this._tracer.traceRequest(this._serverId, serverRequest, requestItem.expectsResponse, this._requestQueue.length); | ||
if (requestItem.expectsResponse && !requestItem.isAsync) { | ||
@@ -203,4 +204,4 @@ this._pendingResponses.add(requestItem.request.seq); | ||
} | ||
logTrace(_message) { | ||
// this._tracer.logTrace(this._serverId, message); | ||
logTrace(message) { | ||
this._tracer.logTrace(this._serverId, message); | ||
} | ||
@@ -207,0 +208,0 @@ static getQueueingType(command, lowPriority) { |
import API from '../utils/api.js'; | ||
import { Logger } from '../logger.js'; | ||
import { Logger } from '../utils/logger.js'; | ||
import type { TspClientOptions } from '../tsp-client.js'; | ||
import type { ILogDirectoryProvider } from './logDirectoryProvider.js'; | ||
import { ITypeScriptServer } from './server.js'; | ||
import type Tracer from './tracer.js'; | ||
import type { TypeScriptVersion } from './versionProvider.js'; | ||
export declare class TypeScriptServerSpawner { | ||
private readonly _apiVersion; | ||
private readonly _logDirectoryProvider; | ||
private readonly _logger; | ||
constructor(_apiVersion: API, _logger: Logger); | ||
private readonly _tracer; | ||
constructor(_apiVersion: API, _logDirectoryProvider: ILogDirectoryProvider, _logger: Logger, _tracer: Tracer); | ||
spawn(version: TypeScriptVersion, configuration: TspClientOptions): ITypeScriptServer; | ||
private kindToServerType; | ||
private getTsServerArgs; | ||
private isLoggingEnabled; | ||
} | ||
//# sourceMappingURL=spawner.d.ts.map |
@@ -11,13 +11,16 @@ /*--------------------------------------------------------------------------------------------- | ||
*/ | ||
import path from 'node:path'; | ||
import API from '../utils/api.js'; | ||
import { ServerType } from './requests.js'; | ||
import { LogLevel } from '../utils/logger.js'; | ||
import { nodeRequestCancellerFactory } from './cancellation.js'; | ||
import { ProcessBasedTsServer } from './server.js'; | ||
import { NodeTsServerProcessFactory } from './serverProcess.js'; | ||
import { TsServerLogLevel } from '../utils/configuration.js'; | ||
export class TypeScriptServerSpawner { | ||
constructor(_apiVersion, | ||
// private readonly _logDirectoryProvider: ILogDirectoryProvider, | ||
_logger) { | ||
constructor(_apiVersion, _logDirectoryProvider, _logger, _tracer) { | ||
this._apiVersion = _apiVersion; | ||
this._logDirectoryProvider = _logDirectoryProvider; | ||
this._logger = _logger; | ||
this._tracer = _tracer; | ||
} | ||
@@ -27,7 +30,15 @@ spawn(version, configuration) { | ||
const processFactory = new NodeTsServerProcessFactory(); | ||
const canceller = nodeRequestCancellerFactory.create( /*kind, this._tracer*/); | ||
const canceller = nodeRequestCancellerFactory.create(kind, this._tracer); | ||
const { args, tsServerLogFile } = this.getTsServerArgs("main" /* TsServerProcessKind.Main */, configuration, this._apiVersion, canceller.cancellationPipeName); | ||
if (this.isLoggingEnabled(configuration)) { | ||
if (tsServerLogFile) { | ||
this._logger.logIgnoringVerbosity(LogLevel.Info, `<${kind}> Log file: ${tsServerLogFile}`); | ||
} | ||
else { | ||
this._logger.logIgnoringVerbosity(LogLevel.Error, `<${kind}> Could not create log directory`); | ||
} | ||
} | ||
const process = processFactory.fork(version, args, "main" /* TsServerProcessKind.Main */, configuration); | ||
this._logger.log('Starting tsserver'); | ||
return new ProcessBasedTsServer(kind, this.kindToServerType(kind), process, tsServerLogFile, canceller, version); | ||
return new ProcessBasedTsServer(kind, this.kindToServerType(kind), process, tsServerLogFile, canceller, version, this._tracer); | ||
} | ||
@@ -65,3 +76,3 @@ kindToServerType(kind) { | ||
} | ||
const { disableAutomaticTypingAcquisition, globalPlugins, locale, logFile, logVerbosity, npmLocation, pluginProbeLocations, } = configuration; | ||
const { disableAutomaticTypingAcquisition, globalPlugins, locale, npmLocation, pluginProbeLocations } = configuration; | ||
if (disableAutomaticTypingAcquisition || kind === "syntax" /* TsServerProcessKind.Syntax */ || kind === "diagnostics" /* TsServerProcessKind.Diagnostics */) { | ||
@@ -76,16 +87,10 @@ args.push('--disableAutomaticTypingAcquisition'); | ||
} | ||
// if (TspClient.isLoggingEnabled(configuration)) { | ||
// const logDir = this._logDirectoryProvider.getNewLogDirectory(); | ||
// if (logDir) { | ||
// tsServerLogFile = path.join(logDir, 'tsserver.log'); | ||
// args.push('--logVerbosity', TsServerLogLevel.toString(configuration.tsServerLogLevel)); | ||
// args.push('--logFile', tsServerLogFile); | ||
// } | ||
// } | ||
if (logFile) { | ||
args.push('--logFile', logFile); | ||
if (this.isLoggingEnabled(configuration)) { | ||
const logDir = this._logDirectoryProvider.getNewLogDirectory(); | ||
if (logDir) { | ||
tsServerLogFile = path.join(logDir, 'tsserver.log'); | ||
args.push('--logVerbosity', TsServerLogLevel.toString(configuration.logVerbosity)); | ||
args.push('--logFile', tsServerLogFile); | ||
} | ||
} | ||
if (logVerbosity) { | ||
args.push('--logVerbosity', logVerbosity); | ||
} | ||
// if (configuration.enableTsServerTracing) { | ||
@@ -125,3 +130,6 @@ // tsServerTraceDirectory = this._logDirectoryProvider.getNewLogDirectory(); | ||
} | ||
isLoggingEnabled(configuration) { | ||
return configuration.logVerbosity !== TsServerLogLevel.Off; | ||
} | ||
} | ||
//# sourceMappingURL=spawner.js.map |
import API from '../utils/api.js'; | ||
import type { IServerOptions } from '../utils/configuration.js'; | ||
import type { Logger } from '../logger.js'; | ||
import type { TypeScriptServiceConfiguration } from '../utils/configuration.js'; | ||
import type { Logger } from '../utils/logger.js'; | ||
export declare const enum TypeScriptVersionSource { | ||
@@ -12,6 +12,6 @@ Bundled = "bundled", | ||
readonly path: string; | ||
private readonly logger; | ||
private readonly _pathLabel?; | ||
private readonly logger?; | ||
private _api; | ||
constructor(source: TypeScriptVersionSource, path: string, _pathLabel?: string | undefined, logger?: Logger | undefined); | ||
constructor(source: TypeScriptVersionSource, path: string, logger: Logger, _pathLabel?: string | undefined); | ||
get tscPath(): string; | ||
@@ -27,5 +27,5 @@ get tsServerPath(): string; | ||
export declare class TypeScriptVersionProvider { | ||
private configuration?; | ||
private logger?; | ||
constructor(configuration?: IServerOptions | undefined, logger?: Logger | undefined); | ||
private configuration; | ||
private logger; | ||
constructor(configuration: TypeScriptServiceConfiguration, logger: Logger); | ||
getUserSettingVersion(): TypeScriptVersion | null; | ||
@@ -32,0 +32,0 @@ getWorkspaceVersion(workspaceFolders: string[]): TypeScriptVersion | null; |
@@ -5,2 +5,8 @@ /*--------------------------------------------------------------------------------------------- | ||
*--------------------------------------------------------------------------------------------*/ | ||
/* | ||
* Copyright (C) 2022 TypeFox and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
import fs from 'node:fs'; | ||
@@ -14,7 +20,7 @@ import { createRequire } from 'node:module'; | ||
export class TypeScriptVersion { | ||
constructor(source, path, _pathLabel, logger) { | ||
constructor(source, path, logger, _pathLabel) { | ||
this.source = source; | ||
this.path = path; | ||
this.logger = logger; | ||
this._pathLabel = _pathLabel; | ||
this.logger = logger; | ||
this._api = null; | ||
@@ -46,5 +52,5 @@ } | ||
getTypeScriptVersion(serverPath) { | ||
this.logger?.info(`Resolving TypeScript version from path "${serverPath}"...`); | ||
this.logger.log(`Resolving TypeScript version from path "${serverPath}"...`); | ||
if (!fs.existsSync(serverPath)) { | ||
this.logger?.info('Server path does not exist on disk'); | ||
this.logger.log('Server path does not exist on disk'); | ||
return null; | ||
@@ -54,3 +60,3 @@ } | ||
if (p.length <= 2) { | ||
this.logger?.info('Server path is invalid (has less than two path components).'); | ||
this.logger.log('Server path is invalid (has less than two path components).'); | ||
return null; | ||
@@ -68,6 +74,6 @@ } | ||
if (!fs.existsSync(fileName)) { | ||
this.logger?.info(`Failed to find package.json at path "${fileName}"`); | ||
this.logger.log(`Failed to find package.json at path "${fileName}"`); | ||
return null; | ||
} | ||
this.logger?.info(`Reading version from package.json at "${fileName}"`); | ||
this.logger.log(`Reading version from package.json at "${fileName}"`); | ||
const contents = fs.readFileSync(fileName).toString(); | ||
@@ -79,10 +85,10 @@ let desc = null; | ||
catch (err) { | ||
this.logger?.info('Failed parsing contents of package.json.'); | ||
this.logger.log('Failed parsing contents of package.json.'); | ||
return null; | ||
} | ||
if (!desc || !desc.version) { | ||
this.logger?.info('Failed reading version number from package.json.'); | ||
this.logger.log('Failed reading version number from package.json.'); | ||
return null; | ||
} | ||
this.logger?.info(`Resolved TypeScript version to "${desc.version}"`); | ||
this.logger.log(`Resolved TypeScript version to "${desc.version}"`); | ||
return API.fromVersionString(desc.version); | ||
@@ -98,7 +104,7 @@ } | ||
getUserSettingVersion() { | ||
const { tsserverPath } = this.configuration || {}; | ||
const { tsserverPath } = this.configuration; | ||
if (!tsserverPath) { | ||
return null; | ||
} | ||
this.logger?.info(`Resolving user-provided tsserver path "${tsserverPath}"...`); | ||
this.logger.log(`Resolving user-provided tsserver path "${tsserverPath}"...`); | ||
let resolvedPath = tsserverPath; | ||
@@ -111,3 +117,3 @@ // Resolve full path to the binary if path is not absolute. | ||
} | ||
this.logger?.info(`Non-absolute tsserver path resolved to "${binaryPath ? resolvedPath : '<failed>'}"`); | ||
this.logger.log(`Non-absolute tsserver path resolved to "${binaryPath ? resolvedPath : '<failed>'}"`); | ||
} | ||
@@ -118,3 +124,3 @@ // Resolve symbolic link. | ||
resolvedPath = fs.realpathSync(resolvedPath); | ||
this.logger?.info(`Symbolic link tsserver path resolved to "${resolvedPath}"`); | ||
this.logger.log(`Symbolic link tsserver path resolved to "${resolvedPath}"`); | ||
} | ||
@@ -125,3 +131,3 @@ // Get directory path | ||
resolvedPath = path.dirname(resolvedPath); | ||
this.logger?.info(`Resolved directory path from a file path: ${resolvedPath}`); | ||
this.logger.log(`Resolved directory path from a file path: ${resolvedPath}`); | ||
} | ||
@@ -131,6 +137,6 @@ // Resolve path to the "lib" dir. | ||
const packageJsonPath = pkgUpSync({ cwd: resolvedPath }); | ||
this.logger?.info(`Resolved package.json location: "${packageJsonPath}"`); | ||
this.logger.log(`Resolved package.json location: "${packageJsonPath}"`); | ||
if (packageJsonPath) { | ||
resolvedPath = path.join(path.dirname(packageJsonPath), 'lib'); | ||
this.logger?.info(`Assumed tsserver lib location: "${resolvedPath}"`); | ||
this.logger.log(`Assumed tsserver lib location: "${resolvedPath}"`); | ||
} | ||
@@ -141,3 +147,3 @@ } | ||
} | ||
return new TypeScriptVersion("user-setting" /* TypeScriptVersionSource.UserSetting */, resolvedPath, undefined, this.logger); | ||
return new TypeScriptVersion("user-setting" /* TypeScriptVersionSource.UserSetting */, resolvedPath, this.logger, undefined); | ||
} | ||
@@ -148,3 +154,3 @@ getWorkspaceVersion(workspaceFolders) { | ||
if (libFolder) { | ||
const version = new TypeScriptVersion("workspace" /* TypeScriptVersionSource.Workspace */, libFolder); | ||
const version = new TypeScriptVersion("workspace" /* TypeScriptVersionSource.Workspace */, libFolder, this.logger); | ||
if (version.isValid) { | ||
@@ -161,3 +167,3 @@ return version; | ||
const file = require.resolve('typescript'); | ||
const bundledVersion = new TypeScriptVersion("bundled" /* TypeScriptVersionSource.Bundled */, path.dirname(file), ''); | ||
const bundledVersion = new TypeScriptVersion("bundled" /* TypeScriptVersionSource.Bundled */, path.dirname(file), this.logger, ''); | ||
return bundledVersion; | ||
@@ -164,0 +170,0 @@ } |
@@ -1,10 +0,19 @@ | ||
import { Logger } from '../logger.js'; | ||
import { LspClient } from '../lsp-client.js'; | ||
export interface IServerOptions { | ||
logger: Logger; | ||
tsserverPath?: string; | ||
tsserverLogFile?: string; | ||
tsserverLogVerbosity?: string; | ||
lspClient: LspClient; | ||
import type { Logger } from '../utils/logger.js'; | ||
import type { LspClient } from '../lsp-client.js'; | ||
export declare enum TsServerLogLevel { | ||
Off = 0, | ||
Normal = 1, | ||
Terse = 2, | ||
Verbose = 3 | ||
} | ||
export declare namespace TsServerLogLevel { | ||
function fromString(value: string): TsServerLogLevel; | ||
function toString(value: TsServerLogLevel): string; | ||
} | ||
export interface TypeScriptServiceConfiguration { | ||
readonly logger: Logger; | ||
readonly lspClient: LspClient; | ||
readonly tsserverLogVerbosity: TsServerLogLevel; | ||
readonly tsserverPath?: string; | ||
} | ||
//# sourceMappingURL=configuration.d.ts.map |
@@ -1,2 +0,44 @@ | ||
export {}; | ||
/* | ||
* Copyright (C) 2021. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
export var TsServerLogLevel; | ||
(function (TsServerLogLevel) { | ||
TsServerLogLevel[TsServerLogLevel["Off"] = 0] = "Off"; | ||
TsServerLogLevel[TsServerLogLevel["Normal"] = 1] = "Normal"; | ||
TsServerLogLevel[TsServerLogLevel["Terse"] = 2] = "Terse"; | ||
TsServerLogLevel[TsServerLogLevel["Verbose"] = 3] = "Verbose"; | ||
})(TsServerLogLevel = TsServerLogLevel || (TsServerLogLevel = {})); | ||
(function (TsServerLogLevel) { | ||
function fromString(value) { | ||
switch (value?.toLowerCase()) { | ||
case 'normal': | ||
return TsServerLogLevel.Normal; | ||
case 'terse': | ||
return TsServerLogLevel.Terse; | ||
case 'verbose': | ||
return TsServerLogLevel.Verbose; | ||
case 'off': | ||
default: | ||
return TsServerLogLevel.Off; | ||
} | ||
} | ||
TsServerLogLevel.fromString = fromString; | ||
function toString(value) { | ||
switch (value) { | ||
case TsServerLogLevel.Normal: | ||
return 'normal'; | ||
case TsServerLogLevel.Terse: | ||
return 'terse'; | ||
case TsServerLogLevel.Verbose: | ||
return 'verbose'; | ||
case TsServerLogLevel.Off: | ||
default: | ||
return 'off'; | ||
} | ||
} | ||
TsServerLogLevel.toString = toString; | ||
})(TsServerLogLevel = TsServerLogLevel || (TsServerLogLevel = {})); | ||
//# sourceMappingURL=configuration.js.map |
{ | ||
"name": "typescript-language-server", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"description": "Language Server Protocol (LSP) implementation for TypeScript using tsserver", | ||
@@ -23,5 +23,5 @@ "author": "TypeFox and others", | ||
"clean": "rimraf lib *.tsbuildinfo", | ||
"test": "cross-env CONSOLE_LOG_LEVEL=warn TS_NODE_PROJECT=./tsconfig.json mocha", | ||
"test:watch": "cross-env CONSOLE_LOG_LEVEL=warn TS_NODE_PROJECT=./tsconfig.json mocha --watch", | ||
"test:compiled": "cross-env CONSOLE_LOG_LEVEL=warn mocha \"./lib/**/*.spec.js\"", | ||
"test": "cross-env CONSOLE_LOG_LEVEL=warning TS_NODE_PROJECT=./tsconfig.json mocha", | ||
"test:watch": "cross-env CONSOLE_LOG_LEVEL=warning TS_NODE_PROJECT=./tsconfig.json mocha --watch", | ||
"test:compiled": "cross-env CONSOLE_LOG_LEVEL=warning mocha \"./lib/**/*.spec.js\"", | ||
"lint": "eslint --ext \".js,.ts\" src", | ||
@@ -55,3 +55,3 @@ "fix": "eslint --ext \".js,.ts\" --fix src", | ||
"vscode-languageserver-textdocument": "1.0.7", | ||
"vscode-uri": "^3.0.3", | ||
"vscode-uri": "^3.0.6", | ||
"which": "^2.0.2" | ||
@@ -64,11 +64,11 @@ }, | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^16.11.56", | ||
"@types/node": "^16.11.62", | ||
"@types/semver": "^7.3.12", | ||
"@types/which": "^2.0.1", | ||
"@typescript-eslint/eslint-plugin": "^5.36.1", | ||
"@typescript-eslint/parser": "^5.36.1", | ||
"@typescript-eslint/eslint-plugin": "^5.38.1", | ||
"@typescript-eslint/parser": "^5.38.1", | ||
"chai": "^4.3.6", | ||
"concurrently": "^7.3.0", | ||
"concurrently": "^7.4.0", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^8.23.0", | ||
"eslint": "^8.24.0", | ||
"husky": "4.x", | ||
@@ -79,4 +79,4 @@ "mocha": "^10.0.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.8.2" | ||
"typescript": "^4.8.4" | ||
} | ||
} |
@@ -64,3 +64,2 @@ [![Build Status](https://travis-ci.org/theia-ide/typescript-language-server.svg?branch=master)](https://travis-ci.org/theia-ide/typescript-language-server) | ||
--log-level <log-level> A number indicating the log level (4 = log, 3 = info, 2 = warn, 1 = error). Defaults to `3`. | ||
--tsserver-log-file <tsServerLogFile> Specify a tsserver log file. example: --tsserver-log-file=ts-logs.txt | ||
--tsserver-log-verbosity <verbosity> Specify tsserver log verbosity (off, terse, normal, verbose). Defaults to `normal`. example: --tsserver-log-verbosity=verbose | ||
@@ -87,3 +86,25 @@ --tsserver-path <path> Specify path to tsserver directory. example: --tsserver-path=/Users/me/typescript/lib/ | ||
| preferences | object | Preferences passed to the Typescript (`tsserver`) process. See below for more info. | | ||
| tsserver | object | Options related to the `tsserver` process. See below for more info. | | ||
The `tsserver` setting specifies additional options related to the internal `tsserver` process, like tracing and logging. | ||
```ts | ||
interface TsserverOptions { | ||
/** | ||
* The path to the directory where the `tsserver` logs will be created. | ||
* If not provided, the log files will be created within the workspace, inside the `.log` directory. | ||
* If no workspace root is provided when initializating the server and no custom path is specified then | ||
* the logs will not be created. | ||
* @default undefined | ||
*/ | ||
logDirectory?: string; | ||
/** | ||
* The verbosity of logging of the tsserver communication. | ||
* Delivered through the LSP messages and not related to file logging. | ||
* @default 'off' | ||
*/ | ||
trace?: 'off' | 'messages' | 'verbose'; | ||
} | ||
``` | ||
The `preferences` object is an object specifying preferences for the internal `tsserver` process. Those options depend on the version of Typescript used but at the time of writing Typescript v4.4.3 contains these options: | ||
@@ -259,2 +280,7 @@ | ||
* Complete functions with their parameter signature. | ||
* | ||
* This functionality relies on LSP client resolving the completion using the `completionItem/resolve` call. If the | ||
* client can't do that before inserting the completion then it's not safe to enable it as it will result in some | ||
* completions having a snippet type without actually being snippets, which can then cause problems when inserting them. | ||
* | ||
* @default false | ||
@@ -564,3 +590,3 @@ */ | ||
By default only console logs of level `warn` and higher are printed to the console. You can override the `CONSOLE_LOG_LEVEL` level in `package.json` to either `log`, `info`, `warn` or `error` to log other levels. | ||
By default only console logs of level `warning` and higher are printed to the console. You can override the `CONSOLE_LOG_LEVEL` level in `package.json` to either `log`, `info`, `warning` or `error` to log other levels. | ||
@@ -567,0 +593,0 @@ ### Watch |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
721617
212
9147
598
7
Updatedvscode-uri@^3.0.6