mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2025-12-31 13:48:24 +03:00
Add lint configuration to enable or disable some feature for syntax check
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,5 +1,17 @@
|
||||
# Change Log
|
||||
|
||||
### 0.3.7
|
||||
* Fix error with run godot editor when the editor contains spaces
|
||||
* Disable semicolons and brackets checks as default can be enabled with project settings
|
||||
```json
|
||||
{
|
||||
"lint": {
|
||||
"semicolon": true,
|
||||
"conditionBrackets": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 0.3.6
|
||||
* Fix project configuartion file path
|
||||
|
||||
|
||||
10
package.json
10
package.json
@@ -3,7 +3,7 @@
|
||||
"displayName": "Godot Tools",
|
||||
"icon": "icon.png",
|
||||
"description": "Tools for game development with godot game engine",
|
||||
"version": "0.3.6",
|
||||
"version": "0.3.7",
|
||||
"publisher": "geequlim",
|
||||
"repository": "https://github.com/GodotExplorer/godot-tools",
|
||||
"license": "MIT",
|
||||
@@ -86,6 +86,14 @@
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Turn on/off the syntax checking for GDScript"
|
||||
},
|
||||
"GodotTools.lint": {
|
||||
"type":"object",
|
||||
"default": {
|
||||
"semicolon": false,
|
||||
"conditionBrackets": false
|
||||
},
|
||||
"description": "Lint configurations"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -71,6 +71,8 @@ class GDScriptDiagnosticSeverity {
|
||||
}
|
||||
|
||||
private validateExpression(doc : vscode.TextDocument) {
|
||||
let cfg : any = vscode.workspace.getConfiguration("GodotTools").get("lint");
|
||||
|
||||
let diagnostics = [];
|
||||
let expectEndOfLine = false;
|
||||
const text = doc.getText();
|
||||
@@ -88,7 +90,7 @@ class GDScriptDiagnosticSeverity {
|
||||
line = "\t" + line + "\t";
|
||||
var range = new vscode.Range(i, curLineStartAt, i, line.length);
|
||||
|
||||
if (line.match(/[^#].*?\;/) && !line.match(/[#].*?\;/)) {
|
||||
if (cfg.semicolon && line.match(/[^#].*?\;/) && !line.match(/[#].*?\;/)) {
|
||||
const semicolonIndex = line.indexOf(';');
|
||||
diagnostics.push(new vscode.Diagnostic(new vscode.Range(i, semicolonIndex, i, semicolonIndex + 1), "Statement contains a semicolon.", DiagnosticSeverity.Warning));
|
||||
}
|
||||
@@ -121,7 +123,7 @@ class GDScriptDiagnosticSeverity {
|
||||
if(!(line.match(/".*?for.*?"/) || line.match(/'.*?for.*?'/)))
|
||||
diagnostics.push(new vscode.Diagnostic(range, "Invalid for expression", DiagnosticSeverity.Error));
|
||||
}
|
||||
else if (line.match(/(if|elif|while|match)\s*\(.*\)/))
|
||||
else if (cfg.conditionBrackets && line.match(/(if|elif|while|match)\s*\(.*\)/))
|
||||
diagnostics.push(new vscode.Diagnostic(range, "Extra brackets in condition expression.", DiagnosticSeverity.Warning));
|
||||
const blockIndetCheck = function() {
|
||||
const err = new vscode.Diagnostic(range, "Expected indented block after expression", DiagnosticSeverity.Error);
|
||||
|
||||
Reference in New Issue
Block a user