private static IType[] getAllEnclosedTypes(IType type) throws JavaModelException { List<IType> result= new ArrayList<>(2); IType[] directlyEnclosed= type.getTypes(); result.addAll(Arrays.asList(directlyEnclosed)); for (int i= 0; i < directlyEnclosed.length; i++) { IType enclosedType= directlyEnclosed[i]; result.addAll(Arrays.asList(getAllEnclosedTypes(enclosedType))); } return result.toArray(new IType[result.size()]); }
private static IType[] getAllEnclosedTypes(IType type) throws JavaModelException { List<IType> result= new ArrayList<>(2); IType[] directlyEnclosed= type.getTypes(); result.addAll(Arrays.asList(directlyEnclosed)); for (int i= 0; i < directlyEnclosed.length; i++) { IType enclosedType= directlyEnclosed[i]; result.addAll(Arrays.asList(getAllEnclosedTypes(enclosedType))); } return result.toArray(new IType[result.size()]); }
private static IType[] getAllEnclosedTypes(IType type) throws JavaModelException { List result= new ArrayList(2); IType[] directlyEnclosed= type.getTypes(); result.addAll(Arrays.asList(directlyEnclosed)); for (int i= 0; i < directlyEnclosed.length; i++) { IType enclosedType= directlyEnclosed[i]; result.addAll(Arrays.asList(getAllEnclosedTypes(enclosedType))); } return (IType[]) result.toArray(new IType[result.size()]); }
private static void checkHierarchyOfEnclosedTypes(IType destinationType, RefactoringStatus result, IType type) throws JavaModelException { IType[] enclosedTypes= getAllEnclosedTypes(type); for (int i= 0; i < enclosedTypes.length; i++) { IType enclosedType= enclosedTypes[i]; if (destinationType.getElementName().equals(enclosedType.getElementName())){ String message= Messages.format(RefactoringCoreMessages.MemberCheckUtil_type_name_conflict3, new String[]{JavaModelUtil.getFullyQualifiedName(enclosedType), JavaModelUtil.getFullyQualifiedName(type)}); RefactoringStatusContext context= JavaStatusContext.create(destinationType.getCompilationUnit(), destinationType.getNameRange()); result.addError(message, context); } if (typeNameExistsInEnclosingTypeChain(destinationType, enclosedType.getElementName())){ String message= Messages.format(RefactoringCoreMessages.MemberCheckUtil_type_name_conflict4, new String[]{JavaModelUtil.getFullyQualifiedName(enclosedType), JavaModelUtil.getFullyQualifiedName(type)}); RefactoringStatusContext context= JavaStatusContext.create(destinationType.getCompilationUnit(), destinationType.getNameRange()); result.addError(message, context); } } }
private static void checkHierarchyOfEnclosedTypes(IType destinationType, RefactoringStatus result, IType type) throws JavaModelException { IType[] enclosedTypes= getAllEnclosedTypes(type); for (int i= 0; i < enclosedTypes.length; i++) { IType enclosedType= enclosedTypes[i]; if (destinationType.getElementName().equals(enclosedType.getElementName())){ String message= Messages.format(RefactoringCoreMessages.MemberCheckUtil_type_name_conflict3, new String[] { getQualifiedLabel(enclosedType), getQualifiedLabel(type)}); RefactoringStatusContext context= JavaStatusContext.create(destinationType.getCompilationUnit(), destinationType.getNameRange()); result.addError(message, context); } if (typeNameExistsInEnclosingTypeChain(destinationType, enclosedType.getElementName())){ String message= Messages.format(RefactoringCoreMessages.MemberCheckUtil_type_name_conflict4, new String[] { getQualifiedLabel(enclosedType), getQualifiedLabel(type)}); RefactoringStatusContext context= JavaStatusContext.create(destinationType.getCompilationUnit(), destinationType.getNameRange()); result.addError(message, context); } } }
private static void checkHierarchyOfEnclosedTypes(IType destinationType, RefactoringStatus result, IType type) throws JavaModelException { IType[] enclosedTypes= getAllEnclosedTypes(type); for (int i= 0; i < enclosedTypes.length; i++) { IType enclosedType= enclosedTypes[i]; if (destinationType.getElementName().equals(enclosedType.getElementName())){ String message= Messages.format(RefactoringCoreMessages.MemberCheckUtil_type_name_conflict3, new String[] { getQualifiedLabel(enclosedType), getQualifiedLabel(type)}); RefactoringStatusContext context= JavaStatusContext.create(destinationType.getCompilationUnit(), destinationType.getNameRange()); result.addError(message, context); } if (typeNameExistsInEnclosingTypeChain(destinationType, enclosedType.getElementName())){ String message= Messages.format(RefactoringCoreMessages.MemberCheckUtil_type_name_conflict4, new String[] { getQualifiedLabel(enclosedType), getQualifiedLabel(type)}); RefactoringStatusContext context= JavaStatusContext.create(destinationType.getCompilationUnit(), destinationType.getNameRange()); result.addError(message, context); } } }