Search in sources :

Example 16 with IResourceRuleFactory

use of org.eclipse.core.resources.IResourceRuleFactory in project titan.EclipsePlug-ins by eclipse.

the class ProjectSourceParser method getSchedulingRule.

private ISchedulingRule getSchedulingRule() {
    Deque<IProject> temporalList = new LinkedList<IProject>();
    IProject[] tempProjects;
    IProject tempProject;
    List<IProject> projectTobeLocked = ProjectBasedBuilder.getProjectBasedBuilder(project).getAllReachableProjects();
    for (Iterator<IProject> iterator = projectTobeLocked.iterator(); iterator.hasNext(); ) {
        IProject temp = iterator.next();
        if (GlobalParser.getProjectSourceParser(temp).getLastTimeChecked() != null) {
            iterator.remove();
        }
    }
    // analyze the project referencing the just now analyzed
    // projects in a bottom up order.
    temporalList.addLast(project);
    projectTobeLocked.remove(project);
    while (!temporalList.isEmpty()) {
        tempProject = temporalList.getFirst();
        temporalList.removeFirst();
        if (!projectTobeLocked.contains(tempProject)) {
            projectTobeLocked.add(tempProject);
            tempProjects = ProjectBasedBuilder.getProjectBasedBuilder(tempProject).getReferencingProjects();
            for (IProject tempProject2 : tempProjects) {
                if (!GlobalParser.getProjectSourceParser(tempProject2).analyzesRunning) {
                    temporalList.addLast(tempProject2);
                }
            }
        }
    }
    // Collect those projects that might be needed to do the correct
    // analysis.
    List<IProject> additionalRequired = new ArrayList<IProject>();
    for (IProject project : projectTobeLocked) {
        List<IProject> temp = ProjectBasedBuilder.getProjectBasedBuilder(project).getAllReachableProjects();
        for (IProject temp2 : temp) {
            // or not.
            if (!projectTobeLocked.contains(temp2) && !additionalRequired.contains(temp2)) {
                additionalRequired.add(temp2);
            }
        }
    }
    projectTobeLocked.addAll(additionalRequired);
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    ISchedulingRule combinedRule = null;
    for (IProject project : projectTobeLocked) {
        combinedRule = MultiRule.combine(ruleFactory.createRule(project), combinedRule);
    }
    return combinedRule;
}
Also used : ArrayList(java.util.ArrayList) IResourceRuleFactory(org.eclipse.core.resources.IResourceRuleFactory) IProject(org.eclipse.core.resources.IProject) LinkedList(java.util.LinkedList) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Example 17 with IResourceRuleFactory

use of org.eclipse.core.resources.IResourceRuleFactory in project eclipse.jdt.ls by eclipse.

the class BaseDocumentLifeCycleHandler method getRule.

private ISchedulingRule getRule(Set<ICompilationUnit> units) {
    ISchedulingRule result = null;
    IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
    for (ICompilationUnit unit : units) {
        if (unit.getResource() != null) {
            ISchedulingRule rule = ruleFactory.createRule(unit.getResource());
            result = MultiRule.combine(rule, result);
        }
    }
    return result;
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IResourceRuleFactory(org.eclipse.core.resources.IResourceRuleFactory) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Aggregations

IResourceRuleFactory (org.eclipse.core.resources.IResourceRuleFactory)17 ISchedulingRule (org.eclipse.core.runtime.jobs.ISchedulingRule)13 ArrayList (java.util.ArrayList)5 IFile (org.eclipse.core.resources.IFile)5 IResource (org.eclipse.core.resources.IResource)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 IPath (org.eclipse.core.runtime.IPath)4 File (java.io.File)3 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Status (org.eclipse.core.runtime.Status)3 Job (org.eclipse.core.runtime.jobs.Job)3 BufferedReader (java.io.BufferedReader)2 BufferedWriter (java.io.BufferedWriter)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2