fix errors with diagnostic

This commit is contained in:
Geequlim
2017-01-10 18:19:57 +08:00
parent a72e8bc147
commit 75d4bee8aa

View File

@@ -60,7 +60,7 @@ class GDScriptDiagnosticSeverity {
const text = doc.getText();
const check = (name:string, range: vscode.Range) => {
const pattern = `[\\s\\+\\-\\*/%\\^\\(\\[\\{\.]${name}[^0-9A-Za-z_]\\s*`;
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)
diagnostics.push(new vscode.Diagnostic(range, `${name} is never used.`, DiagnosticSeverity.Warning));
@@ -82,7 +82,7 @@ class GDScriptDiagnosticSeverity {
if(semicolonIndex != -1) {
diagnostics.push(new vscode.Diagnostic(new vscode.Range(i, semicolonIndex, i, semicolonIndex+1), "Statement ends with a semicolon.", DiagnosticSeverity.Warning));
}
if(line.match(/\s*(if|elif|else|for|while|func|class)\s/g) && line.indexOf(":") == -1) {
if(line.match(/\s*(if|elif|else|for|while|func|class)\s*/g) && line.indexOf(":") == -1) {
if(line.indexOf("#") == -1)
diagnostics.push(new vscode.Diagnostic(new vscode.Range(i, 0, i, line.length), "':' expected at end of the line.", DiagnosticSeverity.Error));
}