Explorar el Código

Ignore var check in comments for validating
Add workspace documentation for workspace symbols in code completion

Geequlim hace 8 años
padre
commit
60a510ca8c
Se han modificado 3 ficheros con 15 adiciones y 6 borrados
  1. 2 1
      src/config.ts
  2. 5 3
      src/gdscript/diagnostic.ts
  3. 8 2
      src/gdscript/symbolparser.ts

+ 2 - 1
src/config.ts

@@ -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;

+ 5 - 3
src/gdscript/diagnostic.ts

@@ -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

+ 8 - 2
src/gdscript/symbolparser.ts

@@ -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);