Java Code Examples for org.eclipse.jdt.core.IJavaElement#CLASS_FILE
The following examples show how to use
org.eclipse.jdt.core.IJavaElement#CLASS_FILE .
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: GenericRefactoringHandleTransplanter.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
protected IType transplantHandle(IJavaElement parent, IType element) { switch (parent.getElementType()) { case IJavaElement.COMPILATION_UNIT: return ((ICompilationUnit) parent).getType(element.getElementName()); case IJavaElement.CLASS_FILE: if (parent instanceof IOrdinaryClassFile) { return ((IOrdinaryClassFile) parent).getType(); } throw new IllegalStateException(element.toString()); case IJavaElement.METHOD: return ((IMethod) parent).getType(element.getElementName(), element.getOccurrenceCount()); case IJavaElement.FIELD: return ((IField) parent).getType(element.getElementName(), element.getOccurrenceCount()); case IJavaElement.INITIALIZER: return ((IInitializer) parent).getType(element.getElementName(), element.getOccurrenceCount()); case IJavaElement.TYPE: return ((IType) parent).getType(element.getElementName(), element.getOccurrenceCount()); default: throw new IllegalStateException(element.toString()); } }
Example 2
Source File: JavaSearchScope.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private IPath getPath(IJavaElement element, boolean relativeToRoot) { switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: return Path.EMPTY; case IJavaElement.JAVA_PROJECT: return element.getPath(); case IJavaElement.PACKAGE_FRAGMENT_ROOT: if (relativeToRoot) return Path.EMPTY; return element.getPath(); case IJavaElement.PACKAGE_FRAGMENT: String relativePath = Util.concatWith(((PackageFragment) element).names, '/'); return getPath(element.getParent(), relativeToRoot).append(new Path(relativePath)); case IJavaElement.COMPILATION_UNIT: case IJavaElement.CLASS_FILE: return getPath(element.getParent(), relativeToRoot).append(new Path(element.getElementName())); default: return getPath(element.getParent(), relativeToRoot); } }
Example 3
Source File: RefactoringModifications.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
protected IResource[] collectResourcesOfInterest(IPackageFragment source) throws CoreException { IJavaElement[] children = source.getChildren(); int childOfInterest = IJavaElement.COMPILATION_UNIT; if (source.getKind() == IPackageFragmentRoot.K_BINARY) { childOfInterest = IJavaElement.CLASS_FILE; } ArrayList<IResource> result = new ArrayList<>(children.length); for (int i = 0; i < children.length; i++) { IJavaElement child = children[i]; if (child.getElementType() == childOfInterest && child.getResource() != null) { result.add(child.getResource()); } } // Gather non-java resources Object[] nonJavaResources = source.getNonJavaResources(); for (int i= 0; i < nonJavaResources.length; i++) { Object element= nonJavaResources[i]; if (element instanceof IResource) { result.add((IResource) element); } } return result.toArray(new IResource[result.size()]); }
Example 4
Source File: JavaModelCache.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public IJavaElement getExistingElement(IJavaElement element) { switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: return element; case IJavaElement.JAVA_PROJECT: return element; // projectCache is a Hashtable and Hashtables don't support getKey(...) case IJavaElement.PACKAGE_FRAGMENT_ROOT: return (IJavaElement) this.rootCache.getKey(element); case IJavaElement.PACKAGE_FRAGMENT: return (IJavaElement) this.pkgCache.getKey(element); case IJavaElement.COMPILATION_UNIT: case IJavaElement.CLASS_FILE: return (IJavaElement) this.openableCache.getKey(element); case IJavaElement.TYPE: return element; // jarTypeCache or childrenCache are Hashtables and Hashtables don't support getKey(...) default: return element; // childrenCache is a Hashtable and Hashtables don't support getKey(...) } }
Example 5
Source File: JavaModelCache.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Removes the info of the element from the cache. */ protected void removeInfo(JavaElement element) { switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: this.modelInfo = null; break; case IJavaElement.JAVA_PROJECT: this.projectCache.remove(element); this.rootCache.resetSpaceLimit((int) (DEFAULT_ROOT_SIZE * getMemoryRatio()), element); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: this.rootCache.remove(element); this.pkgCache.resetSpaceLimit((int) (DEFAULT_PKG_SIZE * getMemoryRatio()), element); break; case IJavaElement.PACKAGE_FRAGMENT: this.pkgCache.remove(element); this.openableCache.resetSpaceLimit((int) (DEFAULT_OPENABLE_SIZE * getMemoryRatio() * getOpenableRatio()), element); break; case IJavaElement.COMPILATION_UNIT: case IJavaElement.CLASS_FILE: this.openableCache.remove(element); break; default: this.childrenCache.remove(element); } }
Example 6
Source File: JarPackageWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addJavaElement(List<Object> selectedElements, IJavaElement je) { if (je.getElementType() == IJavaElement.COMPILATION_UNIT) selectedElements.add(je); else if (je.getElementType() == IJavaElement.CLASS_FILE) selectedElements.add(je); else if (je.getElementType() == IJavaElement.JAVA_PROJECT) selectedElements.add(je); else if (je.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { if (!isInArchiveOrExternal(je)) selectedElements.add(je); } else if (je.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT) { if (!isInArchiveOrExternal(je)) selectedElements.add(je); } else { IOpenable openable= je.getOpenable(); if (openable instanceof ICompilationUnit) selectedElements.add(((ICompilationUnit) openable).getPrimary()); else if (openable instanceof IClassFile && !isInArchiveOrExternal(je)) selectedElements.add(openable); } }
Example 7
Source File: JavaOutlinePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Checks whether a given Java element is an inner type. * * @param element the java element * @return <code>true</code> iff the given element is an inner type */ private boolean isInnerType(IJavaElement element) { if (element != null && element.getElementType() == IJavaElement.TYPE) { IType type= (IType)element; try { return type.isMember(); } catch (JavaModelException e) { IJavaElement parent= type.getParent(); if (parent != null) { int parentElementType= parent.getElementType(); return (parentElementType != IJavaElement.COMPILATION_UNIT && parentElementType != IJavaElement.CLASS_FILE); } } } return false; }
Example 8
Source File: CopyToClipboardAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void processJavaElements(Set<String> fileNames, StringBuffer namesBuf) { for (int i= 0; i < fJavaElements.length; i++) { IJavaElement element= fJavaElements[i]; switch (element.getElementType()) { case IJavaElement.JAVA_PROJECT : case IJavaElement.PACKAGE_FRAGMENT_ROOT : case IJavaElement.PACKAGE_FRAGMENT : case IJavaElement.COMPILATION_UNIT : case IJavaElement.CLASS_FILE : addFileName(fileNames, ReorgUtils.getResource(element)); break; default : break; } if (namesBuf.length() > 0 || i > 0) namesBuf.append(System.getProperty("line.separator")); //$NON-NLS-1$ namesBuf.append(getName(element)); } }
Example 9
Source File: JavaModelCache.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns the info for the element. */ public Object getInfo(IJavaElement element) { switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: return this.modelInfo; case IJavaElement.JAVA_PROJECT: return this.projectCache.get(element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return this.rootCache.get(element); case IJavaElement.PACKAGE_FRAGMENT: return this.pkgCache.get(element); case IJavaElement.COMPILATION_UNIT: case IJavaElement.CLASS_FILE: return this.openableCache.get(element); case IJavaElement.TYPE: Object result = this.jarTypeCache.get(element); if (result != null) return result; else return this.childrenCache.get(element); default: return this.childrenCache.get(element); } }
Example 10
Source File: JavaElementResourceMapping.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static ResourceMapping create(IJavaElement element) { switch (element.getElementType()) { case IJavaElement.TYPE: return create((IType)element); case IJavaElement.COMPILATION_UNIT: return create((ICompilationUnit)element); case IJavaElement.CLASS_FILE: return create((IClassFile)element); case IJavaElement.PACKAGE_FRAGMENT: return create((IPackageFragment)element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return create((IPackageFragmentRoot)element); case IJavaElement.JAVA_PROJECT: return create((IJavaProject)element); case IJavaElement.JAVA_MODEL: return create((IJavaModel)element); default: return null; } }
Example 11
Source File: JavaOutlineInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean isInnerType(IJavaElement element) { if (element != null && element.getElementType() == IJavaElement.TYPE) { IType type= (IType)element; try { return type.isMember(); } catch (JavaModelException e) { IJavaElement parent= type.getParent(); if (parent != null) { int parentElementType= parent.getElementType(); return (parentElementType != IJavaElement.COMPILATION_UNIT && parentElementType != IJavaElement.CLASS_FILE); } } } return false; }
Example 12
Source File: JavaDeleteProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public boolean needsProgressMonitor() { if (fResources != null && fResources.length > 0) return true; if (fJavaElements != null) { for (int i= 0; i < fJavaElements.length; i++) { int type= fJavaElements[i].getElementType(); if (type <= IJavaElement.CLASS_FILE) return true; } } return false; }
Example 13
Source File: DeleteChangeCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static Change createDeleteChange(IJavaElement javaElement) throws JavaModelException { Assert.isTrue(! ReorgUtils.isInsideCompilationUnit(javaElement)); switch(javaElement.getElementType()){ case IJavaElement.PACKAGE_FRAGMENT_ROOT: return createPackageFragmentRootDeleteChange((IPackageFragmentRoot)javaElement); case IJavaElement.PACKAGE_FRAGMENT: return createSourceManipulationDeleteChange((IPackageFragment)javaElement); case IJavaElement.COMPILATION_UNIT: return createSourceManipulationDeleteChange((ICompilationUnit)javaElement); case IJavaElement.CLASS_FILE: //if this assert fails, it means that a precondition is missing Assert.isTrue(((IClassFile)javaElement).getResource() instanceof IFile); return createDeleteChange(((IClassFile)javaElement).getResource()); case IJavaElement.JAVA_MODEL: //cannot be done Assert.isTrue(false); return null; case IJavaElement.JAVA_PROJECT: //handled differently Assert.isTrue(false); return null; case IJavaElement.TYPE: case IJavaElement.FIELD: case IJavaElement.METHOD: case IJavaElement.INITIALIZER: case IJavaElement.PACKAGE_DECLARATION: case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: Assert.isTrue(false);//not done here return new NullChange(); default: Assert.isTrue(false);//there's no more kinds return new NullChange(); } }
Example 14
Source File: TypeHierarchyLifeCycle.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void processDelta(IJavaElementDelta delta, ArrayList<IType> changedTypes) { IJavaElement element= delta.getElement(); switch (element.getElementType()) { case IJavaElement.TYPE: processTypeDelta((IType) element, changedTypes); processChildrenDelta(delta, changedTypes); // (inner types) break; case IJavaElement.JAVA_MODEL: case IJavaElement.JAVA_PROJECT: case IJavaElement.PACKAGE_FRAGMENT_ROOT: case IJavaElement.PACKAGE_FRAGMENT: processChildrenDelta(delta, changedTypes); break; case IJavaElement.COMPILATION_UNIT: ICompilationUnit cu= (ICompilationUnit)element; if (!JavaModelUtil.isPrimary(cu)) { return; } if (delta.getKind() == IJavaElementDelta.CHANGED && isPossibleStructuralChange(delta.getFlags())) { try { if (cu.exists()) { IType[] types= cu.getAllTypes(); for (int i= 0; i < types.length; i++) { processTypeDelta(types[i], changedTypes); } } } catch (JavaModelException e) { JavaPlugin.log(e); } } else { processChildrenDelta(delta, changedTypes); } break; case IJavaElement.CLASS_FILE: if (delta.getKind() == IJavaElementDelta.CHANGED) { IType type= ((IClassFile) element).getType(); processTypeDelta(type, changedTypes); } else { processChildrenDelta(delta, changedTypes); } break; } }
Example 15
Source File: InterfaceIndicatorLabelDecorator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected void processDelta(IJavaElementDelta delta, List<IJavaElement> result) { IJavaElement elem= delta.getElement(); boolean isChanged= delta.getKind() == IJavaElementDelta.CHANGED; boolean isRemoved= delta.getKind() == IJavaElementDelta.REMOVED; int flags= delta.getFlags(); switch (elem.getElementType()) { case IJavaElement.JAVA_PROJECT: if (isRemoved || (isChanged && (flags & IJavaElementDelta.F_CLOSED) != 0)) { return; } processChildrenDelta(delta, result); return; case IJavaElement.PACKAGE_FRAGMENT_ROOT: if (isRemoved || (isChanged && ( (flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0 || (flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0))) { return; } processChildrenDelta(delta, result); return; case IJavaElement.PACKAGE_FRAGMENT: if (isRemoved) return; processChildrenDelta(delta, result); return; case IJavaElement.TYPE: case IJavaElement.CLASS_FILE: return; case IJavaElement.JAVA_MODEL: processChildrenDelta(delta, result); return; case IJavaElement.COMPILATION_UNIT: // Not the primary compilation unit. Ignore it if (!JavaModelUtil.isPrimary((ICompilationUnit) elem)) { return; } if (isChanged && ((flags & IJavaElementDelta.F_CONTENT) != 0 || (flags & IJavaElementDelta.F_FINE_GRAINED) != 0)) { if (delta.getAffectedChildren().length == 0) return; result.add(elem); } return; default: // fields, methods, imports ect return; } }
Example 16
Source File: OpenTypeHierarchyAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private static IStatus compileCandidates(List<IJavaElement> result, List<IJavaElement> elements) { IStatus ok= Status.OK_STATUS; boolean onlyContainers= true; for (Iterator<IJavaElement> iter= elements.iterator(); iter.hasNext();) { IJavaElement elem= iter.next(); try { switch (elem.getElementType()) { case IJavaElement.INITIALIZER: case IJavaElement.METHOD: case IJavaElement.FIELD: case IJavaElement.TYPE: onlyContainers= false; //$FALL-THROUGH$ case IJavaElement.PACKAGE_FRAGMENT_ROOT: case IJavaElement.JAVA_PROJECT: result.add(elem); break; case IJavaElement.PACKAGE_FRAGMENT: if (((IPackageFragment)elem).containsJavaResources()) result.add(elem); break; case IJavaElement.PACKAGE_DECLARATION: result.add(elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT)); break; case IJavaElement.IMPORT_DECLARATION: IImportDeclaration decl= (IImportDeclaration)elem; if (decl.isOnDemand()) elem= JavaModelUtil.findTypeContainer(elem.getJavaProject(), Signature.getQualifier(elem.getElementName())); else elem= elem.getJavaProject().findType(elem.getElementName()); if (elem != null) { onlyContainers= false; result.add(elem); } break; case IJavaElement.CLASS_FILE: onlyContainers= false; result.add(((IClassFile)elem).getType()); break; case IJavaElement.COMPILATION_UNIT: ICompilationUnit cu= (ICompilationUnit)elem; IType[] types= cu.getTypes(); if (types.length > 0) { onlyContainers= false; result.addAll(Arrays.asList(types)); } } } catch (JavaModelException e) { return e.getStatus(); } } int size= result.size(); if (size == 0 || (size > 1 && !onlyContainers)) return createStatus(ActionMessages.OpenTypeHierarchyAction_messages_no_valid_java_element); return ok; }
Example 17
Source File: OpenTypeHistory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Computes whether the history needs a consistency check or not. * * @param delta the Java element delta * * @return <code>true</code> if consistency must be checked * <code>false</code> otherwise. */ private boolean processDelta(IJavaElementDelta delta) { IJavaElement elem= delta.getElement(); boolean isChanged= delta.getKind() == IJavaElementDelta.CHANGED; boolean isRemoved= delta.getKind() == IJavaElementDelta.REMOVED; switch (elem.getElementType()) { case IJavaElement.JAVA_PROJECT: if (isRemoved || (isChanged && (delta.getFlags() & IJavaElementDelta.F_CLOSED) != 0)) { return true; } return processChildrenDelta(delta); case IJavaElement.PACKAGE_FRAGMENT_ROOT: if (isRemoved || (isChanged && ( (delta.getFlags() & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0 || (delta.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0))) { return true; } return processChildrenDelta(delta); case IJavaElement.TYPE: if (isChanged && (delta.getFlags() & IJavaElementDelta.F_MODIFIERS) != 0) { return true; } if (isRemoved) { return true; } return processChildrenDelta(delta); case IJavaElement.JAVA_MODEL: case IJavaElement.PACKAGE_FRAGMENT: case IJavaElement.CLASS_FILE: if (isRemoved) { return true; } return processChildrenDelta(delta); case IJavaElement.COMPILATION_UNIT: // Not the primary compilation unit. Ignore it if (!JavaModelUtil.isPrimary((ICompilationUnit) elem)) { return false; } if (isRemoved || (isChanged && isUnknownStructuralChange(delta.getFlags()))) { return true; } return processChildrenDelta(delta); default: // fields, methods, imports ect return false; } }
Example 18
Source File: JavaElementLabelComposer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Appends the label for a Java element with the flags as defined by this class. * * @param element the element to render * @param flags the rendering flags. */ public void appendElementLabel(IJavaElement element, long flags) { int type= element.getElementType(); IPackageFragmentRoot root= null; if (type != IJavaElement.JAVA_MODEL && type != IJavaElement.JAVA_PROJECT && type != IJavaElement.PACKAGE_FRAGMENT_ROOT) root= JavaModelUtil.getPackageFragmentRoot(element); if (root != null && getFlag(flags, JavaElementLabels.PREPEND_ROOT_PATH)) { appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED); fBuffer.append(JavaElementLabels.CONCAT_STRING); } switch (type) { case IJavaElement.METHOD: appendMethodLabel((IMethod) element, flags); break; case IJavaElement.FIELD: appendFieldLabel((IField) element, flags); break; case IJavaElement.LOCAL_VARIABLE: appendLocalVariableLabel((ILocalVariable) element, flags); break; case IJavaElement.TYPE_PARAMETER: appendTypeParameterLabel((ITypeParameter) element, flags); break; case IJavaElement.INITIALIZER: appendInitializerLabel((IInitializer) element, flags); break; case IJavaElement.TYPE: appendTypeLabel((IType) element, flags); break; case IJavaElement.CLASS_FILE: appendClassFileLabel((IClassFile) element, flags); break; case IJavaElement.COMPILATION_UNIT: appendCompilationUnitLabel((ICompilationUnit) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT: appendPackageFragmentLabel((IPackageFragment) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: appendPackageFragmentRootLabel((IPackageFragmentRoot) element, flags); break; case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: case IJavaElement.PACKAGE_DECLARATION: appendDeclarationLabel(element, flags); break; case IJavaElement.JAVA_PROJECT: case IJavaElement.JAVA_MODEL: fBuffer.append(element.getElementName()); break; default: fBuffer.append(element.getElementName()); } if (root != null && getFlag(flags, JavaElementLabels.APPEND_ROOT_PATH)) { int offset= fBuffer.length(); fBuffer.append(JavaElementLabels.CONCAT_STRING); appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED); if (getFlag(flags, JavaElementLabels.COLORIZE)) { fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); } } }
Example 19
Source File: ReorgUtils.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private static String createNamePattern(IJavaElement element) throws JavaModelException { switch(element.getElementType()){ case IJavaElement.CLASS_FILE: return RefactoringCoreMessages.ReorgUtils_3; case IJavaElement.COMPILATION_UNIT: return RefactoringCoreMessages.ReorgUtils_4; case IJavaElement.FIELD: return RefactoringCoreMessages.ReorgUtils_5; case IJavaElement.IMPORT_CONTAINER: return RefactoringCoreMessages.ReorgUtils_6; case IJavaElement.IMPORT_DECLARATION: return RefactoringCoreMessages.ReorgUtils_7; case IJavaElement.INITIALIZER: return RefactoringCoreMessages.ReorgUtils_8; case IJavaElement.JAVA_PROJECT: return RefactoringCoreMessages.ReorgUtils_9; case IJavaElement.METHOD: if (((IMethod)element).isConstructor()) { return RefactoringCoreMessages.ReorgUtils_10; } else { return RefactoringCoreMessages.ReorgUtils_11; } case IJavaElement.PACKAGE_DECLARATION: return RefactoringCoreMessages.ReorgUtils_12; case IJavaElement.PACKAGE_FRAGMENT: if (JavaElementUtil.isDefaultPackage(element)) { return RefactoringCoreMessages.ReorgUtils_13; } else { return RefactoringCoreMessages.ReorgUtils_14; } case IJavaElement.PACKAGE_FRAGMENT_ROOT: if (((IPackageFragmentRoot) element).isArchive()) { return RefactoringCoreMessages.ReorgUtils_21; } if (isSourceFolder(element)) { return RefactoringCoreMessages.ReorgUtils_15; } if (isClassFolder(element)) { return RefactoringCoreMessages.ReorgUtils_16; } return RefactoringCoreMessages.ReorgUtils_17; case IJavaElement.TYPE: IType type= (IType)element; if (type.isAnonymous()) { return RefactoringCoreMessages.ReorgUtils_20; } return RefactoringCoreMessages.ReorgUtils_18; default: Assert.isTrue(false); return null; } }
Example 20
Source File: GenericRefactoringHandleTransplanter.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public final IJavaElement transplantHandle(IJavaElement element) { IJavaElement parent= element.getParent(); if (parent != null) { parent= transplantHandle(parent); // recursive } switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: return transplantHandle((IJavaModel) element); case IJavaElement.JAVA_PROJECT: return transplantHandle((IJavaProject) element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return transplantHandle((IJavaProject) parent, (IPackageFragmentRoot) element); case IJavaElement.PACKAGE_FRAGMENT: return transplantHandle((IPackageFragmentRoot) parent, (IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: return transplantHandle((IPackageFragment) parent, (ICompilationUnit) element); case IJavaElement.CLASS_FILE: return transplantHandle((IPackageFragment) parent, (IClassFile) element); case IJavaElement.TYPE: return transplantHandle(parent, (IType) element); case IJavaElement.FIELD: return transplantHandle((IType) parent, (IField) element); case IJavaElement.METHOD: return transplantHandle((IType) parent, (IMethod) element); case IJavaElement.INITIALIZER: return transplantHandle((IType) parent, (IInitializer) element); case IJavaElement.PACKAGE_DECLARATION: return transplantHandle((ICompilationUnit) parent, (IPackageDeclaration) element); case IJavaElement.IMPORT_CONTAINER: return transplantHandle((ICompilationUnit) parent, (IImportContainer) element); case IJavaElement.IMPORT_DECLARATION: return transplantHandle((IImportContainer) parent, (IImportDeclaration) element); case IJavaElement.LOCAL_VARIABLE: return transplantHandle((ILocalVariable) element); case IJavaElement.TYPE_PARAMETER: return transplantHandle((IMember) parent, (ITypeParameter) element); case IJavaElement.ANNOTATION: return transplantHandle((IAnnotatable) parent, (IAnnotation) element); default: throw new IllegalArgumentException(element.toString()); } }