--- /dev/null
+package no.uio.ifi.refaktor.analyze.checkers;
+
+import no.uio.ifi.refaktor.analyze.CollectorManager;
+import no.uio.ifi.refaktor.analyze.collectors.PropertyCollector;
+import no.uio.ifi.refaktor.analyze.exceptions.IllegalExpressionFoundException;
+import no.uio.ifi.refaktor.analyze.exceptions.IllegalStatementFoundException;
+import no.uio.ifi.refaktor.textselection.CompilationUnitTextSelection;
+
+import org.eclipse.jdt.core.dom.ClassInstanceCreation;
+
+class DoubleClassInstanceCreationChecker extends PropertyCollector implements Checker {
+
+ public DoubleClassInstanceCreationChecker(CompilationUnitTextSelection selection) {
+ super(selection);
+ }
+
+ @Override
+ public void check() throws IllegalStatementFoundException, IllegalExpressionFoundException {
+ CollectorManager.collectProperties(selection, this);
+ }
+
+ @Override
+ public void clearData() {
+ }
+
+ @Override
+ public boolean visit(ClassInstanceCreation node) {
+ if (!nodeInSelection(node))
+ return false;
+
+ if (isDoubleClassInstanceCreation(node))
+ node.accept(new NoReferenceToFieldChecker(node));
+
+ return true;
+ }
+
+ private boolean isDoubleClassInstanceCreation(ClassInstanceCreation node) {
+ return node.getParent() instanceof ClassInstanceCreation;
+ }
+
+}