List of usage examples for org.eclipse.jdt.internal.compiler.lookup LookupEnvironment createArrayType
public ArrayBinding createArrayType(TypeBinding leafComponentType, int dimensionCount)
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.RoleTypeCreator.java
License:Open Source License
/** * Decompose a given type into atomic types (taking into account arrays and type arguments) * perform a given type substitution for each atomic type and * re-assemble to a type of the same shape as the given type. * @param original the given type to be substituted * @param environment for creation of parameterized types and array types * @param substitution what to perform on each atomic dependent type * @return either null (after an error should have been reported) or the original type or a legal substitution */// w ww . j a v a 2s . com public static TypeBinding deepSubstitute(TypeBinding original, LookupEnvironment environment, IDependentTypeSubstitution substitution) { TypeBinding type = original; int dimensions = type.dimensions(); type = type.leafComponentType(); TypeBinding[] typeArguments = null; boolean hasInstantiated = false; if (type.isParameterizedType()) { ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) type; if (ptb.arguments != null) { typeArguments = new TypeBinding[ptb.arguments.length]; for (int j = 0; j < ptb.arguments.length; j++) { TypeBinding givenTypeArgument = ptb.arguments[j]; typeArguments[j] = deepSubstitute(givenTypeArgument, environment, substitution); if (typeArguments[j] == null) typeArguments[j] = givenTypeArgument; else if (typeArguments[j] != givenTypeArgument) //$IDENTITY-COMPARISON$ hasInstantiated = true; } if (hasInstantiated) type = ptb.genericType(); else typeArguments = null; } } if (type instanceof DependentTypeBinding) { TypeBinding substituted = substitution.substitute((DependentTypeBinding) type, typeArguments, dimensions); if (substituted != type) // includes substituted == null //$IDENTITY-COMPARISON$ return substituted; } if (hasInstantiated) { TypeBinding parameterized = environment.createParameterizedType((ReferenceBinding) type, typeArguments, original.enclosingType()); if (dimensions == 0) return parameterized; return environment.createArrayType(parameterized, dimensions); } return original; }