/** * Answers if the given <code>element</code> is a valid * input for this part. * * @param element the object to test * @return <true> if the given element is a valid input */ protected boolean isValidInput(Object element) { if (element instanceof IType) { IType type= (IType)element; return type.isBinary() || type.getDeclaringType() == null; } return false; }
/** * Locates and returns source code for the given (binary) type, in this * SourceMapper's ZIP file, or returns <code>null</code> if source * code cannot be found. */ public char[] findSource(IType type, IBinaryType info) { if (!type.isBinary()) { return null; } String simpleSourceFileName = ((BinaryType) type).getSourceFileName(info); if (simpleSourceFileName == null) { return null; } return findSource(type, simpleSourceFileName); }
private static IStatus validateDestinationType(IType type, String typeName){ if (type == null || ! type.exists()) return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(RefactoringMessages.MoveMembersInputPage_not_found, typeName), null); if (type.isBinary()) return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_no_binary, null); return new Status(IStatus.OK, JavaPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$ }
private IType[] getAbstractDestinations(IProgressMonitor monitor) throws JavaModelException { IType[] allDirectSubclasses= getHierarchyOfDeclaringClass(monitor).getSubclasses(getDeclaringType()); List<IType> result= new ArrayList<>(allDirectSubclasses.length); for (int index= 0; index < allDirectSubclasses.length; index++) { IType subclass= allDirectSubclasses[index]; if (subclass.exists() && !subclass.isBinary() && !subclass.isReadOnly() && subclass.getCompilationUnit() != null && subclass.isStructureKnown()) result.add(subclass); } return result.toArray(new IType[result.size()]); }
private IType[] getAbstractDestinations(IProgressMonitor monitor) throws JavaModelException { IType[] allDirectSubclasses= getHierarchyOfDeclaringClass(monitor).getSubclasses(getDeclaringType()); List<IType> result= new ArrayList<>(allDirectSubclasses.length); for (int index= 0; index < allDirectSubclasses.length; index++) { IType subclass= allDirectSubclasses[index]; if (subclass.exists() && !subclass.isBinary() && !subclass.isReadOnly() && subclass.getCompilationUnit() != null && subclass.isStructureKnown()) result.add(subclass); } return result.toArray(new IType[result.size()]); }
private static IStatus validateDestinationType(IType type, String typeName){ if (type == null || ! type.exists()) return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(RefactoringMessages.MoveMembersInputPage_not_found, BasicElementLabels.getJavaElementName(typeName)), null); if (type.isBinary()) return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_no_binary, null); return Status.OK_STATUS; }
private IType[] getAbstractDestinations(IProgressMonitor monitor) throws JavaModelException { IType[] allDirectSubclasses= getHierarchyOfDeclaringClass(monitor).getSubclasses(getDeclaringType()); List result= new ArrayList(allDirectSubclasses.length); for (int index= 0; index < allDirectSubclasses.length; index++) { IType subclass= allDirectSubclasses[index]; if (subclass.exists() && !subclass.isBinary() && !subclass.isReadOnly() && subclass.getCompilationUnit() != null && subclass.isStructureKnown()) result.add(subclass); } return (IType[]) result.toArray(new IType[result.size()]); }
private static IStatus validateDestinationType(IType type, String typeName){ if (type == null || ! type.exists()) return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, Messages.format(RefactoringMessages.MoveMembersInputPage_not_found, BasicElementLabels.getJavaElementName(typeName)), null); if (type.isBinary()) return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_no_binary, null); return Status.OK_STATUS; }
/** * Returns the element at the given position in the given type */ protected static IJavaElement getElementAt(IType type, int pos) throws JavaModelException { if (type.isBinary()) { return type.getClassFile().getElementAt(pos); } return type.getCompilationUnit().getElementAt(pos); }
@Override public final boolean isApplicable() throws CoreException { return Checks.isAvailable(fSubType) && !fSubType.isBinary() && !fSubType.isReadOnly() && !fSubType.isAnnotation() && !fSubType.isAnonymous(); }
private RefactoringStatus checkDeclaringType(){ IType declaringType= getDeclaringType(); if (JavaModelUtil.getFullyQualifiedName(declaringType).equals("java.lang.Object")) //$NON-NLS-1$ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveMembersRefactoring_Object); if (declaringType.isBinary()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveMembersRefactoring_binary); if (declaringType.isReadOnly()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveMembersRefactoring_read_only); return null; }
private RefactoringStatus checkDeclaringType(){ IType declaringType= getDeclaringType(); if (declaringType.getFullyQualifiedName('.').equals("java.lang.Object")) //$NON-NLS-1$ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveMembersRefactoring_Object); if (declaringType.isBinary()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveMembersRefactoring_binary); if (declaringType.isReadOnly()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveMembersRefactoring_read_only); return null; }
@Override public final boolean isApplicable() throws CoreException { return Checks.isAvailable(fSubType) && !fSubType.isBinary() && !fSubType.isReadOnly() && !fSubType.isAnnotation() && !fSubType.isAnonymous(); }
private RefactoringStatus checkDeclaringType(){ IType declaringType= getDeclaringType(); if (declaringType.getFullyQualifiedName('.').equals("java.lang.Object")) //$NON-NLS-1$ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveMembersRefactoring_Object); if (declaringType.isBinary()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveMembersRefactoring_binary); if (declaringType.isReadOnly()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveMembersRefactoring_read_only); return null; }
public static boolean isMainType(IType type) throws JavaModelException{ if (! type.exists()) return false; if (type.isBinary()) return false; if (type.getCompilationUnit() == null) return false; if (type.getDeclaringType() != null) return false; return isPrimaryType(type) || isCuOnlyType(type); }
public static boolean isMainType(IType type) throws JavaModelException{ if (! type.exists()) return false; if (type.isBinary()) return false; if (type.getCompilationUnit() == null) return false; if (type.getDeclaringType() != null) return false; return isPrimaryType(type) || isCuOnlyType(type); }
public static boolean isMainType(IType type) throws JavaModelException{ if (! type.exists()) return false; if (type.isBinary()) return false; if (type.getCompilationUnit() == null) return false; if (type.getDeclaringType() != null) return false; return isPrimaryType(type) || isCuOnlyType(type); }
public static boolean isExtractInterfaceAvailable(final IType type) throws JavaModelException { return Checks.isAvailable(type) && !type.isBinary() && !type.isReadOnly() && !type.isAnnotation() && !type.isAnonymous() && !type.isLambda(); }
@SuppressWarnings("squid:S1067") protected boolean acceptType(IType jdtType) throws CoreException { //fast check before doing expensive source parsing return S2eUtils.exists(jdtType) && S2eUtils.exists(jdtType.getJavaProject()) // required! && !jdtType.isAnonymous() && !jdtType.isBinary() && jdtType.getDeclaringType() == null && Flags.isPublic(jdtType.getFlags()); }
protected RefactoringStatus checkDeclaringType(final IProgressMonitor monitor) throws JavaModelException { final IType type= getDeclaringType(); if (type.isEnum()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_enum_members); if (type.isAnnotation()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_annotation_members); if (type.isInterface()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_interface_members); if (type.isBinary()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_members_of_binary); if (type.isReadOnly()) return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.HierarchyRefactoring_members_of_read_only); return new RefactoringStatus(); }