aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-08-06 17:59:39 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-08-10 14:18:18 +0200
commitcf41e9c2ec6250f767120f71b1facc1cb9ee8180 (patch)
treefa94c5844ddf7edec06c9787d1134efad25ec1c5
parent5adcb11906a8577bb42be02f547a5f18e2e7d4e2 (diff)
downloadsonarqube-cf41e9c2ec6250f767120f71b1facc1cb9ee8180.tar.gz
sonarqube-cf41e9c2ec6250f767120f71b1facc1cb9ee8180.zip
Create TypeAwareVisitor and PathAwareVisitor
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentCrawler.java17
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/DepthTraversalTypeAwareCrawler.java18
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/DequeBasedPath.java75
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareCrawler.java226
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitor.java101
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitorAdapter.java118
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitorWrapper.java112
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/TreeRootHolderImpl.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareCrawler.java26
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitor.java52
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitorAdapter.java88
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitorWrapper.java76
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/Visitor.java42
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/component/VisitorWrapper.java29
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/formula/FormulaExecutorComponentCrawler.java11
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputeQProfileMeasureStep.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/FillMeasuresWithVariationsStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/IntegrateIssuesStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistProjectLinksStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateLoadingStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateMeasuresStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityProfileEventsStep.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/SizeMeasuresStep.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/SqaleMeasuresStep.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/batch/TreeRootHolderRule.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/component/PathAwareCrawlerTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/component/PostOrderDepthTraversalTypeAwareCrawlerTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/component/PreOrderDepthTraversalTypeAwareCrawlerTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java4
38 files changed, 791 insertions, 286 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentCrawler.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentCrawler.java
index 37599cd0283..5ba2fef550c 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentCrawler.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentCrawler.java
@@ -19,20 +19,11 @@
*/
package org.sonar.server.computation.component;
+/**
+ * Allow to crawl a component tree from a given component
+ */
public interface ComponentCrawler {
- void visit(Component tree);
- enum Order {
- /**
- * Each component is visited BEFORE its children. Top-down traversal of
- * tree of components.
- */
- PRE_ORDER,
+ void visit(Component tree);
- /**
- * Each component is visited AFTER its children. Bottom-up traversal of
- * tree of components.
- */
- POST_ORDER
- }
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/DepthTraversalTypeAwareCrawler.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/DepthTraversalTypeAwareCrawler.java
index 0e7d10786ef..5557e22c38d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/DepthTraversalTypeAwareCrawler.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/DepthTraversalTypeAwareCrawler.java
@@ -29,9 +29,9 @@ import static java.util.Objects.requireNonNull;
*/
public abstract class DepthTraversalTypeAwareCrawler implements TypeAwareCrawler {
private final Component.Type maxDepth;
- private final Order order;
+ private final Visitor.Order order;
- protected DepthTraversalTypeAwareCrawler(Component.Type maxDepth, Order order) {
+ protected DepthTraversalTypeAwareCrawler(Component.Type maxDepth, Visitor.Order order) {
this.maxDepth = requireNonNull(maxDepth);
this.order = requireNonNull(order);
}
@@ -42,17 +42,27 @@ public abstract class DepthTraversalTypeAwareCrawler implements TypeAwareCrawler
return;
}
- if (order == Order.PRE_ORDER) {
+ if (order == Visitor.Order.PRE_ORDER) {
visitNode(component);
}
visitChildren(component);
- if (order == Order.POST_ORDER) {
+ if (order == Visitor.Order.POST_ORDER) {
visitNode(component);
}
}
+ @Override
+ public Component.Type getMaxDepth() {
+ return maxDepth;
+ }
+
+ @Override
+ public Order getOrder() {
+ return order;
+ }
+
private void visitNode(Component component) {
visitAny(component);
switch (component.getType()) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/DequeBasedPath.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/DequeBasedPath.java
new file mode 100644
index 00000000000..0c7bb8f64a7
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/DequeBasedPath.java
@@ -0,0 +1,75 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation.component;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+public class DequeBasedPath<T> implements PathAwareVisitor.Path<T>, Iterable<PathAwareVisitor.PathElement<T>> {
+ private final Deque<PathAwareVisitor.PathElement<T>> deque = new ArrayDeque<>();
+
+ @Override
+ public T current() {
+ return deque.getFirst().getElement();
+ }
+
+ @Override
+ public T parent() {
+ Iterator<PathAwareVisitor.PathElement<T>> iterator = deque.iterator();
+ if (iterator.hasNext()) {
+ iterator.next();
+ if (iterator.hasNext()) {
+ return iterator.next().getElement();
+ }
+ }
+ throw new NoSuchElementException("Path is either empty or has only one element. There is no parent");
+ }
+
+ @Override
+ public boolean isRoot() {
+ return deque.size() == 1;
+ }
+
+ @Override
+ public T root() {
+ return deque.getLast().getElement();
+ }
+
+ @Override
+ public Iterator<PathAwareVisitor.PathElement<T>> iterator() {
+ return deque.iterator();
+ }
+
+ @Override
+ public Iterable<PathAwareVisitor.PathElement<T>> getCurrentPath() {
+ return this;
+ }
+
+ public void add(PathAwareVisitor.PathElement<T> pathElement) {
+ deque.addFirst(pathElement);
+ }
+
+ public PathAwareVisitor.PathElement<T> pop() {
+ return deque.pop();
+ }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareCrawler.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareCrawler.java
index 119fbe6d746..c73e78c355d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareCrawler.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareCrawler.java
@@ -19,72 +19,47 @@
*/
package org.sonar.server.computation.component;
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import static java.util.Objects.requireNonNull;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.POST_ORDER;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.POST_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
/**
- * A ComponentVisitor which provide access to a representation of the path from the root to the currently visited
+ * A {@link ComponentCrawler} which provide access to a representation of the path from the root to the currently visited
* Component. It also provides a way to have an object associated to each Component and access it and all of its
* parent's.
- * As for {@link DepthTraversalTypeAwareCrawler}, this visitor supports max depth visit and ordering.
+ * As for {@link DepthTraversalTypeAwareCrawler}, this crawler supports max depth visit and ordering.
*/
-public abstract class PathAwareCrawler<T> implements ComponentCrawler {
- private final Component.Type maxDepth;
- private final Order order;
- private final StackElementFactory<T> factory;
+public abstract class PathAwareCrawler<T> extends PathAwareVisitorAdapter<T> implements ComponentCrawler {
+
private final DequeBasedPath<T> stack = new DequeBasedPath<>();
- public PathAwareCrawler(Component.Type maxDepth, Order order, StackElementFactory<T> factory) {
- this.maxDepth = requireNonNull(maxDepth);
- this.order = requireNonNull(order);
- this.factory = requireNonNull(factory, "Factory can not be null");
+ public PathAwareCrawler(Component.Type maxDepth, Visitor.Order order, StackElementFactory<T> factory) {
+ super(maxDepth, order, factory);
}
@Override
public void visit(Component component) {
- if (component.getType().isDeeperThan(maxDepth)) {
+ if (component.getType().isDeeperThan(getMaxDepth())) {
return;
}
stack.add(new PathElementImpl<>(component, createForComponent(component)));
- if (order == PRE_ORDER) {
+ if (getOrder() == PRE_ORDER) {
visitNode(component);
}
visitChildren(component);
- if (order == POST_ORDER) {
+ if (getOrder() == POST_ORDER) {
visitNode(component);
}
stack.pop();
}
- private T createForComponent(Component component) {
- switch (component.getType()) {
- case PROJECT:
- return factory.createForProject(component);
- case MODULE:
- return factory.createForModule(component);
- case DIRECTORY:
- return factory.createForDirectory(component);
- case FILE:
- return factory.createForFile(component);
- default:
- return factory.createForUnknown(component);
- }
- }
-
private void visitChildren(Component component) {
for (Component child : component.getChildren()) {
- if (!child.getType().isDeeperThan(maxDepth)) {
+ if (!child.getType().isDeeperThan(getMaxDepth())) {
visit(child);
}
}
@@ -110,174 +85,26 @@ public abstract class PathAwareCrawler<T> implements ComponentCrawler {
}
}
- protected void visitProject(Component project, Path<T> path) {
- // empty implementation, meant to be override at will by subclasses
- }
-
- protected void visitModule(Component module, Path<T> path) {
- // empty implementation, meant to be override at will by subclasses
- }
-
- protected void visitDirectory(Component directory, Path<T> path) {
- // empty implementation, meant to be override at will by subclasses
- }
-
- protected void visitFile(Component file, Path<T> path) {
- // empty implementation, meant to be override at will by subclasses
- }
-
- protected void visitUnknown(Component unknownComponent, Path<T> path) {
- // empty implementation, meant to be override at will by subclasses
- }
-
- protected void visitAny(Component component, Path<T> path) {
- // empty implementation, meant to be override at will by subclasses
- }
-
- public interface StackElementFactory<T> {
- T createForProject(Component project);
-
- T createForModule(Component module);
-
- T createForDirectory(Component directory);
-
- T createForFile(Component file);
-
- T createForUnknown(Component file);
- }
-
- /**
- * A Simple implementation which uses the same factory method for all types which can be implemented by subclasses:
- * {@link #createForAny(Component)}.
- */
- public abstract static class SimpleStackElementFactory<T> implements StackElementFactory<T> {
-
- public abstract T createForAny(Component component);
-
- @Override
- public T createForProject(Component project) {
- return createForAny(project);
- }
-
- @Override
- public T createForModule(Component module) {
- return createForAny(module);
- }
-
- @Override
- public T createForDirectory(Component directory) {
- return createForAny(directory);
- }
-
- @Override
- public T createForFile(Component file) {
- return createForAny(file);
- }
-
- @Override
- public T createForUnknown(Component file) {
- return createForAny(file);
- }
- }
-
- private static class DequeBasedPath<T> implements Path<T>, Iterable<PathElement<T>> {
- private final Deque<PathElement<T>> deque = new ArrayDeque<>();
-
- @Override
- public T current() {
- return deque.getFirst().getElement();
- }
-
- @Override
- public T parent() {
- Iterator<PathElement<T>> iterator = deque.iterator();
- if (iterator.hasNext()) {
- iterator.next();
- if (iterator.hasNext()) {
- return iterator.next().getElement();
- }
- }
- throw new NoSuchElementException("Path is either empty or has only one element. There is no parent");
- }
-
- @Override
- public boolean isRoot() {
- return deque.size() == 1;
- }
-
- @Override
- public T root() {
- return deque.getLast().getElement();
- }
-
- @Override
- public Iterator<PathElement<T>> iterator() {
- return deque.iterator();
- }
-
- @Override
- public Iterable<PathElement<T>> getCurrentPath() {
- return this;
- }
-
- public void add(PathElement<T> pathElement) {
- deque.addFirst(pathElement);
- }
-
- public PathElement<T> pop() {
- return deque.pop();
+ private T createForComponent(Component component) {
+ switch (component.getType()) {
+ case PROJECT:
+ return getFactory().createForProject(component);
+ case MODULE:
+ return getFactory().createForModule(component);
+ case DIRECTORY:
+ return getFactory().createForDirectory(component);
+ case FILE:
+ return getFactory().createForFile(component);
+ default:
+ return getFactory().createForUnknown(component);
}
}
- public interface Path<T> {
- /**
- * The stacked element of the current Component.
- */
- T current();
-
- /**
- * Tells whether the current Component is the root of the tree.
- */
- boolean isRoot();
-
- /**
- * The stacked element of the parent of the current Component.
- *
- * @throws NoSuchElementException if the current Component is the root of the tree
- * @see #isRoot()
- */
- T parent();
-
- /**
- * The stacked element of the root of the tree.
- */
- T root();
-
- /**
- * The path to the current Component as an Iterable of {@link PathAwareCrawler.PathElement} which starts with
- * the {@link PathAwareCrawler.PathElement} of the current Component and ends with the
- * {@link PathAwareCrawler.PathElement} of the root of the tree.
- */
- Iterable<PathElement<T>> getCurrentPath();
- }
-
- public interface PathElement<T> {
- /**
- * The Component on the path.
- */
- Component getComponent();
-
- /**
- * The stacked element for the Component of this PathElement.
- */
- T getElement();
- }
-
- private static final class PathElementImpl<T> implements PathElement<T> {
+ public static final class PathElementImpl<T> implements PathElement<T> {
private final Component component;
private final T element;
- private PathElementImpl(Component component, T element) {
+ public PathElementImpl(Component component, T element) {
this.component = component;
this.element = element;
}
@@ -292,4 +119,5 @@ public abstract class PathAwareCrawler<T> implements ComponentCrawler {
return element;
}
}
+
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitor.java
new file mode 100644
index 00000000000..3c4473fe21b
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitor.java
@@ -0,0 +1,101 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation.component;
+
+import java.util.NoSuchElementException;
+
+/**
+ * A {@link Visitor} which provide access to a representation of the path from the root to the currently visited
+ * Component. It also provides a way to have an object associated to each Component and access it and all of its
+ * parent's.
+ */
+public interface PathAwareVisitor<T> extends Visitor {
+
+ StackElementFactory<T> getFactory();
+
+ void visitProject(Component project, Path<T> path);
+
+ void visitModule(Component module, Path<T> path);
+
+ void visitDirectory(Component directory, Path<T> path);
+
+ void visitFile(Component file, Path<T> path);
+
+ void visitUnknown(Component unknownComponent, Path<T> path);
+
+ void visitAny(Component component, Path<T> path);
+
+ interface StackElementFactory<T> {
+ T createForProject(Component project);
+
+ T createForModule(Component module);
+
+ T createForDirectory(Component directory);
+
+ T createForFile(Component file);
+
+ T createForUnknown(Component file);
+ }
+
+ interface Path<T> {
+ /**
+ * The stacked element of the current Component.
+ */
+ T current();
+
+ /**
+ * Tells whether the current Component is the root of the tree.
+ */
+ boolean isRoot();
+
+ /**
+ * The stacked element of the parent of the current Component.
+ *
+ * @throws NoSuchElementException if the current Component is the root of the tree
+ * @see #isRoot()
+ */
+ T parent();
+
+ /**
+ * The stacked element of the root of the tree.
+ */
+ T root();
+
+ /**
+ * The path to the current Component as an Iterable of {@link PathAwareVisitor.PathElement} which starts with
+ * the {@link PathAwareVisitor.PathElement} of the current Component and ends with the
+ * {@link PathAwareVisitor.PathElement} of the root of the tree.
+ */
+ Iterable<PathElement<T>> getCurrentPath();
+ }
+
+ interface PathElement<T> {
+ /**
+ * The Component on the path.
+ */
+ Component getComponent();
+
+ /**
+ * The stacked element for the Component of this PathElement.
+ */
+ T getElement();
+ }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitorAdapter.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitorAdapter.java
new file mode 100644
index 00000000000..775e7b60d57
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitorAdapter.java
@@ -0,0 +1,118 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation.component;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A adapter of the {@link PathAwareVisitor} to be able to visit only some component types
+ */
+public abstract class PathAwareVisitorAdapter<T> implements PathAwareVisitor<T> {
+ private final Component.Type maxDepth;
+ private final Order order;
+ private final StackElementFactory<T> factory;
+
+ public PathAwareVisitorAdapter(Component.Type maxDepth, Order order, StackElementFactory<T> factory) {
+ this.maxDepth = requireNonNull(maxDepth);
+ this.order = requireNonNull(order);
+ this.factory = requireNonNull(factory, "Factory can not be null");
+ }
+
+ @Override
+ public Component.Type getMaxDepth() {
+ return maxDepth;
+ }
+
+ @Override
+ public Order getOrder() {
+ return order;
+ }
+
+ @Override
+ public StackElementFactory<T> getFactory() {
+ return factory;
+ }
+
+ @Override
+ public void visitProject(Component project, Path<T> path) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ @Override
+ public void visitModule(Component module, Path<T> path) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ @Override
+ public void visitDirectory(Component directory, Path<T> path) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ @Override
+ public void visitFile(Component file, Path<T> path) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ @Override
+ public void visitUnknown(Component unknownComponent, Path<T> path) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ @Override
+ public void visitAny(Component component, Path<T> path) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ /**
+ * A Simple implementation which uses the same factory method for all types which can be implemented by subclasses:
+ * {@link #createForAny(Component)}.
+ */
+ public abstract static class SimpleStackElementFactory<T> implements StackElementFactory<T> {
+
+ public abstract T createForAny(Component component);
+
+ @Override
+ public T createForProject(Component project) {
+ return createForAny(project);
+ }
+
+ @Override
+ public T createForModule(Component module) {
+ return createForAny(module);
+ }
+
+ @Override
+ public T createForDirectory(Component directory) {
+ return createForAny(directory);
+ }
+
+ @Override
+ public T createForFile(Component file) {
+ return createForAny(file);
+ }
+
+ @Override
+ public T createForUnknown(Component file) {
+ return createForAny(file);
+ }
+ }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitorWrapper.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitorWrapper.java
new file mode 100644
index 00000000000..ba36b285aeb
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/PathAwareVisitorWrapper.java
@@ -0,0 +1,112 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation.component;
+
+public class PathAwareVisitorWrapper<T> implements VisitorWrapper {
+
+ private final PathAwareVisitor<T> delegate;
+
+ private final DequeBasedPath<T> stack = new DequeBasedPath<>();
+
+ public PathAwareVisitorWrapper(PathAwareVisitor<T> delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void beforeComponent(Component component){
+ stack.add(new PathElementImpl<>(component, createForComponent(component)));
+ }
+
+ @Override
+ public void afterComponent(Component component){
+ stack.pop();
+ }
+
+ @Override
+ public void visitProject(Component tree) {
+ delegate.visitProject(tree, stack);
+ }
+
+ @Override
+ public void visitModule(Component tree) {
+ delegate.visitModule(tree, stack);
+ }
+
+ @Override
+ public void visitDirectory(Component tree) {
+ delegate.visitDirectory(tree, stack);
+ }
+
+ @Override
+ public void visitFile(Component tree) {
+ delegate.visitFile(tree, stack);
+ }
+
+ @Override
+ public void visitAny(Component component) {
+ delegate.visitAny(component, stack);
+ }
+
+ @Override
+ public Visitor.Order getOrder() {
+ return delegate.getOrder();
+ }
+
+ @Override
+ public Component.Type getMaxDepth() {
+ return delegate.getMaxDepth();
+ }
+
+ private T createForComponent(Component component) {
+ switch (component.getType()) {
+ case PROJECT:
+ return delegate.getFactory().createForProject(component);
+ case MODULE:
+ return delegate.getFactory().createForModule(component);
+ case DIRECTORY:
+ return delegate.getFactory().createForDirectory(component);
+ case FILE:
+ return delegate.getFactory().createForFile(component);
+ default:
+ return delegate.getFactory().createForUnknown(component);
+ }
+ }
+
+ public static final class PathElementImpl<T> implements PathAwareVisitor.PathElement<T> {
+ private final Component component;
+ private final T element;
+
+ public PathElementImpl(Component component, T element) {
+ this.component = component;
+ this.element = element;
+ }
+
+ @Override
+ public Component getComponent() {
+ return component;
+ }
+
+ @Override
+ public T getElement() {
+ return element;
+ }
+ }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/TreeRootHolderImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TreeRootHolderImpl.java
index 6cd47a20ed4..11337d9ee3e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/TreeRootHolderImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TreeRootHolderImpl.java
@@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.POST_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.POST_ORDER;
/**
* Holds the reference to the root of the {@link Component} tree for the current CE run.
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareCrawler.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareCrawler.java
index cf9117baadf..2a10a165a6e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareCrawler.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareCrawler.java
@@ -22,34 +22,10 @@ package org.sonar.server.computation.component;
/**
* A {@link ComponentCrawler} which can exposes methods which ensure the type of the visited Component.
*/
-public interface TypeAwareCrawler extends ComponentCrawler {
- /**
- * Called when encountering a Component of type {@link Component.Type#PROJECT}
- */
- void visitProject(Component tree);
-
- /**
- * Called when encountering a Component of type {@link Component.Type#MODULE}
- */
- void visitModule(Component tree);
-
- /**
- * Called when encountering a Component of type {@link Component.Type#DIRECTORY}
- */
- void visitDirectory(Component tree);
-
- /**
- * Called when encountering a Component of type {@link Component.Type#FILE}
- */
- void visitFile(Component tree);
+public interface TypeAwareCrawler extends ComponentCrawler, TypeAwareVisitor {
/**
* Called when encountering a Component of an unknown type
*/
void visitUnknown(Component tree);
-
- /**
- * Called for any component, <strong>in addition</strong> to the methods specific to each type
- */
- void visitAny(Component component);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitor.java
new file mode 100644
index 00000000000..180ad426ff1
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitor.java
@@ -0,0 +1,52 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation.component;
+
+/**
+ * A {@link Visitor} which can exposes methods which ensure the type of the visited Component.
+ */
+public interface TypeAwareVisitor extends Visitor {
+ /**
+ * Called when encountering a Component of type {@link Component.Type#PROJECT}
+ */
+ void visitProject(Component project);
+
+ /**
+ * Called when encountering a Component of type {@link Component.Type#MODULE}
+ */
+ void visitModule(Component module);
+
+ /**
+ * Called when encountering a Component of type {@link Component.Type#DIRECTORY}
+ */
+ void visitDirectory(Component directory);
+
+ /**
+ * Called when encountering a Component of type {@link Component.Type#FILE}
+ */
+ void visitFile(Component file);
+
+ /**
+ * Called for any component, <strong>in addition</strong> to the methods specific to each type
+ */
+ void visitAny(Component any);
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitorAdapter.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitorAdapter.java
new file mode 100644
index 00000000000..ad955573ec1
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitorAdapter.java
@@ -0,0 +1,88 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation.component;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * A adapter of the {@link TypeAwareVisitor} to be able to visit only some component types
+ */
+public abstract class TypeAwareVisitorAdapter implements TypeAwareVisitor {
+
+ private final Component.Type maxDepth;
+ private final Order order;
+
+ public TypeAwareVisitorAdapter(Component.Type maxDepth, Order order) {
+ this.maxDepth = requireNonNull(maxDepth);
+ this.order = requireNonNull(order);
+ }
+
+ @Override
+ public Component.Type getMaxDepth() {
+ return maxDepth;
+ }
+
+ @Override
+ public Order getOrder() {
+ return order;
+ }
+
+ /**
+ * Called when encountering a Component of type {@link Component.Type#PROJECT}
+ */
+ @Override
+ public void visitProject(Component project) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ /**
+ * Called when encountering a Component of type {@link Component.Type#MODULE}
+ */
+ @Override
+ public void visitModule(Component module) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ /**
+ * Called when encountering a Component of type {@link Component.Type#DIRECTORY}
+ */
+ @Override
+ public void visitDirectory(Component directory) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ /**
+ * Called when encountering a Component of type {@link Component.Type#FILE}
+ */
+ @Override
+ public void visitFile(Component file) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+ /**
+ * Called for any component, <strong>in addition</strong> to the methods specific to each type
+ */
+ @Override
+ public void visitAny(Component any) {
+ // empty implementation, meant to be override at will by subclasses
+ }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitorWrapper.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitorWrapper.java
new file mode 100644
index 00000000000..fb28c9b972a
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TypeAwareVisitorWrapper.java
@@ -0,0 +1,76 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation.component;
+
+public class TypeAwareVisitorWrapper implements VisitorWrapper {
+
+ private final TypeAwareVisitor delegate;
+
+ public TypeAwareVisitorWrapper(TypeAwareVisitor delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void beforeComponent(Component component){
+ // Nothing to do
+ }
+
+ @Override
+ public void afterComponent(Component component){
+ // Nothing to do
+ }
+
+ @Override
+ public void visitProject(Component tree) {
+ delegate.visitProject(tree);
+ }
+
+ @Override
+ public void visitModule(Component tree) {
+ delegate.visitModule(tree);
+ }
+
+ @Override
+ public void visitDirectory(Component tree) {
+ delegate.visitDirectory(tree);
+ }
+
+ @Override
+ public void visitFile(Component tree) {
+ delegate.visitFile(tree);
+ }
+
+ @Override
+ public void visitAny(Component component) {
+ delegate.visitAny(component);
+ }
+
+ @Override
+ public Visitor.Order getOrder() {
+ return delegate.getOrder();
+ }
+
+ @Override
+ public Component.Type getMaxDepth() {
+ return delegate.getMaxDepth();
+ }
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/Visitor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/Visitor.java
new file mode 100644
index 00000000000..017d59764d8
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/Visitor.java
@@ -0,0 +1,42 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation.component;
+
+public interface Visitor {
+
+ Order getOrder();
+
+ Component.Type getMaxDepth();
+
+ enum Order {
+ /**
+ * Each component is visited BEFORE its children. Top-down traversal of
+ * tree of components.
+ */
+ PRE_ORDER,
+
+ /**
+ * Each component is visited AFTER its children. Bottom-up traversal of
+ * tree of components.
+ */
+ POST_ORDER
+ }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/VisitorWrapper.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/VisitorWrapper.java
new file mode 100644
index 00000000000..21a782f0ed6
--- /dev/null
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/VisitorWrapper.java
@@ -0,0 +1,29 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.computation.component;
+
+public interface VisitorWrapper extends TypeAwareVisitor {
+
+ void beforeComponent(Component component);
+
+ void afterComponent(Component component);
+
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/formula/FormulaExecutorComponentCrawler.java b/server/sonar-server/src/main/java/org/sonar/server/computation/formula/FormulaExecutorComponentCrawler.java
index ef0d10adc0b..9b86cec3a30 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/formula/FormulaExecutorComponentCrawler.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/formula/FormulaExecutorComponentCrawler.java
@@ -27,6 +27,7 @@ import java.util.Map;
import javax.annotation.CheckForNull;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.PathAwareCrawler;
+import org.sonar.server.computation.component.Visitor;
import org.sonar.server.computation.measure.Measure;
import org.sonar.server.computation.measure.MeasureRepository;
import org.sonar.server.computation.metric.Metric;
@@ -58,7 +59,7 @@ public class FormulaExecutorComponentCrawler extends PathAwareCrawler<FormulaExe
private final List<Formula> formulas;
private FormulaExecutorComponentCrawler(Builder builder, List<Formula> formulas) {
- super(Component.Type.FILE, Order.POST_ORDER, COUNTERS_FACTORY);
+ super(Component.Type.FILE, Visitor.Order.POST_ORDER, COUNTERS_FACTORY);
this.periodsHolder = builder.periodsHolder;
this.measureRepository = builder.measureRepository;
this.metricRepository = builder.metricRepository;
@@ -95,22 +96,22 @@ public class FormulaExecutorComponentCrawler extends PathAwareCrawler<FormulaExe
}
@Override
- protected void visitProject(Component project, Path<FormulaExecutorComponentCrawler.Counters> path) {
+ public void visitProject(Component project, Path<FormulaExecutorComponentCrawler.Counters> path) {
processNotFile(project, path);
}
@Override
- protected void visitModule(Component module, Path<FormulaExecutorComponentCrawler.Counters> path) {
+ public void visitModule(Component module, Path<FormulaExecutorComponentCrawler.Counters> path) {
processNotFile(module, path);
}
@Override
- protected void visitDirectory(Component directory, Path<FormulaExecutorComponentCrawler.Counters> path) {
+ public void visitDirectory(Component directory, Path<FormulaExecutorComponentCrawler.Counters> path) {
processNotFile(directory, path);
}
@Override
- protected void visitFile(Component file, Path<FormulaExecutorComponentCrawler.Counters> path) {
+ public void visitFile(Component file, Path<FormulaExecutorComponentCrawler.Counters> path) {
processFile(file, path);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputeQProfileMeasureStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputeQProfileMeasureStep.java
index 71e24866917..1ba19ba8ec9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputeQProfileMeasureStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputeQProfileMeasureStep.java
@@ -36,7 +36,7 @@ import org.sonar.server.computation.qualityprofile.QPMeasureData;
import org.sonar.server.computation.qualityprofile.QualityProfile;
import static org.sonar.server.computation.component.Component.Type.MODULE;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.POST_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.POST_ORDER;
/**
* Aggregates quality profile on lower-level module nodes on their parent modules and project
@@ -74,7 +74,7 @@ public class ComputeQProfileMeasureStep implements ComputationStep {
}
@Override
- protected void visitProject(Component project, Path<QProfiles> path) {
+ public void visitProject(Component project, Path<QProfiles> path) {
addMeasure(project, path.current());
Optional<Measure> qProfileMeasure = measureRepository.getRawMeasure(project, qProfilesMetric);
if (!qProfileMeasure.isPresent() || QPMeasureData.fromJson(qProfileMeasure.get().getData()).getProfiles().isEmpty()) {
@@ -84,7 +84,7 @@ public class ComputeQProfileMeasureStep implements ComputationStep {
}
@Override
- protected void visitModule(Component module, Path<QProfiles> path) {
+ public void visitModule(Component module, Path<QProfiles> path) {
Optional<Measure> measure = measureRepository.getRawMeasure(module, qProfilesMetric);
QProfiles qProfiles = path.current();
if (measure.isPresent()) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java
index 3f0339c7148..bc5e02d52e9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/CustomMeasuresCopyStep.java
@@ -29,6 +29,7 @@ import org.sonar.db.measure.custom.CustomMeasureDto;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
import org.sonar.server.computation.component.TreeRootHolder;
+import org.sonar.server.computation.component.Visitor;
import org.sonar.server.computation.measure.Measure;
import org.sonar.server.computation.measure.MeasureRepository;
import org.sonar.server.computation.metric.Metric;
@@ -51,7 +52,7 @@ public class CustomMeasuresCopyStep implements ComputationStep {
@Override
public void execute() {
- new DepthTraversalTypeAwareCrawler(Component.Type.FILE, DepthTraversalTypeAwareCrawler.Order.PRE_ORDER) {
+ new DepthTraversalTypeAwareCrawler(Component.Type.FILE, Visitor.Order.PRE_ORDER) {
@Override
public void visitAny(Component component) {
copy(component);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/FillMeasuresWithVariationsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/FillMeasuresWithVariationsStep.java
index 187a17c7f11..b2a87eb2a6c 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/FillMeasuresWithVariationsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/FillMeasuresWithVariationsStep.java
@@ -46,7 +46,7 @@ import org.sonar.server.computation.metric.MetricRepository;
import org.sonar.server.computation.period.Period;
import org.sonar.server.computation.period.PeriodsHolder;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
/**
* Set variations on all numeric measures found in the repository.
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/IntegrateIssuesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/IntegrateIssuesStep.java
index 7d30c8a853e..1e357c6b624 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/IntegrateIssuesStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/IntegrateIssuesStep.java
@@ -36,7 +36,7 @@ import org.sonar.server.computation.issue.IssueVisitors;
import org.sonar.server.computation.issue.TrackerExecution;
import org.sonar.server.util.cache.DiskCache;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.POST_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.POST_ORDER;
public class IntegrateIssuesStep implements ComputationStep {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java
index 9413a9831e6..920dcbf1330 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java
@@ -36,7 +36,7 @@ import org.sonar.server.computation.component.DbIdsRepository;
import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
import org.sonar.server.computation.component.TreeRootHolder;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
/**
* Persist duplications into
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java
index 0a6f75a775b..152dd24c662 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java
@@ -32,6 +32,7 @@ import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.DbIdsRepository;
import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
import org.sonar.server.computation.component.TreeRootHolder;
+import org.sonar.server.computation.component.Visitor;
import org.sonar.server.computation.event.Event;
import org.sonar.server.computation.event.EventRepository;
@@ -138,7 +139,7 @@ public class PersistEventsStep implements ComputationStep {
private final long analysisDate;
public PersistEventComponentCrawler(DbSession session, long analysisDate) {
- super(Component.Type.FILE, Order.PRE_ORDER);
+ super(Component.Type.FILE, Visitor.Order.PRE_ORDER);
this.session = session;
this.analysisDate = analysisDate;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java
index 1880bcec4c6..0a188c1a4cd 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java
@@ -49,7 +49,7 @@ import org.sonar.server.computation.source.LineReader;
import org.sonar.server.computation.source.ScmLineReader;
import org.sonar.server.computation.source.SymbolsLineReader;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
public class PersistFileSourcesStep implements ComputationStep {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java
index e57968b5cea..6cd01463a9b 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java
@@ -46,7 +46,7 @@ import static com.google.common.collect.FluentIterable.from;
import static org.sonar.api.measures.CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION_KEY;
import static org.sonar.api.measures.CoreMetrics.FILE_COMPLEXITY_DISTRIBUTION_KEY;
import static org.sonar.api.measures.CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
public class PersistMeasuresStep implements ComputationStep {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java
index cd69f4d4f89..e40475f2ef1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java
@@ -39,7 +39,7 @@ import org.sonar.server.computation.metric.MetricRepository;
import org.sonar.server.source.index.SourceLineIndex;
import static com.google.common.base.Objects.firstNonNull;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
public class PersistNumberOfDaysSinceLastCommitStep implements ComputationStep {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistProjectLinksStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistProjectLinksStep.java
index b14e7a3a39a..d6c04562054 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistProjectLinksStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistProjectLinksStep.java
@@ -41,7 +41,7 @@ import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
import org.sonar.server.computation.component.TreeRootHolder;
import static com.google.common.collect.Sets.newHashSet;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
/**
* Persist project and module links
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java
index 5bbacc7f002..d3f27f950b8 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java
@@ -51,6 +51,7 @@ import org.sonar.server.computation.batch.BatchReportReader;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
import org.sonar.server.computation.component.TreeRootHolder;
+import org.sonar.server.computation.component.Visitor;
public class PersistTestsStep implements ComputationStep {
@@ -96,7 +97,7 @@ public class PersistTestsStep implements ComputationStep {
boolean hasUnprocessedCoverageDetails = false;
public TestDepthTraversalTypeAwareCrawler(DbSession session) {
- super(Component.Type.FILE, Order.PRE_ORDER);
+ super(Component.Type.FILE, Visitor.Order.PRE_ORDER);
this.session = session;
this.existingFileSourcesByUuid = new HashMap<>();
this.projectUuid = treeRootHolder.getRoot().getUuid();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java
index 0e045ef70c8..450e4abe150 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java
@@ -28,6 +28,7 @@ import org.sonar.api.utils.log.Loggers;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
import org.sonar.server.computation.component.TreeRootHolder;
+import org.sonar.server.computation.component.Visitor;
import org.sonar.server.computation.event.Event;
import org.sonar.server.computation.event.EventRepository;
import org.sonar.server.computation.measure.Measure;
@@ -61,7 +62,7 @@ public class QualityGateEventsStep implements ComputationStep {
@Override
public void execute() {
- new DepthTraversalTypeAwareCrawler(Component.Type.PROJECT, DepthTraversalTypeAwareCrawler.Order.PRE_ORDER) {
+ new DepthTraversalTypeAwareCrawler(Component.Type.PROJECT, Visitor.Order.PRE_ORDER) {
@Override
public void visitProject(Component project) {
executeForProject(project);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateLoadingStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateLoadingStep.java
index 1cbd1cde4f3..818416f671a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateLoadingStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateLoadingStep.java
@@ -34,7 +34,7 @@ import org.sonar.server.computation.qualitygate.QualityGate;
import org.sonar.server.computation.qualitygate.QualityGateService;
import static org.sonar.server.computation.component.Component.Type.PROJECT;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
/**
* This step retrieves the QualityGate for the current {@link ReportQueue.Item} and stores it in
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateMeasuresStep.java
index 9d65c9c1e0e..12f512483dc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateMeasuresStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateMeasuresStep.java
@@ -44,7 +44,7 @@ import org.sonar.server.computation.qualitygate.QualityGate;
import org.sonar.server.computation.qualitygate.QualityGateHolder;
import static org.sonar.server.computation.component.Component.Type.PROJECT;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
/**
* This step:
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityProfileEventsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityProfileEventsStep.java
index 003e044e533..f84a1dec15f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityProfileEventsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityProfileEventsStep.java
@@ -42,7 +42,7 @@ import org.sonar.server.computation.metric.MetricRepository;
import org.sonar.server.computation.qualityprofile.QPMeasureData;
import org.sonar.server.computation.qualityprofile.QualityProfile;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.POST_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.POST_ORDER;
/**
* Computation of quality profile events
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SizeMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SizeMeasuresStep.java
index 373b5141bd2..2c2f6700f22 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SizeMeasuresStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SizeMeasuresStep.java
@@ -40,7 +40,7 @@ import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
import static org.sonar.api.measures.CoreMetrics.STATEMENTS_KEY;
import static org.sonar.server.computation.component.Component.Type.FILE;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.POST_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.POST_ORDER;
import static org.sonar.server.computation.measure.Measure.newMeasureBuilder;
/**
@@ -97,12 +97,12 @@ public class SizeMeasuresStep implements ComputationStep {
}
@Override
- protected void visitProject(Component project, Path<Counter> path) {
+ public void visitProject(Component project, Path<Counter> path) {
createMeasures(project, path.current().directories, path.current().files);
}
@Override
- protected void visitModule(Component module, Path<Counter> path) {
+ public void visitModule(Component module, Path<Counter> path) {
createMeasures(module, path.current().directories, path.current().files);
path.parent().directories += path.current().directories;
@@ -110,7 +110,7 @@ public class SizeMeasuresStep implements ComputationStep {
}
@Override
- protected void visitDirectory(Component directory, Path<Counter> path) {
+ public void visitDirectory(Component directory, Path<Counter> path) {
createMeasures(directory, 1, path.current().files);
path.parent().directories += 1;
@@ -125,7 +125,7 @@ public class SizeMeasuresStep implements ComputationStep {
}
@Override
- protected void visitFile(Component file, Path<Counter> path) {
+ public void visitFile(Component file, Path<Counter> path) {
if (file.getFileAttributes().isUnitTest()) {
return;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SqaleMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SqaleMeasuresStep.java
index 38fa3a2ab11..441d09746e6 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SqaleMeasuresStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SqaleMeasuresStep.java
@@ -24,6 +24,7 @@ import org.sonar.api.measures.CoreMetrics;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.PathAwareCrawler;
import org.sonar.server.computation.component.TreeRootHolder;
+import org.sonar.server.computation.component.Visitor;
import org.sonar.server.computation.measure.Measure;
import org.sonar.server.computation.measure.MeasureRepository;
import org.sonar.server.computation.metric.Metric;
@@ -64,7 +65,7 @@ public class SqaleMeasuresStep implements ComputationStep {
private final Metric sqaleRatingMetric;
public SqaleMeasuresCrawler() {
- super(Component.Type.FILE, Order.POST_ORDER, new SimpleStackElementFactory<DevelopmentCost>() {
+ super(Component.Type.FILE, Visitor.Order.POST_ORDER, new SimpleStackElementFactory<DevelopmentCost>() {
@Override
public DevelopmentCost createForAny(Component component) {
return new DevelopmentCost();
@@ -88,7 +89,7 @@ public class SqaleMeasuresStep implements ComputationStep {
}
@Override
- protected void visitModule(Component module, Path<DevelopmentCost> path) {
+ public void visitModule(Component module, Path<DevelopmentCost> path) {
computeAndSaveMeasures(module, path);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java
index af6f3a24a35..f28b30abb12 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java
@@ -44,6 +44,7 @@ import org.sonar.server.computation.batch.BatchReportReader;
import org.sonar.server.computation.component.Component;
import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
import org.sonar.server.computation.component.TreeRootHolder;
+import org.sonar.server.computation.component.Visitor;
import static org.sonar.api.utils.DateUtils.formatDateTime;
@@ -107,7 +108,7 @@ public class ValidateProjectStep implements ComputationStep {
private Component rawProject;
public ValidateProjectsCrawler(DbSession session, ComponentDao componentDao, boolean preventAutomaticProjectCreation, Map<String, ComponentDto> baseModulesByKey) {
- super(Component.Type.MODULE, Order.PRE_ORDER);
+ super(Component.Type.MODULE, Visitor.Order.PRE_ORDER);
this.session = session;
this.componentDao = componentDao;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/TreeRootHolderRule.java b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/TreeRootHolderRule.java
index 5c3cc2e2c43..bbf7aeb57fd 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/TreeRootHolderRule.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/TreeRootHolderRule.java
@@ -30,7 +30,7 @@ import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
import org.sonar.server.computation.component.MutableTreeRootHolder;
import org.sonar.server.computation.component.TreeRootHolder;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.POST_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.POST_ORDER;
public class TreeRootHolderRule implements TestRule, MutableTreeRootHolder {
private Component root;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/component/PathAwareCrawlerTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/component/PathAwareCrawlerTest.java
index 9d14c21c66f..5bf623620d8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/component/PathAwareCrawlerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/component/PathAwareCrawlerTest.java
@@ -38,8 +38,8 @@ import static org.sonar.server.computation.component.Component.Type.DIRECTORY;
import static org.sonar.server.computation.component.Component.Type.FILE;
import static org.sonar.server.computation.component.Component.Type.MODULE;
import static org.sonar.server.computation.component.Component.Type.PROJECT;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.POST_ORDER;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.POST_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
public class PathAwareCrawlerTest {
@@ -258,7 +258,7 @@ public class PathAwareCrawlerTest {
private static class TestPathAwareCrawler extends PathAwareCrawler<Integer> {
private final List<CallRecord> callsRecords = new ArrayList<>();
- public TestPathAwareCrawler(Component.Type maxDepth, ComponentCrawler.Order order) {
+ public TestPathAwareCrawler(Component.Type maxDepth, Visitor.Order order) {
super(maxDepth, order, new SimpleStackElementFactory<Integer>() {
@Override
public Integer createForAny(Component component) {
@@ -268,32 +268,32 @@ public class PathAwareCrawlerTest {
}
@Override
- protected void visitProject(Component project, Path<Integer> path) {
+ public void visitProject(Component project, Path<Integer> path) {
callsRecords.add(newCallRecord(project, path, "visitProject"));
}
@Override
- protected void visitModule(Component module, Path<Integer> path) {
+ public void visitModule(Component module, Path<Integer> path) {
callsRecords.add(newCallRecord(module, path, "visitModule"));
}
@Override
- protected void visitDirectory(Component directory, Path<Integer> path) {
+ public void visitDirectory(Component directory, Path<Integer> path) {
callsRecords.add(newCallRecord(directory, path, "visitDirectory"));
}
@Override
- protected void visitFile(Component file, Path<Integer> path) {
+ public void visitFile(Component file, Path<Integer> path) {
callsRecords.add(newCallRecord(file, path, "visitFile"));
}
@Override
- protected void visitUnknown(Component unknownComponent, Path<Integer> path) {
+ public void visitUnknown(Component unknownComponent, Path<Integer> path) {
callsRecords.add(newCallRecord(unknownComponent, path, "visitUnknown"));
}
@Override
- protected void visitAny(Component component, Path<Integer> path) {
+ public void visitAny(Component component, Path<Integer> path) {
callsRecords.add(newCallRecord(component, path, "visitAny"));
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/component/PostOrderDepthTraversalTypeAwareCrawlerTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/component/PostOrderDepthTraversalTypeAwareCrawlerTest.java
index 1f0a0f08193..9ba230af816 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/component/PostOrderDepthTraversalTypeAwareCrawlerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/component/PostOrderDepthTraversalTypeAwareCrawlerTest.java
@@ -29,7 +29,7 @@ import static org.sonar.server.computation.component.Component.Type.DIRECTORY;
import static org.sonar.server.computation.component.Component.Type.FILE;
import static org.sonar.server.computation.component.Component.Type.MODULE;
import static org.sonar.server.computation.component.Component.Type.PROJECT;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.POST_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.POST_ORDER;
public class PostOrderDepthTraversalTypeAwareCrawlerTest {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/component/PreOrderDepthTraversalTypeAwareCrawlerTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/component/PreOrderDepthTraversalTypeAwareCrawlerTest.java
index d3650860a95..aeb2c28c823 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/component/PreOrderDepthTraversalTypeAwareCrawlerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/component/PreOrderDepthTraversalTypeAwareCrawlerTest.java
@@ -29,7 +29,7 @@ import static org.sonar.server.computation.component.Component.Type.DIRECTORY;
import static org.sonar.server.computation.component.Component.Type.FILE;
import static org.sonar.server.computation.component.Component.Type.MODULE;
import static org.sonar.server.computation.component.Component.Type.PROJECT;
-import static org.sonar.server.computation.component.ComponentCrawler.Order.PRE_ORDER;
+import static org.sonar.server.computation.component.Visitor.Order.PRE_ORDER;
public class PreOrderDepthTraversalTypeAwareCrawlerTest {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java
index ea612d42e8d..e2effb13ea3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java
@@ -33,9 +33,9 @@ import javax.annotation.Nullable;
import org.junit.rules.ExternalResource;
import org.sonar.db.rule.RuleDto;
import org.sonar.server.computation.component.Component;
-import org.sonar.server.computation.component.ComponentCrawler;
import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler;
import org.sonar.server.computation.component.TreeRootHolder;
+import org.sonar.server.computation.component.Visitor;
import org.sonar.server.computation.debt.Characteristic;
import org.sonar.server.computation.metric.Metric;
import org.sonar.server.computation.metric.MetricRepositoryRule;
@@ -386,7 +386,7 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe
private final Map<Integer, Component> componentsByRef = new HashMap<>();
public TreeComponentProvider(Component root) {
- new DepthTraversalTypeAwareCrawler(Component.Type.FILE, ComponentCrawler.Order.PRE_ORDER) {
+ new DepthTraversalTypeAwareCrawler(Component.Type.FILE, Visitor.Order.PRE_ORDER) {
@Override
public void visitAny(Component component) {
checkState(!componentsByRef.containsKey(component.getRef()), "Tree contains more than one component with ref " + component.getRef());