1.0.5 自动补全优化,补齐参数
This commit is contained in:
27
dist/providers/completionProvider.js
vendored
27
dist/providers/completionProvider.js
vendored
@@ -101,7 +101,14 @@ class CompletionProvider {
|
|||||||
const item = new vscode.CompletionItem(func.name, vscode.CompletionItemKind.Function);
|
const item = new vscode.CompletionItem(func.name, vscode.CompletionItemKind.Function);
|
||||||
item.detail = '内置函数';
|
item.detail = '内置函数';
|
||||||
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${this.apiParser.generateFunctionSignature(func)}\n\`\`\`\n${func.description}`);
|
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${this.apiParser.generateFunctionSignature(func)}\n\`\`\`\n${func.description}`);
|
||||||
item.insertText = func.name;
|
// 为函数创建带参数的插入文本
|
||||||
|
if (func.params.length > 0) {
|
||||||
|
const paramText = func.params.map((param, index) => `\${${index + 1}:${param.name}}`).join(', ');
|
||||||
|
item.insertText = new vscode.SnippetString(`${func.name}(${paramText})`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item.insertText = new vscode.SnippetString(`${func.name}()`);
|
||||||
|
}
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -155,7 +162,14 @@ class CompletionProvider {
|
|||||||
const item = new vscode.CompletionItem(functionName, vscode.CompletionItemKind.Function);
|
const item = new vscode.CompletionItem(functionName, vscode.CompletionItemKind.Function);
|
||||||
item.detail = `函数 - ${func.filePath}`;
|
item.detail = `函数 - ${func.filePath}`;
|
||||||
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${func.signature}\n\`\`\``);
|
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${func.signature}\n\`\`\``);
|
||||||
item.insertText = functionName;
|
// 为函数创建带参数的插入文本
|
||||||
|
if (func.parameters.length > 0) {
|
||||||
|
const paramText = func.parameters.map((param, index) => `\${${index + 1}:${param}}`).join(', ');
|
||||||
|
item.insertText = new vscode.SnippetString(`${functionName}(${paramText})`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item.insertText = new vscode.SnippetString(`${functionName}()`);
|
||||||
|
}
|
||||||
completions.push(item);
|
completions.push(item);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -164,7 +178,14 @@ class CompletionProvider {
|
|||||||
const item = new vscode.CompletionItem(`${functionName} (${func.filePath})`, vscode.CompletionItemKind.Function);
|
const item = new vscode.CompletionItem(`${functionName} (${func.filePath})`, vscode.CompletionItemKind.Function);
|
||||||
item.detail = `函数 - ${func.filePath}`;
|
item.detail = `函数 - ${func.filePath}`;
|
||||||
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${func.signature}\n\`\`\``);
|
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${func.signature}\n\`\`\``);
|
||||||
item.insertText = functionName;
|
// 为函数创建带参数的插入文本
|
||||||
|
if (func.parameters.length > 0) {
|
||||||
|
const paramText = func.parameters.map((param, index) => `\${${index + 1}:${param}}`).join(', ');
|
||||||
|
item.insertText = new vscode.SnippetString(`${functionName}(${paramText})`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item.insertText = new vscode.SnippetString(`${functionName}()`);
|
||||||
|
}
|
||||||
item.filterText = functionName;
|
item.filterText = functionName;
|
||||||
completions.push(item);
|
completions.push(item);
|
||||||
});
|
});
|
||||||
|
|||||||
2
dist/providers/completionProvider.js.map
vendored
2
dist/providers/completionProvider.js.map
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -98,7 +98,15 @@ export class CompletionProvider implements vscode.CompletionItemProvider {
|
|||||||
const item = new vscode.CompletionItem(func.name, vscode.CompletionItemKind.Function);
|
const item = new vscode.CompletionItem(func.name, vscode.CompletionItemKind.Function);
|
||||||
item.detail = '内置函数';
|
item.detail = '内置函数';
|
||||||
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${this.apiParser.generateFunctionSignature(func)}\n\`\`\`\n${func.description}`);
|
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${this.apiParser.generateFunctionSignature(func)}\n\`\`\`\n${func.description}`);
|
||||||
item.insertText = func.name;
|
|
||||||
|
// 为函数创建带参数的插入文本
|
||||||
|
if (func.params.length > 0) {
|
||||||
|
const paramText = func.params.map((param, index) => `\${${index + 1}:${param.name}}`).join(', ');
|
||||||
|
item.insertText = new vscode.SnippetString(`${func.name}(${paramText})`);
|
||||||
|
} else {
|
||||||
|
item.insertText = new vscode.SnippetString(`${func.name}()`);
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -158,7 +166,15 @@ export class CompletionProvider implements vscode.CompletionItemProvider {
|
|||||||
const item = new vscode.CompletionItem(functionName, vscode.CompletionItemKind.Function);
|
const item = new vscode.CompletionItem(functionName, vscode.CompletionItemKind.Function);
|
||||||
item.detail = `函数 - ${func.filePath}`;
|
item.detail = `函数 - ${func.filePath}`;
|
||||||
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${func.signature}\n\`\`\``);
|
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${func.signature}\n\`\`\``);
|
||||||
item.insertText = functionName;
|
|
||||||
|
// 为函数创建带参数的插入文本
|
||||||
|
if (func.parameters.length > 0) {
|
||||||
|
const paramText = func.parameters.map((param, index) => `\${${index + 1}:${param}}`).join(', ');
|
||||||
|
item.insertText = new vscode.SnippetString(`${functionName}(${paramText})`);
|
||||||
|
} else {
|
||||||
|
item.insertText = new vscode.SnippetString(`${functionName}()`);
|
||||||
|
}
|
||||||
|
|
||||||
completions.push(item);
|
completions.push(item);
|
||||||
} else {
|
} else {
|
||||||
// 多个同名函数,创建带文件路径信息的完成项
|
// 多个同名函数,创建带文件路径信息的完成项
|
||||||
@@ -166,7 +182,15 @@ export class CompletionProvider implements vscode.CompletionItemProvider {
|
|||||||
const item = new vscode.CompletionItem(`${functionName} (${func.filePath})`, vscode.CompletionItemKind.Function);
|
const item = new vscode.CompletionItem(`${functionName} (${func.filePath})`, vscode.CompletionItemKind.Function);
|
||||||
item.detail = `函数 - ${func.filePath}`;
|
item.detail = `函数 - ${func.filePath}`;
|
||||||
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${func.signature}\n\`\`\``);
|
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${func.signature}\n\`\`\``);
|
||||||
item.insertText = functionName;
|
|
||||||
|
// 为函数创建带参数的插入文本
|
||||||
|
if (func.parameters.length > 0) {
|
||||||
|
const paramText = func.parameters.map((param, index) => `\${${index + 1}:${param}}`).join(', ');
|
||||||
|
item.insertText = new vscode.SnippetString(`${functionName}(${paramText})`);
|
||||||
|
} else {
|
||||||
|
item.insertText = new vscode.SnippetString(`${functionName}()`);
|
||||||
|
}
|
||||||
|
|
||||||
item.filterText = functionName;
|
item.filterText = functionName;
|
||||||
completions.push(item);
|
completions.push(item);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user