Java Code Examples for org.eclipse.jdt.core.dom.ITypeBinding#isEnum()

The following examples show how to use org.eclipse.jdt.core.dom.ITypeBinding#isEnum() . 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: BindingLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static ImageDescriptor getTypeImageDescriptor(boolean inner, ITypeBinding binding, int flags) {
	if (binding.isEnum())
		return JavaPluginImages.DESC_OBJS_ENUM;
	else if (binding.isAnnotation())
		return JavaPluginImages.DESC_OBJS_ANNOTATION;
	else if (binding.isInterface()) {
		if ((flags & JavaElementImageProvider.LIGHT_TYPE_ICONS) != 0)
			return JavaPluginImages.DESC_OBJS_INTERFACEALT;
		if (inner)
			return getInnerInterfaceImageDescriptor(binding.getModifiers());
		return getInterfaceImageDescriptor(binding.getModifiers());
	} else if (binding.isClass()) {
		if ((flags & JavaElementImageProvider.LIGHT_TYPE_ICONS) != 0)
			return JavaPluginImages.DESC_OBJS_CLASSALT;
		if (inner)
			return getInnerClassImageDescriptor(binding.getModifiers());
		return getClassImageDescriptor(binding.getModifiers());
	} else if (binding.isTypeVariable()) {
		return JavaPluginImages.DESC_OBJS_TYPEVARIABLE;
	}
	// primitive type, wildcard
	return null;
}
 
Example 2
Source File: TypeURIHelper.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void createResourceURI(ITypeBinding typeBinding, StringBuilder uriBuilder) {
	if (typeBinding.isPrimitive()) {
		createResourceURIForPrimitive(uriBuilder);
		return;
	}
	if (typeBinding.isClass() || typeBinding.isInterface() || typeBinding.isAnnotation() || typeBinding.isEnum()) {
		createResourceURIForClass(typeBinding, uriBuilder);
		return;
	}
	if (typeBinding.isArray()) {
		createResourceURIForArray(typeBinding, uriBuilder);
		return;
	}
	if (typeBinding.isTypeVariable()) {
		createResourceURIForTypeVariable(typeBinding, uriBuilder);
		return;
	}
	throw new IllegalStateException("Unexpected type: " + typeBinding);
}
 
Example 3
Source File: QuickAssistProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean getMissingCaseStatementProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> proposals) {
	if (node instanceof SwitchCase) {
		node= node.getParent();
	}
	if (!(node instanceof SwitchStatement))
		return false;

	SwitchStatement switchStatement= (SwitchStatement)node;
	ITypeBinding expressionBinding= switchStatement.getExpression().resolveTypeBinding();
	if (expressionBinding == null || !expressionBinding.isEnum())
		return false;

	ArrayList<String> missingEnumCases= new ArrayList<String>();
	boolean hasDefault= LocalCorrectionsSubProcessor.evaluateMissingSwitchCases(expressionBinding, switchStatement.statements(), missingEnumCases);
	if (missingEnumCases.size() == 0 && hasDefault)
		return false;

	if (proposals == null)
		return true;

	LocalCorrectionsSubProcessor.createMissingCaseProposals(context, switchStatement, missingEnumCases, proposals);
	return true;
}
 
Example 4
Source File: LocalCorrectionsSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static void getMissingEnumConstantCaseProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
	for (Iterator<ICommandAccess> iterator= proposals.iterator(); iterator.hasNext();) {
		ICommandAccess proposal= iterator.next();
		if (proposal instanceof ChangeCorrectionProposal) {
			if (CorrectionMessages.LocalCorrectionsSubProcessor_add_missing_cases_description.equals(((ChangeCorrectionProposal) proposal).getName())) {
				return;
			}
		}
	}
	
	ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
	if (selectedNode instanceof Expression && selectedNode.getLocationInParent() == SwitchStatement.EXPRESSION_PROPERTY) {
		SwitchStatement statement= (SwitchStatement) selectedNode.getParent();
		ITypeBinding binding= statement.getExpression().resolveTypeBinding();
		if (binding == null || !binding.isEnum()) {
			return;
		}

		ArrayList<String> missingEnumCases= new ArrayList<String>();
		boolean hasDefault= evaluateMissingSwitchCases(binding, statement.statements(), missingEnumCases);
		if (missingEnumCases.size() == 0 && hasDefault)
			return;

		createMissingCaseProposals(context, statement, missingEnumCases, proposals);
	}
}
 
