mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2025-12-31 13:48:24 +03:00
const value in hover tip and comletion items
This commit is contained in:
@@ -147,13 +147,14 @@ class Config {
|
||||
const _items: CompletionItem[] = [];
|
||||
for (let name of Object.keys(items)) {
|
||||
const signature = (script.signatures && script.signatures[name])?script.signatures[name]:"";
|
||||
const cvalue = (script.constvalues && script.constvalues[name])?script.constvalues[name]:"";
|
||||
const item = new CompletionItem(name+signature, kind);
|
||||
item.sortText = name;
|
||||
item.filterText = name;
|
||||
item.detail = workspace.asRelativePath(path);
|
||||
item.detail = cvalue;
|
||||
item.insertText = insertText(name) + (signature=="()"?"()":"");
|
||||
item.documentation = (script.documents && script.documents[name])?script.documents[name]+"\r\n":"";
|
||||
item.documentation += `${kindName} defined in ${item.detail}`;
|
||||
item.documentation += `${kindName} defined in ${workspace.asRelativePath(path)}`;
|
||||
_items.push(item);
|
||||
}
|
||||
return _items;
|
||||
|
||||
@@ -48,10 +48,12 @@ class GDScriptHoverProvider implements HoverProvider {
|
||||
let signature = "";
|
||||
if(type == "func"|| type == "signal" && script.signatures[name])
|
||||
signature = script.signatures[name];
|
||||
if(type == "const" && script.constvalues[name])
|
||||
signature = ` = ${script.constvalues[name]}`;
|
||||
_items.push({language:'gdscript', value:`${type} ${name}${signature}`});
|
||||
let doc = script.documents[name];
|
||||
doc = doc?doc+"\r\n\r\n":"";
|
||||
doc += `*Defined in [${dfile}](${Uri.file(path).toString()}).*`
|
||||
doc += `*Defined in [${dfile}](${Uri.file(path).toString()})*`
|
||||
_items.push(doc)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ interface GDScript {
|
||||
native: string,
|
||||
signatures: {},
|
||||
// symbol: marked string
|
||||
documents: {}
|
||||
documents: {},
|
||||
// name : value
|
||||
constvalues: {}
|
||||
}
|
||||
|
||||
class GDScriptSymbolParser {
|
||||
@@ -28,7 +30,8 @@ class GDScriptSymbolParser {
|
||||
base: "Object",
|
||||
native: "Object",
|
||||
signatures: {},
|
||||
documents: {}
|
||||
documents: {},
|
||||
constvalues: {}
|
||||
}
|
||||
const text = content;
|
||||
const lines = text.split(/\r?\n/);
|
||||
@@ -86,7 +89,7 @@ class GDScriptSymbolParser {
|
||||
while( line > 0){
|
||||
const linecontent = lines[line];
|
||||
let match = linecontent.match(/\s*#\s*(.*)/);
|
||||
const commentAtEnd = linecontent.match(/[A-z0-8,\[\{]+\s*#\s*(.*)/);
|
||||
const commentAtEnd = linecontent.match(/[\w'",\[\{\]\}\(\)]+\s*#\s*(.*)/);
|
||||
if(!match && line != range.start.line)
|
||||
break;
|
||||
if(commentAtEnd && line != range.start.line)
|
||||
@@ -138,6 +141,11 @@ class GDScriptSymbolParser {
|
||||
if(newdoc == "" && script.documents[key])
|
||||
newdoc = script.documents[key];
|
||||
script.documents[key] = newdoc;
|
||||
|
||||
const linecontent = lines[r.start.line];
|
||||
const match = linecontent.match(/const\s+([_A-Za-z]+[_A-Za-z0-9]*)\s*=\s*([\w+]+\(.*\)|"[^"]*"|\-?\d+\.?\d*|\[.*\]|\{.*\})/);
|
||||
if(match && match.length && match.length >1)
|
||||
script.constvalues[key] = match[2];
|
||||
}
|
||||
|
||||
let classnames = getMatches(text, /class\s+([_A-Za-z]+[_A-Za-z0-9]*)\s*extends\s+/g, 1);
|
||||
|
||||
Reference in New Issue
Block a user