Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Provide the missing parameters for the tsWorker. #4414

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/language/typescript/languageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export class SuggestAdapter extends Adapter implements languages.CompletionItemP
return;
}

const info = await worker.getCompletionsAtPosition(resource.toString(), offset);
const info = await worker.getCompletionsAtPosition(resource.toString(), offset, undefined);

if (!info || model.isDisposed()) {
return;
Expand Down Expand Up @@ -509,7 +509,11 @@ export class SuggestAdapter extends Adapter implements languages.CompletionItemP
const details = await worker.getCompletionEntryDetails(
resource.toString(),
offset,
myItem.label
myItem.label,
undefined,
undefined,
undefined,
undefined
);
if (!details) {
return myItem;
Expand Down Expand Up @@ -1099,7 +1103,8 @@ export class CodeActionAdaptor extends FormatHelper implements languages.CodeAct
start,
end,
errorCodes,
formatOptions
formatOptions,
{}
);

if (!codeFixes || model.isDisposed()) {
Expand Down
23 changes: 20 additions & 3 deletions src/language/typescript/monaco.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,22 +414,37 @@ export interface TypeScriptWorker {

/**
* Get code completions for the given file and position.
* @param options `typescript.GetCompletionsAtPositionOptions | undefined`
* @param formattingSettings `typescript.FormatCodeSettings`
* @returns `Promise<typescript.CompletionInfo | undefined>`
*/
getCompletionsAtPosition(fileName: string, position: number): Promise<any | undefined>;
getCompletionsAtPosition(
fileName: string,
position: number,
options: any,
formattingSettings?: any
): Promise<any | undefined>;

/**
* Get code completion details for the given file, position, and entry.
* @param formatOptions `typescript.FormatCodeOptions | typescript.FormatCodeSettings | undefined`
* @param preferences `typescript.UserPreferences | undefined`
* @param data `typescript.CompletionEntryData | undefined`
* @returns `Promise<typescript.CompletionEntryDetails | undefined>`
*/
getCompletionEntryDetails(
fileName: string,
position: number,
entry: string
entryName: string,
formatOptions: any,
source: string | undefined,
preferences: any,
data: any
): Promise<any | undefined>;

/**
* Get signature help items for the item at the given file and position.
* @param options `typescript.SignatureHelpItemsOptions | undefined`
* @returns `Promise<typescript.SignatureHelpItems | undefined>`
*/
getSignatureHelpItems(fileName: string, position: number, options: any): Promise<any | undefined>;
Expand Down Expand Up @@ -526,14 +541,16 @@ export interface TypeScriptWorker {
/**
* Get possible code fixes at the given position in the file.
* @param formatOptions `typescript.FormatCodeOptions`
* @param preferences `typescript.UserPreferences`
* @returns `Promise<ReadonlyArray<typescript.CodeFixAction>>`
*/
getCodeFixesAtPosition(
fileName: string,
start: number,
end: number,
errorCodes: number[],
formatOptions: any
formatOptions: any,
preferences: any
): Promise<ReadonlyArray<any>>;

/**
Expand Down
39 changes: 25 additions & 14 deletions src/language/typescript/tsWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,38 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork

async getCompletionsAtPosition(
fileName: string,
position: number
): Promise<ts.CompletionInfo | undefined> {
position: number,
options: ts.GetCompletionsAtPositionOptions | undefined,
formattingSettings?: ts.FormatCodeSettings
): Promise<ts.WithMetadata<ts.CompletionInfo> | undefined> {
if (fileNameIsLib(fileName)) {
return undefined;
}
return this._languageService.getCompletionsAtPosition(fileName, position, undefined);
return this._languageService.getCompletionsAtPosition(
fileName,
position,
options,
formattingSettings
);
}

async getCompletionEntryDetails(
fileName: string,
position: number,
entry: string
entryName: string,
formatOptions: ts.FormatCodeOptions | ts.FormatCodeSettings | undefined,
source: string | undefined,
preferences: ts.UserPreferences | undefined,
data: ts.CompletionEntryData | undefined
): Promise<ts.CompletionEntryDetails | undefined> {
return this._languageService.getCompletionEntryDetails(
fileName,
position,
entry,
undefined,
undefined,
undefined,
undefined
entryName,
formatOptions,
source,
preferences,
data
);
}

Expand Down Expand Up @@ -339,7 +350,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork

async getFormattingEditsForDocument(
fileName: string,
options: ts.FormatCodeOptions
options: ts.FormatCodeOptions | ts.FormatCodeSettings
): Promise<ts.TextChange[]> {
if (fileNameIsLib(fileName)) {
return [];
Expand All @@ -351,7 +362,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
fileName: string,
start: number,
end: number,
options: ts.FormatCodeOptions
options: ts.FormatCodeOptions | ts.FormatCodeSettings
): Promise<ts.TextChange[]> {
if (fileNameIsLib(fileName)) {
return [];
Expand All @@ -363,7 +374,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
fileName: string,
postion: number,
ch: string,
options: ts.FormatCodeOptions
options: ts.FormatCodeOptions | ts.FormatCodeSettings
): Promise<ts.TextChange[]> {
if (fileNameIsLib(fileName)) {
return [];
Expand Down Expand Up @@ -413,12 +424,12 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
start: number,
end: number,
errorCodes: number[],
formatOptions: ts.FormatCodeOptions
formatOptions: ts.FormatCodeOptions | ts.FormatCodeSettings,
preferences: ts.UserPreferences
): Promise<ReadonlyArray<ts.CodeFixAction>> {
if (fileNameIsLib(fileName)) {
return [];
}
const preferences = {};
try {
return this._languageService.getCodeFixesAtPosition(
fileName,
Expand Down