Example 5
Source File: ExtractConstantRefactoring.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static boolean canReplace(IASTFragment fragment) {
	ASTNode node = fragment.getAssociatedNode();
	ASTNode parent = node.getParent();
	if (parent instanceof VariableDeclarationFragment) {
		VariableDeclarationFragment vdf = (VariableDeclarationFragment) parent;
		if (node.equals(vdf.getName())) {
			return false;
		}
	}
	if (parent instanceof ExpressionStatement) {
		return false;
	}
	if (parent instanceof SwitchCase) {
		if (node instanceof Name) {
			Name name = (Name) node;
			ITypeBinding typeBinding = name.resolveTypeBinding();
			if (typeBinding != null) {
				return !typeBinding.isEnum();
			}
		}
	}
	return true;
}
 
Example 6
Source File: GenerateHashCodeEqualsAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
RefactoringStatus checkMember(Object memberBinding) {
	RefactoringStatus status= new RefactoringStatus();
	IVariableBinding variableBinding= (IVariableBinding)memberBinding;
	ITypeBinding fieldsType= variableBinding.getType();
	if (fieldsType.isArray())
		fieldsType= fieldsType.getElementType();
	if (!fieldsType.isPrimitive() && !fieldsType.isEnum() && !alreadyCheckedMemberTypes.contains(fieldsType) && !fieldsType.equals(fTypeBinding)) {
		status.merge(checkHashCodeEqualsExists(fieldsType, false));
		alreadyCheckedMemberTypes.add(fieldsType);
	}
	if (Modifier.isTransient(variableBinding.getModifiers()))
		status.addWarning(Messages.format(ActionMessages.GenerateHashCodeEqualsAction_transient_field_included_error, BasicElementLabels.getJavaElementName(variableBinding.getName())),
				createRefactoringStatusContext(variableBinding.getJavaElement()));
	return status;
}
 
Example 7
Source File: ScopeAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean visit(SwitchCase node) {
	// switch on enum allows to use enum constants without qualification
	if (hasFlag(VARIABLES, fFlags) && !node.isDefault() && isInside(node.getExpression())) {
		SwitchStatement switchStatement= (SwitchStatement) node.getParent();
		ITypeBinding binding= switchStatement.getExpression().resolveTypeBinding();
		if (binding != null && binding.isEnum()) {
			IVariableBinding[] declaredFields= binding.getDeclaredFields();
			for (int i= 0; i < declaredFields.length; i++) {
				IVariableBinding curr= declaredFields[i];
				if (curr.isEnumConstant()) {
					fBreak= fRequestor.acceptBinding(curr);
					if (fBreak)
						return false;
				}
			}
		}
	}
	return false;
}
 
Example 8
Source File: ExtractConstantRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean canReplace(IASTFragment fragment) {
	ASTNode node= fragment.getAssociatedNode();
	ASTNode parent= node.getParent();
	if (parent instanceof VariableDeclarationFragment) {
		VariableDeclarationFragment vdf= (VariableDeclarationFragment) parent;
		if (node.equals(vdf.getName()))
			return false;
	}
	if (parent instanceof ExpressionStatement)
		return false;
	if (parent instanceof SwitchCase) {
		if (node instanceof Name) {
			Name name= (Name) node;
			ITypeBinding typeBinding= name.resolveTypeBinding();
			if (typeBinding != null) {
				return !typeBinding.isEnum();
			}
		}
	}
	return true;
}
 
