[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jdt-dev] Binding not found for TypeDeclaration
|
I also getting some 'null' error in the Error log of the IDE (but
without a stacktrace sadly) and I experienced:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=577943
no idea if this is related.
Am 23.12.21 um 07:02 schrieb Rishad Rahman:
*We are constantly getting 'null' for 'binding of TypeDeclaration' in
some specific java files in https://github.com/bazelbuild/bazel
<https://github.com/bazelbuild/bazel>
Over 3000+ files show this behaviour. We are querious and concerned if
we are missing something.*
ITypeBinding binding = typeDec.resolveBinding();
While debugging, we found that 'compilationResult' of
'org.eclipse.jdt.internal.compiler.ast.TypeDeclaration' shows some
strange problems and showing 'COMPILED type(s)' as empty.
Filename :
/bazel-master/tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator/GcovJsonParser.java
COMPILED type(s)
1 PROBLEM(s) detected
- Pb(324) The type java.lang.String cannot be resolved. It is indirectly
referenced from required .class files
Filename :
/bazel-master/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
COMPILED type(s)
1 PROBLEM(s) detected
- Pb(324) The type java.lang.Object cannot be resolved. It is indirectly
referenced from required .class files
Filename :
/bazel-master/tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator/Main.java
COMPILED type(s)
2 PROBLEM(s) detected
- Pb(324) The type java.lang.String cannot be resolved. It is indirectly
referenced from required .class files
- Pb(1455) The package java.lang is accessible from more than one
module: <unnamed>, java.base
Filename :
/bazel-master/src/main/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryBaseRule.java
COMPILED type(s)
No PROBLEM
We are using the following code to parse AST
protected CompilationUnit parse(String filename) {
IModelFileElement fileElement =
Model.getInstance().getFile(filename);
ASTParser parser = ASTParser.newParser(AST.JLS11);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
if (fileElement instanceof EclipseModelFileElement) {
parser.setSource(((EclipseModelFileElement)fileElement).getCompilationUnit());
} else {
File file = new File(fileElement.getFullPath());
parser.setUnitName(fileElement.getName());
parser.setEnvironment(null, null, null, true);
try {
parser.setSource(readFileToString(file).toCharArray());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
parser.setResolveBindings(true);
parser.setBindingsRecovery(true);
try {
ASTNode node = parser.createAST(null);
if (node instanceof CompilationUnit) {
return (CompilationUnit)node;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Thanks and regards,
Md. Rishadur Rahman
Software Engineer
OpenRefactory Inc.
_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jdt-dev