Search in sources :

Example 1 with Analyzer

use of org.eclipse.titanium.markers.utils.Analyzer in project titan.EclipsePlug-ins by eclipse.

the class CustomExpansionListener method performOk.

@Override
public boolean performOk() {
    final boolean result = super.performOk();
    // the others should be checked too.
    if (changed) {
        ErrorReporter.parallelWarningDisplayInMessageDialog("Code smell markers", "Settings of the code smell analyzer have changed," + " the known projects have to be re-analyzed completly.\nThis might take some time.");
        final IProject[] projs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
        final Analyzer analyzer = AnalyzerCache.withPreference();
        for (final IProject project : projs) {
            if (TITANNature.hasTITANNature(project)) {
                final WorkspaceJob op = new WorkspaceJob("Code smells") {

                    @Override
                    public IStatus runInWorkspace(final IProgressMonitor monitor) {
                        MarkerHandler mh;
                        synchronized (project) {
                            mh = analyzer.analyzeProject(monitor, project);
                        }
                        mh.showAll(project);
                        return Status.OK_STATUS;
                    }
                };
                op.setPriority(Job.SHORT);
                op.setSystem(false);
                op.setUser(true);
                op.schedule();
            }
        }
    }
    return result;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Analyzer(org.eclipse.titanium.markers.utils.Analyzer) MarkerHandler(org.eclipse.titanium.markers.handler.MarkerHandler) IProject(org.eclipse.core.resources.IProject)

Example 2 with Analyzer

use of org.eclipse.titanium.markers.utils.Analyzer in project titan.EclipsePlug-ins by eclipse.

the class CheckCodeSmells method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IWorkbenchPage iwPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    final ISelection selection = iwPage.getSelection();
    final List<IResource> res = org.eclipse.titan.common.utils.SelectionUtils.getResourcesFromSelection(selection);
    final Map<IProject, List<IFile>> files = new HashMap<IProject, List<IFile>>();
    final List<IProject> projects = new ArrayList<IProject>();
    collectResourcesToBeAnalyzed(new LinkedList<IResource>(res), files, projects);
    final String titaniumId = Activator.PLUGIN_ID;
    final String onTheFlyPref = PreferenceConstants.ON_THE_FLY_SMELLS;
    final boolean onTheFlyEnabled = Platform.getPreferencesService().getBoolean(titaniumId, onTheFlyPref, false, null);
    final Analyzer analyzer = AnalyzerCache.withPreference();
    // Clear the files, that will be analyzed inside projects.
    for (final IProject project : projects) {
        files.remove(project);
    }
    // check projects
    checkProjects(projects, onTheFlyEnabled, analyzer);
    // check separate files of project
    checkSeparateFiles(files, onTheFlyEnabled, analyzer);
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Analyzer(org.eclipse.titanium.markers.utils.Analyzer) IProject(org.eclipse.core.resources.IProject) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) IResource(org.eclipse.core.resources.IResource)

Aggregations

IProject (org.eclipse.core.resources.IProject)2 Analyzer (org.eclipse.titanium.markers.utils.Analyzer)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ISelection (org.eclipse.jface.viewers.ISelection)1 MarkerHandler (org.eclipse.titanium.markers.handler.MarkerHandler)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1