Example 9
Source File: UnresolvedElementsSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static void addNewFieldForType(ICompilationUnit targetCU, ITypeBinding binding, ITypeBinding senderDeclBinding, SimpleName simpleName, boolean isWriteAccess, boolean mustBeConst, Collection<ICommandAccess> proposals) {
	String name= simpleName.getIdentifier();
	String nameLabel= BasicElementLabels.getJavaElementName(name);
	String label;
	Image image;
	if (senderDeclBinding.isEnum() && !isWriteAccess) {
		label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createenum_description, new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) });
		image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
		proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.ENUM_CONST, simpleName, senderDeclBinding, 10, image));
	} else {
		if (!mustBeConst) {
			if (binding == null) {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createfield_description, nameLabel);
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE);
			} else {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createfield_other_description, new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) } );
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
			}
			int fieldRelevance= StubUtility.hasFieldName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_FIELD_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_FIELD;
			proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.FIELD, simpleName, senderDeclBinding, fieldRelevance, image));
		}

		if (!isWriteAccess && !senderDeclBinding.isAnonymous()) {
			if (binding == null) {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createconst_description, nameLabel);
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE);
			} else {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createconst_other_description, new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) } );
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
			}
			int constRelevance= StubUtility.hasConstantName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_CONSTANT_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_CONSTANT;
			proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.CONST_FIELD, simpleName, senderDeclBinding, constRelevance, image));
		}
	}
}
 
Example 10
Source File: JdtUtils.java    From j2cl with Apache License 2.0 5 votes vote down vote up
private static Kind getKindFromTypeBinding(ITypeBinding typeBinding) {
  if (typeBinding.isEnum() && !typeBinding.isAnonymous()) {
    // Do not consider the anonymous classes that constitute enum values as Enums, only the
    // enum "class" itself is considered Kind.ENUM.
    return Kind.ENUM;
  } else if (typeBinding.isClass() || (typeBinding.isEnum() && typeBinding.isAnonymous())) {
    return Kind.CLASS;
  } else if (typeBinding.isInterface()) {
    return Kind.INTERFACE;
  }
  throw new InternalCompilerError("Type binding %s not handled", typeBinding);
}
 
Example 11
Source File: TType.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Initialized the type from the given binding
 *
 * @param binding the binding to initialize from
 */
protected void initialize(ITypeBinding binding) {
	fBindingKey= binding.getKey();
	Assert.isNotNull(fBindingKey);
	fModifiers= binding.getModifiers();
	if (binding.isClass()) {
		fFlags= F_IS_CLASS;
	// the annotation test has to be done before test for interface
	// since annotations are interfaces as well.
	} else if (binding.isAnnotation()) {
		fFlags= F_IS_ANNOTATION | F_IS_INTERFACE;
	} else if (binding.isInterface()) {
		fFlags= F_IS_INTERFACE;
	} else if (binding.isEnum()) {
		fFlags= F_IS_ENUM;
	}

	if (binding.isTopLevel()) {
		fFlags|= F_IS_TOP_LEVEL;
	} else if (binding.isNested()) {
		fFlags|= F_IS_NESTED;
		if (binding.isMember()) {
			fFlags|= F_IS_MEMBER;
		} else if (binding.isLocal()) {
			fFlags|= F_IS_LOCAL;
		} else if (binding.isAnonymous()) {
			fFlags|= F_IS_ANONYMOUS;
		}
	}
}
 
Example 12
Source File: MoveInstanceMethodProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Computes the target categories for the method to move.
 *
 * @param declaration
 *            the method declaration
 * @return the possible targets as variable bindings of read-only fields and
 *         parameters
 */
protected IVariableBinding[] computeTargetCategories(final MethodDeclaration declaration) {
	Assert.isNotNull(declaration);
	if (fPossibleTargets.length == 0 || fCandidateTargets.length == 0) {
		final List<IVariableBinding> possibleTargets= new ArrayList<IVariableBinding>(16);
		final List<IVariableBinding> candidateTargets= new ArrayList<IVariableBinding>(16);
		final IMethodBinding method= declaration.resolveBinding();
		if (method != null) {
			final ITypeBinding declaring= method.getDeclaringClass();
			IVariableBinding[] bindings= getArgumentBindings(declaration);
			ITypeBinding binding= null;
			for (int index= 0; index < bindings.length; index++) {
				binding= bindings[index].getType();
				if ((binding.isClass() || binding.isEnum() || is18OrHigherInterface(binding)) && binding.isFromSource()) {
					possibleTargets.add(bindings[index]);
					candidateTargets.add(bindings[index]);
				}
			}
			final ReadyOnlyFieldFinder visitor= new ReadyOnlyFieldFinder(declaring);
			declaration.accept(visitor);
			bindings= visitor.getReadOnlyFields();
			for (int index= 0; index < bindings.length; index++) {
				binding= bindings[index].getType();
				if ((binding.isClass() || is18OrHigherInterface(binding)) && binding.isFromSource())
					possibleTargets.add(bindings[index]);
			}
			bindings= visitor.getDeclaredFields();
			for (int index= 0; index < bindings.length; index++) {
				binding= bindings[index].getType();
				if ((binding.isClass() || is18OrHigherInterface(binding)) && binding.isFromSource())
					candidateTargets.add(bindings[index]);
			}
		}
		fPossibleTargets= new IVariableBinding[possibleTargets.size()];
		possibleTargets.toArray(fPossibleTargets);
		fCandidateTargets= new IVariableBinding[candidateTargets.size()];
		candidateTargets.toArray(fCandidateTargets);
	}
	return fPossibleTargets;
}
 
Example 13
Source File: GenerateConstructorsHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static IMethodBinding[] getVisibleConstructors(CompilationUnit astRoot, ITypeBinding typeBinding) {
	if (typeBinding.isEnum()) {
		return new IMethodBinding[] { getObjectConstructor(astRoot.getAST()) };
	} else {
		return StubUtility2Core.getVisibleConstructors(typeBinding, false, true);
	}
}
 
Example 14
Source File: UnresolvedElementsSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static void addNewFieldForType(ICompilationUnit targetCU, ITypeBinding binding,
		ITypeBinding senderDeclBinding, SimpleName simpleName, boolean isWriteAccess, boolean mustBeConst,
		Collection<ChangeCorrectionProposal> proposals) {
	String name= simpleName.getIdentifier();
	String nameLabel= BasicElementLabels.getJavaElementName(name);
	String label;
	if (senderDeclBinding.isEnum() && !isWriteAccess) {
		label = Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createenum_description,
				new Object[] { nameLabel, org.eclipse.jdt.ls.core.internal.corrections.ASTResolving.getTypeSignature(senderDeclBinding) });
		proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.ENUM_CONST,
				simpleName, senderDeclBinding, 10));
	} else {
		if (!mustBeConst) {
			if (binding == null) {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createfield_description, nameLabel);
			} else {
				label = Messages.format(
						CorrectionMessages.UnresolvedElementsSubProcessor_createfield_other_description,
						new Object[] { nameLabel, org.eclipse.jdt.ls.core.internal.corrections.ASTResolving.getTypeSignature(senderDeclBinding) });
			}
			int fieldRelevance= StubUtility.hasFieldName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_FIELD_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_FIELD;
			proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.FIELD,
					simpleName, senderDeclBinding, fieldRelevance));
		}

		if (!isWriteAccess && !senderDeclBinding.isAnonymous()) {
			if (binding == null) {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createconst_description, nameLabel);
			} else {
				label = Messages.format(
						CorrectionMessages.UnresolvedElementsSubProcessor_createconst_other_description,
						new Object[] { nameLabel, org.eclipse.jdt.ls.core.internal.corrections.ASTResolving.getTypeSignature(senderDeclBinding) });
			}
			int constRelevance= StubUtility.hasConstantName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_CONSTANT_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_CONSTANT;
			proposals.add(new NewVariableCorrectionProposal(label, targetCU,
					NewVariableCorrectionProposal.CONST_FIELD, simpleName, senderDeclBinding, constRelevance));
		}
	}
}
 
Example 15
Source File: LocalCorrectionsSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static void getMissingEnumConstantCaseProposals(IInvocationContext context, IProblemLocationCore problem, Collection<ChangeCorrectionProposal> proposals) {
	for (ChangeCorrectionProposal proposal : proposals) {
		if (CorrectionMessages.LocalCorrectionsSubProcessor_add_missing_cases_description.equals(proposal.getName())) {
			return;
		}
	}

	ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
	if (selectedNode instanceof Expression) {
		StructuralPropertyDescriptor locationInParent = selectedNode.getLocationInParent();
		ASTNode parent = selectedNode.getParent();
		ITypeBinding binding;
		List<Statement> statements;

		if (locationInParent == SwitchStatement.EXPRESSION_PROPERTY) {
			SwitchStatement statement = (SwitchStatement) parent;
			binding = statement.getExpression().resolveTypeBinding();
			statements = statement.statements();
		} else if (locationInParent == SwitchExpression.EXPRESSION_PROPERTY) {
			SwitchExpression switchExpression = (SwitchExpression) parent;
			binding = switchExpression.getExpression().resolveTypeBinding();
			statements = switchExpression.statements();
		} else {
			return;
		}

		if (binding == null || !binding.isEnum()) {
			return;
		}

		ArrayList<String> missingEnumCases = new ArrayList<>();
		boolean hasDefault = evaluateMissingSwitchCases(binding, statements, missingEnumCases);
		if (missingEnumCases.size() == 0 && hasDefault) {
			return;
		}

		createMissingCaseProposals(context, parent, missingEnumCases, proposals);
	}
}
 
Example 16
Source File: SystemObject.java    From JDeodorant with MIT License 5 votes vote down vote up
private boolean allStaticFieldsWithinSystemBoundary(List<SimpleName> staticFields) {
	for(SimpleName staticField : staticFields) {
		IBinding binding = staticField.resolveBinding();
		if(binding != null && binding.getKind() == IBinding.VARIABLE) {
			IVariableBinding variableBinding = (IVariableBinding)binding;
			ITypeBinding declaringClassTypeBinding = variableBinding.getDeclaringClass();
			if(declaringClassTypeBinding != null) {
				if(getPositionInClassList(declaringClassTypeBinding.getQualifiedName()) == -1 && !declaringClassTypeBinding.isEnum())
					return false;
			}
		}
	}
	return true;
}
 
Example 17
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
ParameterNameInitializer createParameterNameInitializer(
		IMethodBinding method,
		WorkingCopyOwner workingCopyOwner,
		JvmExecutable result,
		String handleIdentifier,
		String[] path,
		String name,
		SegmentSequence signaturex) {
	if (method.isConstructor()) {
		ITypeBinding declarator = method.getDeclaringClass();
		if (declarator.isEnum()) {
			return new EnumConstructorParameterNameInitializer(workingCopyOwner, result, handleIdentifier, path, name, signaturex);
		}
		if (declarator.isMember()) {
			return new ParameterNameInitializer(workingCopyOwner, result, handleIdentifier, path, name, signaturex) {
				@Override
				protected void setParameterNames(IMethod javaMethod, java.util.List<JvmFormalParameter> parameters) throws JavaModelException {
					String[] parameterNames = javaMethod.getParameterNames();
					int size = parameters.size();
					if (size == parameterNames.length) {
						super.setParameterNames(javaMethod, parameters);
					} else if (size == parameterNames.length - 1) {
						for (int i = 1; i < parameterNames.length; i++) {
							String string = parameterNames[i];
							parameters.get(i - 1).setName(string);
						}
					} else {
						throw new IllegalStateException("unmatching arity for java method "+javaMethod.toString()+" and "+getExecutable().getIdentifier());
					}
				}
			};
		}
	}
	return new ParameterNameInitializer(workingCopyOwner, result, handleIdentifier, path, name, signaturex);
}
 
Example 18
Source File: SystemObject.java    From JDeodorant with MIT License 4 votes vote down vote up
private boolean validTypeBinding(ITypeBinding typeBinding) {
	return typeBinding.isPrimitive() || typeBinding.isEnum() || typeBinding.getQualifiedName().equals("java.lang.String");
}
 
Example 19
Source File: ElementTypeTeller.java    From txtUML with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isModelEnum(ITypeBinding binding) {
	return binding.isEnum() && SharedUtils.typeIsAssignableFrom(binding, ModelEnum.class);
}
 
Example 20
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.4
 */
protected JvmDeclaredType createType(ITypeBinding typeBinding, String handleIdentifier, List<String> path, StringBuilder fqn) {
	if (typeBinding.isAnonymous() || typeBinding.isSynthetic())
		throw new IllegalStateException("Cannot create type for anonymous or synthetic classes");

	// Creates the right type of instance based on the type of binding.
	//
	JvmGenericType jvmGenericType;
	JvmDeclaredType result;
	if (typeBinding.isAnnotation()) {
		jvmGenericType = null;
		result = TypesFactory.eINSTANCE.createJvmAnnotationType();
	} else if (typeBinding.isEnum()) {
		jvmGenericType = null;
		result = TypesFactory.eINSTANCE.createJvmEnumerationType();
	} else {
		result = jvmGenericType = TypesFactory.eINSTANCE.createJvmGenericType();
		jvmGenericType.setInterface(typeBinding.isInterface());
	}

	// Populate the information computed from the modifiers.
	//
	int modifiers = typeBinding.getModifiers();
	setTypeModifiers(result, modifiers);
	result.setDeprecated(typeBinding.isDeprecated());
	setVisibility(result, modifiers);

	// Determine the simple name and compose the fully qualified name and path, remembering the fqn length and path size so we can reset them.
	//
	String simpleName = typeBinding.getName();
	fqn.append(simpleName);
	int length = fqn.length();
	int size = path.size();
	path.add(simpleName);

	String qualifiedName = fqn.toString();
	result.internalSetIdentifier(qualifiedName);
	result.setSimpleName(simpleName);

	// Traverse the nested types using '$' as the qualified name separator.
	//
	fqn.append('$');
	createNestedTypes(typeBinding, result, handleIdentifier, path, fqn);

	// Traverse the methods using '.'as the qualifed name separator.
	//
	fqn.setLength(length);
	fqn.append('.');
	createMethods(typeBinding, handleIdentifier, path, fqn, result);
	
	createFields(typeBinding, fqn, result);

	// Set the super types.
	//
	setSuperTypes(typeBinding, qualifiedName, result);

	// If this is for a generic type, populate the type parameters.
	//
	if (jvmGenericType != null) {
		ITypeBinding[] typeParameterBindings = typeBinding.getTypeParameters();
		if (typeParameterBindings.length > 0) {
			InternalEList<JvmTypeParameter> typeParameters = (InternalEList<JvmTypeParameter>)jvmGenericType.getTypeParameters();
			for (ITypeBinding variable : typeParameterBindings) {
				typeParameters.addUnique(createTypeParameter(variable, result));
			}
		}
	}

	// Populate the annotation values.
	//
	createAnnotationValues(typeBinding, result);

	// Restore the path.
	//
	path.remove(size);

	return result;
}