Deleted the façade
This commit is contained in:
@ -11,6 +11,7 @@ import net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSigMask;
|
||||
* Represents a class for signature matching.
|
||||
*
|
||||
* @author Clément Fournier
|
||||
* @since 6.0.0
|
||||
*/
|
||||
interface ClassMirror {
|
||||
|
||||
|
@ -26,6 +26,7 @@ import net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSignature;
|
||||
* QualifiedNames anymore, only Strings.
|
||||
*
|
||||
* @author Clément Fournier
|
||||
* @since 6.0.0
|
||||
*/
|
||||
final class ClassStats implements ClassMirror {
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.java.multifile;
|
||||
|
||||
/**
|
||||
* Facade class for multi-file analysis. Stores an instance of a ProjectMirror.
|
||||
*
|
||||
* @author Clément Fournier
|
||||
*/
|
||||
final class MultifileFacade {
|
||||
|
||||
private static final MultifileFacadeBacker FACADE = new MultifileFacadeBacker();
|
||||
|
||||
|
||||
private MultifileFacade() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Resets the entire data structure. Used for tests. */
|
||||
static void reset() {
|
||||
FACADE.reset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the PackageStats instance representing the currently analysed project.
|
||||
*
|
||||
* @return The project mirror
|
||||
*/
|
||||
static PackageStats getTopLevelPackageStats() {
|
||||
return FACADE.getTopLevelPackageStats();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.java.multifile;
|
||||
|
||||
/**
|
||||
* @author Clément Fournier
|
||||
*/
|
||||
final class MultifileFacadeBacker {
|
||||
|
||||
|
||||
private final PackageStats topLevelPackageStats = new PackageStats();
|
||||
|
||||
|
||||
/** Resets the data structure. Used for tests. */
|
||||
void reset() {
|
||||
topLevelPackageStats.reset();
|
||||
}
|
||||
|
||||
|
||||
PackageStats getTopLevelPackageStats() {
|
||||
return topLevelPackageStats;
|
||||
}
|
||||
|
||||
}
|
@ -12,7 +12,10 @@ import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorReducedAdapter;
|
||||
|
||||
/**
|
||||
* Fills the PackageStats.
|
||||
*
|
||||
* @author Clément Fournier
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class MultifileVisitor extends JavaParserVisitorReducedAdapter {
|
||||
|
||||
|
@ -9,11 +9,12 @@ import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
|
||||
|
||||
/**
|
||||
* @author Clément Fournier
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public final class MultifileVisitorFacade extends JavaParserVisitorAdapter {
|
||||
|
||||
public void initializeWith(ASTCompilationUnit rootNode) {
|
||||
PackageStats projectMirror = MultifileFacade.getTopLevelPackageStats();
|
||||
PackageStats projectMirror = PackageStats.INSTANCE;
|
||||
MultifileVisitor visitor = new MultifileVisitor(projectMirror);
|
||||
rootNode.jjtAccept(visitor, null);
|
||||
}
|
||||
|
@ -19,9 +19,12 @@ import net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSigMask;
|
||||
*
|
||||
* @author Clément Fournier
|
||||
* @see ClassStats
|
||||
* @since 6.0.0
|
||||
*/
|
||||
final class PackageStats implements ProjectMirror {
|
||||
|
||||
static final PackageStats INSTANCE = new PackageStats();
|
||||
|
||||
private final Map<String, PackageStats> subPackages = new HashMap<>();
|
||||
private final Map<String, ClassStats> classes = new HashMap<>();
|
||||
|
||||
|
@ -12,6 +12,7 @@ import net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSigMask;
|
||||
* Represents the analysed project to provide all rules with info about other classes.
|
||||
*
|
||||
* @author Clément Fournier
|
||||
* @since 6.0.0
|
||||
*/
|
||||
interface ProjectMirror {
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class ClassStatsTest {
|
||||
|
||||
@Before
|
||||
public void resetMultifile() {
|
||||
MultifileFacade.reset();
|
||||
PackageStats.INSTANCE.reset();
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ public class ClassStatsTest {
|
||||
|
||||
JavaMultifileVisitorTest.parseAndVisitForClass(SignatureCountTestData.class);
|
||||
|
||||
final ProjectMirror toplevel = MultifileFacade.getTopLevelPackageStats();
|
||||
final ProjectMirror toplevel = PackageStats.INSTANCE;
|
||||
|
||||
final ClassMirror classMirror = toplevel.getClassMirror(JavaQualifiedName.ofClass(SignatureCountTestData.class));
|
||||
|
||||
|
@ -31,13 +31,13 @@ public class JavaMultifileVisitorTest {
|
||||
|
||||
@Test
|
||||
public void testPackageStatsNotNull() {
|
||||
assertNotNull(MultifileFacade.getTopLevelPackageStats());
|
||||
assertNotNull(PackageStats.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void resetMultifile() {
|
||||
MultifileFacade.reset();
|
||||
PackageStats.INSTANCE.reset();
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ public class JavaMultifileVisitorTest {
|
||||
public void testOperationsAreThere() {
|
||||
ASTCompilationUnit acu = parseAndVisitForClass(MultifileVisitorTestData.class);
|
||||
|
||||
final ProjectMirror toplevel = MultifileFacade.getTopLevelPackageStats();
|
||||
final ProjectMirror toplevel = PackageStats.INSTANCE;
|
||||
|
||||
final JavaOperationSigMask opMask = new JavaOperationSigMask();
|
||||
|
||||
@ -64,7 +64,7 @@ public class JavaMultifileVisitorTest {
|
||||
public void testFieldsAreThere() {
|
||||
parseAndVisitForClass(MultifileVisitorTestData.class);
|
||||
|
||||
final ProjectMirror toplevel = MultifileFacade.getTopLevelPackageStats();
|
||||
final ProjectMirror toplevel = PackageStats.INSTANCE;
|
||||
|
||||
final JavaFieldSigMask fieldSigMask = new JavaFieldSigMask();
|
||||
|
||||
|
Reference in New Issue
Block a user