protected boolean equalsOneOf(IPath path, IPath[] otherPaths) { for (int i = 0, length = otherPaths.length; i < length; i++) { if (path.equals(otherPaths[i])) { return true; } } return false; } /**
@Override public boolean equals(Object o) { if (o == null) { return false; } if (o.getClass() != this.getClass()) return false; LinkDescription other = (LinkDescription) o; return localLocation.equals(other.localLocation) && path.equals(other.path) && type == other.type; }
public static int indexOfNestedPath(IPath checkedPath, IPath[] paths, int pathCount) { for (int i = 0; i < pathCount; i++){ if (checkedPath.equals(paths[i])) continue; if (checkedPath.isPrefixOf(paths[i])) return i; } return -1; } /**
public static void verifyRelative(IPath archiveRelativePath) { if (archiveRelativePath.isAbsolute() && !archiveRelativePath.equals(IArchive.EMPTY_MODEL_PATH)) { throw new RuntimeException(archiveRelativePath + " must be relative."); //$NON-NLS-1$ } }
private boolean toBeDeleted(IClasspathEntry entry){ if (entry == null) //safety net return false; return fPathToDelete.equals(entry.getPath()); }
private boolean isDirectChildOfWorkspaceRootFolder(File location) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IPath rootLocationPath = workspace.getRoot().getLocation(); IPath locationPath = Path.fromOSString(location.getPath()); return rootLocationPath.equals(locationPath) || rootLocationPath.equals(locationPath.removeLastSegments(1)); }
@Override public boolean applies(IProgressMonitor monitor) throws OperationCanceledException, CoreException { IPath workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation(); IPath rootPath = ResourceUtils.filePathFromURI(rootFolder.toPath().toUri().toString()); if (workspaceLocation.equals(rootPath)) { return false; } return ProjectUtils.getVisibleProjects(rootPath).isEmpty(); }
private int indexOfClasspath(IClasspathEntry[] entries, IPath path) { for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER && curr.getPath().equals(path)) { return i; } } return -1; }
@Override public ProjectFacade findProject(IPath path) { for (IJavaProject project : openProjects()) { if (project.getPath().equals(path)) { return createProjectFacade(project); } } return null; }
/** * Tests if the package fragment root is located on the project. * * @param root the package fragment root * @return returns <code>true</code> if the package fragment root is the located on the project */ protected boolean isProjectPackageFragmentRoot(IPackageFragmentRoot root) { IJavaProject javaProject= root.getJavaProject(); return javaProject != null && javaProject.getPath().equals(root.getPath()); }
private static CPListElement findElement(IJavaElement element, CPListElement[] elements) { IPath path= element.getPath(); for (int i= 0; i < elements.length; i++) { CPListElement cur= elements[i]; if (cur.getEntryKind() == IClasspathEntry.CPE_SOURCE && cur.getPath().equals(path)) { return cur; } } return null; }
private boolean isOurEntry(IClasspathEntry cpe) { if (cpe.getEntryKind() != IClasspathEntry.CPE_PROJECT) return false; if (!cpe.getPath().equals(getResourcePath())) return false; return true; }
public static boolean isOnSourcePath(IPath sourcePath, IJavaProject project) throws JavaModelException { for (IClasspathEntry entry : project.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().equals(sourcePath)) { return true; } } return false; }
private IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry entry, IJavaProject project, LaunchConfigurationScope configurationScopes) throws CoreException { if (entry.getType() != IRuntimeClasspathEntry.CONTAINER || !entry.getPath().equals(GradleClasspathContainer.CONTAINER_PATH)) { return new IRuntimeClasspathEntry[0]; } return collectContainerRuntimeClasspathIfPresent(project, configurationScopes); }
private IPath getFolderPath(IPath packPath, IPath relpath) { int remainingSegments= packPath.segmentCount() - relpath.segmentCount(); if (remainingSegments >= 0) { IPath common= packPath.removeFirstSegments(remainingSegments); if (common.equals(relpath)) { return packPath.uptoSegment(remainingSegments); } } return null; }
@Override public void bufferCreated(IFileBuffer buffer) { // begin https://bugs.eclipse.org/bugs/show_bug.cgi?id=67821 if (buffer.getLocation().equals(fFile.getFullPath()) && buffer instanceof ITextFileBuffer) { ITextFileBuffer textBuffer= (ITextFileBuffer)buffer; if (fDocumentListener == null) fDocumentListener= new DocumentChangedListener(); textBuffer.getDocument().addDocumentListener(fDocumentListener); } // end fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=67821 } @Override
private static void updateReferencedClasspathEntry(IJavaProject javaProject, IClasspathEntry newEntry, IProgressMonitor monitor) throws JavaModelException { List<IClasspathEntry> newEntries = updateElements(javaProject.getReferencedClasspathEntries(), newEntry, (entry) -> { return entry.getEntryKind() == newEntry.getEntryKind() && entry.getPath().equals(newEntry.getPath()); }); javaProject.setRawClasspath(javaProject.getRawClasspath(), newEntries.toArray(new IClasspathEntry[0]), javaProject.getOutputLocation(), monitor); }
private static void updateContainerClasspath(IJavaProject javaProject, IPath containerPath, IClasspathEntry newEntry) throws CoreException { IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, javaProject); List<IClasspathEntry> newEntries = updateElements(container.getClasspathEntries(), newEntry, (entry) -> { return entry.getEntryKind() == newEntry.getEntryKind() && entry.getPath().equals(newEntry.getPath()); }); IClasspathContainer updatedContainer = new UpdatedClasspathContainer(container, newEntries.toArray(new IClasspathEntry[0])); ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); if (initializer != null) { initializer.requestClasspathContainerUpdate(containerPath, javaProject, updatedContainer); } }
@Override public IClasspathEntry getSelection() { if (fEditResult != null) { if (fOldClasspathEntry != null && fOldClasspathEntry.getPath().equals(fEditResult.getPath())) { return JavaCore.newContainerEntry(fEditResult.getPath(), fOldClasspathEntry.getAccessRules(), fOldClasspathEntry.getExtraAttributes(), fOldClasspathEntry.isExported()); } else { return JavaCore.newContainerEntry(fEditResult.getPath(), false); } } return null; }
@Override public boolean equals(Object obj) { if (obj instanceof LibraryLocation) { LibraryLocation lib = (LibraryLocation)obj; return getSystemLibraryPath().equals(lib.getSystemLibraryPath()) && equals(getSystemLibrarySourcePath(), lib.getSystemLibrarySourcePath()) && equals(getExternalAnnotationsPath(), lib.getExternalAnnotationsPath()) && equals(getPackageRootPath(), lib.getPackageRootPath()) && LaunchingPlugin.sameURL(getJavadocLocation(), lib.getJavadocLocation()); } return false; }