Przeglądaj źródła

代码提示优化

mxd 3 lat temu
rodzic
commit
f24789112c

+ 2 - 2
magic-editor/src/console/src/scripts/editor/hover.js

@@ -31,9 +31,9 @@ const findBestMatch = (node, row, col) => {
     }
     return null;
 }
-const generateMethodDocument = (prefix,method, contents) => {
+const generateMethodDocument = (prefix, method, contents) => {
     contents.push({value: `${prefix}${method.fullName}`})
-    contents.push({value: `${method.comment}`})
+    method.comment && contents.push({value: `${method.comment}`})
     method.parameters.forEach((param, pIndex) => {
         if (pIndex > 0 || !method.extension) {
             contents.push({value: `${param.name}:${(param.comment || param.type)}`})

+ 6 - 6
magic-editor/src/console/src/scripts/editor/java-class.js

@@ -115,9 +115,9 @@ const processMethod = (method, begin, sort) => {
                 params2.push(getSimpleClass(method.parameters[j].type) + " " + method.parameters[j].name);
             }
         }
-        if (!method.comment) {
-            method.comment = getSimpleClass(method.returnType) + ':' + method.name + '(' + params2.join(',') + ')';
-        }
+        // if (!method.comment) {
+        //     method.comment = getSimpleClass(method.returnType) + '.' + method.name + '(' + params2.join(', ') + ')';
+        // }
         method.sortText = padding(sort, 10) + method.name;
         method.fullName = method.name + '(' + params2.join(', ') + ')';
         method.insertText += '(' + params.join(',') + ')';
@@ -126,9 +126,9 @@ const processMethod = (method, begin, sort) => {
         method.sortText = padding(sort, 10) + method.name;
         method.insertText += '()';
         method.fullName = method.name + '()';
-        if (!method.comment) {
-            method.comment = getSimpleClass(method.returnType) + ':' + method.name + '()';
-        }
+        // if (!method.comment) {
+        //     method.comment = getSimpleClass(method.returnType) + '.' + method.name + '()';
+        // }
         method.signature = method.name;
     }
     return method;

+ 6 - 0
magic-editor/src/console/src/scripts/parsing/ast.js

@@ -114,6 +114,12 @@ class FunctionCall extends Node {
     }
 
     async getJavaType(env) {
+        if(this.target instanceof VariableAccess){
+            const method = JavaClass.findFunction().find(method => method.name === this.target.variable)
+            if(method){
+                return method.returnType
+            }
+        }
         return await this.target.getJavaType(env);
     }
 }