Example usage for org.eclipse.jdt.core.search IJavaSearchScope enclosingProjectsAndJars

List of usage examples for org.eclipse.jdt.core.search IJavaSearchScope enclosingProjectsAndJars

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.search IJavaSearchScope enclosingProjectsAndJars.

Prototype

IPath[] enclosingProjectsAndJars();

Source Link

Document

Returns the paths to the enclosing projects and JARs for this search scope.

Usage

From source file:org.eclipse.ajdt.internal.launching.AJMainMethodSearchEngine.java

License:Open Source License

/**
 * Searches for all main methods in the given scope. Also searches 
 * for Aspects that have main methods./* w ww. j  av a 2  s.com*/
 */
public IType[] searchMainMethodsIncludingAspects(IProgressMonitor pm, IJavaSearchScope scope,
        boolean includeSubtypes) throws JavaModelException {

    pm.beginTask(LauncherMessages.MainMethodSearchEngine_1, 100);
    IProgressMonitor javaSearchMonitor = new SubProgressMonitor(pm, 100);
    IType[] mainTypes = super.searchMainMethods(javaSearchMonitor, scope, includeSubtypes);
    IProject[] projects = AspectJPlugin.getWorkspace().getRoot().getProjects();

    Set<IType> mainSet = new HashSet<IType>();
    for (int i = 0; i < mainTypes.length; i++) {
        mainSet.add(mainTypes[i]);
    }

    // Bug 261745 --- must search for aspect types in Java files.  
    // these are not found through JDT Weaving
    IProgressMonitor ajSearchMonitor = new SubProgressMonitor(pm, 100);
    ajSearchMonitor.beginTask(LauncherMessages.MainMethodSearchEngine_1, 100);
    double ticksPerProject = Math.floor(100F / (float) projects.length);
    if (ticksPerProject < 1) {
        ticksPerProject = 1;
    }
    IPath[] paths = scope.enclosingProjectsAndJars();
    Set<IPath> pathsSet = new HashSet<IPath>(paths.length * 2);
    for (int i = 0; i < paths.length; i++) {
        pathsSet.add(paths[i]);
    }

    for (int i = 0; i < projects.length; i++) {
        try {
            if (projects[i].hasNature("org.eclipse.ajdt.ui.ajnature")) { //$NON-NLS-1$ 
                IJavaProject jp = JavaCore.create(projects[i]);
                if (jp != null) {
                    if (pathsSet.contains(jp.getResource().getFullPath())) {
                        Set<IFile> includedFiles = BuildConfig.getIncludedSourceFiles(projects[i]);
                        Set<IType> mains = getAllAspectsWithMain(scope, includedFiles);
                        mainSet.addAll(mains);
                    }
                }
            }
        } catch (Exception e) {
        }
        ajSearchMonitor.internalWorked(ticksPerProject);
        ajSearchMonitor.done();
    }
    pm.done();
    return mainSet.toArray(new IType[mainSet.size()]);
}

From source file:org.eclipse.xtext.common.types.xtext.ui.IntersectingJavaSearchScope.java

License:Open Source License

@Override
public IPath[] enclosingProjectsAndJars() {
    if (scopes.length == 0)
        return new IPath[0];
    if (scopes.length == 1)
        return scopes[0].enclosingProjectsAndJars();
    Collection<IPath> result = null;
    for (IJavaSearchScope scope : scopes) {
        if (result == null) {
            result = Sets.newLinkedHashSet(Arrays.asList(scope.enclosingProjectsAndJars()));
        } else {/*w ww.ja va2  s. c o  m*/
            result.retainAll(Arrays.asList(scope.enclosingProjectsAndJars()));
        }
    }
    if (result == null)
        return new IPath[0];
    return result.toArray(new IPath[result.size()]);
}

From source file:org.hawkinssoftware.rns.analysis.compile.util.CompoundHierarchiesScope.java

License:Open Source License

@Override
public IPath[] enclosingProjectsAndJars() {
    List<IPath> allPaths = new ArrayList<IPath>();
    for (IJavaSearchScope scope : hierarchyScopes) {
        for (IPath path : scope.enclosingProjectsAndJars()) {
            allPaths.add(path);//from w ww .j  av  a2 s  .  c  o  m
        }
    }
    return allPaths.toArray(new IPath[0]);
}

From source file:org.jboss.tools.batch.ui.participants.BatchArtifactSearchParticipant.java

License:Open Source License

private static boolean containsInSearchScope(QuerySpecification querySpecification, IPath projectPath) {
    IJavaSearchScope searchScope = querySpecification.getScope();
    if (searchScope == null)
        return true;
    IPath[] paths = searchScope.enclosingProjectsAndJars();
    for (IPath path : paths) {
        if (path.equals(projectPath))
            return true;
    }/*from ww  w  .j  a v  a2s.c o  m*/
    return false;
}

From source file:org.summer.dsl.model.types.xtext.ui.IntersectingJavaSearchScope.java

License:Open Source License

public IPath[] enclosingProjectsAndJars() {
    if (scopes.length == 0)
        return new IPath[0];
    if (scopes.length == 1)
        return scopes[0].enclosingProjectsAndJars();
    Collection<IPath> result = null;
    for (IJavaSearchScope scope : scopes) {
        if (result == null) {
            result = Sets.newLinkedHashSet(Arrays.asList(scope.enclosingProjectsAndJars()));
        } else {/*from w ww .jav a2 s.c  o  m*/
            result.retainAll(Arrays.asList(scope.enclosingProjectsAndJars()));
        }
    }
    if (result == null)
        return new IPath[0];
    return result.toArray(new IPath[result.size()]);
}