Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
oowekyala committed Aug 3, 2017
1 parent aa8c21d commit 6d0ebbf
Show file tree
Hide file tree
Showing 25 changed files with 57 additions and 746 deletions.
Expand Up @@ -56,7 +56,7 @@ public double computeForOperation(MetricKey<O> key, O node, boolean force,

@Override
public double computeWithResultOption(MetricKey<O> key, T node, boolean force, MetricVersion version,
ResultOption option, ProjectMirror<T, O> stats) {
ResultOption option, ProjectMemoizer<T, O> stats) {

List<O> ops = findOperations(node);

Expand Down
Expand Up @@ -34,7 +34,7 @@ public abstract class AbstractMetricsFacade<T extends QualifiableNode, O extends
*
* @return The project mirror
*/
protected abstract ProjectMirror<T, O> getLanguageSpecificProjectMirror();
protected abstract ProjectMemoizer<T, O> getLanguageSpecificProjectMemoizer();


/**
Expand All @@ -56,7 +56,7 @@ public double computeForType(MetricKey<T> key, T node, MetricVersion version) {
}

MetricVersion safeVersion = (version == null) ? Version.STANDARD : version;
MetricMemoizer<T> memoizer = getLanguageSpecificProjectMirror().getClassStats(node.getQualifiedName());
MetricMemoizer<T> memoizer = getLanguageSpecificProjectMemoizer().getClassStats(node.getQualifiedName());

return memoizer == null ? Double.NaN
: getLanguageSpecificComputer().computeForType(key, node, false, safeVersion, memoizer);
Expand All @@ -82,7 +82,7 @@ public double computeForOperation(MetricKey<O> key, O node,
}

MetricVersion safeVersion = (version == null) ? Version.STANDARD : version;
MetricMemoizer<O> memoizer = getLanguageSpecificProjectMirror().getOperationStats(node.getQualifiedName());
MetricMemoizer<O> memoizer = getLanguageSpecificProjectMemoizer().getOperationStats(node.getQualifiedName());

return memoizer == null ? Double.NaN
: getLanguageSpecificComputer().computeForOperation(key, node, false,
Expand Down Expand Up @@ -112,6 +112,6 @@ public double computeWithResultOption(MetricKey<O> key, T node,
MetricVersion safeVersion = (version == null) ? Version.STANDARD : version;

return getLanguageSpecificComputer().computeWithResultOption(key, node, false, safeVersion,
option, getLanguageSpecificProjectMirror());
option, getLanguageSpecificProjectMemoizer());
}
}
Expand Up @@ -5,11 +5,10 @@
package net.sourceforge.pmd.lang.metrics;

import net.sourceforge.pmd.lang.ast.QualifiableNode;
import net.sourceforge.pmd.lang.ast.SignedNode;

/**
* Basic interface for metrics computers that can compute metrics for types, operations and compute aggregate results
* with a result option. Computers should typically be separated from the storage units (ProjectMirror) to split
* with a result option. Computers should typically be separated from the storage units (ProjectMemoizer) to split
* responsibilities.
*
* @param <T> Type of type declaration nodes of the language
Expand Down Expand Up @@ -63,7 +62,7 @@ public interface MetricsComputer<T extends QualifiableNode, O extends Qualifiabl
* @return The result of the computation, or {@code Double.NaN} if it couldn't be performed
*/
double computeWithResultOption(MetricKey<O> key, T node, boolean force, MetricVersion version,
ResultOption option, ProjectMirror<T, O> stats);
ResultOption option, ProjectMemoizer<T, O> stats);


}
Expand Up @@ -8,9 +8,8 @@
import net.sourceforge.pmd.lang.ast.QualifiedName;

