Skip to content

Commit 5582f48

Browse files
committed
avoid NPE case on startup
1 parent 2583c7c commit 5582f48

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

java/src/processing/mode/java/pdex/ASTGenerator.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,31 +2741,31 @@ protected static ASTNode findDeclaration(Name findMe) {
27412741
// .toString()));
27422742

27432743
SimpleType stp = extracTypeInfo(findDeclaration((qnn.getQualifier())));
2744-
// log(qnn.getQualifier() + "->" + qnn.getName());
2745-
declaringClass = findDeclaration(stp.getName());
2746-
2747-
// log("QN decl class: "
2748-
// + getNodeAsString(declaringClass));
2749-
constrains.clear();
2750-
constrains.add(ASTNode.TYPE_DECLARATION);
2751-
constrains.add(ASTNode.FIELD_DECLARATION);
2752-
return definedIn(declaringClass, qnn.getName().toString(), constrains,
2753-
null);
2744+
if (stp != null) {
2745+
declaringClass = findDeclaration(stp.getName());
2746+
constrains.clear();
2747+
constrains.add(ASTNode.TYPE_DECLARATION);
2748+
constrains.add(ASTNode.FIELD_DECLARATION);
2749+
return definedIn(declaringClass, qnn.getName().toString(),
2750+
constrains, null);
2751+
} else {
2752+
return null;
2753+
}
27542754
}
27552755
}
27562756
} else if (parent.getNodeType() == ASTNode.SIMPLE_TYPE) {
27572757
constrains.add(ASTNode.TYPE_DECLARATION);
2758-
if (parent.getParent().getNodeType() == ASTNode.CLASS_INSTANCE_CREATION)
2758+
if (parent.getParent().getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
27592759
constrains.add(ASTNode.CLASS_INSTANCE_CREATION);
2760-
} else if(parent.getNodeType() == ASTNode.TYPE_DECLARATION){
2760+
}
2761+
} else if (parent.getNodeType() == ASTNode.TYPE_DECLARATION) {
27612762
// The condition where we look up the name of a class decl
27622763
TypeDeclaration td = (TypeDeclaration) parent;
2763-
if(findMe.equals(td.getName()))
2764-
{
2764+
if (findMe.equals(td.getName())) {
27652765
return parent;
27662766
}
2767-
}
2768-
else if (parent instanceof Expression) {
2767+
2768+
} else if (parent instanceof Expression) {
27692769
// constrains.add(ASTNode.TYPE_DECLARATION);
27702770
// constrains.add(ASTNode.METHOD_DECLARATION);
27712771
// constrains.add(ASTNode.FIELD_DECLARATION);

0 commit comments

Comments
 (0)