protected final boolean inConstructor() { final MethodDefinition currentMethod = context.getCurrentMethod(); return currentMethod != null && currentMethod.isConstructor(); }
protected final boolean inConstructor() { final MethodDefinition currentMethod = context.getCurrentMethod(); return currentMethod != null && currentMethod.isConstructor(); }
protected final boolean inConstructor() { final MethodDefinition currentMethod = context.getCurrentMethod(); return currentMethod != null && currentMethod.isConstructor(); }
private void sortMethods(List<MethodDefinition> declMethods) { declMethods.sort(Comparator.comparingInt(md -> md.isTypeInitializer() ? 0 : md.isConstructor() ? 1 : 2)); int start = -1, end = declMethods.size(); for (int i = 0; i < end; i++) { if(start == -1) { if(declMethods.get(i).isConstructor()) start = i; } else if(!declMethods.get(i).isConstructor()) { end = i; } } if(start >= 0) { sortConstructors(declMethods.subList(start, end)); } }
@Override protected Void visitChildren(final AstNode node, final Void p) { final MethodDefinition currentMethod = context.getCurrentMethod(); if (currentMethod != null && !(currentMethod.isConstructor()/* && currentMethod.isSynthetic()*/)) { return null; } return super.visitChildren(node, p); }
@Override protected Void visitChildren(final AstNode node, final Void _) { final MethodDefinition currentMethod = context.getCurrentMethod(); if (currentMethod != null && !(currentMethod.isConstructor()/* && currentMethod.isSynthetic()*/)) { return null; } return super.visitChildren(node, _); }
@Override protected Void visitChildren(final AstNode node, final Void _) { final MethodDefinition currentMethod = context.getCurrentMethod(); if (currentMethod != null && !(currentMethod.isConstructor()/* && currentMethod.isSynthetic()*/)) { return null; } return super.visitChildren(node, _); }
public void makeFieldsFrom(Frame frame) { if(frame == null) return; if(md.isTypeInitializer()) { cf.setStaticFinalFields(frame); } else if(md.isConstructor()) { cf.mergeConstructor(md, frame, this); } } }
@MethodVisitor public boolean checkMethod(MethodDefinition md) { return !md.isConstructor() && !md.getName().equals("init") && !md.getName().equals("destroy") && !Flags.testAny(md.getFlags(), Flags.SYNCHRONIZED); }
@Override public boolean test(final MethodDefinition m) { return m.isConstructor() && !m.isSynthetic() && !StringUtilities.equals(m.getErasedSignature(), method.getErasedSignature()); } }
@Override public boolean test(final MethodDefinition m) { return m.isConstructor() && !m.isSynthetic() && !StringUtilities.equals(m.getErasedSignature(), method.getErasedSignature()); } }
@Override public boolean test(final MethodDefinition m) { return m.isConstructor() && !m.isSynthetic() && !StringUtilities.equals(m.getErasedSignature(), method.getErasedSignature()); } }
@Override public Void visitSuperReferenceExpression(final SuperReferenceExpression node, final Void _) { super.visitSuperReferenceExpression(node, _); if (context.getCurrentMethod() != null && context.getCurrentMethod().isConstructor() && node.getParent() instanceof InvocationExpression) { // // We only care about field initializations that occur before the base constructor call. // _baseConstructorCalled = true; } return null; }
@Override public Void visitSuperReferenceExpression(final SuperReferenceExpression node, final Void _) { super.visitSuperReferenceExpression(node, _); if (context.getCurrentMethod() != null && context.getCurrentMethod().isConstructor() && node.getParent() instanceof InvocationExpression) { // // We only care about field initializations that occur before the base constructor call. // _baseConstructorCalled = true; } return null; }
@Override public Void visitSuperReferenceExpression(final SuperReferenceExpression node, final Void p) { super.visitSuperReferenceExpression(node, p); if (context.getCurrentMethod() != null && context.getCurrentMethod().isConstructor() && node.getParent() instanceof InvocationExpression) { // // We only care about field initializations that occur before the base constructor call. // _baseConstructorCalled = true; } return null; }
@AstVisitor(nodes = AstNodes.ROOT) public void checkSameAsConstructor(Block root, MethodDefinition md, TypeDefinition td, MethodContext mc) { if (md.getName().equals(td.getSimpleName()) && md.getReturnType().isVoid() && !md.isDeprecated()) { int priority = 0; if (root.getBody().isEmpty()) { priority += 20; } else if (root.getBody().size() == 1 && Nodes.isOp(root.getBody().get(0), AstCode.AThrow)) { priority += 40; } if (td.getDeclaredMethods().stream().anyMatch( m -> m.isConstructor() && m.getErasedSignature().equals(md.getErasedSignature()))) { priority += 10; } mc.report("BadNameOfMethodSameAsConstructor", priority); } }
private Expression findOverloadCall(MethodDefinition md, Block block) { return (Expression)Nodes.find(block, node -> { if (Nodes.isOp(node, md.isConstructor() ? AstCode.InvokeSpecial : md.isStatic() ? AstCode.InvokeStatic : AstCode.InvokeVirtual)) { Expression expr = (Expression) node; MethodReference mr = (MethodReference) expr.getOperand(); if (mr.getDeclaringType().isEquivalentTo(md.getDeclaringType()) && mr.getName().equals(md.getName()) && !mr.getSignature().equals(md.getSignature())) { return true; } } return false; }); } }
private InstructionAnalyzer(final MethodBody body, final InstructionVisitor innerVisitor) { _body = VerifyArgument.notNull(body, "body"); _innerVisitor = innerVisitor; if (body.getMethod().isConstructor()) { set(0, FrameValue.UNINITIALIZED_THIS); } _factory = CoreMetadataFactory.make(_body.getMethod().getDeclaringType(), _body.getMethod()); }
private InstructionAnalyzer(final MethodBody body, final InstructionVisitor innerVisitor) { _body = VerifyArgument.notNull(body, "body"); _innerVisitor = innerVisitor; if (body.getMethod().isConstructor()) { set(0, FrameValue.UNINITIALIZED_THIS); } _factory = CoreMetadataFactory.make(_body.getMethod().getDeclaringType(), _body.getMethod()); }
private InstructionAnalyzer(final MethodBody body, final InstructionVisitor innerVisitor) { _body = VerifyArgument.notNull(body, "body"); _innerVisitor = innerVisitor; if (body.getMethod().isConstructor()) { set(0, FrameValue.UNINITIALIZED_THIS); } _factory = CoreMetadataFactory.make(_body.getMethod().getDeclaringType(), _body.getMethod()); }