/**
* Object storing the statistics and memoizers of the analysed project, like PackageStats for Java. These are the entry
* point for signature matching requests. If retrieving eg an operation stats is expensive, consider implementing a
* cache.
* Object storing the memoizers of the analysed project, like PackageStats for Java. If retrieving eg an operation stats
* is expensive, consider implementing a cache.
*
* <p>Language specific implementations should implement some signature matching utilities for metrics to use. The
* details of how the mirror and its subcomponents are built must be kept out of the interfaces and visible only to the
Expand All @@ -27,7 +26,7 @@
*
* @author Clément Fournier
*/
public interface ProjectMirror<T extends QualifiableNode, O extends QualifiableNode> {
public interface ProjectMemoizer<T extends QualifiableNode, O extends QualifiableNode> {

/**
* Gets the operation metric memoizer corresponding to the qualified name.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -11,10 +11,10 @@

import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.JavaQualifiedName;
import net.sourceforge.pmd.lang.java.metrics.signature.FieldSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaFieldSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaFieldSignature;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaOperationSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaOperationSignature;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSigMask;
import net.sourceforge.pmd.lang.metrics.AbstractMetricMemoizer;

/**
Expand Down Expand Up @@ -138,7 +138,7 @@ OperationStats getOperationStats(String operationName, JavaOperationSignature si
* @return True if the class declares an operation by the name given which is covered by the signature mask, false
* otherwise
*/
/* default */ boolean hasMatchingSig(String name, OperationSigMask mask) {
/* default */ boolean hasMatchingSig(String name, JavaOperationSigMask mask) {
// Indexing on signatures optimises this type of request
for (JavaOperationSignature sig : operations.keySet()) {
if (mask.covers(sig)) {
Expand All @@ -160,7 +160,7 @@ OperationStats getOperationStats(String operationName, JavaOperationSignature si
* @return True if the class declares a field by the name given which is covered by the signature mask, false
* otherwise
*/
/* default */ boolean hasMatchingSig(String name, FieldSigMask mask) {
/* default */ boolean hasMatchingSig(String name, JavaFieldSigMask mask) {
for (JavaFieldSignature sig : fields.keySet()) {
if (mask.covers(sig)) {
if (fields.get(sig).contains(name)) {
Expand Down
Expand Up @@ -34,7 +34,7 @@ private JavaMetrics() { // Cannot be instantiated
* @return The project mirror
*/
static PackageStats getTopLevelPackageStats() {
return FACADE.getLanguageSpecificProjectMirror();
return FACADE.getLanguageSpecificProjectMemoizer();
}


Expand Down
Expand Up @@ -26,7 +26,7 @@ void reset() {


@Override
public PackageStats getLanguageSpecificProjectMirror() {
public PackageStats getLanguageSpecificProjectMemoizer() {
return topLevelPackageStats;
}

Expand Down
Expand Up @@ -6,13 +6,13 @@

import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.metrics.ProjectMirror;
import net.sourceforge.pmd.lang.metrics.ProjectMemoizer;

/**
* Shorthand for a project mirror parameterized with Java-specific node types.
*
* @author Clément Fournier
*/
interface JavaProjectMirror extends ProjectMirror<ASTAnyTypeDeclaration, ASTMethodOrConstructorDeclaration> {
interface JavaProjectMemoizer extends ProjectMemoizer<ASTAnyTypeDeclaration, ASTMethodOrConstructorDeclaration> {

}
Expand Up @@ -5,8 +5,8 @@
package net.sourceforge.pmd.lang.java.metrics;

import net.sourceforge.pmd.lang.java.ast.JavaQualifiedName;
import net.sourceforge.pmd.lang.java.metrics.signature.FieldSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaFieldSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaOperationSigMask;

/**
* Gathers the methods that the Java project mirror should make available to metrics during the computation.
Expand All @@ -23,7 +23,7 @@ public interface JavaSignatureMatcher {
*
* @return True if the signature of the operation designated by the qualified name is covered by the mask
*/
boolean hasMatchingSig(JavaQualifiedName qname, OperationSigMask sigMask);
boolean hasMatchingSig(JavaQualifiedName qname, JavaOperationSigMask sigMask);


/**
Expand All @@ -36,7 +36,7 @@ public interface JavaSignatureMatcher {
*
* @return True if the signature of the field is covered by the mask
*/
boolean hasMatchingSig(JavaQualifiedName qname, String fieldName, FieldSigMask sigMask);
boolean hasMatchingSig(JavaQualifiedName qname, String fieldName, JavaFieldSigMask sigMask);


}
Expand Up @@ -11,9 +11,9 @@
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.ast.JavaQualifiedName;
import net.sourceforge.pmd.lang.java.metrics.signature.FieldSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaFieldSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaOperationSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaOperationSignature;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSigMask;
import net.sourceforge.pmd.lang.metrics.MetricMemoizer;


Expand All @@ -24,7 +24,7 @@
* @author Clément Fournier
* @see ClassStats
*/
public final class PackageStats implements JavaProjectMirror, JavaSignatureMatcher {
public final class PackageStats implements JavaProjectMemoizer, JavaSignatureMatcher {

private final Map<String, PackageStats> subPackages = new HashMap<>();
private final Map<String, ClassStats> classes = new HashMap<>();
Expand Down Expand Up @@ -144,15 +144,15 @@ private PackageStats getSubPackage(JavaQualifiedName qname, boolean createIfNotF


@Override
public boolean hasMatchingSig(JavaQualifiedName qname, OperationSigMask sigMask) {
public boolean hasMatchingSig(JavaQualifiedName qname, JavaOperationSigMask sigMask) {
ClassStats clazz = getClassStats(qname, false);

return clazz != null && clazz.hasMatchingSig(qname.getOperation(), sigMask);
}


@Override
public boolean hasMatchingSig(JavaQualifiedName qname, String fieldName, FieldSigMask sigMask) {
public boolean hasMatchingSig(JavaQualifiedName qname, String fieldName, JavaFieldSigMask sigMask) {
ClassStats clazz = getClassStats(qname, false);

return clazz != null && clazz.hasMatchingSig(fieldName, sigMask);
Expand Down
Expand Up @@ -9,9 +9,9 @@
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
import net.sourceforge.pmd.lang.java.ast.JavaQualifiedName;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaOperationSigMask;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaOperationSignature.Role;
import net.sourceforge.pmd.lang.java.metrics.signature.JavaSignature.Visibility;
import net.sourceforge.pmd.lang.java.metrics.signature.OperationSigMask;
import net.sourceforge.pmd.lang.metrics.MetricVersion;

/**
Expand All @@ -27,7 +27,7 @@ public static final class AtfdOperationMetric extends AbstractJavaOperationMetri
@Override // TODO:cf
public double computeFor(ASTMethodOrConstructorDeclaration node, MetricVersion version) {

OperationSigMask targetOps = new OperationSigMask();
JavaOperationSigMask targetOps = new JavaOperationSigMask();
targetOps.restrictVisibilitiesTo(Visibility.PUBLIC);
targetOps.restrictRolesTo(Role.GETTER_OR_SETTER);

Expand Down

0 comments on commit 6d0ebbf

Please sign in to comment.