Search in sources :

Example 1 with BaseProjectCodeSmellSpotter

use of org.eclipse.titanium.markers.spotters.BaseProjectCodeSmellSpotter in project titan.EclipsePlug-ins by eclipse.

the class Analyzer method internalAnalyzeProject.

private List<Marker> internalAnalyzeProject(final IProject project) {
    final List<Marker> markers = new ArrayList<Marker>();
    for (final BaseProjectCodeSmellSpotter spotter : projectActions) {
        List<Marker> ms;
        synchronized (project) {
            ms = spotter.checkProject(project);
        }
        markers.addAll(ms);
    }
    return markers;
}
Also used : ArrayList(java.util.ArrayList) Marker(org.eclipse.titanium.markers.handler.Marker) BaseProjectCodeSmellSpotter(org.eclipse.titanium.markers.spotters.BaseProjectCodeSmellSpotter)

Example 2 with BaseProjectCodeSmellSpotter

use of org.eclipse.titanium.markers.spotters.BaseProjectCodeSmellSpotter in project titan.EclipsePlug-ins by eclipse.

the class AnalyzerBuilder method addProblem.

/**
 * @param problemType
 *            the analyzer will use this code smell
 * @return this for method chaining
 */
public AnalyzerBuilder addProblem(final CodeSmellType problemType) {
    if (exhausted) {
        throw new IllegalStateException("One must not use the builder after build() method is called");
    }
    if (spotters.get(problemType) != null) {
        for (final BaseModuleCodeSmellSpotter spotter : spotters.get(problemType)) {
            final Queue<Class<? extends IVisitableNode>> subtypes = new ArrayDeque<Class<? extends IVisitableNode>>();
            subtypes.addAll(spotter.getStartNode());
            while (!subtypes.isEmpty()) {
                final Class<? extends IVisitableNode> sub = subtypes.poll();
                if (StaticData.TYPE_HIERARCHY.get(sub) != null) {
                    Collections.addAll(subtypes, StaticData.TYPE_HIERARCHY.get(sub));
                }
                if (actions.get(sub) == null) {
                    actions.put(sub, new HashSet<BaseModuleCodeSmellSpotter>());
                }
                actions.get(sub).add(spotter);
            }
        }
    } else if (projectSpotters.get(problemType) != null) {
        for (final BaseProjectCodeSmellSpotter spotter : projectSpotters.get(problemType)) {
            projectActions.add(spotter);
        }
    }
    return this;
}
Also used : BaseModuleCodeSmellSpotter(org.eclipse.titanium.markers.spotters.BaseModuleCodeSmellSpotter) ArrayDeque(java.util.ArrayDeque) BaseProjectCodeSmellSpotter(org.eclipse.titanium.markers.spotters.BaseProjectCodeSmellSpotter) IVisitableNode(org.eclipse.titan.designer.AST.IVisitableNode)

Aggregations

BaseProjectCodeSmellSpotter (org.eclipse.titanium.markers.spotters.BaseProjectCodeSmellSpotter)2 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 IVisitableNode (org.eclipse.titan.designer.AST.IVisitableNode)1 Marker (org.eclipse.titanium.markers.handler.Marker)1 BaseModuleCodeSmellSpotter (org.eclipse.titanium.markers.spotters.BaseModuleCodeSmellSpotter)1