/** * This methods checks whether the given package fragment root is still on the * classpath. This check is required as the user might change the classpath * and old coverage sessions afterwards (SF #1836551). * * @param root * package fragment root * @return true, if the classpath entry still exists * @throws JavaModelException */ private boolean isOnClasspath(IPackageFragmentRoot root) throws JavaModelException { IPath path = root.getPath(); IJavaProject project = root.getJavaProject(); return project.findPackageFragmentRoot(path) != null; }
private IPackageFragmentRoot findPackageFragmentRoot(IJavaProject jProject, IPath path) throws JavaModelException { if (jProject == null || path == null || path.segmentCount() <= 0) return null; IPackageFragmentRoot pkgRoot= jProject.findPackageFragmentRoot(path); if (pkgRoot != null) return pkgRoot; else return findPackageFragmentRoot(jProject, path.removeLastSegments(1)); }
private IPackageFragmentRoot findPackageFragmentRoot(IJavaProject jProject, IPath path) throws JavaModelException { if (jProject == null || path == null || path.segmentCount() <= 0) return null; IPackageFragmentRoot pkgRoot= jProject.findPackageFragmentRoot(path); if (pkgRoot != null) return pkgRoot; else return findPackageFragmentRoot(jProject, path.removeLastSegments(1)); }
private IPackageFragmentRoot findPackageFragmentRoot(IJavaProject jProject, IPath path) throws JavaModelException { if (jProject == null || path == null || path.segmentCount() <= 0) return null; IPackageFragmentRoot pkgRoot= jProject.findPackageFragmentRoot(path); if (pkgRoot != null) return pkgRoot; else return findPackageFragmentRoot(jProject, path.removeLastSegments(1)); }
private IPackageFragmentRoot findPackageFragmentRoot(IJavaProject jProject, IPath path) throws JavaModelException { if (jProject == null || path == null || path.segmentCount() <= 0) return null; IPackageFragmentRoot pkgRoot= jProject.findPackageFragmentRoot(path); if (pkgRoot != null) return pkgRoot; else return findPackageFragmentRoot(jProject, path.removeLastSegments(1)); }
private void removeUnconfirmedReferencedArchiveFiles(IConfirmQuery query) throws JavaModelException, OperationCanceledException { List filesToSkip= new ArrayList(0); for (int i= 0; i < fResources.length; i++) { IResource resource= fResources[i]; if (! (resource instanceof IFile)) continue; IJavaProject project= JavaCore.create(resource.getProject()); if (project == null || ! project.exists()) continue; IPackageFragmentRoot root= project.findPackageFragmentRoot(resource.getFullPath()); if (root == null) continue; List referencingProjects= Arrays.asList(JavaElementUtil.getReferencingProjects(root)); if (skipDeletingReferencedRoot(query, root, referencingProjects)) filesToSkip.add(resource); } removeFromSetToDelete((IFile[]) filesToSkip.toArray(new IFile[filesToSkip.size()])); }
private void removeUnconfirmedReferencedArchiveFiles(IConfirmQuery query) throws JavaModelException, OperationCanceledException { List<IResource> filesToSkip= new ArrayList<>(0); for (int i= 0; i < fResources.length; i++) { IResource resource= fResources[i]; if (! (resource instanceof IFile)) continue; IJavaProject project= JavaCore.create(resource.getProject()); if (project == null || ! project.exists()) continue; IPackageFragmentRoot root= project.findPackageFragmentRoot(resource.getFullPath()); if (root == null) continue; List<IJavaProject> referencingProjects= Arrays.asList(JavaElementUtil.getReferencingProjects(root)); if (skipDeletingReferencedRoot(query, root, referencingProjects)) filesToSkip.add(resource); } removeFromSetToDelete(filesToSkip.toArray(new IFile[filesToSkip.size()])); }
public void removeFromInvalidArchiveCache(IPath path) { if (this.invalidArchives != null) { if (this.invalidArchives.remove(path) != null) { try { // Bug 455042: Force an update of the JavaProjectElementInfo project caches. for (IJavaProject project : getJavaModel().getJavaProjects()) { if (project.findPackageFragmentRoot(path) != null) { ((JavaProject) project).resetCaches(); } } } catch (JavaModelException e) { Util.log(e, "Unable to retrieve the Java model."); //$NON-NLS-1$ } } } }
@Override public boolean isSelectedValid(Object element) { try { if (element instanceof IJavaProject) { IJavaProject jproject= (IJavaProject) element; IPath path= jproject.getProject().getFullPath(); return (jproject.findPackageFragmentRoot(path) != null); } else if (element instanceof IPackageFragmentRoot) { return (((IPackageFragmentRoot) element).getKind() == IPackageFragmentRoot.K_SOURCE); } return true; } catch (JavaModelException e) { // fall through returning false } return false; } }
public boolean isSelectedValid(Object element) { try { if (element instanceof IJavaProject) { IJavaProject jproject= (IJavaProject) element; IPath path= jproject.getProject().getFullPath(); return (jproject.findPackageFragmentRoot(path) != null); } else if (element instanceof IPackageFragmentRoot) { return (((IPackageFragmentRoot) element).getKind() == IPackageFragmentRoot.K_SOURCE); } return true; } catch (JavaModelException e) { // fall through returning false } return false; } }
/** * Check whether the provided file is an archive (.jar or .zip). * * @param file the file to be checked * @param project the Java project * @return <code>true</code> if the file is an archive, <code>false</code> * otherwise * @throws JavaModelException */ public static boolean isArchive(IFile file, IJavaProject project) throws JavaModelException { if (!ArchiveFileFilter.isArchivePath(file.getFullPath(), true)) return false; if (project != null && project.exists() && (project.findPackageFragmentRoot(file.getFullPath()) == null)) return true; return false; }
/** * Check whether the provided file is an archive (.jar or .zip). * * @param file the file to be checked * @param project the Java project * @return <code>true</code> if the file is an archive, <code>false</code> * otherwise * @throws JavaModelException */ public static boolean isArchive(IFile file, IJavaProject project) throws JavaModelException { if (!ArchiveFileFilter.isArchivePath(file.getFullPath(), true)) return false; if (project != null && project.exists() && (project.findPackageFragmentRoot(file.getFullPath()) == null)) return true; return false; }
/** * Check whether the provided file is an archive (.jar or .zip). * * @param file the file to be checked * @param project the Java project * @return <code>true</code> if the file is an archive, <code>false</code> * otherwise * @throws JavaModelException */ public static boolean isArchive(IFile file, IJavaProject project) throws JavaModelException { if (!ArchiveFileFilter.isArchivePath(file.getFullPath())) return false; if (project != null && project.exists() && (project.findPackageFragmentRoot(file.getFullPath()) == null)) return true; return false; }
public boolean isSelectedValid(Object element) { try { if (element instanceof IJavaProject) { IJavaProject jproject= (IJavaProject)element; IPath path= jproject.getProject().getFullPath(); return (jproject.findPackageFragmentRoot(path) != null); } else if (element instanceof IPackageFragmentRoot) { return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE); } return true; } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); // just log, no ui in validation } return false; } };
@Override public boolean isSelectedValid(Object element) { try { if (element instanceof IJavaProject) { IJavaProject jproject= (IJavaProject)element; IPath path= jproject.getProject().getFullPath(); return (jproject.findPackageFragmentRoot(path) != null); } else if (element instanceof IPackageFragmentRoot) { return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE); } return true; } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); // just log, no UI in validation } return false; } };
public boolean isSelectedValid(Object element) { try { if (element instanceof IJavaProject) { IJavaProject jproject= (IJavaProject)element; IPath path= jproject.getProject().getFullPath(); return (jproject.findPackageFragmentRoot(path) != null); } else if (element instanceof IPackageFragmentRoot) { return (((IPackageFragmentRoot)element).getKind() == IPackageFragmentRoot.K_SOURCE); } return true; } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); // just log, no UI in validation } return false; } };
private static IFile getCandidate(IAdaptable element) throws JavaModelException { IResource resource = (IResource) element.getAdapter(IResource.class); if (!(resource instanceof IFile) || !ArchiveFileFilter.isArchivePath(resource.getFullPath())) return null; IJavaProject project = JavaCore.create(resource.getProject()); if (project != null && project.exists() && (project.findPackageFragmentRoot(resource.getFullPath()) == null)) return (IFile) resource; return null; }
private static IFile getCandidate(IAdaptable element) throws JavaModelException { IResource resource= element.getAdapter(IResource.class); if (! (resource instanceof IFile) || ! ArchiveFileFilter.isArchivePath(resource.getFullPath(), true)) return null; IJavaProject project= JavaCore.create(resource.getProject()); if (project != null && project.exists() && (project.findPackageFragmentRoot(resource.getFullPath()) == null)) return (IFile) resource; return null; }
private static IFile getCandidate(IAdaptable element) throws JavaModelException { IResource resource= element.getAdapter(IResource.class); if (! (resource instanceof IFile) || ! ArchiveFileFilter.isArchivePath(resource.getFullPath(), true)) return null; IJavaProject project= JavaCore.create(resource.getProject()); if (project != null && project.exists() && (project.findPackageFragmentRoot(resource.getFullPath()) == null)) return (IFile) resource; return null; }
private static IFile getCandidate(IAdaptable element) throws JavaModelException { IResource resource= (IResource)element.getAdapter(IResource.class); if (! (resource instanceof IFile) || ! ArchiveFileFilter.isArchivePath(resource.getFullPath())) return null; IJavaProject project= JavaCore.create(resource.getProject()); if (project != null && project.exists() && (project.findPackageFragmentRoot(resource.getFullPath()) == null)) return (IFile) resource; return null; }