Kaynağa Gözat

Multiline statements

arrkiin 8 yıl önce
ebeveyn
işleme
e21de33ffc
1 değiştirilmiş dosya ile 12 ekleme ve 2 silme
  1. 12 2
      src/gdscript/diagnostic.ts

+ 12 - 2
src/gdscript/diagnostic.ts

@@ -77,6 +77,7 @@ class GDScriptDiagnosticSeverity {
 
   private validateExpression(doc: vscode.TextDocument) {
     let diagnostics = [];
+    let expectEndOfLine = false;
     const text = doc.getText();
     const lines = text.split(/\r?\n/);
     lines.map((line:string, i: number) =>{
@@ -93,10 +94,19 @@ class GDScriptDiagnosticSeverity {
       if(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));
+              }      if (line.match(/[^#].*?/) && expectEndOfLine){
+        if(!line.match(/.*?(\\|\:)/)){
+          diagnostics.push(new vscode.Diagnostic(range, "': or /' expected at end of the line.", DiagnosticSeverity.Error));
+          expectEndOfLine = false;
+        }
+        if(line.match(/.*?\:/))
+          expectEndOfLine = false;
       }
       if(line.match(/[^\w](if|elif|else|for|while|func|class)[^\w].*?/) && !line.match(/#.*?[^\w](if|elif|else|for|while|func|class)[^\w].*?/)) {
-        if(!line.match(/(if|elif|else|for|while|func|class).*?\:/))
-          diagnostics.push(new vscode.Diagnostic(range, "':' expected at end of the line.", DiagnosticSeverity.Error));
+        if(line.match(/(if|elif|else|for|while|func|class).*?\\/))
+          expectEndOfLine = true;
+        if(line.match(/(if|elif|else|for|while|func|class).*?/) && !line.match(/.*?(\\|\:)/))
+          diagnostics.push(new vscode.Diagnostic(range, "': or /' expected at end of the line.", DiagnosticSeverity.Error));          
         else if(line.match(/(if|elif|while|func|class)\s*\:/))
           diagnostics.push(new vscode.Diagnostic(range, "Indentifier expected before ':'", DiagnosticSeverity.Error));
         else if(line.match(/[^\w]for[^\w]/) && !line.match(/\s+for\s\w+\s+in\s+[\w+]|\{.*?\}|\[.*?\]/))