本文整理汇总了Java中org.aikodi.chameleon.oo.type.generics.InstantiatedTypeParameter类的典型用法代码示例。如果您正苦于以下问题:Java InstantiatedTypeParameter类的具体用法?Java InstantiatedTypeParameter怎么用?Java InstantiatedTypeParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InstantiatedTypeParameter类属于org.aikodi.chameleon.oo.type.generics包,在下文中一共展示了InstantiatedTypeParameter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCaseSSFormalExtends
import org.aikodi.chameleon.oo.type.generics.InstantiatedTypeParameter; //导入依赖的package包/类
private void processCaseSSFormalExtends(List<SecondPhaseConstraint> result, JavaTypeReference U, int index, Class<? extends TypeArgumentWithTypeReference> t)
throws LookupException {
try {
TypeParameter ithTypeParameterOfA = A().parameters(TypeParameter.class).get(index);
if(ithTypeParameterOfA instanceof InstantiatedTypeParameter) {
TypeArgument arg = ((InstantiatedTypeParameter)ithTypeParameterOfA).argument();
if(t.isInstance(arg)) {
JavaTypeReference V = (JavaTypeReference) ((TypeArgumentWithTypeReference)arg).typeReference();
EQConstraint recursive = new EQConstraint(V, U.getElement());
recursive.setUniParent(parent());
result.addAll(recursive.process());
}
}
}
catch(IndexOutOfBoundsException exc) {
return;
}
}
示例2: getElement
import org.aikodi.chameleon.oo.type.generics.InstantiatedTypeParameter; //导入依赖的package包/类
@Override
public Type getElement() throws LookupException {
JLoType typeConstructor = (JLoType) typeConstructorReference().getElement();
Type result = new JLoTypeRefinement(typeConstructor);
for(KeywordTypeArgument a: arguments()) {
// The name is wrong. It won't be found!
NameReference<TypeMemberDeclarator> nameReference = new NameReference<>(a.name(), TypeMemberDeclarator.class);
// The constructor sets the unidirectional parent of the name reference.
new LookupRedirector(typeConstructor,nameReference);
TypeMemberDeclarator element = nameReference.getElement();
TypeParameter typeArgument = new InstantiatedTypeParameter(element.parameter().name(), a.argument());
TypeMemberDeclarator declarator = new TypeMemberDeclarator(new SimpleNameSignature(a.name()), typeArgument);
result.add(declarator);
}
return result;
}
示例3: involvesTypeParameter
import org.aikodi.chameleon.oo.type.generics.InstantiatedTypeParameter; //导入依赖的package包/类
public boolean involvesTypeParameter(Type type) throws LookupException {
return ((type instanceof TypeVariable) && (parent().typeParameters().contains(((TypeVariable) type).parameter())))
|| ((type instanceof ArrayType) && (involvesTypeParameter(((ArrayType) type).elementType())))
|| ((type instanceof TypeInstantiation) && (involvesTypeParameter(type.baseType())))
|| exists(type.parameters(TypeParameter.class), object -> (object instanceof InstantiatedTypeParameter)
&& involvesTypeParameter(((InstantiatedTypeParameter) object).argument()));
}
示例4: createTypeReference
import org.aikodi.chameleon.oo.type.generics.InstantiatedTypeParameter; //导入依赖的package包/类
@Override
public BasicJavaTypeReference createTypeReference(Type type) {
BasicJavaTypeReference result = createTypeReference(type.getFullyQualifiedName());
if(! (type instanceof TypeIndirection)) {
for(TypeParameter par: type.parameters(TypeParameter.class)) {
if(par instanceof InstantiatedTypeParameter) {
InstantiatedTypeParameter inst = (InstantiatedTypeParameter) par;
result.addArgument(Util.clone(inst.argument()));
}
}
}
return result;
}
示例5: lcta
import org.aikodi.chameleon.oo.type.generics.InstantiatedTypeParameter; //导入依赖的package包/类
private List<TypeParameter> lcta(List<TypeArgument> firsts, List<TypeArgument> seconds, Binder root) throws LookupException {
List<TypeParameter> result = new ArrayList<TypeParameter>();
int size = firsts.size();
for(int i=0; i<size;i++) {
TypeArgument ith = firsts.get(i);
Element parent = ith.parent();
result.add(new InstantiatedTypeParameter(((TypeParameter)parent).name(),lcta(ith, seconds.get(i),root)));
}
return result;
}
示例6: captureConversion
import org.aikodi.chameleon.oo.type.generics.InstantiatedTypeParameter; //导入依赖的package包/类
public Type captureConversion() throws LookupException {
if(_captureConversion == null) {
Type result = this;
if(! (parameter(TypeParameter.class,0) instanceof CapturedTypeParameter)) {
List<TypeParameter> actualParameters = parameters(TypeParameter.class);
List<TypeParameter> typeParameters = Lists.create();
Type base = baseType();
List<TypeParameter> formalParameters = base.parameters(TypeParameter.class);
Iterator<TypeParameter> formals = formalParameters.iterator();
Iterator<TypeParameter> actuals = actualParameters.iterator();
// substitute parameters by their capture bounds.
// ITERATOR because we iterate over 'formals' and 'actuals' simultaneously.
boolean doCapture = false;
while(actuals.hasNext()) {
TypeParameter formalParam = formals.next();
if(!(formalParam instanceof FormalTypeParameter)) {
throw new LookupException("Type parameter of base type is not a formal parameter.");
}
TypeParameter actualParam = actuals.next();
if(!(actualParam instanceof InstantiatedTypeParameter)) {
throw new LookupException("Type parameter of type instantiation is not an instantiated parameter: "+actualParam.getClass().getName());
}
InstantiatedTypeParameter instantiatedTypeParameter = (InstantiatedTypeParameter) actualParam;
if(instantiatedTypeParameter.hasWildCardBound()) {
doCapture = true;
}
TypeParameter capturedParameter = instantiatedTypeParameter.capture((FormalTypeParameter) formalParam);
typeParameters.add(capturedParameter);
}
if(doCapture) {
// Everything works as well when we pass 'this' instead of 'base'.
result = language(Java7.class).createdCapturedType(new ParameterSubstitution(TypeParameter.class,typeParameters), base);
result.setUniParent(parent());
}
}
_captureConversion = result;
}
return _captureConversion;
}
示例7: addTypeParameters
import org.aikodi.chameleon.oo.type.generics.InstantiatedTypeParameter; //导入依赖的package包/类
protected void addTypeParameters(InheritanceRelation relation, Type jloType) throws LookupException {
// applyToSortedTypeMemberDeclarators(jloType, d -> {
// ((BasicJavaTypeReference)relation.superClassReference()).addArgument(new EqualityTypeArgument(java(relation).createTypeReference(d.parameter().name())));
// });
applyToSortedTypeMemberDeclarators(jloType, d -> {
BasicJavaTypeReference basicJavaTypeReference = (BasicJavaTypeReference)relation.superClassReference();
TypeParameter parameter = d.parameter();
if(parameter instanceof InstantiatedTypeParameter) {
basicJavaTypeReference.addArgument(d.clone(((InstantiatedTypeParameter)parameter).argument()));
} else if (parameter instanceof FormalTypeParameter) {
basicJavaTypeReference.addArgument(new EqualityTypeArgument(java(relation).createTypeReference(d.parameter().name())));
}
});
}
示例8: instantiatedMethodTemplate
import org.aikodi.chameleon.oo.type.generics.InstantiatedTypeParameter; //导入依赖的package包/类
protected M instantiatedMethodTemplate(Method method) throws LookupException {
M result=(M) method;
int nbTypeParameters = _assignment == null ? 0 : _assignment.nbAssignments();
boolean cloned = false;
if(nbTypeParameters > 0) {
result = clonedMethod();
cloned=true;
for(int i=0; i < nbTypeParameters;i++) {
TypeParameter originalPar = _template.typeParameter(i);
TypeParameter clonedPar = result.typeParameter(i);
// we detach the signature from the clone.
Type assignedType = _assignment.type(originalPar);
Java7 language = _template.language(Java7.class);
JavaTypeReference reference = language.reference(assignedType);
Element parent = reference.parent();
reference.setUniParent(null);
EqualityTypeArgument argument = language.createEqualityTypeArgument(reference);
argument.setUniParent(parent);
TypeParameter newPar = new InstantiatedTypeParameter(clonedPar.name(), argument);
SingleAssociation parentLink = clonedPar.parentLink();
parentLink.getOtherRelation().replace(parentLink, newPar.parentLink());
}
}
if(requiredUncheckedConversion()) {
if(! cloned) {
result = clonedMethod();
}
TypeReference erasure = (TypeReference)method.language(Java7.class).erasure(result.returnTypeReference());
result.setReturnTypeReference(erasure);
} else {
if(nbTypeParameters > 0) {
Type returnType = returnType(method);
if(returnType instanceof JavaTypeInstantiation) {
TypeReference oldDeclaredReturnTypeReference = result.returnTypeReference();
Type declaredReturnType = result.returnType();
// The capture conversion may refer to the old return type for the actual type arguments.
// FIXME This is still a hack though, we should create a captured type reference based on the return type reference
// there we can just clone any arguments such that the original return type reference is no longer needed.
// FIXME No more substitutions can be done in the new return type reference as it is a direct one. Therefore
// we do need that captured type reference.
result.setReturnTypeReference(new DirectJavaTypeReference(((JavaTypeInstantiation)declaredReturnType).captureConversion()));
oldDeclaredReturnTypeReference.setUniParent(result);
}
}
}
return result;
}