Skip to content

Commit fea1361

Browse files
committed
Import resolve type, try to find static class
1 parent 28a87f4 commit fea1361

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/src/main/java/com/duy/ide/javaide/editor/autocomplete/internal/TypeResolver.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,23 @@ private IClass resolveTypeImpl(@NonNull final JCExpression expression, int curso
7878
JCVariableDecl variableDecl = getVariableDeclaration(mUnit, jcIdent);
7979
if (DLog.DEBUG) DLog.d(TAG, "variableDecl = " + variableDecl);
8080
if (variableDecl != null) {
81-
String className = variableDecl.getType().toString();
81+
String className;
82+
if (variableDecl.getType() instanceof JCTree.JCTypeApply) { //generic
83+
className = ((JCTree.JCTypeApply) variableDecl.getType()).getType().toString();
84+
} else {
85+
className = variableDecl.getType().toString();
86+
}
8287
//try to find full class name
8388
className = findImportedClassName(className);
8489
currentType = mClassLoader.getClassReader().getParsedClass(className);
90+
} else {
91+
//case: System.out -> find imported class, this expression can be static access
92+
String className = findImportedClassName(jcIdent.getName().toString());
93+
currentType = mClassLoader.getClassReader().getParsedClass(className);
8594
}
8695
// TODO: 13-Jun-18 case: static import
8796
// TODO: 13-Jun-18 case inner class
8897
} else if (tree instanceof JCMethodInvocation) {
89-
9098
// TODO: 13-Jun-18 find method in current class or import static
9199
JCMethodInvocation jcMethod = (JCMethodInvocation) tree;
92100
JCExpression methodSelect = jcMethod.getMethodSelect();

0 commit comments

Comments
 (0)