1.1.1 优化自动补全和悬浮显示
This commit is contained in:
33
dist/providers/completionProvider.js
vendored
33
dist/providers/completionProvider.js
vendored
@@ -96,21 +96,50 @@ class CompletionProvider {
|
||||
}
|
||||
// 获取API函数完成项
|
||||
getApiFunctionCompletions() {
|
||||
const completions = [];
|
||||
// 添加普通函数(不自动填写第一个参数)
|
||||
const functions = this.apiParser.getFunctions();
|
||||
return functions.map(func => {
|
||||
functions.forEach(func => {
|
||||
const item = new vscode.CompletionItem(func.name, vscode.CompletionItemKind.Function);
|
||||
item.detail = '内置函数';
|
||||
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${this.apiParser.generateFunctionSignature(func)}\n\`\`\`\n${func.description}`);
|
||||
// 为函数创建带参数的插入文本
|
||||
if (func.params.length > 0) {
|
||||
// 普通函数不自动填写第一个参数,用户需要手动输入
|
||||
if (func.params.length > 1) {
|
||||
// 从第二个参数开始添加占位符
|
||||
const remainingParams = func.params.slice(1);
|
||||
const paramText = remainingParams.map((param, index) => `\${${index + 1}:${param.name}}`).join(', ');
|
||||
item.insertText = new vscode.SnippetString(`${func.name}(${paramText})`);
|
||||
}
|
||||
else {
|
||||
// 只有一个参数或无参数
|
||||
item.insertText = new vscode.SnippetString(`${func.name}()`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
item.insertText = new vscode.SnippetString(`${func.name}()`);
|
||||
}
|
||||
completions.push(item);
|
||||
});
|
||||
// 添加扩展函数(自动填写所有参数)
|
||||
const functionEx = this.apiParser.getFunctionEx();
|
||||
functionEx.forEach(func => {
|
||||
const item = new vscode.CompletionItem(func.name, vscode.CompletionItemKind.Function);
|
||||
item.detail = '扩展函数';
|
||||
item.documentation = new vscode.MarkdownString(`\`\`\`squirrel\n${this.apiParser.generateFunctionSignature(func)}\n\`\`\`\n${func.description}`);
|
||||
// 为函数创建带参数的插入文本
|
||||
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;
|
||||
completions.push(item);
|
||||
});
|
||||
return completions;
|
||||
}
|
||||
// 获取API类完成项
|
||||
getApiClassCompletions() {
|
||||
|
||||
Reference in New Issue
Block a user