Minor doc changes
This commit is contained in:
@ -4,24 +4,22 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.java.oom;
|
||||
|
||||
import static net.sourceforge.pmd.lang.java.oom.visitor.MetricsVisitorFacade.topLevelPackage;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.oom.metrics.AtfdMetric;
|
||||
import net.sourceforge.pmd.lang.java.oom.metrics.WmcMetric;
|
||||
import net.sourceforge.pmd.lang.java.oom.visitor.PackageStats;
|
||||
|
||||
|
||||
/**
|
||||
* Façade of the Metrics Framework.
|
||||
* User bound façade of the Metrics Framework. Provides a uniform interface for the calculation of
|
||||
* metrics.
|
||||
*
|
||||
* @author Clément Fournier
|
||||
*/
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* Holds sufficient statistics and memoises results
|
||||
*/
|
||||
private static PackageStats topLevelPackage;
|
||||
|
||||
private Metrics() { // Cannot be instantiated
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import java.util.List;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.QualifiableNode.QualifiedName;
|
||||
|
||||
|
||||
/**
|
||||
@ -22,8 +22,10 @@ public abstract class AbstractMetric {
|
||||
|
||||
protected boolean isAbstractHandler = false;
|
||||
|
||||
protected List<String> findAllCalls(ASTMethodOrConstructorDeclaration node) {
|
||||
List<String> result = new ArrayList<>();
|
||||
protected List<QualifiedName> findAllCalls(ASTMethodOrConstructorDeclaration node) {
|
||||
List<QualifiedName> result = new ArrayList<>();
|
||||
// TODO
|
||||
// Needs TypeRes!!
|
||||
// Find the qualified names of all methods called in that method's block
|
||||
return result;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.QualifiableNode.QualifiedName;
|
||||
import net.sourceforge.pmd.lang.java.oom.ClassMetric;
|
||||
import net.sourceforge.pmd.lang.java.oom.OperationMetric;
|
||||
import net.sourceforge.pmd.lang.java.oom.visitor.OperationSigMask;
|
||||
@ -36,9 +37,9 @@ public class AtfdMetric extends AbstractMetric implements ClassMetric, Operation
|
||||
targetOps.setVisibilityMask(Visibility.PUBLIC);
|
||||
targetOps.setRoleMask(Role.GETTER_OR_SETTER);
|
||||
|
||||
List<String> callQNames = findAllCalls(node);
|
||||
List<QualifiedName> callQNames = findAllCalls(node);
|
||||
int foreignCalls = 0;
|
||||
for (String name : callQNames) {
|
||||
for (QualifiedName name : callQNames) {
|
||||
if (holder.hasMatchingSig(name, targetOps)) {
|
||||
foreignCalls++;
|
||||
}
|
||||
|
@ -4,6 +4,9 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.java.oom.visitor;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
|
||||
|
||||
/**
|
||||
@ -11,6 +14,25 @@ import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
|
||||
*/
|
||||
public class MetricsVisitor extends JavaParserVisitorAdapter {
|
||||
|
||||
@Override
|
||||
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
||||
PackageStats stats = (PackageStats) data;
|
||||
System.err.println("Visiting class " + node.getQualifiedName());
|
||||
return super.visit(node, data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object visit(ASTConstructorDeclaration node, Object data) {
|
||||
PackageStats stats = (PackageStats) data;
|
||||
System.err.println("Visiting constructor " + node.getQualifiedName());
|
||||
return super.visit(node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTMethodDeclaration node, Object data) {
|
||||
PackageStats stats = (PackageStats) data;
|
||||
System.err.println("Visiting method " + node.getQualifiedName());
|
||||
return super.visit(node, data);
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,10 @@ import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
|
||||
*/
|
||||
public class MetricsVisitorFacade extends JavaParserVisitorAdapter {
|
||||
|
||||
private PackageStats topLevelPackageStats;
|
||||
public static final PackageStats topLevelPackage = new PackageStats();
|
||||
|
||||
public void initializeWith(ClassLoader classLoader, ASTCompilationUnit rootNode) {
|
||||
topLevelPackageStats = new PackageStats();
|
||||
MetricsVisitor visitor = new MetricsVisitor();
|
||||
rootNode.jjtAccept(visitor, topLevelPackageStats);
|
||||
rootNode.jjtAccept(visitor, topLevelPackage);
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class PackageStats {
|
||||
return classes.get(name);
|
||||
}
|
||||
|
||||
public boolean hasMatchingSig(String qname, OperationSigMask sigMask) {
|
||||
public boolean hasMatchingSig(QualifiedName qname, OperationSigMask sigMask) {
|
||||
// TODO
|
||||
// navigate to the class in the tree
|
||||
// return true if the signature of the qualified name is covered by the
|
||||
|
Reference in New Issue
Block a user