Java Code Examples for org.eclipse.jdt.core.IPackageFragmentRoot#equals()
The following examples show how to use
org.eclipse.jdt.core.IPackageFragmentRoot#equals() .
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: Storage2UriMapperJavaImpl.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void addRoot(IPackageFragmentRoot root) { if (root != null) { // Do not cache intermediate bridge objects if ("JImageModuleFragmentBridge".equals(root.getClass().getSimpleName())) { return; } String handleIdentifier = root.getHandleIdentifier(); Map<String, IPackageFragmentRoot> roots = associatedRoots; if (!root.equals(roots.get(handleIdentifier))) { Map<String,IPackageFragmentRoot> copy = newLinkedHashMap(roots); copy.put(handleIdentifier, root); associatedRoots = copy; } } }
Example 2
Source File: OverwriteHelper.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private boolean canOverwrite(IPackageFragment pack) { if (fDestination instanceof IPackageFragmentRoot) { IPackageFragmentRoot destination= (IPackageFragmentRoot)fDestination; return ! destination.equals(pack.getParent()) && destination.getPackageFragment(pack.getElementName()).exists(); } else { return willOverwrite(pack.getResource()); } }
Example 3
Source File: OverwriteHelper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean canOverwrite(IPackageFragment pack) { if (fDestination instanceof IPackageFragmentRoot) { IPackageFragmentRoot destination= (IPackageFragmentRoot)fDestination; return ! destination.equals(pack.getParent()) && destination.getPackageFragment(pack.getElementName()).exists(); } else { return willOverwrite(pack.getResource()); } }
Example 4
Source File: BinaryRefactoringHistoryWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Checks whether the archive referenced by the package fragment root is not * shared with multiple java projects in the workspace. * * @param root * the package fragment root * @param monitor * the progress monitor to use * @return the status of the operation */ private static RefactoringStatus checkPackageFragmentRoots(final IPackageFragmentRoot root, final IProgressMonitor monitor) { final RefactoringStatus status= new RefactoringStatus(); try { monitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, 100); final IWorkspaceRoot workspace= ResourcesPlugin.getWorkspace().getRoot(); if (workspace != null) { final IJavaModel model= JavaCore.create(workspace); if (model != null) { try { final URI uri= getLocationURI(root.getRawClasspathEntry()); if (uri != null) { final IJavaProject[] projects= model.getJavaProjects(); final IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL); try { subMonitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, projects.length * 100); for (int index= 0; index < projects.length; index++) { final IPackageFragmentRoot[] roots= projects[index].getPackageFragmentRoots(); final IProgressMonitor subsubMonitor= new SubProgressMonitor(subMonitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL); try { subsubMonitor.beginTask(JarImportMessages.JarImportWizard_prepare_import, roots.length); for (int offset= 0; offset < roots.length; offset++) { final IPackageFragmentRoot current= roots[offset]; if (!current.equals(root) && current.getKind() == IPackageFragmentRoot.K_BINARY) { final IClasspathEntry entry= current.getRawClasspathEntry(); if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { final URI location= getLocationURI(entry); if (uri.equals(location)) status.addFatalError(Messages.format(JarImportMessages.JarImportWizard_error_shared_jar, new String[] { JavaElementLabels.getElementLabel(current.getJavaProject(), JavaElementLabels.ALL_DEFAULT) })); } } subsubMonitor.worked(1); } } finally { subsubMonitor.done(); } } } finally { subMonitor.done(); } } } catch (CoreException exception) { status.addError(exception.getLocalizedMessage()); } } } } finally { monitor.done(); } return status; }
Example 5
Source File: NewTypeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Hook method that gets called when the enclosing type name has changed. The method * validates the enclosing type and returns the status of the validation. It also updates the * enclosing type model. * <p> * Subclasses may extend this method to perform their own validation. * </p> * * @return the status of the validation */ protected IStatus enclosingTypeChanged() { StatusInfo status= new StatusInfo(); fCurrEnclosingType= null; IPackageFragmentRoot root= getPackageFragmentRoot(); fEnclosingTypeDialogField.enableButton(root != null); if (root == null) { status.setError(""); //$NON-NLS-1$ return status; } String enclName= getEnclosingTypeText(); if (enclName.length() == 0) { status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingTypeEnterName); return status; } try { IType type= findType(root.getJavaProject(), enclName); if (type == null) { status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingTypeNotExists); return status; } if (type.getCompilationUnit() == null) { status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingNotInCU); return status; } if (!JavaModelUtil.isEditable(type.getCompilationUnit())) { status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingNotEditable); return status; } fCurrEnclosingType= type; IPackageFragmentRoot enclosingRoot= JavaModelUtil.getPackageFragmentRoot(type); if (!enclosingRoot.equals(root)) { status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_EnclosingNotInSourceFolder); } return status; } catch (JavaModelException e) { status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingTypeNotExists); JavaPlugin.log(e); return status; } }
Example 6
Source File: ClassFileDocumentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Recursively check whether the class file has been deleted. * * @param input the package fragment root * @param delta the Java element delta * @return <code>true</code> if delta processing can be stopped */ protected boolean check(IPackageFragmentRoot input, IJavaElementDelta delta) { IJavaElement element= delta.getElement(); if ((delta.getKind() & IJavaElementDelta.REMOVED) != 0 || (delta.getFlags() & IJavaElementDelta.F_CLOSED) != 0) { // http://dev.eclipse.org/bugs/show_bug.cgi?id=19023 if (element.equals(input.getJavaProject()) || element.equals(input)) { handleDeleted(fInput); return true; } } if (((delta.getFlags() & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) && input.equals(element)) { handleDeleted(fInput); return true; } if (((delta.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) && input.equals(element)) { handleDeleted(fInput); return true; } IJavaElementDelta[] subdeltas= delta.getAffectedChildren(); for (int i= 0; i < subdeltas.length; i++) { if (check(input, subdeltas[i])) return true; } if ((delta.getFlags() & IJavaElementDelta.F_SOURCEDETACHED) != 0 || (delta.getFlags() & IJavaElementDelta.F_SOURCEATTACHED) != 0) { IClassFile file= fInput != null ? fInput.getClassFile() : null; IJavaProject project= input != null ? input.getJavaProject() : null; boolean isOnClasspath= false; if (file != null && project != null) isOnClasspath= project.isOnClasspath(file); if (isOnClasspath) { fireInputChanged(fInput); return false; } else { handleDeleted(fInput); return true; } } return false; }