List of usage examples for org.eclipse.jdt.core IJavaProject exists
boolean exists();
From source file:tod.plugin.SourceRevealerUtils.java
License:Open Source License
/** * Returns all the java projects of the given session. *///from ww w . j a v a2s . c o m public static List<IJavaProject> getJavaProjects(ISession aSession) { List<IProject> theProjects = getProjects(aSession); List<IJavaProject> theJavaProjects = new ArrayList<IJavaProject>(); for (IProject theProject : theProjects) { IJavaProject theJavaProject = JavaCore.create(theProject); if (theJavaProject != null && theJavaProject.exists()) { theJavaProjects.add(theJavaProject); } } return theJavaProjects; }
From source file:tod.plugin.TODPluginUtils.java
License:Open Source License
/** * Searches for declarations of the given name and kind in the whole workspace. *///from www . j a va2 s .co m public static List searchDeclarations(List<IJavaProject> aJavaProject, String aName, int aKind) throws CoreException { // Recursively add referenced projects (because Eclipse doesn't recursively include non-exported referenced projects) Set<IJavaProject> theProjects = new HashSet<IJavaProject>(); Stack<IJavaProject> theWorkingList = new ArrayStack<IJavaProject>(); for (IJavaProject theProject : aJavaProject) theWorkingList.push(theProject); while (!theWorkingList.isEmpty()) { IJavaProject theProject = theWorkingList.pop(); theProjects.add(theProject); IJavaModel theJavaModel = theProject.getJavaModel(); IClasspathEntry[] theEntries = theProject.getResolvedClasspath(true); for (IClasspathEntry theEntry : theEntries) if (theEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IJavaProject theReferencedProject = theJavaModel .getJavaProject(theEntry.getPath().lastSegment()); if (theReferencedProject.exists() && !theProjects.contains(theReferencedProject)) theWorkingList.push(theReferencedProject); } } SearchPattern thePattern = SearchPattern.createPattern(aName.replace('$', '.'), aKind, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH); IJavaSearchScope theScope = SearchEngine .createJavaSearchScope(theProjects.toArray(new IJavaElement[theProjects.size()]), true); SearchEngine theSearchEngine = new SearchEngine(); SimpleResultCollector theCollector = new SimpleResultCollector(); theSearchEngine.search(thePattern, PARTICIPANTS, theScope, theCollector, null); return theCollector.getResults(); }
From source file:x10dt.search.core.pdb.X10FactGenerator.java
License:Open Source License
private CompilerOptionsBuilder processResource(final IResource resource) throws AnalysisException { final IJavaProject javaProject = JavaCore.create(resource.getProject()); if (javaProject.exists()) { final CompilerOptionsBuilder cmpOptBuilder = new CompilerOptionsBuilder(); final IWorkspaceRoot wsRoot = javaProject.getProject().getWorkspace().getRoot(); try {/*ww w. j av a2 s . c o m*/ processEntries(cmpOptBuilder, wsRoot, javaProject.getRawClasspath(), javaProject, resource, false); } catch (CoreException except) { throw new AnalysisException(NLS.bind(Messages.XFG_ResourceAccessError, resource.getFullPath()), except); } return cmpOptBuilder; } else { return null; } }