fix unused variable checking error when be same part of another one

This commit is contained in:
geequlim
2017-03-09 19:30:06 +08:00
parent c657fc16de
commit 91c6acb1fd

View File

@@ -60,9 +60,9 @@ class GDScriptDiagnosticSeverity {
const text = doc.getText();
const check = (name:string, range: vscode.Range) => {
var matchs = text.match(new RegExp(`[^0-9A-Za-z_]\\s*${name}[^0-9A-Za-z_]\\s*`, 'g'));
var matchs = text.match(new RegExp(`[^\w]\\s*${name}[^\w]\\s*`, 'g'));
let count = matchs?matchs.length:0;
var incomment = text.match(new RegExp(`#[^0-9A-z_]*${name}[^0-9A-z_]`, 'g'));
var incomment = text.match(new RegExp(`#.*?[^\w]*${name}[^\w]`, 'g'));
count -= incomment?incomment.length:0;
if(count <= 1)
diagnostics.push(new vscode.Diagnostic(range, `${name} is never used.`, DiagnosticSeverity.Warning));