private boolean isInitCauseCalled(String target, List<NameOccurrence> occurrences) { boolean initCauseCalled = false; for (NameOccurrence occurrence : occurrences) { String image = null; if (occurrence.getLocation() != null) { image = occurrence.getLocation().getImage(); } if (image != null && image.endsWith("initCause")) { ASTPrimaryExpression primaryExpression = occurrence.getLocation().getFirstParentOfType(ASTPrimaryExpression.class); if (primaryExpression != null) { ASTArgumentList args2 = primaryExpression.getFirstDescendantOfType(ASTArgumentList.class); if (checkForTargetUsage(target, args2)) { initCauseCalled = true; break; } } } } return initCauseCalled; }
private boolean initializedInConstructor(List<NameOccurrence> usages) { boolean initInConstructor = false; for (NameOccurrence occ : usages) { // specifically omitting prefix and postfix operators as there are // legitimate usages of these with static fields, e.g. typesafe enum pattern. if (((JavaNameOccurrence) occ).isOnLeftHandSide()) { Node node = occ.getLocation(); Node constructor = node.getFirstParentOfType(ASTConstructorDeclaration.class); if (constructor != null) { initInConstructor = true; } } } return initInConstructor; }