private TypeMirror getActualTypeFor(TypeParameterElement typeParameter) { TypeMirror type = asType(); while (type.getKind() == TypeKind.DECLARED) { DeclaredType dt = (DeclaredType) type; TypeElement te = (TypeElement) dt.asElement(); Name name = typeParameter.getSimpleName(); int index = 0; for (TypeParameterElement tpe : te.getTypeParameters()) { if (name.contentEquals(tpe.getSimpleName())) { TypeMirror actualType = dt.getTypeArguments().get(index); return actualType; } index++; } type = te.getSuperclass(); } throw new IllegalArgumentException("no actual type for type parameter "+typeParameter+" "+typeParameter.getEnclosingElement()); }
private boolean isPartial(CompileEnvironment environment, TypeMirror type) { assert environment != null; assert type != null; if (type.getKind() != TypeKind.TYPEVAR) { return false; } TypeVariable var = (TypeVariable) type; TypeParameterElement parameter = (TypeParameterElement) var.asElement(); if (hasKindMatched(environment, parameter) == false) { return false; } Element parent = parameter.getEnclosingElement(); // MEMO Eclipse JDT returns null for "TypeParameterElement.enclosingElement." if (parent == null) { return true; } return isOperatorSource(environment, parent); }