mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2026-01-05 14:10:13 +03:00
Ignore var check in comments for validating
Add workspace documentation for workspace symbols in code completion
This commit is contained in:
@@ -148,7 +148,8 @@ class Config {
|
||||
const item = new CompletionItem(name, kind);
|
||||
item.detail = workspace.asRelativePath(path);
|
||||
item.insertText = insertText(name);
|
||||
item.documentation = `${kindName} defined in ${item.detail}`;
|
||||
item.documentation = (script.documents && script.documents[name])?script.documents[name]+"\r\n":"";
|
||||
item.documentation += `${kindName} defined in ${item.detail}`;
|
||||
_items.push(item);
|
||||
}
|
||||
return _items;
|
||||
|
||||
@@ -60,9 +60,11 @@ class GDScriptDiagnosticSeverity {
|
||||
const text = doc.getText();
|
||||
|
||||
const check = (name:string, range: vscode.Range) => {
|
||||
const pattern = `[^0-9A-Za-z_]\\s*${name}[^0-9A-Za-z_]\\s*`;
|
||||
var matchs = text.match(new RegExp(pattern, 'g'));
|
||||
if(matchs.length <= 1)
|
||||
var matchs = text.match(new RegExp(`[^0-9A-Za-z_]\\s*${name}[^0-9A-Za-z_]\\s*`, 'g'));
|
||||
let count = matchs?matchs.length:0;
|
||||
var incomment = text.match(new RegExp(`#[^0-9A-z_]*${name}[^0-9A-z_]`, 'g'));
|
||||
count -= incomment?incomment.length:0;
|
||||
if(count <= 1)
|
||||
diagnostics.push(new vscode.Diagnostic(range, `${name} is never used.`, DiagnosticSeverity.Warning));
|
||||
};
|
||||
// Unused variables
|
||||
|
||||
@@ -121,7 +121,10 @@ class GDScriptSymbolParser {
|
||||
for (let key of Object.keys(vars)){
|
||||
const r:Range = determRange(key, vars)
|
||||
script.variables[key] = r;
|
||||
script.documents[key] = parseDocument(r);
|
||||
let newdoc = parseDocument(r);
|
||||
if(newdoc == "" && script.documents[key])
|
||||
newdoc = script.documents[key];
|
||||
script.documents[key] = newdoc;
|
||||
}
|
||||
|
||||
let constnames = getMatches(text, /const\s+([_A-Za-z]+[_A-Za-z0-9]*)\s*/g, 1);
|
||||
@@ -129,7 +132,10 @@ class GDScriptSymbolParser {
|
||||
for (let key of Object.keys(consts)){
|
||||
const r:Range = determRange(key, consts)
|
||||
script.constants[key] = r;
|
||||
script.documents[key] = parseDocument(r);
|
||||
let newdoc = parseDocument(r);
|
||||
if(newdoc == "" && script.documents[key])
|
||||
newdoc = script.documents[key];
|
||||
script.documents[key] = newdoc;
|
||||
}
|
||||
|
||||
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