/** * Checks if the given {@link IJavaElement} is not <code>null</code> and exists. * * @param element * The element to check. * @return <code>true</code> if the given element is not <code>null</code> and exists. */ public static boolean exists(IJavaElement element) { return element != null && element.exists(); }
private void processResource(IResource resource, Collection<IAdaptable> result) { IJavaElement elem= JavaCore.create(resource); if (elem != null && elem.exists()) { result.add(elem); } else { result.add(resource); } }
private static boolean canCopyToClipboard(IJavaElement element) throws JavaModelException { if (element == null || ! element.exists()) return false; if (JavaElementUtil.isDefaultPackage(element)) return false; return true; }
private void processResource(IResource resource, Collection<IAdaptable> result) { IJavaElement elem= JavaCore.create(resource); if (elem != null && elem.exists()) { result.add(elem); } else { result.add(resource); } }
private static boolean canCopyToClipboard(IJavaElement element) { if (element == null || ! element.exists()) return false; if (JavaElementUtil.isDefaultPackage(element)) return false; return true; }
private static Set<IJavaElement> extractElements(SearchMatch[] searchResults, int elementType) { Set<IJavaElement> elements= new HashSet<>(); for (int i= 0; i < searchResults.length; i++) { IJavaElement el= SearchUtils.getEnclosingJavaElement(searchResults[i]); if (el.exists() && el.getElementType() == elementType) elements.add(el); } return elements; } }
private static Set extractElements(SearchMatch[] searchResults, int elementType) { Set elements= new HashSet(); for (int i= 0; i < searchResults.length; i++) { IJavaElement el= SearchUtils.getEnclosingJavaElement(searchResults[i]); if (el.exists() && el.getElementType() == elementType) elements.add(el); } return elements; } }
private static Set<IJavaElement> extractElements(SearchMatch[] searchResults, int elementType) { Set<IJavaElement> elements= new HashSet<>(); for (int i= 0; i < searchResults.length; i++) { IJavaElement el= SearchUtils.getEnclosingJavaElement(searchResults[i]); if (el.exists() && el.getElementType() == elementType) { elements.add(el); } } return elements; } }
/** * Verifies that the positioning sibling specified for the <code>element</code> is exists and * its parent is the destination container of this <code>element</code>. */ protected void verifySibling(IJavaElement element, IJavaElement destination) throws JavaModelException { IJavaElement insertBeforeElement = (IJavaElement) this.insertBeforeElements.get(element); if (insertBeforeElement != null) { if (!insertBeforeElement.exists() || !insertBeforeElement.getParent().equals(destination)) { error(IJavaModelStatusConstants.INVALID_SIBLING, insertBeforeElement); } } } }
private void addResource(List<Object> selectedElements, IResource resource) { IJavaElement je= JavaCore.create(resource); if (je != null && je.exists() && je.getElementType() == IJavaElement.COMPILATION_UNIT) selectedElements.add(je); else selectedElements.add(resource); }
/** * Verifies that the positioning sibling specified for the <code>element</code> is exists and * its parent is the destination container of this <code>element</code>. */ protected void verifySibling(IJavaElement element, IJavaElement destination) throws JavaModelException { IJavaElement insertBeforeElement = (IJavaElement) this.insertBeforeElements.get(element); if (insertBeforeElement != null) { if (!insertBeforeElement.exists() || !insertBeforeElement.getParent().equals(destination)) { error(IJavaModelStatusConstants.INVALID_SIBLING, insertBeforeElement); } } } }
public static boolean isDescendantOf(IResource subResource, IJavaElement superElement) { IResource parent= subResource.getParent(); while(parent != null){ IJavaElement el= JavaCore.create(parent); if (el != null && el.exists() && el.equals(superElement)) return true; parent= parent.getParent(); } return false; }
public static boolean isDescendantOf(IResource subResource, IJavaElement superElement) { IResource parent= subResource.getParent(); while(parent != null){ IJavaElement el= JavaCore.create(parent); if (el != null && el.exists() && el.equals(superElement)) { return true; } parent= parent.getParent(); } return false; }
public static boolean isDescendantOf(IResource subResource, IJavaElement superElement) { IResource parent= subResource.getParent(); while(parent != null){ IJavaElement el= JavaCore.create(parent); if (el != null && el.exists() && el.equals(superElement)) return true; parent= parent.getParent(); } return false; }
public void run(IStructuredSelection selection) { IJavaElement element= getJavaElement(selection, false); if (element == null || !element.exists()) { showOperationUnavailableDialog(); return; } else if (element == RETURN_WITHOUT_BEEP) return; run(element); }
protected final IJavaElement getDestinationContainerAsJavaElement() { if (getJavaElementDestination() != null) return getJavaElementDestination(); IContainer destinationAsContainer= getDestinationAsContainer(); if (destinationAsContainer == null) return null; IJavaElement je= JavaCore.create(destinationAsContainer); if (je != null && je.exists()) return je; return null; }
protected final IJavaElement getDestinationContainerAsJavaElement() { if (getJavaElementDestination() != null) return getJavaElementDestination(); IContainer destinationAsContainer= getDestinationAsContainer(); if (destinationAsContainer == null) return null; IJavaElement je= JavaCore.create(destinationAsContainer); if (je != null && je.exists()) return je; return null; }
protected final IJavaElement getDestinationContainerAsJavaElement() { if (getJavaElementDestination() != null) return getJavaElementDestination(); IContainer destinationAsContainer= getDestinationAsContainer(); if (destinationAsContainer == null) return null; IJavaElement je= JavaCore.create(destinationAsContainer); if (je != null && je.exists()) return je; return null; }
protected static void checkExistence(RefactoringStatus status, Object element) { if (element == null) { status.addFatalError(RefactoringCoreMessages.DynamicValidationStateChange_workspace_changed); } else if (element instanceof IResource && !((IResource)element).exists()) { status.addFatalError(Messages.format( RefactoringCoreMessages.Change_does_not_exist, ((IResource)element).getFullPath().toString())); } else if (element instanceof IJavaElement && !((IJavaElement)element).exists()) { status.addFatalError(Messages.format( RefactoringCoreMessages.Change_does_not_exist, ((IJavaElement)element).getElementName())); } }
public RefactoringStatus setDestination(IJavaElement destination) { fDestination= destination; if (ReorgUtils.getCompilationUnit(destination) == null) return RefactoringStatus.createFatalErrorStatus(ReorgMessages.PasteAction_wrong_destination); if (! destination.exists()) return RefactoringStatus.createFatalErrorStatus(ReorgMessages.PasteAction_element_doesnot_exist); if (! canPasteAll(destination)) return RefactoringStatus.createFatalErrorStatus(ReorgMessages.PasteAction_invalid_destination); return new RefactoringStatus(); } private boolean canPasteAll(IJavaElement destination) {