Class ASTMethodDeclaration

    • Method Detail

      • acceptVisitor

        protected <P,​R> R acceptVisitor​(JavaVisitor<? super P,​? extends R> visitor,
                                              P data)
      • isOverridden

        public boolean isOverridden()
        Returns true if this method is overridden. TODO for now, this just checks for an @Override annotation, but this should definitely do what MissingOverride does. This could be useful in UnusedPrivateMethod (to check not only private methods), and also UselessOverridingMethod, and overall many many rules.
      • getPreferredReportLocation

        protected @Nullable JavaccToken getPreferredReportLocation()
        Temporary hack so that classes and methods are reported on their identifier token and not the first annotation. Changes about text documents make that more general, in a future PR.
      • getName

        public String getName()
        Returns the simple name of the method.
      • getAccessedRecordComponent

        public @Nullable ASTRecordComponent getAccessedRecordComponent()
        If this method declaration is an explicit record component accessor, returns the corresponding record component. Otherwise returns null.
      • isVoid

        public boolean isVoid()
        Returns true if the result type of this method is void.
      • getDefaultClause

        public @Nullable ASTDefaultValue getDefaultClause()
        Returns the default clause, if this is an annotation method declaration that features one. Otherwise returns null.
      • getResultType

        @Deprecated
        public ASTResultType getResultType()
        Deprecated.
        todo When removed from java-grammar, rename the other to this good name
        Returns the result type node of the method.
      • getResultTypeNode

        public @NonNull ASTType getResultTypeNode()
        Returns the result type node of the method. This may be a ASTVoidType.
      • getExtraDimensions

        public @Nullable ASTArrayDimensions getExtraDimensions()
        Returns the extra array dimensions that may be after the formal parameters.
      • isMainMethod

        public boolean isMainMethod()
        Returns whether this is a main method declaration.
      • acceptVisitor

        public final <P,​R> R acceptVisitor​(AstVisitor<? super P,​? extends R> visitor,
                                                 P data)
        Specified by:
        acceptVisitor in interface Node
      • addChild

        protected void addChild​(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode child,
                                int index)
        Overrides:
        addChild in class AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,​JavaNode>
      • insertChild

        protected void insertChild​(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode child,
                                   int index)
        Overrides:
        insertChild in class AbstractJjtreeNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,​JavaNode>
      • removeChildAtIndex

        protected void removeChildAtIndex​(int childIndex)
        Overrides:
        removeChildAtIndex in class AbstractNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,​JavaNode>
      • setChild

        protected void setChild​(net.sourceforge.pmd.lang.java.ast.AbstractJavaNode child,
                                int index)
        Overrides:
        setChild in class AbstractNode<net.sourceforge.pmd.lang.java.ast.AbstractJavaNode,​JavaNode>
      • getSymbolTable

        public @NonNull JSymbolTable getSymbolTable()
        Description copied from interface: JavaNode
        Returns the symbol table for the program point represented by this node.
        Specified by:
        getSymbolTable in interface JavaNode
      • getTypeSystem

        public TypeSystem getTypeSystem()
        Description copied from interface: JavaNode
        Returns the type system with which this node was created. This is the object responsible for representing types in the compilation unit.
        Specified by:
        getTypeSystem in interface JavaNode