Last corrections
This commit is contained in:
@@ -227,7 +227,7 @@ public abstract class AbstractNode implements Node {
|
||||
List<T> parents = new ArrayList<>();
|
||||
Node parentNode = jjtGetParent();
|
||||
while (parentNode != null) {
|
||||
if (parentNode.getClass() == parentType) {
|
||||
if (parentType.isInstance(parentNode.getClass())) {
|
||||
parents.add((T) parentNode);
|
||||
}
|
||||
parentNode = parentNode.jjtGetParent();
|
||||
|
@@ -32,7 +32,7 @@ public interface Node {
|
||||
|
||||
|
||||
/**
|
||||
* Sets the parent of the node
|
||||
* Sets the parent of this node.
|
||||
*
|
||||
* @param parent The parent
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ public interface Node {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the parent of this node
|
||||
* Returns the parent of this node.
|
||||
*
|
||||
* @return The parent of the node
|
||||
*/
|
||||
@@ -110,14 +110,15 @@ public interface Node {
|
||||
|
||||
boolean isFindBoundary();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the n-th parent or null if there are not <code>n</code> ancestors
|
||||
* Returns the n-th parent or null if there are not {@code n} ancestors
|
||||
*
|
||||
* @param n how many ancestors to iterate over.
|
||||
*
|
||||
* @param n
|
||||
* how many ancestors to iterate over.
|
||||
* @return the n-th parent or null.
|
||||
* @throws IllegalArgumentException
|
||||
* if <code>n</code> is not positive.
|
||||
*
|
||||
* @throws IllegalArgumentException if {@code n} is negative or zero.
|
||||
*/
|
||||
Node getNthParent(int n);
|
||||
|
||||
@@ -136,7 +137,7 @@ public interface Node {
|
||||
|
||||
/**
|
||||
* Traverses up the tree to find all of the parent instances of type
|
||||
* parentType
|
||||
* parentType or one of its subclasses.
|
||||
*
|
||||
* @param parentType Class literal of the type you want to find
|
||||
* @param <T> The type you want to find
|
||||
|
@@ -7,11 +7,9 @@ package net.sourceforge.pmd.lang.java.oom;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.oom.api.ClassMetric;
|
||||
import net.sourceforge.pmd.lang.java.oom.api.Metric.Version;
|
||||
import net.sourceforge.pmd.lang.java.oom.api.MetricKey;
|
||||
import net.sourceforge.pmd.lang.java.oom.api.MetricVersion;
|
||||
import net.sourceforge.pmd.lang.java.oom.api.OperationMetric;
|
||||
import net.sourceforge.pmd.lang.java.oom.api.ResultOption;
|
||||
|
||||
|
||||
|
@@ -10,6 +10,8 @@ import net.sourceforge.pmd.lang.java.oom.AbstractMetric;
|
||||
import net.sourceforge.pmd.lang.java.oom.api.ClassMetric;
|
||||
|
||||
/**
|
||||
* Base class for class metrics.
|
||||
*
|
||||
* @author Clément Fournier
|
||||
*/
|
||||
public abstract class AbstractClassMetric extends AbstractMetric<ASTAnyTypeDeclaration> implements ClassMetric {
|
||||
|
@@ -9,6 +9,8 @@ import net.sourceforge.pmd.lang.java.oom.AbstractMetric;
|
||||
import net.sourceforge.pmd.lang.java.oom.api.OperationMetric;
|
||||
|
||||
/**
|
||||
* Base class for operation metrics.
|
||||
*
|
||||
* @author Clément Fournier
|
||||
*/
|
||||
public abstract class AbstractOperationMetric extends AbstractMetric<ASTMethodOrConstructorDeclaration>
|
||||
@@ -24,6 +26,4 @@ public abstract class AbstractOperationMetric extends AbstractMetric<ASTMethodOr
|
||||
public boolean supports(ASTMethodOrConstructorDeclaration node) {
|
||||
return !node.isAbstract();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -76,5 +76,4 @@ public final class NcssMetric {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -21,12 +21,10 @@ import net.sourceforge.pmd.lang.java.ast.ASTForInit;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTForStatement;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTForUpdate;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTIfStatement;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTInitializer;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTLabeledStatement;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTLocalVariableDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTPackageDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTReturnStatement;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTStatementExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTSwitchLabel;
|
||||
|
@@ -40,4 +40,4 @@ public class NcssTestRule extends AbstractMetricTestRule {
|
||||
mappings.put("javaNcss", NcssVersion.JAVANCSS);
|
||||
return mappings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user