mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Update a few interfaces for TS 2.6.2
This commit is contained in:
parent
2bbdabd97e
commit
3200d2afa6
|
@ -84,7 +84,7 @@ export function getJavascriptMode(documentRegions: LanguageModelCache<HTMLDocume
|
||||||
doComplete(document: TextDocument, position: Position): CompletionList {
|
doComplete(document: TextDocument, position: Position): CompletionList {
|
||||||
updateCurrentTextDocument(document);
|
updateCurrentTextDocument(document);
|
||||||
let offset = currentTextDocument.offsetAt(position);
|
let offset = currentTextDocument.offsetAt(position);
|
||||||
let completions = jsLanguageService.getCompletionsAtPosition(FILE_NAME, offset);
|
let completions = jsLanguageService.getCompletionsAtPosition(FILE_NAME, offset, { includeExternalModuleExports: false });
|
||||||
if (!completions) {
|
if (!completions) {
|
||||||
return { isIncomplete: false, items: [] };
|
return { isIncomplete: false, items: [] };
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,13 +134,13 @@ class ApplyCompletionCodeActionCommand implements Command {
|
||||||
private readonly client: ITypeScriptServiceClient
|
private readonly client: ITypeScriptServiceClient
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
public async execute(file: string, codeActions: CodeAction[]): Promise<boolean> {
|
public async execute(_file: string, codeActions: CodeAction[]): Promise<boolean> {
|
||||||
if (codeActions.length === 0) {
|
if (codeActions.length === 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codeActions.length === 1) {
|
if (codeActions.length === 1) {
|
||||||
return applyCodeAction(this.client, codeActions[0], file);
|
return applyCodeAction(this.client, codeActions[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MyQuickPickItem extends QuickPickItem {
|
interface MyQuickPickItem extends QuickPickItem {
|
||||||
|
@ -165,7 +165,7 @@ class ApplyCompletionCodeActionCommand implements Command {
|
||||||
if (!action) {
|
if (!action) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return applyCodeAction(this.client, action, file);
|
return applyCodeAction(this.client, action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,10 +250,10 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const args = {
|
const args: CompletionsRequestArgs = {
|
||||||
...vsPositionToTsFileLocation(file, position),
|
...vsPositionToTsFileLocation(file, position),
|
||||||
includeExternalModuleExports: config.autoImportSuggestions
|
includeExternalModuleExports: config.autoImportSuggestions
|
||||||
} as CompletionsRequestArgs;
|
};
|
||||||
const msg = await this.client.execute('completions', args, token);
|
const msg = await this.client.execute('completions', args, token);
|
||||||
// This info has to come from the tsserver. See https://github.com/Microsoft/TypeScript/issues/2831
|
// This info has to come from the tsserver. See https://github.com/Microsoft/TypeScript/issues/2831
|
||||||
// let isMemberCompletion = false;
|
// let isMemberCompletion = false;
|
||||||
|
|
|
@ -29,8 +29,7 @@ export function getEditForCodeAction(
|
||||||
|
|
||||||
export async function applyCodeAction(
|
export async function applyCodeAction(
|
||||||
client: ITypeScriptServiceClient,
|
client: ITypeScriptServiceClient,
|
||||||
action: Proto.CodeAction,
|
action: Proto.CodeAction
|
||||||
file: string
|
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const workspaceEdit = getEditForCodeAction(client, action);
|
const workspaceEdit = getEditForCodeAction(client, action);
|
||||||
if (workspaceEdit) {
|
if (workspaceEdit) {
|
||||||
|
@ -38,17 +37,16 @@ export async function applyCodeAction(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return applyCodeActionCommands(client, action, file);
|
return applyCodeActionCommands(client, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function applyCodeActionCommands(
|
export async function applyCodeActionCommands(
|
||||||
client: ITypeScriptServiceClient,
|
client: ITypeScriptServiceClient,
|
||||||
action: Proto.CodeAction,
|
action: Proto.CodeAction
|
||||||
file: string
|
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (action.commands && action.commands.length) {
|
if (action.commands && action.commands.length) {
|
||||||
for (const command of action.commands) {
|
for (const command of action.commands) {
|
||||||
const response = await client.execute('applyCodeActionCommand', { file, command });
|
const response = await client.execute('applyCodeActionCommand', { command });
|
||||||
if (!response || !response.body) {
|
if (!response || !response.body) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue