Java Code Examples for org.eclipse.jdt.core.IType#getTypes()
The following examples show how to use
org.eclipse.jdt.core.IType#getTypes() .
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: ResolveMainMethodHandler.java From java-debug with Eclipse Public License 1.0 | 6 votes |
private static List<IType> getPotentialMainClassTypesInChildren(IType type) throws JavaModelException { IType[] children = type.getTypes(); if (children.length == 0) { return Collections.emptyList(); } List<IType> result = new ArrayList<>(); for (IType child : children) { // main method can only exist in the static class or top level class. if (child.isClass() && Flags.isStatic(child.getFlags())) { result.add(child); result.addAll(getPotentialMainClassTypesInChildren(child)); } } return result; }
Example 2
Source File: DeltaConverter.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.8 */ private void convertChangedTypeAndChildren(List<IResourceDescription.Delta> result, TypeNames previousTypeNames, IType type, URI topLevelUri) { String typeName = type.getFullyQualifiedName(); if (previousTypeNames.remove(typeName)) { convertChangedType(topLevelUri, type, result); } else { convertNewType(topLevelUri, type, result); } try { for(IType child : type.getTypes()){ convertChangedTypeAndChildren(result, previousTypeNames, child, topLevelUri); } } catch (JavaModelException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(e, e); } } }
Example 3
Source File: RenameFieldProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private RefactoringStatus checkNestedHierarchy(IType type) throws CoreException { IType[] nestedTypes= type.getTypes(); if (nestedTypes == null) { return null; } RefactoringStatus result= new RefactoringStatus(); for (int i= 0; i < nestedTypes.length; i++){ IField otherField= nestedTypes[i].getField(getNewElementName()); if (otherField.exists()){ String msg= Messages.format( RefactoringCoreMessages.RenameFieldRefactoring_hiding, new String[]{ BasicElementLabels.getJavaElementName(fField.getElementName()), BasicElementLabels.getJavaElementName(getNewElementName()), BasicElementLabels.getJavaElementName(nestedTypes[i].getFullyQualifiedName('.'))}); result.addWarning(msg, JavaStatusContext.create(otherField)); } result.merge(checkNestedHierarchy(nestedTypes[i])); } return result; }
Example 4
Source File: RefactoringAvailabilityTester.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public static IMember[] getPullUpMembers(final IType type) throws JavaModelException { final List<IMember> list = new ArrayList<>(3); if (type.exists()) { IMember[] members = type.getFields(); for (int index = 0; index < members.length; index++) { if (isPullUpAvailable(members[index])) { list.add(members[index]); } } members = type.getMethods(); for (int index = 0; index < members.length; index++) { if (isPullUpAvailable(members[index])) { list.add(members[index]); } } members = type.getTypes(); for (int index = 0; index < members.length; index++) { if (isPullUpAvailable(members[index])) { list.add(members[index]); } } } return list.toArray(new IMember[list.size()]); }
Example 5
Source File: RenameFieldProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private RefactoringStatus checkNestedHierarchy(IType type) throws CoreException { IType[] nestedTypes= type.getTypes(); if (nestedTypes == null) return null; RefactoringStatus result= new RefactoringStatus(); for (int i= 0; i < nestedTypes.length; i++){ IField otherField= nestedTypes[i].getField(getNewElementName()); if (otherField.exists()){ String msg= Messages.format( RefactoringCoreMessages.RenameFieldRefactoring_hiding, new String[]{ BasicElementLabels.getJavaElementName(fField.getElementName()), BasicElementLabels.getJavaElementName(getNewElementName()), BasicElementLabels.getJavaElementName(nestedTypes[i].getFullyQualifiedName('.'))}); result.addWarning(msg, JavaStatusContext.create(otherField)); } result.merge(checkNestedHierarchy(nestedTypes[i])); } return result; }
Example 6
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static IMember[] getPullUpMembers(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 (isPullUpAvailable(members[index])) list.add(members[index]); } members= type.getMethods(); for (int index= 0; index < members.length; index++) { if (isPullUpAvailable(members[index])) list.add(members[index]); } members= type.getTypes(); for (int index= 0; index < members.length; index++) { if (isPullUpAvailable(members[index])) list.add(members[index]); } } return list.toArray(new IMember[list.size()]); }
Example 7
Source File: ExtraFlags.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example 8
Source File: SystemObject.java From JDeodorant with MIT License | 6 votes |
public Set<ClassObject> getClassObjects(IType type) { Set<ClassObject> classObjectSet = new LinkedHashSet<ClassObject>(); String typeQualifiedName = type.getFullyQualifiedName('.'); ClassObject classObject = getClassObject(typeQualifiedName); if(classObject != null) classObjectSet.add(classObject); try { IType[] nestedTypes = type.getTypes(); for(IType nestedType : nestedTypes) { classObjectSet.addAll(getClassObjects(nestedType)); } } catch (JavaModelException e) { e.printStackTrace(); } return classObjectSet; }
Example 9
Source File: DeltaConverter.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.8 */ protected void convertNewTypeAndChildren(URI topLevelType, IType type, List<IResourceDescription.Delta> result) { convertNewType(topLevelType, type, result); try { for(IType child : type.getTypes()){ convertNewTypeAndChildren(topLevelType, child, result); } } catch (JavaModelException e) { if (LOGGER.isDebugEnabled()) LOGGER.debug(e, e); } }
Example 10
Source File: RenameTypeProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static IType findEnclosedType(IType type, String newName) throws CoreException { IType[] enclosedTypes = type.getTypes(); for (int i = 0; i < enclosedTypes.length; i++) { if (newName.equals(enclosedTypes[i].getElementName()) || findEnclosedType(enclosedTypes[i], newName) != null) { return enclosedTypes[i]; } } return null; }
Example 11
Source File: MemberCheckUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static IType[] getAllEnclosedTypes(IType type) throws JavaModelException { List<IType> result= new ArrayList<IType>(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()]); }
Example 12
Source File: RenameTypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static IType findEnclosedType(IType type, String newName) throws CoreException { IType[] enclosedTypes= type.getTypes(); for (int i= 0; i < enclosedTypes.length; i++){ if (newName.equals(enclosedTypes[i].getElementName()) || findEnclosedType(enclosedTypes[i], newName) != null) return enclosedTypes[i]; } return null; }
Example 13
Source File: NameLookup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Notifies the given requestor of all types (classes and interfaces) in the * given type with the given (possibly qualified) name. Checks * the requestor at regular intervals to see if the requestor * has canceled. */ protected boolean seekTypesInType(String prefix, int firstDot, IType type, IJavaElementRequestor requestor, int acceptFlags) { IType[] types= null; try { types= type.getTypes(); } catch (JavaModelException npe) { return false; // the enclosing type is not present } int length= types.length; if (length == 0) return false; String memberPrefix = prefix; boolean isMemberTypePrefix = false; if (firstDot != -1) { memberPrefix= prefix.substring(0, firstDot); isMemberTypePrefix = true; } for (int i= 0; i < length; i++) { if (requestor.isCanceled()) return false; IType memberType= types[i]; if (memberType.getElementName().toLowerCase().startsWith(memberPrefix)) if (isMemberTypePrefix) { String subPrefix = prefix.substring(firstDot + 1, prefix.length()); return seekTypesInType(subPrefix, subPrefix.indexOf('.'), memberType, requestor, acceptFlags); } else { if (acceptType(memberType, acceptFlags, true/*a source type*/)) { requestor.acceptMemberType(memberType); return true; } } } return false; }