Java Code Examples for javax.lang.model.type.TypeVariable#getLowerBound()
The following examples show how to use
javax.lang.model.type.TypeVariable#getLowerBound() .
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: SpringXMLConfigCompletionItem.java From netbeans with Apache License 2.0 | 6 votes |
@Override public StringBuilder visitTypeVariable(TypeVariable t, Boolean p) { Element e = t.asElement(); if (e != null) { String name = e.getSimpleName().toString(); if (!CAPTURED_WILDCARD.equals(name)) return DEFAULT_VALUE.append(name); } DEFAULT_VALUE.append("?"); //NOI18N TypeMirror bound = t.getLowerBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" super "); //NOI18N visit(bound, p); } else { bound = t.getUpperBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" extends "); //NOI18N if (bound.getKind() == TypeKind.TYPEVAR) bound = ((TypeVariable)bound).getLowerBound(); visit(bound, p); } } return DEFAULT_VALUE; }
Example 2
Source File: AutoImport.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Void visitTypeVariable(TypeVariable type, Void p) { Element e = type.asElement(); if (e != null) { CharSequence name = e.getSimpleName(); if (!CAPTURED_WILDCARD.contentEquals(name)) { builder.append(name); return null; } } builder.append("?"); //NOI18N TypeMirror bound = type.getLowerBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { builder.append(" super "); //NOI18N visit(bound); } else { bound = type.getUpperBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { builder.append(" extends "); //NOI18N if (bound.getKind() == TypeKind.TYPEVAR) bound = ((TypeVariable)bound).getLowerBound(); visit(bound); } } return null; }
Example 3
Source File: TypeUtils.java From Mixin with MIT License | 6 votes |
private static String describeGenericBound(TypeMirror type) { if (type instanceof TypeVariable) { StringBuilder description = new StringBuilder("<"); TypeVariable typeVar = (TypeVariable)type; description.append(typeVar.toString()); TypeMirror lowerBound = typeVar.getLowerBound(); if (lowerBound.getKind() != TypeKind.NULL) { description.append(" super ").append(lowerBound); } TypeMirror upperBound = typeVar.getUpperBound(); if (upperBound.getKind() != TypeKind.NULL) { description.append(" extends ").append(upperBound); } return description.append(">").toString(); } return type.toString(); }
Example 4
Source File: JavaSymbolProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override public StringBuilder visitTypeVariable(TypeVariable t, Boolean p) { Element e = t.asElement(); if (e != null) { String name = e.getSimpleName().toString(); if (!CAPTURED_WILDCARD.equals(name)) { return DEFAULT_VALUE.append(name); } } DEFAULT_VALUE.append("?"); //NOI18N if (!insideCapturedWildcard) { insideCapturedWildcard = true; TypeMirror bound = t.getLowerBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" super "); //NOI18N visit(bound, p); } else { bound = t.getUpperBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" extends "); //NOI18N if (bound.getKind() == TypeKind.TYPEVAR) { bound = ((TypeVariable)bound).getLowerBound(); } visit(bound, p); } } insideCapturedWildcard = false; } return DEFAULT_VALUE; }
Example 5
Source File: TypeUtilities.java From netbeans with Apache License 2.0 | 5 votes |
@Override public StringBuilder visitTypeVariable(TypeVariable t, Boolean p) { Element e = t.asElement(); if (e != null) { String name = e.getSimpleName().toString(); if (!CAPTURED_WILDCARD.equals(name)) return DEFAULT_VALUE.append(name); } DEFAULT_VALUE.append("?"); //NOI18N if (!insideCapturedWildcard) { insideCapturedWildcard = true; TypeMirror bound = t.getLowerBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" super "); //NOI18N visit(bound, p); } else { bound = t.getUpperBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" extends "); //NOI18N if (bound.getKind() == TypeKind.TYPEVAR) bound = ((TypeVariable)bound).getLowerBound(); visit(bound, p); } } insideCapturedWildcard = false; } return DEFAULT_VALUE; }
Example 6
Source File: VarUsageVisitor.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Tree visitMethodInvocation(MethodInvocationTree node, Element p) { List<? extends ExpressionTree> arguments = node.getArguments(); for (int i = 0; i < arguments.size(); i++) { ExpressionTree argument = arguments.get(i); Element argElement = asElement(argument); // TODO: Slow and misses ternary expressions if(p.equals(argElement)) { Element element = asElement(node); if (element.getKind() == ElementKind.METHOD) { ExecutableElement method = (ExecutableElement) element; VariableElement parameter = method.getParameters().get(i); Types types = workingCopy.getTypes(); TypeMirror parameterType = parameter.asType(); if(parameterType.getKind().equals(TypeKind.TYPEVAR)) { TypeVariable typeVariable = (TypeVariable) parameterType; TypeMirror upperBound = typeVariable.getUpperBound(); TypeMirror lowerBound = typeVariable.getLowerBound(); if(upperBound != null && !types.isSubtype(superTypeElement.asType(), upperBound)) { isReplCandidate = false; } if(lowerBound != null && !types.isSubtype(lowerBound, superTypeElement.asType())) { isReplCandidate = false; } } else if(!types.isAssignable(superTypeElement.asType(), parameterType)) { isReplCandidate = false; } } } } return super.visitMethodInvocation(node, p); }
Example 7
Source File: DeclaredTypeCollector.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Void visitTypeVariable(TypeVariable t, Collection<DeclaredType> p) { if (t.getLowerBound() != null) { visit(t.getLowerBound(), p); } if (t.getUpperBound() != null) { visit(t.getUpperBound(), p); } return DEFAULT_VALUE; }
Example 8
Source File: MethodModelSupport.java From netbeans with Apache License 2.0 | 5 votes |
@Override public StringBuilder visitTypeVariable(TypeVariable t, Boolean p) { Element e = t.asElement(); if (e != null) { String name = e.getSimpleName().toString(); if (!CAPTURED_WILDCARD.equals(name)) return DEFAULT_VALUE.append(name); } DEFAULT_VALUE.append("?"); //NOI18N if (!insideCapturedWildcard) { insideCapturedWildcard = true; TypeMirror bound = t.getLowerBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" super "); //NOI18N visit(bound, p); } else { bound = t.getUpperBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" extends "); //NOI18N if (bound.getKind() == TypeKind.TYPEVAR) bound = ((TypeVariable)bound).getLowerBound(); visit(bound, p); } } insideCapturedWildcard = false; } return DEFAULT_VALUE; }
Example 9
Source File: Utilities.java From netbeans with Apache License 2.0 | 5 votes |
@Override public StringBuilder visitTypeVariable(TypeVariable t, Boolean p) { Element e = t.asElement(); if (e != null) { String name = e.getSimpleName().toString(); if (!CAPTURED_WILDCARD.equals(name)) return DEFAULT_VALUE.append(name); } DEFAULT_VALUE.append("?"); //NOI18N if (!insideCapturedWildcard) { insideCapturedWildcard = true; TypeMirror bound = t.getLowerBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" super "); //NOI18N visit(bound, p); } else { bound = t.getUpperBound(); if (bound != null && bound.getKind() != TypeKind.NULL) { DEFAULT_VALUE.append(" extends "); //NOI18N if (bound.getKind() == TypeKind.TYPEVAR) bound = ((TypeVariable)bound).getLowerBound(); visit(bound, p); } } insideCapturedWildcard = false; } return DEFAULT_VALUE; }
Example 10
Source File: ControllerGenerator.java From netbeans with Apache License 2.0 | 5 votes |
@Override public TypeMirror visitTypeVariable(TypeVariable t, CompilationInfo p) { TypeMirror lb = t.getLowerBound() == null ? null : visit(t.getLowerBound(), p); TypeMirror ub = t.getUpperBound() == null ? null : visit(t.getUpperBound(), p); if (ub.getKind() == TypeKind.DECLARED) { DeclaredType dt = (DeclaredType)ub; TypeElement tel = (TypeElement)dt.asElement(); if (tel.getQualifiedName().contentEquals("java.lang.Object")) { // NOI18N ub = null; } else if (tel.getSimpleName().length() == 0) { ub = null; } } return p.getTypes().getWildcardType(ub, lb); }