Java Code Examples for org.eclipse.core.resources.IProject#getReferencingProjects()
The following examples show how to use
org.eclipse.core.resources.IProject#getReferencingProjects() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectModulesManager.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * @param project the project for which we want references. * @param referenced whether we want to get the referenced projects or the ones referencing this one. * @param memo (out) this is the place where all the projects will e available. * * Note: the project itself will not be added. */ private static void getProjectsRecursively(IProject project, boolean referenced, HashSet<IProject> memo) { IProject[] projects = null; try { if (project == null || !project.isOpen() || !project.exists()) { return; } if (referenced) { projects = project.getReferencedProjects(); } else { projects = project.getReferencingProjects(); } } catch (CoreException e) { //ignore (it's closed) } if (projects != null) { for (IProject p : projects) { if (!memo.contains(p)) { memo.add(p); getProjectsRecursively(p, referenced, memo); } } } }
Example 2
Source File: Importer.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 5 votes |
private void closeProjectsThatAreNotReferenced(IProgressMonitor monitor, File platformHome) throws CoreException { if (DEBUG) Activator.log("Retrieving projects not in localextensions using platformhome [" + platformHome.getAbsolutePath() + "]"); Set<IProject> projectsToClose = FixProjectsUtils.getProjectsNotInLocalExtensionsFile(platformHome.getAbsolutePath()); // close projects from the above set that are not referenced by a // project that is not scheduled for closing if (projectsToClose != null) { for (IProject projectToClose : projectsToClose) { // check if this project is a dependency of another project that // is not scheduled to be closed IProject[] referencingProjects = projectToClose.getReferencingProjects(); boolean abortClose = false; if (referencingProjects != null) { for (IProject proj : referencingProjects) { if (!projectsToClose.contains(proj)) { if (DEBUG) Activator.log("Aborting close of project [" + projectToClose.getName() + "] because it is referenced by [" + proj.getName() + "]"); abortClose = true; } } } // close projects if (!abortClose) { if (DEBUG) Activator.log("Closing project [" + projectToClose.getName() + "]"); projectToClose.close(monitor); } } } }
Example 3
Source File: RenameModifications.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public void rename(IJavaProject project, RenameArguments args) { add(project, args, null); IProject rProject= project.getProject(); if (rProject != null) { getResourceModifications().addRename(rProject, args); IProject[] referencingProjects= rProject.getReferencingProjects(); for (int i= 0; i < referencingProjects.length; i++) { IFile classpath= getClasspathFile(referencingProjects[i]); if (classpath != null) { getResourceModifications().addChanged(classpath); } } } }
Example 4
Source File: ResourceProcessors.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static void computeNatures(Set<String> result, Set<IProject> visitedProjects, IProject focus) throws CoreException { if (visitedProjects.contains(focus)) return; String[] pns= focus.getDescription().getNatureIds(); for (int p = 0; p < pns.length; p++) { result.add(pns[p]); } visitedProjects.add(focus); IProject[] referencing= focus.getReferencingProjects(); for (int i= 0; i < referencing.length; i++) { computeNatures(result, visitedProjects, referencing[i]); } }
Example 5
Source File: QualifiedNameFinder.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static void addReferencingProjects(IProject root, Set<IProject> res) { IProject[] projects= root.getReferencingProjects(); for (int i= 0; i < projects.length; i++) { IProject project= projects[i]; if (res.add(project)) { addReferencingProjects(project, res); } } }
Example 6
Source File: RenameModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void rename(IJavaProject project, RenameArguments args) { add(project, args, null); IProject rProject= project.getProject(); if (rProject != null) { getResourceModifications().addRename(rProject, args); IProject[] referencingProjects= rProject.getReferencingProjects(); for (int i= 0; i < referencingProjects.length; i++) { IFile classpath= getClasspathFile(referencingProjects[i]); if (classpath != null) { getResourceModifications().addChanged(classpath); } } } }
Example 7
Source File: ResourceProcessors.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static void computeNatures(Set<String> result, Set<IProject> visitedProjects, IProject focus) throws CoreException { if (visitedProjects.contains(focus)) return; String[] pns= focus.getDescription().getNatureIds(); for (int p = 0; p < pns.length; p++) { result.add(pns[p]); } visitedProjects.add(focus); IProject[] referencing= focus.getReferencingProjects(); for (int i= 0; i < referencing.length; i++) { computeNatures(result, visitedProjects, referencing[i]); } }
Example 8
Source File: QualifiedNameFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static void addReferencingProjects(IProject root, Set<IProject> res) { IProject[] projects= root.getReferencingProjects(); for (int i= 0; i < projects.length; i++) { IProject project= projects[i]; if (res.add(project)) { addReferencingProjects(project, res); } } }
Example 9
Source File: VerySimpleBuilder.java From textuml with Eclipse Public License 1.0 | 4 votes |
@SuppressWarnings("unchecked") @Override protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { IProject toBuild = getProject(); // mark all referencing as needing rebuild for (IProject referencing : toBuild.getReferencingProjects()) referencing.touch(monitor); // build location context IFileStore storeToBuild = EFS.getStore(toBuild.getLocationURI()); LocationContext context = new LocationContext(storeToBuild); context.addSourcePath(storeToBuild, null); for (IProject referenced : toBuild.getReferencedProjects()) { URI referencedLocation = referenced.getLocationURI(); if (referencedLocation != null) { IFileStore modelPathEntry = EFS.getStore(referencedLocation); context.addRelatedPath(modelPathEntry); } } removeMarkers(toBuild); IProblem[] problems = FrontEnd.getCompilationDirector().compile(null, null, context, ICompilationDirector.FULL_BUILD, monitor); toBuild.refreshLocal(IResource.DEPTH_INFINITE, null); Arrays.sort(problems, new Comparator<IProblem>() { public int compare(IProblem o1, IProblem o2) { if ((o1 instanceof InternalProblem) || (o2 instanceof InternalProblem)) { if (!(o1 instanceof InternalProblem)) return 1; if (!(o2 instanceof InternalProblem)) return -1; return 0; } int fileNameDelta = ((IFileStore) o1.getAttribute(IProblem.FILE_NAME)).toURI().compareTo( ((IFileStore) o2.getAttribute(IProblem.FILE_NAME)).toURI()); if (fileNameDelta != 0) return fileNameDelta; int lineNo1 = getLineNumber(o1); int lineNo2 = getLineNumber(o2); return lineNo1 - lineNo2; } }); createMarkers(toBuild, problems); return null; }