/** * @see ITypeRoot#findPrimaryType() */ public IType findPrimaryType() { IType primaryType= getType(); if (primaryType.exists()) { return primaryType; } return null; } @Override
/** * Returns the primary type of a class file. * * @param classFile the class file * @return returns the primary type of the class file, or <code>null</code> * if is does not have one */ private IType getMainType(IClassFile classFile) { IType type= classFile.getType(); return type != null && type.exists() ? type : null; } }
/** * @see ITypeRoot#findPrimaryType() */ @Override public IType findPrimaryType() { IType primaryType= getType(); if (primaryType.exists()) { return primaryType; } return null; } @Override
/** * @see ITypeHierarchy */ public boolean exists() { if (!this.needsRefresh) return true; return (this.focusType == null || this.focusType.exists()) && javaProject().exists(); } /**
/** * @see ITypeHierarchy */ @Override public boolean exists() { if (!this.needsRefresh) return true; return (this.focusType == null || this.focusType.exists()) && javaProject().exists(); } /**
private static IType findType(IPackageFragment pack, String fullyQualifiedName) throws JavaModelException{ ICompilationUnit[] cus= pack.getCompilationUnits(); for (int i= 0; i < cus.length; i++) { ICompilationUnit unit= cus[i]; IType type= findType(unit, fullyQualifiedName); if (type != null && type.exists()) return type; } return null; }
/** * @see ICompilationUnit#findPrimaryType() */ public IType findPrimaryType() { String typeName = Util.getNameWithoutJavaLikeExtension(getElementName()); IType primaryType= getType(typeName); if (primaryType.exists()) { return primaryType; } return null; }
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()]); }
/** * @see ICompilationUnit#findPrimaryType() */ public IType findPrimaryType() { String typeName = Util.getNameWithoutJavaLikeExtension(getElementName()); IType primaryType= getType(typeName); if (primaryType.exists()) { return primaryType; } return null; }
public static boolean isExtractClassAvailable(IType type) throws JavaModelException { if (type == null) { return false; } if (!type.exists()) { return false; } return ReorgUtils.isInsideCompilationUnit(type) && type.isClass() && !type.isAnonymous() && !type.isLambda(); } }
public static boolean isExtractClassAvailable(IType type) throws JavaModelException { if (type == null) return false; if (!type.exists()) return false; return ReorgUtils.isInsideCompilationUnit(type) && type.isClass() && !type.isAnonymous() && !type.isLambda(); } }
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 RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { IType primary= (IType) fType.getPrimaryElement(); if (primary == null || !primary.exists()) { String message= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_does_not_exist, new String[] { JavaModelUtil.getFullyQualifiedName(fType), fType.getCompilationUnit().getElementName()}); return RefactoringStatus.createFatalErrorStatus(message); } fType= primary; return Checks.checkIfCuBroken(fType); }
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { IType primary = (IType) fType.getPrimaryElement(); if (primary == null || !primary.exists()) { String qualifiedTypeName = JavaElementLabels.getElementLabel(fType, JavaElementLabels.F_FULLY_QUALIFIED); String message = Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_does_not_exist, new String[] { BasicElementLabels.getJavaElementName(qualifiedTypeName), BasicElementLabels.getFileName(fType.getCompilationUnit()) }); return RefactoringStatus.createFatalErrorStatus(message); } fType = primary; return Checks.checkIfCuBroken(fType); }
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { IType primary= (IType) fType.getPrimaryElement(); if (primary == null || !primary.exists()) { String qualifiedTypeName= JavaElementLabels.getElementLabel(fType, JavaElementLabels.F_FULLY_QUALIFIED); String message= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_does_not_exist, new String[] { BasicElementLabels.getJavaElementName(qualifiedTypeName), BasicElementLabels.getFileName(fType.getCompilationUnit())}); return RefactoringStatus.createFatalErrorStatus(message); } fType= primary; return Checks.checkIfCuBroken(fType); }
private RefactoringStatus checkTypesInPackage() throws CoreException { IType type = Checks.findTypeInPackage(fType.getPackageFragment(), getNewElementName()); if (type == null || !type.exists()) { return null; } String msg = Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_exists, new String[] { getNewElementLabel(), JavaElementLabels.getElementLabel(fType.getPackageFragment(), JavaElementLabels.ALL_DEFAULT) }); return RefactoringStatus.createErrorStatus(msg, JavaStatusContext.create(type)); }
private RefactoringStatus checkTypesInCompilationUnit() { RefactoringStatus result= new RefactoringStatus(); if (! Checks.isTopLevel(fType)){ //the other case checked in checkTypesInPackage IType siblingType= fType.getDeclaringType().getType(getNewElementName()); if (siblingType.exists()){ String msg= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_member_type_exists, new String[]{getNewElementName(), JavaModelUtil.getFullyQualifiedName(fType.getDeclaringType())}); result.addError(msg, JavaStatusContext.create(siblingType)); } } return result; }
private RefactoringStatus checkTypesInCompilationUnit() { RefactoringStatus result= new RefactoringStatus(); if (! Checks.isTopLevel(fType)){ //the other case checked in checkTypesInPackage IType siblingType= fType.getDeclaringType().getType(getNewElementName()); if (siblingType.exists()){ String msg= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_member_type_exists, new String[] { getNewElementLabel(), BasicElementLabels.getJavaElementName(fType.getDeclaringType().getFullyQualifiedName('.'))}); result.addError(msg, JavaStatusContext.create(siblingType)); } } return result; }
private RefactoringStatus checkTypesInCompilationUnit() { RefactoringStatus result = new RefactoringStatus(); if (!Checks.isTopLevel(fType)) { //the other case checked in checkTypesInPackage IType siblingType = fType.getDeclaringType().getType(getNewElementName()); if (siblingType.exists()) { String msg = Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_member_type_exists, new String[] { getNewElementLabel(), BasicElementLabels.getJavaElementName(fType.getDeclaringType().getFullyQualifiedName('.')) }); result.addError(msg, JavaStatusContext.create(siblingType)); } } return result; }
private RefactoringStatus checkClass() { RefactoringStatus status= new RefactoringStatus(); IType type= fDescriptor.getType(); if (!fDescriptor.isCreateTopLevel()) { if (type.getType(fDescriptor.getClassName()).exists()) { status.addError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_errror_nested_name_clash, new Object[] { BasicElementLabels.getJavaElementName(fDescriptor.getClassName()), BasicElementLabels.getJavaElementName(type.getElementName()) })); } } else { status.merge(checkPackageClass()); } return status; }