public static boolean isInsideLocalType(IType type) throws JavaModelException { while (type != null) { if (type.isLocal()) return true; type= type.getDeclaringType(); } return false; }
public static boolean isInsideLocalType(IType type) throws JavaModelException { while (type != null) { if (type.isLocal()) return true; type= type.getDeclaringType(); } return false; }
public static boolean isInsideLocalType(IType type) throws JavaModelException { while (type != null) { if (type.isLocal()) return true; type= type.getDeclaringType(); } return false; }
public static int getExtraFlags(IType type) throws JavaModelException { int extraFlags = 0; if (type.isMember()) { extraFlags |= ExtraFlags.IsMemberType; } if (type.isLocal()) { extraFlags |= ExtraFlags.IsLocalType; } IType[] memberTypes = type.getTypes(); int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length; if (memberTypeCounter > 0) { done : for (int i = 0; i < memberTypeCounter; i++) { int flags = memberTypes[i].getFlags(); // if the member type is static and not private if ((flags & ClassFileConstants.AccStatic) != 0 && (flags & ClassFileConstants.AccPrivate) == 0 ) { extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes; break done; } } } return extraFlags; }
public static int getExtraFlags(IType type) throws JavaModelException { int extraFlags = 0; if (type.isMember()) { extraFlags |= ExtraFlags.IsMemberType; } if (type.isLocal()) { extraFlags |= ExtraFlags.IsLocalType; } IType[] memberTypes = type.getTypes(); int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length; if (memberTypeCounter > 0) { done : for (int i = 0; i < memberTypeCounter; i++) { int flags = memberTypes[i].getFlags(); // if the member type is static and not private if ((flags & ClassFileConstants.AccStatic) != 0 && (flags & ClassFileConstants.AccPrivate) == 0 ) { extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes; break done; } } } return extraFlags; }
public static int getExtraFlags(IType type) throws JavaModelException { int extraFlags = 0; if (type.isMember()) { extraFlags |= ExtraFlags.IsMemberType; } if (type.isLocal()) { extraFlags |= ExtraFlags.IsLocalType; } IType[] memberTypes = type.getTypes(); int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length; if (memberTypeCounter > 0) { done : for (int i = 0; i < memberTypeCounter; i++) { int flags = memberTypes[i].getFlags(); // if the member type is static and not private if ((flags & ClassFileConstants.AccStatic) != 0 && (flags & ClassFileConstants.AccPrivate) == 0 ) { extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes; break done; } } } return extraFlags; }
public static int getExtraFlags(IType type) throws JavaModelException { int extraFlags = 0; if (type.isMember()) { extraFlags |= ExtraFlags.IsMemberType; } if (type.isLocal()) { extraFlags |= ExtraFlags.IsLocalType; } IType[] memberTypes = type.getTypes(); int memberTypeCounter = memberTypes == null ? 0 : memberTypes.length; if (memberTypeCounter > 0) { done : for (int i = 0; i < memberTypeCounter; i++) { int flags = memberTypes[i].getFlags(); // if the member type is static and not private if ((flags & ClassFileConstants.AccStatic) != 0 && (flags & ClassFileConstants.AccPrivate) == 0 ) { extraFlags |= ExtraFlags.HasNonPrivateStaticMemberTypes; break done; } } } return extraFlags; }
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(); }
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(); }
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(); }
protected int getDescriptorFlags() { int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE; try { if (!Flags.isPrivate(fMethod.getFlags())) flags|= RefactoringDescriptor.MULTI_CHANGE; final IType declaring= fMethod.getDeclaringType(); if (declaring.isAnonymous() || declaring.isLocal()) flags|= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT; } catch (JavaModelException exception) { JavaPlugin.log(exception); } return flags; }
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(); } //
protected int getDescriptorFlags() { int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE; try { if (!Flags.isPrivate(fMethod.getFlags())) flags|= RefactoringDescriptor.MULTI_CHANGE; final IType declaring= fMethod.getDeclaringType(); if (declaring.isAnonymous() || declaring.isLocal()) flags|= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT; } catch (JavaModelException exception) { JavaPlugin.log(exception); } return flags; }
private Object[] getPackageContents(IPackageFragment fragment) throws JavaModelException { ISourceReference[] sourceRefs; if (fragment.getKind() == IPackageFragmentRoot.K_SOURCE) { sourceRefs= fragment.getCompilationUnits(); } else { IOrdinaryClassFile[] classFiles= fragment.getOrdinaryClassFiles(); List<IOrdinaryClassFile> topLevelClassFile= new ArrayList<>(); for (int i= 0; i < classFiles.length; i++) { IType type= classFiles[i].getType(); if (type != null && type.getDeclaringType() == null && !type.isAnonymous() && !type.isLocal()) topLevelClassFile.add(classFiles[i]); } sourceRefs= topLevelClassFile.toArray(new ISourceReference[topLevelClassFile.size()]); } Object[] result= new Object[0]; for (int i= 0; i < sourceRefs.length; i++) result= concatenate(result, removeImportAndPackageDeclarations(getChildren(sourceRefs[i]))); return concatenate(result, fragment.getNonJavaResources()); }
private Object[] getPackageContents(IPackageFragment fragment) throws JavaModelException { ISourceReference[] sourceRefs; if (fragment.getKind() == IPackageFragmentRoot.K_SOURCE) { sourceRefs= fragment.getCompilationUnits(); } else { IClassFile[] classFiles= fragment.getClassFiles(); List topLevelClassFile= new ArrayList(); for (int i= 0; i < classFiles.length; i++) { IType type= classFiles[i].getType(); if (type != null && type.getDeclaringType() == null && !type.isAnonymous() && !type.isLocal()) topLevelClassFile.add(classFiles[i]); } sourceRefs= (ISourceReference[])topLevelClassFile.toArray(new ISourceReference[topLevelClassFile.size()]); } Object[] result= new Object[0]; for (int i= 0; i < sourceRefs.length; i++) result= concatenate(result, removeImportAndPackageDeclarations(getChildren(sourceRefs[i]))); return concatenate(result, fragment.getNonJavaResources()); }
private Object[] getPackageContents(IPackageFragment fragment) throws JavaModelException { ISourceReference[] sourceRefs; if (fragment.getKind() == IPackageFragmentRoot.K_SOURCE) { sourceRefs= fragment.getCompilationUnits(); } else { IClassFile[] classFiles= fragment.getClassFiles(); List<IClassFile> topLevelClassFile= new ArrayList<>(); for (int i= 0; i < classFiles.length; i++) { IType type= classFiles[i].getType(); if (type != null && type.getDeclaringType() == null && !type.isAnonymous() && !type.isLocal()) topLevelClassFile.add(classFiles[i]); } sourceRefs= topLevelClassFile.toArray(new ISourceReference[topLevelClassFile.size()]); } Object[] result= new Object[0]; for (int i= 0; i < sourceRefs.length; i++) result= concatenate(result, removeImportAndPackageDeclarations(getChildren(sourceRefs[i]))); return concatenate(result, fragment.getNonJavaResources()); }
protected boolean initialize(Object element) { fType= (IType)element; try { // check that the type is no a local, and is no declared in a local type IType declaringType= fType; while (declaringType != null) { if (fType.isLocal()) { return false; } declaringType= declaringType.getDeclaringType(); } } catch (JavaModelException e) { JDIDebugUIPlugin.log(e); } Object destination= getArguments().getDestination(); if (destination instanceof IPackageFragment || destination instanceof IType) { fDestination= (IJavaElement) destination; return true; } return false; }
protected IType getType(ITextSelection selection) { IMember member = ActionDelegateHelper.getDefault().getCurrentMember(selection); IType type = null; if (member instanceof IType) { type = (IType) member; } else if (member != null) { type = member.getDeclaringType(); } // bug 52385: we don't want local and anonymous types from compilation // unit, // we are getting 'not-always-correct' names for them. try { while (type != null && !type.isBinary() && type.isLocal()) { type = type.getDeclaringType(); } } catch (JavaModelException e) { JDIDebugUIPlugin.log(e); } return type; }
@Override public boolean test(IType candidate) { try { if (candidate.isMember() || candidate.isAnonymous() || candidate.isEnum() || candidate.isLocal()) { return false; } int modifiers = candidate.getFlags(); return Flags.isPublic(modifiers) && !Flags.isDeprecated(modifiers); } catch (JavaModelException e) { throw new SdkException(e); } } }
private boolean canEnable(IStructuredSelection selection) throws JavaModelException { if (getSelectedFields(selection) != null) return true; if ((selection.size() == 1) && (selection.getFirstElement() instanceof IType)) { IType type= (IType) selection.getFirstElement(); return type.getCompilationUnit() != null && !type.isInterface() && !type.isLocal(); } if ((selection.size() == 1) && (selection.getFirstElement() instanceof ICompilationUnit)) return true; return false; }