@Override public Object visit(ASTPrimaryPrefix pp, Object ctx) { List<ASTPrimarySuffix> primarySuffixes = pp.jjtGetParent().findChildrenOfType(ASTPrimarySuffix.class); ASTPrimarySuffix firstSuffix = null; if (!primarySuffixes.isEmpty()) { firstSuffix = primarySuffixes.get(0); } if (firstSuffix == null || firstSuffix.getImage() == null || !firstSuffix.getImage().endsWith("finalize")) { return super.visit(pp, ctx); } if (!checkForViolation(pp)) { return super.visit(pp, ctx); } addViolation(ctx, pp); return super.visit(pp, ctx); }
boolean hasArguments = guardCall.jjtGetParent().hasDescendantOfType(ASTArgumentList.class); } else if (guardMethodCallMatches && hasArguments) { String guardArgLogLevel = getLogLevelName(guardCall.jjtGetParent(), guardMethodCall); foundGuard = logLevel.equals(guardArgLogLevel);
@Override public Object visit(ASTPrimaryPrefix node, Object data) { if (node.jjtGetNumChildren() == 0 || !(node.jjtGetChild(0) instanceof ASTName)) { return super.visit(node, data); } String image = ((ASTName) node.jjtGetChild(0)).getImage(); if (image.startsWith("java.lang.")) { image = image.substring(10); } boolean checkBoolean = ((RuleContext) data).getLanguageVersion() .compareTo(LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("1.5")) >= 0; if (PREFIX_SET.contains(image) || checkBoolean && "Boolean.valueOf".equals(image)) { ASTPrimaryExpression parent = (ASTPrimaryExpression) node.jjtGetParent(); if (parent.jjtGetNumChildren() >= 3) { Node n = parent.jjtGetChild(2); if (n instanceof ASTPrimarySuffix) { ASTPrimarySuffix suffix = (ASTPrimarySuffix) n; image = suffix.getImage(); if (SUFFIX_SET.contains(image) || checkBoolean && "booleanValue".equals(image)) { super.addViolation(data, node); return data; } } } } return super.visit(node, data); }
ASTPrimaryExpression parent = (ASTPrimaryExpression) node.jjtGetParent(); ASTPrimarySuffix suffix = parent.getFirstDescendantOfType(ASTPrimarySuffix.class); if (suffix == null) {
Node parent = node.jjtGetParent(); if (parent.jjtGetNumChildren() != 2) { return super.visit(node, data);
@Override public Object visit(ASTPrimaryPrefix pp, Object ctx) { List<ASTPrimarySuffix> primarySuffixes = pp.jjtGetParent().findChildrenOfType(ASTPrimarySuffix.class); ASTPrimarySuffix firstSuffix = null; if (!primarySuffixes.isEmpty()) { firstSuffix = primarySuffixes.get(0); } if (firstSuffix == null || firstSuffix.getImage() == null || !firstSuffix.getImage().endsWith("finalize")) { return super.visit(pp, ctx); } if (!checkForViolation(pp)) { return super.visit(pp, ctx); } addViolation(ctx, pp); return super.visit(pp, ctx); }
boolean hasArguments = guardCall.jjtGetParent().hasDescendantOfType(ASTArgumentList.class); } else if (guardMethodCallMatches && hasArguments) { String guardArgLogLevel = getLogLevelName(guardCall.jjtGetParent(), guardMethodCall); foundGuard = logLevel.equals(guardArgLogLevel);
@Override public Object visit(ASTPrimaryPrefix node, Object data) { if (node.jjtGetNumChildren() == 0 || !(node.jjtGetChild(0) instanceof ASTName)) { return super.visit(node, data); } String image = ((ASTName) node.jjtGetChild(0)).getImage(); if (image.startsWith("java.lang.")) { image = image.substring(10); } boolean checkBoolean = ((RuleContext) data).getLanguageVersion() .compareTo(LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getVersion("1.5")) >= 0; if (PREFIX_SET.contains(image) || checkBoolean && "Boolean.valueOf".equals(image)) { ASTPrimaryExpression parent = (ASTPrimaryExpression) node.jjtGetParent(); if (parent.jjtGetNumChildren() >= 3) { Node n = parent.jjtGetChild(2); if (n instanceof ASTPrimarySuffix) { ASTPrimarySuffix suffix = (ASTPrimarySuffix) n; image = suffix.getImage(); if (SUFFIX_SET.contains(image) || checkBoolean && "booleanValue".equals(image)) { super.addViolation(data, node); return data; } } } } return super.visit(node, data); }
ASTPrimaryExpression parent = (ASTPrimaryExpression) node.jjtGetParent(); ASTPrimarySuffix suffix = parent.getFirstDescendantOfType(ASTPrimarySuffix.class); if (suffix == null) {
Node parent = node.jjtGetParent(); if (parent.jjtGetNumChildren() != 2) { return super.visit(node, data);