List of usage examples for org.eclipse.jdt.core IJavaProject isOnClasspath
boolean isOnClasspath(IResource resource);
From source file:org.eclipse.objectteams.otdt.debug.ui.internal.actions.OTToggleBreakpointAdapter.java
License:Open Source License
/** * Returns the binary name for the {@link IType} derived from its {@link ITypeBinding}. * <br><br>/*from w w w . ja v a 2s .com*/ * If the {@link ITypeBinding} cannot be derived this method falls back to calling * {@link #createQualifiedTypeName(IType)} to try and compose the type name. * @param type * @return the binary name for the given {@link IType} * @since 3.6 */ String getQualifiedName(IType type) throws JavaModelException { IJavaProject project = type.getJavaProject(); if (project != null && project.isOnClasspath(type) && needsBindings(type)) { CompilationUnit cuNode = parseCompilationUnit(type.getTypeRoot()); ISourceRange nameRange = type.getNameRange(); if (SourceRange.isAvailable(nameRange)) { ASTNode node = NodeFinder.perform(cuNode, nameRange); if (node instanceof SimpleName) { IBinding binding; if (node.getLocationInParent() == SimpleType.NAME_PROPERTY && node.getParent().getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) { binding = ((ClassInstanceCreation) node.getParent().getParent()).resolveTypeBinding(); } else { binding = ((SimpleName) node).resolveBinding(); } if (binding instanceof ITypeBinding) { String name = ((ITypeBinding) binding).getBinaryName(); if (name != null) { return name; } } } } } return createQualifiedTypeName(type); }
From source file:org.eclipse.objectteams.otdt.internal.refactoring.util.RefactoringUtil.java
License:Open Source License
private static IJavaElement[] getRelevantProjects(IJavaProject srcProject) throws JavaModelException { List<IJavaProject> relevantProjects = new ArrayList<IJavaProject>(); relevantProjects.add(srcProject); // this one is relevant for sure IJavaProject[] allJavaProjects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects(); for (int idx = 0; idx < allJavaProjects.length; idx++) { IJavaProject prj = allJavaProjects[idx]; if (prj.isOnClasspath(srcProject)) { relevantProjects.add(prj);// w ww . ja v a 2 s.c om } } return relevantProjects.toArray(new IJavaElement[relevantProjects.size()]); }
From source file:org.eclipse.xtend.shared.ui.core.builder.XtendXpandBuilder.java
License:Open Source License
boolean isOnJavaClassPath(final IResource resource) { final IJavaProject jp = JavaCore.create(resource.getProject()); if (jp != null) return jp.isOnClasspath(resource); return false; }
From source file:org.eclipse.xtend.shared.ui.MetamodelContainer.java
License:Open Source License
public void elementChanged(final ElementChangedEvent event) { for (final Iterator<IJavaProject> iter = projects.iterator(); !changed && iter.hasNext();) { final IJavaProject project = iter.next(); if (project.isOnClasspath(event.getDelta().getElement())) { changed = true;/* w ww . j a v a 2 s .c om*/ } } }
From source file:org.eclipse.xtend.typesystem.uml2.ui.Uml2MetamodelContributor.java
License:Open Source License
public MetaModel[] getMetamodels(IJavaProject project, TypeSystem builtin) { MetamodelContainer container = metamodels.get(project); if (container == null || container.hasChanged()) { if (container != null) { metamodels.remove(project);/*from w ww .j a v a 2 s .com*/ JavaCore.removeElementChangedListener(container); ResourcesPlugin.getWorkspace().removeResourceChangeListener(container); } Map<Profile, MetaModel> result = new HashMap<Profile, MetaModel>(); List<IJavaProject> projects = new ArrayList<IJavaProject>(); projects.add(project); try { IProject[] ps = project.getProject().getReferencedProjects(); for (int i = 0; i < ps.length; i++) { IProject p = ps[i]; IJavaProject jp = JavaCore.create(p); if (jp != null) { projects.add(jp); } } } catch (CoreException e1) { Uml2AdapterLog.logError(e1); } Set<IResource> resources = new HashSet<IResource>(); Map<IResource, Profile> models = Uml2AdapterPlugin.getFileModels(); if (!models.isEmpty()) { Set<IJavaProject> jps = new HashSet<IJavaProject>(); for (Iterator<IResource> iter = models.keySet().iterator(); iter.hasNext();) { IFile f = (IFile) iter.next(); if (project.isOnClasspath(f) || isOnProjectsClasspath(f, jps)) { Profile profile = models.get(f); result.put(profile, new ProfileMetaModel(profile)); resources.add(f); } } } container = new MetamodelContainer(projects, resources, new HashSet<MetaModel>(result.values())); JavaCore.addElementChangedListener(container); ResourcesPlugin.getWorkspace().addResourceChangeListener(container); metamodels.put(project, container); } List<MetaModel> all = new ArrayList<MetaModel>(); all.add(new UML2MetaModel()); all.addAll(container.getMetaModels()); return all.toArray(new MetaModel[all.size()]); }
From source file:org.eclipse.xtend.typesystem.uml2.ui.Uml2MetamodelContributor.java
License:Open Source License
private boolean isOnProjectsClasspath(IFile f, Set<IJavaProject> jps) { for (Iterator<IJavaProject> iter = jps.iterator(); iter.hasNext();) { IJavaProject element = iter.next(); if (element.isOnClasspath(f)) { return true; }//from w w w . j a v a 2s .c o m } return false; }
From source file:org.eclipse.xtext.builder.impl.javasupport.JdtToBeBuiltComputer.java
License:Open Source License
protected boolean isBuiltByUpstream(IPackageFragmentRoot root, IProject project, IProject[] projectsInCorrectBuildOrder) { for (IProject p : projectsInCorrectBuildOrder) { if (p.equals(project)) return false; if (XtextProjectHelper.hasNature(p) && XtextProjectHelper.hasBuilder(p)) { IJavaProject javaProject = JavaCore.create(p); if (javaProject.exists()) { if (javaProject.isOnClasspath(root)) { if (log.isTraceEnabled()) log.trace("Build of project '" + project.getName() + "' skips indexing classpath entry '" + root.getPath() + "' because it already indexed by " + javaProject.getElementName()); return true; }/* ww w .j a v a 2 s . co m*/ } } } return false; }
From source file:org.eclipse.xtext.builder.JDTAwareEclipseResourceFileSystemAccess2.java
License:Open Source License
/** * @since 2.6/*w w w . j a v a 2 s . co m*/ */ protected void addToSourceFolders(IContainer container) throws JavaModelException { IJavaProject jp = JavaCore.create(container.getProject()); if (jp.exists() && !jp.isOnClasspath(container)) { IPackageFragmentRoot currentSource = jp .findPackageFragmentRoot(jp.getPath().append(getCurrentSource())); if (currentSource != null) { IClasspathEntry currentClasspathEntry = currentSource.getRawClasspathEntry(); if (currentClasspathEntry != null) { insertClasspathEntry(container, currentClasspathEntry, jp); return; } } addClasspathEntry(container, jp); } }
From source file:org.eclipse.xtext.common.types.access.jdt.WorkingCopyOwnerProvider.java
License:Open Source License
/** * @deprecated This method is not used anymore. It is not necessary that a resource, that contains derived jvm types, is on the project's classpath. * @since 2.9//from w w w.j a va 2s . co m */ @Deprecated protected boolean isOnClassPath(IJavaProject javaProject, IStorage storage) { if (storage instanceof IJarEntryResource) { javaProject.isOnClasspath(((IJarEntryResource) storage).getPackageFragmentRoot()); } if (storage instanceof IResource) { return javaProject.isOnClasspath((IResource) storage); } return false; }
From source file:org.eclipseguru.gwt.core.GwtModule.java
License:Open Source License
/** * Indicates if the specified resource is part of this module. * <p>//ww w.j av a2s .c om * This method just calls <code>{@link #isModulePath(IPath)}</code>. * </p> * * @param resource * @return <code>true</code> if the resource is a module resource, * <code>false</code> otherwise * @throws GwtModelException * @see #isModulePath(IPath) */ public boolean isModuleResource(final IResource resource) throws GwtModelException { // if the resource is below the module path, then consider it a module resource if (isModulePath(resource.getFullPath())) { return true; } // check if resource in reachable from classpath and is within a module package final IJavaProject javaProject = JavaCore.create(getProjectResource()); if (javaProject.isOnClasspath(resource)) { final String resourceFullPath = resource.getFullPath().toString(); final String modulePackageBaseName = getModulePackage().getElementName().replace('.', '/'); final GwtModuleSourceHandler info = getModuleSourceInfo(); for (final String sourcePath : info.getSourcePaths()) { String modulePackageName; if (sourcePath.equals(".") || sourcePath.equals("./") || sourcePath.equals("/") || sourcePath.equals("")) { modulePackageName = modulePackageBaseName; } else { modulePackageName = modulePackageBaseName.concat("/").concat(sourcePath); } if (resourceFullPath.indexOf(modulePackageName) != -1) { // resource is on the classpath *AND* within a module package return true; } } } // give up return false; }