Java Code Examples for org.eclipse.jdt.core.IJavaElement#METHOD
The following examples show how to use
org.eclipse.jdt.core.IJavaElement#METHOD .
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: JavaMatchFilter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public boolean isApplicable(JavaSearchQuery query) { QuerySpecification spec= query.getSpecification(); if (spec instanceof ElementQuerySpecification) { ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; IJavaElement element= elementSpec.getElement(); switch (element.getElementType()) { case IJavaElement.TYPE: case IJavaElement.METHOD: case IJavaElement.FIELD: case IJavaElement.PACKAGE_FRAGMENT: return true; default: return false; } } else if (spec instanceof PatternQuerySpecification) { return true; } return false; }
Example 2
Source File: PullUpRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void checkAccessModifiers(final RefactoringStatus result, final Set<IMember> notDeletedMembersInSubtypes) throws JavaModelException { if (fDestinationType.isInterface()) return; final List<IMethod> toDeclareAbstract= Arrays.asList(fAbstractMethods); for (final Iterator<IMember> iter= notDeletedMembersInSubtypes.iterator(); iter.hasNext();) { final IMember member= iter.next(); if (member.getElementType() == IJavaElement.METHOD && !toDeclareAbstract.contains(member)) { final IMethod method= ((IMethod) member); if (method.getDeclaringType().getPackageFragment().equals(fDestinationType.getPackageFragment())) { if (JdtFlags.isPrivate(method)) result.addError(Messages.format(RefactoringCoreMessages.PullUpRefactoring_lower_default_visibility, new String[] { JavaElementLabels.getTextLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(method.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)}), JavaStatusContext.create(method)); } else if (!JdtFlags.isPublic(method) && !JdtFlags.isProtected(method)) result.addError(Messages.format(RefactoringCoreMessages.PullUpRefactoring_lower_protected_visibility, new String[] { JavaElementLabels.getTextLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(method.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)}), JavaStatusContext.create(method)); } } }
Example 3
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 4
Source File: StubCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected void appendFlags(final IMember member) throws JavaModelException { if (member instanceof IAnnotatable) for (IAnnotation annotation : ((IAnnotatable) member).getAnnotations()) { appendAnnotation(annotation); } int flags= member.getFlags(); final int kind= member.getElementType(); if (kind == IJavaElement.TYPE) { flags&= ~Flags.AccSuper; final IType type= (IType) member; if (!type.isMember()) flags&= ~Flags.AccPrivate; if (Flags.isEnum(flags)) flags&= ~Flags.AccAbstract; } if (Flags.isEnum(flags)) flags&= ~Flags.AccFinal; if (kind == IJavaElement.METHOD) { flags&= ~Flags.AccVarargs; flags&= ~Flags.AccBridge; } if (flags != 0) fBuffer.append(Flags.toString(flags)); }
Example 5
Source File: JavaQueryParticipant.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
private Set<IIndexedJavaRef> findMatches(PatternQuerySpecification query) { // Translate the IJavaSearchConstant element type constants to IJavaElement // type constants. int elementType; switch (query.getSearchFor()) { case IJavaSearchConstants.TYPE: elementType = IJavaElement.TYPE; break; case IJavaSearchConstants.FIELD: elementType = IJavaElement.FIELD; break; case IJavaSearchConstants.METHOD: case IJavaSearchConstants.CONSTRUCTOR: // IJavaElement.METHOD represents both methods & ctors elementType = IJavaElement.METHOD; break; default: // We only support searching for types, fields, methods, and ctors return Collections.emptySet(); } return JavaRefIndex.getInstance().findElementReferences(query.getPattern(), elementType, query.isCaseSensitive()); }
Example 6
Source File: ASTNodeSearchUtil.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public static ASTNode[] getDeclarationNodes(IJavaElement element, CompilationUnit cuNode) throws JavaModelException { switch(element.getElementType()){ case IJavaElement.FIELD: return new ASTNode[]{getFieldOrEnumConstantDeclaration((IField) element, cuNode)}; case IJavaElement.IMPORT_CONTAINER: return getImportNodes((IImportContainer)element, cuNode); case IJavaElement.IMPORT_DECLARATION: return new ASTNode[]{getImportDeclarationNode((IImportDeclaration)element, cuNode)}; case IJavaElement.INITIALIZER: return new ASTNode[]{getInitializerNode((IInitializer)element, cuNode)}; case IJavaElement.METHOD: return new ASTNode[]{getMethodOrAnnotationTypeMemberDeclarationNode((IMethod) element, cuNode)}; case IJavaElement.PACKAGE_DECLARATION: return new ASTNode[]{getPackageDeclarationNode((IPackageDeclaration)element, cuNode)}; case IJavaElement.TYPE: return new ASTNode[]{getAbstractTypeDeclarationNode((IType) element, cuNode)}; default: Assert.isTrue(false, String.valueOf(element.getElementType())); return null; } }
Example 7
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean isRenameElementAvailable(IJavaElement element) throws CoreException { switch (element.getElementType()) { case IJavaElement.JAVA_PROJECT: return isRenameAvailable((IJavaProject) element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return isRenameAvailable((IPackageFragmentRoot) element); case IJavaElement.PACKAGE_FRAGMENT: return isRenameAvailable((IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: return isRenameAvailable((ICompilationUnit) element); case IJavaElement.TYPE: return isRenameAvailable((IType) element); case IJavaElement.METHOD: final IMethod method= (IMethod) element; if (method.isConstructor()) return isRenameAvailable(method.getDeclaringType()); else return isRenameAvailable(method); case IJavaElement.FIELD: final IField field= (IField) element; if (Flags.isEnum(field.getFlags())) return isRenameEnumConstAvailable(field); else return isRenameFieldAvailable(field); case IJavaElement.TYPE_PARAMETER: return isRenameAvailable((ITypeParameter) element); case IJavaElement.LOCAL_VARIABLE: return isRenameAvailable((ILocalVariable) element); } return false; }
Example 8
Source File: JavaElementFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void consumeTypeVariable(char[] position, char[] typeVariableName) { if (this.element == null) return; switch (this.element.getElementType()) { case IJavaElement.TYPE: this.element = ((IType) this.element).getTypeParameter(new String(typeVariableName)); break; case IJavaElement.METHOD: this.element = ((IMethod) this.element).getTypeParameter(new String(typeVariableName)); break; } }
Example 9
Source File: QueryParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private boolean isHandled(QuerySpecification query) { switch (query.getLimitTo()) { case IJavaSearchConstants.REFERENCES: case IJavaSearchConstants.ALL_OCCURRENCES: { break; } default: { return false; } } if (query instanceof ElementQuerySpecification) { IJavaElement element = ((ElementQuerySpecification) query).getElement(); return element.getElementType() == IJavaElement.TYPE || element.getElementType() == IJavaElement.FIELD || element.getElementType() == IJavaElement.METHOD; } // if (query instanceof PatternQuerySpecification) { // PatternQuerySpecification patternQuery = (PatternQuerySpecification) query; // switch (patternQuery.getSearchFor()) { // case IJavaSearchConstants.UNKNOWN: // case IJavaSearchConstants.TYPE: // case IJavaSearchConstants.CLASS: // case IJavaSearchConstants.CLASS_AND_INTERFACE: // case IJavaSearchConstants.CLASS_AND_ENUM: { // return true; // } // } // } return false; }
Example 10
Source File: PatternStrings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static String getSignature(IJavaElement element) { if (element == null) return null; else switch (element.getElementType()) { case IJavaElement.METHOD: return getMethodSignature((IMethod)element); case IJavaElement.TYPE: return getTypeSignature((IType) element); case IJavaElement.FIELD: return getFieldSignature((IField) element); default: return element.getElementName(); } }
Example 11
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean isMoveStaticAvailable(final IMember member) throws JavaModelException { if (!member.exists()) return false; final int type= member.getElementType(); if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE) return false; if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE) return false; final IType declaring= member.getDeclaringType(); if (declaring == null) return false; if (!Checks.isAvailable(member)) return false; if (type == IJavaElement.METHOD && declaring.isInterface()) { boolean is18OrHigher= JavaModelUtil.is18OrHigher(member.getJavaProject()); if (!is18OrHigher || !Flags.isStatic(member.getFlags())) return false; } if (type == IJavaElement.METHOD && !JdtFlags.isStatic(member)) return false; if (type == IJavaElement.METHOD && ((IMethod) member).isConstructor()) return false; if (type == IJavaElement.TYPE && !JdtFlags.isStatic(member)) return false; if (!declaring.isInterface() && !JdtFlags.isStatic(member)) return false; return true; }
Example 12
Source File: DocumentSymbolHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private boolean isInitializer(IJavaElement element) { if (element.getElementType() == IJavaElement.METHOD) { String name = element.getElementName(); if ((name != null && name.indexOf('<') >= 0)) { return true; } } return false; }
Example 13
Source File: DocumentSymbolHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void collectChildren(ITypeRoot unit, IJavaElement[] elements, ArrayList<SymbolInformation> symbols, IProgressMonitor monitor) throws JavaModelException { for (IJavaElement element : elements) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } if (element instanceof IParent) { collectChildren(unit, filter(((IParent) element).getChildren()), symbols, monitor); } int type = element.getElementType(); if (type != IJavaElement.TYPE && type != IJavaElement.FIELD && type != IJavaElement.METHOD) { continue; } Location location = JDTUtils.toLocation(element); if (location != null) { SymbolInformation si = new SymbolInformation(); String name = JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT); si.setName(name == null ? element.getElementName() : name); si.setKind(mapKind(element)); if (element.getParent() != null) { si.setContainerName(element.getParent().getElementName()); } location.setUri(ResourceUtils.toClientUri(location.getUri())); si.setLocation(location); if (!symbols.contains(si)) { symbols.add(si); } } } }
Example 14
Source File: PullUpRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void checkMethodReturnTypes(final IProgressMonitor monitor, final RefactoringStatus status, final Set<IMember> notDeletedMembersInSubtypes) throws JavaModelException { final Map<IMember, Set<IMember>> mapping= getMatchingMembers(getDestinationTypeHierarchy(monitor), getDestinationType(), true); final IMember[] members= getCreatedDestinationMembers(); for (int i= 0; i < members.length; i++) { if (members[i].getElementType() != IJavaElement.METHOD) continue; final IMethod method= (IMethod) members[i]; if (mapping.containsKey(method)) { final Set<IMember> set= mapping.get(method); if (set != null) { final String returnType= Signature.toString(Signature.getReturnType(method.getSignature()).toString()); for (final Iterator<IMember> iter= set.iterator(); iter.hasNext();) { final IMethod matchingMethod= (IMethod) iter.next(); if (method.equals(matchingMethod)) continue; if (!notDeletedMembersInSubtypes.contains(matchingMethod)) continue; if (returnType.equals(Signature.toString(Signature.getReturnType(matchingMethod.getSignature()).toString()))) continue; final String[] keys= { JavaElementLabels.getTextLabel(matchingMethod, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(matchingMethod.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)}; final String message= Messages.format(RefactoringCoreMessages.PullUpRefactoring_different_method_return_type, keys); final RefactoringStatusContext context= JavaStatusContext.create(matchingMethod.getCompilationUnit(), matchingMethod.getNameRange()); status.addError(message, context); } } } } }
Example 15
Source File: ParameterGuesser.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public Variable createVariable(IJavaElement element, IType enclosingType, String expectedType, int positionScore) throws JavaModelException { int variableType; int elementType= element.getElementType(); String elementName= element.getElementName(); String typeSignature; switch (elementType) { case IJavaElement.FIELD: { IField field= (IField) element; if (field.getDeclaringType().equals(enclosingType)) { variableType= Variable.FIELD; } else { variableType= Variable.INHERITED_FIELD; } if (field.isResolved()) { typeSignature= new BindingKey(field.getKey()).toSignature(); } else { typeSignature= field.getTypeSignature(); } break; } case IJavaElement.LOCAL_VARIABLE: { ILocalVariable locVar= (ILocalVariable) element; variableType= Variable.LOCAL; typeSignature= locVar.getTypeSignature(); break; } case IJavaElement.METHOD: { IMethod method= (IMethod) element; if (isMethodToSuggest(method)) { if (method.getDeclaringType().equals(enclosingType)) { variableType= Variable.METHOD; } else { variableType= Variable.INHERITED_METHOD; } if (method.isResolved()) { typeSignature= Signature.getReturnType(new BindingKey(method.getKey()).toSignature()); } else { typeSignature= method.getReturnType(); } elementName= elementName + "()"; //$NON-NLS-1$ } else { return null; } break; } default: return null; } String type= Signature.toString(typeSignature); boolean isAutoboxMatch= isPrimitiveType(expectedType) != isPrimitiveType(type); return new Variable(type, elementName, variableType, isAutoboxMatch, positionScore); }
Example 16
Source File: OpenTypeHierarchyUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Converts the input to a possible input candidates * @param input input * @return the possible candidates */ public static IJavaElement[] getCandidates(Object input) { if (!(input instanceof IJavaElement)) { return null; } try { IJavaElement elem= (IJavaElement) input; switch (elem.getElementType()) { case IJavaElement.INITIALIZER: case IJavaElement.METHOD: case IJavaElement.FIELD: case IJavaElement.TYPE: case IJavaElement.PACKAGE_FRAGMENT_ROOT: case IJavaElement.JAVA_PROJECT: return new IJavaElement[] { elem }; case IJavaElement.PACKAGE_FRAGMENT: if (((IPackageFragment)elem).containsJavaResources()) return new IJavaElement[] {elem}; break; case IJavaElement.PACKAGE_DECLARATION: return new IJavaElement[] { elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT) }; 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) return null; return new IJavaElement[] {elem}; case IJavaElement.CLASS_FILE: return new IJavaElement[] { ((IClassFile)input).getType() }; case IJavaElement.COMPILATION_UNIT: { ICompilationUnit cu= (ICompilationUnit) elem.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null) { IType[] types= cu.getTypes(); if (types.length > 0) { return types; } } break; } default: } } catch (JavaModelException e) { JavaPlugin.log(e); } return null; }
Example 17
Source File: JavaElementLabelComposer.java From eclipse.jdt.ls with Eclipse Public License 2.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); fBuilder.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: fBuilder.append(element.getElementName()); break; default: fBuilder.append(element.getElementName()); } if (root != null && getFlag(flags, JavaElementLabels.APPEND_ROOT_PATH)) { fBuilder.append(JavaElementLabels.CONCAT_STRING); appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED); } }
Example 18
Source File: JavaElementHyperlinkSuperImplementationDetector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected void addHyperlinks(List<IHyperlink> hyperlinksCollector, IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) { if (element.getElementType() == IJavaElement.METHOD && SelectionConverter.canOperateOn(editor) && isOverriddenMethod((IMethod)element)) { hyperlinksCollector.add(new JavaElementSuperImplementationHyperlink(wordRegion, openAction, (IMethod)element, qualify)); } }
Example 19
Source File: CallHierarchyViewPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Computes the content description for the call hierarchy computation. * * @param includeMask the include mask * @return the content description * @since 3.7 */ private String computeContentDescription(int includeMask) { // see also HistoryAction.getElementLabel(IMember[]) String scopeDescription= fSearchScopeActions.getFullDescription(includeMask); if (fInputElements.length == 1) { IMember element= fInputElements[0]; String elementName= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT); String[] args= new String[] { elementName, scopeDescription }; if (fCurrentCallMode == CALL_MODE_CALLERS) { switch (element.getElementType()) { case IJavaElement.TYPE: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToConstructors, args); case IJavaElement.FIELD: switch (this.fCurrentFieldMode) { case IJavaSearchConstants.READ_ACCESSES: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToFieldRead, args); case IJavaSearchConstants.WRITE_ACCESSES: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToFieldWrite, args); default: // all references return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToField, args); } case IJavaElement.METHOD: case IJavaElement.INITIALIZER: default: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMethod, args); } } else { switch (element.getElementType()) { case IJavaElement.TYPE: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromConstructors, args); case IJavaElement.FIELD: case IJavaElement.METHOD: case IJavaElement.INITIALIZER: default: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMethod, args); } } } else { if (fCurrentCallMode == CALL_MODE_CALLERS) { switch (fInputElements.length) { case 0: Assert.isTrue(false); return null; case 2: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMembers_2, new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription }); default: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMembers_more, new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription }); } } else { switch (fInputElements.length) { case 0: Assert.isTrue(false); return null; case 2: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMembers_2, new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription }); default: return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMembers_more, new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription }); } } } }
Example 20
Source File: MoveStaticMembersProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private String createNonAccessibleMemberMessage(IMember member, IType accessingType, boolean moved){ //Non-visibility can have various reasons and always displaying all visibility //flags for all enclosing elements would be too heavy. Context reveals exact cause. IType declaringType= moved ? getDestinationType() : getDeclaringType(); String message; switch (member.getElementType()){ case IJavaElement.FIELD: { if (moved) message= Messages.format(RefactoringCoreMessages.MoveMembersRefactoring_moved_field, new String[]{JavaElementUtil.createFieldSignature((IField)member), getQualifiedTypeLabel(accessingType), getQualifiedTypeLabel(declaringType)}); else message= Messages.format(RefactoringCoreMessages.MoveMembersRefactoring_accessed_field, new String[]{JavaElementUtil.createFieldSignature((IField)member), getQualifiedTypeLabel(accessingType)}); return message; } case IJavaElement.METHOD: { if (moved) message= Messages.format(RefactoringCoreMessages.MoveMembersRefactoring_moved_method, new String[]{JavaElementUtil.createMethodSignature((IMethod)member), getQualifiedTypeLabel(accessingType), getQualifiedTypeLabel(declaringType)}); else message= Messages.format(RefactoringCoreMessages.MoveMembersRefactoring_accessed_method, new String[]{JavaElementUtil.createMethodSignature((IMethod)member), getQualifiedTypeLabel(accessingType)}); return message; } case IJavaElement.TYPE:{ if (moved) message= Messages.format(RefactoringCoreMessages.MoveMembersRefactoring_moved_type, new String[]{getQualifiedTypeLabel((IType)member), getQualifiedTypeLabel(accessingType), getQualifiedTypeLabel(declaringType)}); else message= Messages.format(RefactoringCoreMessages.MoveMembersRefactoring_accessed_type, new String[]{ getQualifiedTypeLabel((IType)member), getQualifiedTypeLabel(accessingType)}); return message; } default: Assert.isTrue(false); return null; } }