org.eclipse.jdt.core.IMember Java Examples
The following examples show how to use
org.eclipse.jdt.core.IMember.
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: CallHierarchyUI.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static CallHierarchyViewPart openView(IMember[] input, IWorkbenchWindow window) { if (input.length == 0) { MessageDialog.openInformation(window.getShell(), CallHierarchyMessages.CallHierarchyUI_selectionDialog_title, CallHierarchyMessages.CallHierarchyUI_open_operation_unavialable); return null; } IWorkbenchPage page= window.getActivePage(); try { CallHierarchyViewPart viewPart= getDefault().findLRUCallHierarchyViewPart(page); //find the first view which is not pinned String secondaryId= null; if (viewPart == null) { if (page.findViewReference(CallHierarchyViewPart.ID_CALL_HIERARCHY) != null) //all the current views are pinned, open a new instance secondaryId= String.valueOf(++getDefault().fViewCount); } else secondaryId= viewPart.getViewSite().getSecondaryId(); viewPart= (CallHierarchyViewPart)page.showView(CallHierarchyViewPart.ID_CALL_HIERARCHY, secondaryId, IWorkbenchPage.VIEW_ACTIVATE); viewPart.setInputElements(input); return viewPart; } catch (CoreException e) { ExceptionHandler.handle(e, window.getShell(), CallHierarchyMessages.CallHierarchyUI_error_open_view, e.getMessage()); } return null; }
Example #2
Source File: ExtractInterfaceWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected void updateUIElementEnablement() { final IMember[] checked= getCheckedMembers(); IMember[] extractable; try { extractable= getExtractableMembers(); } catch (JavaModelException exception) { extractable= new IMember[0]; JavaPlugin.log(exception); } final boolean enabled= containsMethods(checked); fDeclarePublicCheckbox.setEnabled(enabled); fDeclareAbstractCheckbox.setEnabled(enabled); fGenerateAnnotationsCheckbox.setEnabled(enabled); fGenerateCommentsCheckbox.setEnabled(enabled); fInstanceofCheckbox.setEnabled(fReplaceAllCheckbox.getSelection()); fSelectAllButton.setEnabled(checked.length < extractable.length); fDeselectAllButton.setEnabled(checked.length > 0); }
Example #3
Source File: ExtractSuperClassAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static IMember[] getSelectedMembers(final IStructuredSelection selection) { if (selection.isEmpty()) return null; if (selection.size() == 1) { try { final IType type= RefactoringAvailabilityTester.getSingleSelectedType(selection); if (type != null) return new IType[] {type}; } catch (JavaModelException exception) { JavaPlugin.log(exception); } } for (final Iterator<?> iterator= selection.iterator(); iterator.hasNext();) { if (!(iterator.next() instanceof IMember)) return null; } final Set<IMember> set= new HashSet<IMember>(); @SuppressWarnings("unchecked") List<IMember> selectionList= (List<IMember>) (List<?>) Arrays.asList(selection.toArray()); set.addAll(selectionList); return set.toArray(new IMember[set.size()]); }
Example #4
Source File: PullUpRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addMethodStubForAbstractMethod(final IMethod sourceMethod, final CompilationUnit declaringCuNode, final AbstractTypeDeclaration typeToCreateStubIn, final ICompilationUnit newCu, final CompilationUnitRewrite rewriter, final Map<IMember, IncomingMemberVisibilityAdjustment> adjustments, final IProgressMonitor monitor, final RefactoringStatus status) throws CoreException { final MethodDeclaration methodToCreateStubFor= ASTNodeSearchUtil.getMethodDeclarationNode(sourceMethod, declaringCuNode); final AST ast= rewriter.getRoot().getAST(); final MethodDeclaration newMethod= ast.newMethodDeclaration(); newMethod.setBody(createMethodStub(methodToCreateStubFor, ast)); newMethod.setConstructor(false); copyExtraDimensions(methodToCreateStubFor, newMethod); newMethod.modifiers().addAll(ASTNodeFactory.newModifiers(ast, getModifiersWithUpdatedVisibility(sourceMethod, JdtFlags.clearFlag(Modifier.NATIVE | Modifier.ABSTRACT, methodToCreateStubFor.getModifiers()), adjustments, new SubProgressMonitor(monitor, 1), false, status))); newMethod.setName(((SimpleName) ASTNode.copySubtree(ast, methodToCreateStubFor.getName()))); final TypeVariableMaplet[] mapping= TypeVariableUtil.composeMappings(TypeVariableUtil.subTypeToSuperType(getDeclaringType(), getDestinationType()), TypeVariableUtil.superTypeToInheritedType(getDestinationType(), ((IType) typeToCreateStubIn.resolveBinding().getJavaElement()))); copyReturnType(rewriter.getASTRewrite(), getDeclaringType().getCompilationUnit(), methodToCreateStubFor, newMethod, mapping); copyParameters(rewriter.getASTRewrite(), getDeclaringType().getCompilationUnit(), methodToCreateStubFor, newMethod, mapping); copyThrownExceptions(methodToCreateStubFor, newMethod); newMethod.setJavadoc(createJavadocForStub(typeToCreateStubIn.getName().getIdentifier(), methodToCreateStubFor, newMethod, newCu, rewriter.getASTRewrite())); ImportRewriteContext context= new ContextSensitiveImportRewriteContext(typeToCreateStubIn, rewriter.getImportRewrite()); ImportRewriteUtil.addImports(rewriter, context, newMethod, new HashMap<Name, String>(), new HashMap<Name, String>(), false); rewriter.getASTRewrite().getListRewrite(typeToCreateStubIn, typeToCreateStubIn.getBodyDeclarationsProperty()).insertAt(newMethod, ASTNodes.getInsertionIndex(newMethod, typeToCreateStubIn.bodyDeclarations()), rewriter.createCategorizedGroupDescription(RefactoringCoreMessages.PullUpRefactoring_add_method_stub, SET_PULL_UP)); }
Example #5
Source File: RefactoringScopeFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
/** * Creates a new search scope with all compilation units possibly referencing * <code>javaElement</code>. * * @param javaElement * the java element * @param considerVisibility * consider visibility of javaElement iff <code>true</code> * @param sourceReferencesOnly * consider references in source only (no references in binary) * @return the search scope * @throws JavaModelException * if an error occurs */ public static IJavaSearchScope create(IJavaElement javaElement, boolean considerVisibility, boolean sourceReferencesOnly) throws JavaModelException { if (considerVisibility & javaElement instanceof IMember) { IMember member = (IMember) javaElement; if (JdtFlags.isPrivate(member)) { if (member.getCompilationUnit() != null) { return SearchEngine.createJavaSearchScope(new IJavaElement[] { member.getCompilationUnit() }); } else { return SearchEngine.createJavaSearchScope(new IJavaElement[] { member }); } } // Removed code that does some optimizations regarding package visible members. The problem is that // there can be a package fragment with the same name in a different source folder or project. So we // have to treat package visible members like public or protected members. } IJavaProject javaProject = javaElement.getJavaProject(); return SearchEngine.createJavaSearchScope(getAllScopeElements(javaProject, sourceReferencesOnly), false); }
Example #6
Source File: RefactoringAvailabilityTester.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public static boolean isMoveAvailable(final IResource[] resources, final IJavaElement[] elements) throws JavaModelException { if (elements != null) { for (int index = 0; index < elements.length; index++) { IJavaElement element = elements[index]; if (element == null || !element.exists()) { return false; } if ((element instanceof IType) && ((IType) element).isLocal()) { return false; } if ((element instanceof IPackageDeclaration)) { return false; } if (element instanceof IField && JdtFlags.isEnum((IMember) element)) { return false; } } } return ReorgPolicyFactory.createMovePolicy(resources, elements).canEnable(); }
Example #7
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static boolean isMoveAvailable(final IResource[] resources, final IJavaElement[] elements) throws JavaModelException { if (elements != null) { for (int index= 0; index < elements.length; index++) { IJavaElement element= elements[index]; if (element == null || !element.exists()) return false; if ((element instanceof IType) && ((IType) element).isLocal()) return false; if ((element instanceof IPackageDeclaration)) return false; if (element instanceof IField && JdtFlags.isEnum((IMember) element)) return false; } } return ReorgPolicyFactory.createMovePolicy(resources, elements).canEnable(); }
Example #8
Source File: JavaElementLabelComposer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Appends the styled label for a type parameter. * * @param typeParameter the element to render * @param flags the rendering flags. Flags with names starting with 'T_' are considered. */ public void appendTypeParameterLabel(ITypeParameter typeParameter, long flags) { try { appendTypeParameterWithBounds(typeParameter, flags); // post qualification if (getFlag(flags, JavaElementLabels.TP_POST_QUALIFIED)) { fBuffer.append(JavaElementLabels.CONCAT_STRING); IMember declaringMember= typeParameter.getDeclaringMember(); appendElementLabel(declaringMember, JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_FULLY_QUALIFIED | JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS)); } } catch (JavaModelException e) { JavaPlugin.log(e); // NotExistsException will not reach this point } }
Example #9
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static IMember[] getPushDownMembers(final IType type) throws JavaModelException { final List<IMember> list= new ArrayList<IMember>(3); if (type.exists()) { IMember[] members= type.getFields(); for (int index= 0; index < members.length; index++) { if (isPushDownAvailable(members[index])) list.add(members[index]); } members= type.getMethods(); for (int index= 0; index < members.length; index++) { if (isPushDownAvailable(members[index])) list.add(members[index]); } } return list.toArray(new IMember[list.size()]); }
Example #10
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public boolean canEnable() throws JavaModelException { if (!super.canEnable() || fJavaElements.length == 0) { return false; } for (int i= 0; i < fJavaElements.length; i++) { if (fJavaElements[i] instanceof IMember) { IMember member= (IMember) fJavaElements[i]; // we can copy some binary members, but not all if (member.isBinary() && member.getSourceRange() == null) { return false; } } } return true; }
Example #11
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public boolean canEnable() throws JavaModelException { if (!super.canEnable() || fJavaElements.length == 0) return false; for (int i= 0; i < fJavaElements.length; i++) { if (fJavaElements[i] instanceof IMember) { IMember member= (IMember) fJavaElements[i]; // we can copy some binary members, but not all if (member.isBinary() && member.getSourceRange() == null) return false; } } return true; }
Example #12
Source File: CallHierarchyHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private IMember getEnclosingMember(ITypeRoot root, int offset) { Assert.isNotNull(root, "root"); try { IJavaElement enclosingElement = root.getElementAt(offset); if (enclosingElement instanceof IMethod || enclosingElement instanceof IInitializer || enclosingElement instanceof IField) { // opening on the enclosing type would be too confusing (since the type resolves to the constructors) return (IMember) enclosingElement; } } catch (JavaModelException e) { JavaLanguageServerPlugin.log(e); } return null; }
Example #13
Source File: RenameMethodProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private IType[] searchForOuterTypesOfReferences(IMethod[] newNameMethods, IProgressMonitor pm) throws CoreException { final Set<IType> outerTypesOfReferences= new HashSet<>(); SearchPattern pattern= RefactoringSearchEngine.createOrPattern(newNameMethods, IJavaSearchConstants.REFERENCES); IJavaSearchScope scope= createRefactoringScope(getMethod()); SearchRequestor requestor= new SearchRequestor() { @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { Object element= match.getElement(); if (!(element instanceof IMember)) { return; // e.g. an IImportDeclaration for a static method import } IMember member= (IMember) element; IType declaring= member.getDeclaringType(); if (declaring == null) { return; } IType outer= declaring.getDeclaringType(); if (outer != null) { outerTypesOfReferences.add(declaring); } } }; new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm); return outerTypesOfReferences.toArray(new IType[outerTypesOfReferences.size()]); }
Example #14
Source File: RefactoringAvailabilityTester.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static boolean isMoveStaticMembersAvailable(final IMember[] members) throws JavaModelException { if (members == null) { return false; } if (members.length == 0) { return false; } if (!isMoveStaticAvailable(members)) { return false; } if (!isCommonDeclaringType(members)) { return false; } return true; }
Example #15
Source File: ExtractInterfaceProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Is the specified member extractable from the type? * * @param member * the member to test * @return <code>true</code> if the member is extractable, * <code>false</code> otherwise * @throws JavaModelException * if an error occurs */ protected static boolean isExtractableMember(final IMember member) throws JavaModelException { Assert.isNotNull(member); switch (member.getElementType()) { case IJavaElement.METHOD: return JdtFlags.isPublic(member) && !JdtFlags.isStatic(member) && !((IMethod) member).isConstructor(); case IJavaElement.FIELD: return JdtFlags.isPublic(member) && JdtFlags.isStatic(member) && JdtFlags.isFinal(member) && !JdtFlags.isEnum(member); default: return false; } }
Example #16
Source File: CallHierarchy.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private MethodWrapper[] getRoots(IMember[] members, boolean callers) { ArrayList<MethodWrapper> roots= new ArrayList<MethodWrapper>(); for (int i= 0; i < members.length; i++) { IMember member= members[i]; if (member instanceof IType) { IType type= (IType) member; try { if (! type.isAnonymous()) { IMethod[] constructors= JavaElementUtil.getAllConstructors(type); if (constructors.length == 0) { addRoot(member, roots, callers); // IType is a stand-in for the non-existing default constructor } else { for (int j= 0; j < constructors.length; j++) { IMethod constructor= constructors[j]; addRoot(constructor, roots, callers); } } } else { addRoot(member, roots, callers); } } catch (JavaModelException e) { JavaPlugin.log(e); } } else { addRoot(member, roots, callers); } } return roots.toArray(new MethodWrapper[roots.size()]); }
Example #17
Source File: RefactoringAvailabilityTester.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static boolean isPushDownAvailable(final IMember member) throws JavaModelException { if (!member.exists()) { return false; } final int type = member.getElementType(); if (type != IJavaElement.METHOD && type != IJavaElement.FIELD) { return false; } if (JdtFlags.isEnum(member)) { return false; } if (!Checks.isAvailable(member)) { return false; } if (JdtFlags.isStatic(member)) { return false; } if (type == IJavaElement.METHOD) { final IMethod method = (IMethod) member; if (method.isConstructor()) { return false; } if (JdtFlags.isNative(method)) { return false; } final IType declaring = method.getDeclaringType(); if (declaring != null && declaring.isAnnotation()) { return false; } } return true; }
Example #18
Source File: MoveMembersWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void setVisible(boolean visible){ if (visible){ IMember[] membersToMove= getMoveProcessor().getMembersToMove(); int membersToMoveCount= membersToMove.length; String label= JavaElementLabels.getElementLabel(getMoveProcessor().getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED); String message= membersToMoveCount == 1 ? Messages.format(RefactoringMessages.MoveMembersInputPage_descriptionKey_singular, new String[] { JavaElementLabels.getTextLabel(membersToMove[0], JavaElementLabels.ALL_FULLY_QUALIFIED), label }) : Messages.format( RefactoringMessages.MoveMembersInputPage_descriptionKey_plural, new String[] { new Integer(membersToMoveCount).toString(), label }); setDescription(message); } super.setVisible(visible); }
Example #19
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static boolean hasOnlyMembers(IJavaElement[] javaElements) { for (int i= 0; i < javaElements.length; i++) { if (!(javaElements[i] instanceof IMember)) { return false; } } return true; }
Example #20
Source File: MemberFilter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { try { if (element instanceof IMember) { IMember member= (IMember) element; int memberType= member.getElementType(); if (hasFilter(FILTER_FIELDS) && memberType == IJavaElement.FIELD) { return false; } if (hasFilter(FILTER_LOCALTYPES) && memberType == IJavaElement.TYPE && isLocalType((IType) member)) { return false; } if (member.getElementName().startsWith("<")) { // filter out <clinit> //$NON-NLS-1$ return false; } int flags= member.getFlags(); if (hasFilter(FILTER_STATIC) && (Flags.isStatic(flags) || isFieldInInterfaceOrAnnotation(member)) && memberType != IJavaElement.TYPE) { return false; } if (hasFilter(FILTER_NONPUBLIC) && !Flags.isPublic(flags) && !isMemberInInterfaceOrAnnotation(member) && !isTopLevelType(member) && !isEnumConstant(member)) { return false; } } } catch (JavaModelException e) { // ignore } return true; }
Example #21
Source File: PushDownRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IMember[] getDeletableMembers() { List<IMember> result= new ArrayList<IMember>(fMemberInfos.length); for (int i= 0; i < fMemberInfos.length; i++) { MemberActionInfo info= fMemberInfos[i]; if (info.isToBeDeletedFromDeclaringClass()) result.add(info.getMember()); } return result.toArray(new IMember[result.size()]); }
Example #22
Source File: JavaCompareUtilities.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
static ImageDescriptor getImageDescriptor(IMember element) { int t= element.getElementType(); if (t == IJavaElement.TYPE) { IType type= (IType) element; try { return getTypeImageDescriptor(type.isClass()); } catch (CoreException e) { JavaPlugin.log(e); return JavaPluginImages.DESC_OBJS_GHOST; } } return getImageDescriptor(t); }
Example #23
Source File: RenameTypeParameterProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringStatus checkNewElementName(String name) throws CoreException { Assert.isNotNull(name); RefactoringStatus result= Checks.checkTypeParameterName(name, fTypeParameter); if (Checks.startsWithLowerCase(name)) { result.addWarning(RefactoringCoreMessages.RenameTypeParameterRefactoring_should_start_lowercase); } if (Checks.isAlreadyNamed(fTypeParameter, name)) { result.addFatalError(RefactoringCoreMessages.RenameTypeParameterRefactoring_another_name); } IMember member= fTypeParameter.getDeclaringMember(); if (member instanceof IType) { IType type= (IType) member; if (type.getTypeParameter(name).exists()) { result.addFatalError(RefactoringCoreMessages.RenameTypeParameterRefactoring_class_type_parameter_already_defined); } } else if (member instanceof IMethod) { IMethod method= (IMethod) member; if (method.getTypeParameter(name).exists()) { result.addFatalError(RefactoringCoreMessages.RenameTypeParameterRefactoring_method_type_parameter_already_defined); } } else { JavaLanguageServerPlugin.logError("Unexpected sub-type of IMember: " + member.getClass().getName()); //$NON-NLS-1$ Assert.isTrue(false); } return result; }
Example #24
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void copyToDestination(IJavaElement element, CompilationUnitRewrite targetRewriter, CompilationUnit sourceCuNode, CompilationUnit targetCuNode) throws CoreException { final ASTRewrite rewrite= targetRewriter.getASTRewrite(); switch (element.getElementType()) { case IJavaElement.FIELD: copyMemberToDestination((IMember) element, targetRewriter, sourceCuNode, targetCuNode, createNewFieldDeclarationNode(((IField) element), rewrite, sourceCuNode)); break; case IJavaElement.IMPORT_CONTAINER: copyImportsToDestination((IImportContainer) element, rewrite, sourceCuNode, targetCuNode); break; case IJavaElement.IMPORT_DECLARATION: copyImportToDestination((IImportDeclaration) element, rewrite, sourceCuNode, targetCuNode); break; case IJavaElement.INITIALIZER: copyInitializerToDestination((IInitializer) element, targetRewriter, sourceCuNode, targetCuNode); break; case IJavaElement.METHOD: copyMethodToDestination((IMethod) element, targetRewriter, sourceCuNode, targetCuNode); break; case IJavaElement.PACKAGE_DECLARATION: copyPackageDeclarationToDestination((IPackageDeclaration) element, rewrite, sourceCuNode, targetCuNode); break; case IJavaElement.TYPE: copyTypeToDestination((IType) element, targetRewriter, sourceCuNode, targetCuNode); break; default: Assert.isTrue(false); } }
Example #25
Source File: PushDownWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IMember[] getMembers() { final MemberActionInfo[] infos= (MemberActionInfo[]) fTableViewer.getInput(); final List<IMember> result= new ArrayList<IMember>(infos.length); for (int index= 0; index < infos.length; index++) { result.add(infos[index].getMember()); } return result.toArray(new IMember[result.size()]); }
Example #26
Source File: PullUpAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void run(IStructuredSelection selection) { try { IMember[] members= getSelectedMembers(selection); if (RefactoringAvailabilityTester.isPullUpAvailable(members) && ActionUtil.isEditable(getShell(), members[0])) RefactoringExecutionStarter.startPullUpRefactoring(members, getShell()); } catch (JavaModelException e) { ExceptionHandler.handle(e, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringMessages.OpenRefactoringWizardAction_exception); } }
Example #27
Source File: Jdt2Ecore.java From sarl with Apache License 2.0 | 5 votes |
/** Replies if the target feature is visible from the type. * * <p>The type finder could be obtained with {@link #toTypeFinder(IJavaProject)}. * * @param typeFinder the type finder to be used for finding the type definitions. * @param fromType the type from which the feature visibility is tested. * @param target the feature to test for the visibility. * @return <code>true</code> if the given type can see the target feature. * @throws JavaModelException if the Java model is invalid. * @see #toTypeFinder(IJavaProject) */ public boolean isVisible(TypeFinder typeFinder, IType fromType, IMember target) throws JavaModelException { final int flags = target.getFlags(); if (Flags.isPublic(flags)) { return true; } final String fromTypeName = fromType.getFullyQualifiedName(); final String memberType = target.getDeclaringType().getFullyQualifiedName(); if (Flags.isPrivate(flags)) { return target.getDeclaringType().getFullyQualifiedName().equals(fromTypeName); } if (Flags.isProtected(flags)) { IType t = fromType; while (t != null) { if (memberType.equals(t.getFullyQualifiedName())) { return true; } final String typeName = t.getSuperclassName(); if (Strings.isNullOrEmpty(typeName)) { t = null; } else { t = typeFinder.findType(typeName); } } } final IPackageFragment f1 = target.getDeclaringType().getPackageFragment(); final IPackageFragment f2 = fromType.getPackageFragment(); if (f1.isDefaultPackage()) { return f2.isDefaultPackage(); } return f1.getElementName().equals(f2.getElementName()); }
Example #28
Source File: HierarchyProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected boolean needsVisibilityAdjustment(final IMember member, final boolean references, final IProgressMonitor monitor, final RefactoringStatus status) throws JavaModelException { if (JdtFlags.isPublic(member) || JdtFlags.isProtected(member)) return false; if (!references) return true; return hasNonMovedReferences(member, monitor, status); }
Example #29
Source File: JavaMatchFilter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean filters(JavaElementMatch match) { Object element= match.getElement(); if (element instanceof IMember) { try { return ! JdtFlags.isStatic((IMember) element); } catch (JavaModelException e) { JavaPlugin.log(e); } } return false; }
Example #30
Source File: RefactoringExecutionStarter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void startExtractSupertypeRefactoring(final IMember[] members, final Shell shell) throws JavaModelException { if (!RefactoringAvailabilityTester.isExtractSupertypeAvailable(members)) return; IJavaProject project= null; if (members != null && members.length > 0) project= members[0].getJavaProject(); ExtractSupertypeProcessor processor= new ExtractSupertypeProcessor(members, JavaPreferencesSettings.getCodeGenerationSettings(project)); Refactoring refactoring= new ProcessorBasedRefactoring(processor); ExtractSupertypeWizard wizard= new ExtractSupertypeWizard(processor, refactoring); new RefactoringStarter().activate(wizard, shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringSaveHelper.SAVE_REFACTORING); }