com.sun.tools.javac.code.Type.CapturedType Java Examples
The following examples show how to use
com.sun.tools.javac.code.Type.CapturedType.
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: Printer.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (seenCaptured.contains(t)) return localize(locale, "compiler.misc.type.captureof.1", capturedVarId(t, locale)); else { try { seenCaptured = seenCaptured.prepend(t); return localize(locale, "compiler.misc.type.captureof", capturedVarId(t, locale), visit(t.wildcard, locale)); } finally { seenCaptured = seenCaptured.tail; } } }
Example #2
Source File: JavaEnvironment.java From j2cl with Apache License 2.0 | 6 votes |
private TypeVariable createTypeVariable(javax.lang.model.type.TypeVariable typeVariable) { if (typeVariable instanceof CapturedType) { return createWildcardTypeVariable(typeVariable.getUpperBound()); } Supplier<TypeDescriptor> boundTypeDescriptorFactory = () -> createTypeDescriptor(typeVariable.getUpperBound()); List<String> classComponents = getClassComponents(typeVariable); return TypeVariable.newBuilder() .setBoundTypeDescriptorSupplier(boundTypeDescriptorFactory) .setWildcardOrCapture(false) .setUniqueKey( classComponents.stream().collect(Collectors.joining("::")) + (typeVariable.getUpperBound() != null ? typeVariable.getUpperBound().toString() : "")) .setName(typeVariable.asElement().getSimpleName().toString()) .build(); }
Example #3
Source File: Printer.java From javaide with GNU General Public License v3.0 | 6 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (seenCaptured.contains(t)) return localize(locale, "compiler.misc.type.captureof.1", capturedVarId(t, locale)); else { try { seenCaptured = seenCaptured.prepend(t); return localize(locale, "compiler.misc.type.captureof", capturedVarId(t, locale), visit(t.wildcard, locale)); } finally { seenCaptured = seenCaptured.tail; } } }
Example #4
Source File: ExpectedTypeResolver.java From netbeans with Apache License 2.0 | 6 votes |
private TypeMirror decapture(TypeMirror argm) { if (argm instanceof CapturedType) { argm = ((CapturedType)argm).wildcard; } if (argm.getKind() == TypeKind.WILDCARD) { WildcardType wctype = (WildcardType)argm; TypeMirror bound = wctype.getExtendsBound(); if (bound != null) { return bound; } bound = wctype.getSuperBound(); if (bound != null) { return bound; } return null; } return argm; }
Example #5
Source File: AbstractDiagnosticFormatter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #6
Source File: AbstractDiagnosticFormatter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #7
Source File: AbstractDiagnosticFormatter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #8
Source File: AbstractDiagnosticFormatter.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #9
Source File: VarTypePrinter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public Void visitCapturedType(CapturedType t, Set<Type> seen) { if (seen.add(t)) { visit(t.getUpperBound(), seen); visit(t.getLowerBound(), seen); } return null; }
Example #10
Source File: VarTypePrinter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { /* Any type variable mentioned in the inferred type must have been declared as a type parameter (i.e cannot have been produced by capture conversion (5.1.10)) */ return WILD; // Non-denotable }
Example #11
Source File: AbstractDiagnosticFormatter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #12
Source File: RichDiagnosticFormatter.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (getConfiguration().isEnabled(RichFormatterFeature.WHERE_CLAUSES)) { return localize(locale, "compiler.misc.captured.type", indexOf(t, WhereClauseKind.CAPTURED)); } else return super.visitCapturedType(t, locale); }
Example #13
Source File: AbstractDiagnosticFormatter.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #14
Source File: AbstractDiagnosticFormatter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #15
Source File: Infer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override Type solve(UndetVar uv, InferenceContext inferenceContext) { Infer infer = inferenceContext.infer; Type upper = UPPER.filterBounds(uv, inferenceContext).nonEmpty() ? UPPER.solve(uv, inferenceContext) : infer.syms.objectType; Type lower = LOWER.filterBounds(uv, inferenceContext).nonEmpty() ? LOWER.solve(uv, inferenceContext) : infer.syms.botType; CapturedType prevCaptured = (CapturedType)uv.qtype; return new CapturedType(prevCaptured.tsym.name, prevCaptured.tsym.owner, upper, lower, prevCaptured.wildcard); }
Example #16
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Boolean visitCapturedType(CapturedType t, Void s) { /* Any type variable mentioned in the inferred type must have been declared as a type parameter (i.e cannot have been produced by capture conversion (5.1.10)) */ return false; }
Example #17
Source File: AbstractDiagnosticFormatter.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #18
Source File: AbstractDiagnosticFormatter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #19
Source File: AbstractDiagnosticFormatter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #20
Source File: RichDiagnosticFormatter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (getConfiguration().isEnabled(RichFormatterFeature.WHERE_CLAUSES)) { return localize(locale, "compiler.misc.captured.type", indexOf(t, WhereClauseKind.CAPTURED)); } else return super.visitCapturedType(t, locale); }
Example #21
Source File: AbstractDiagnosticFormatter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public String visitCapturedType(CapturedType t, Locale locale) { if (!allCaptured.contains(t)) { allCaptured = allCaptured.append(t); } return super.visitCapturedType(t, locale); }
Example #22
Source File: JavacResolution.java From EasyMPermission with MIT License | 4 votes |
private static JCExpression typeToJCTree0(Type type, JavacAST ast, boolean allowCompound, boolean allowVoid) throws TypeNotConvertibleException { // NB: There's such a thing as maker.Type(type), but this doesn't work very well; it screws up anonymous classes, captures, and adds an extra prefix dot for some reason too. // -- so we write our own take on that here. JavacTreeMaker maker = ast.getTreeMaker(); if (CTC_BOT.equals(typeTag(type))) return createJavaLangObject(ast); if (CTC_VOID.equals(typeTag(type))) return allowVoid ? primitiveToJCTree(type.getKind(), maker) : createJavaLangObject(ast); if (type.isPrimitive()) return primitiveToJCTree(type.getKind(), maker); if (type.isErroneous()) throw new TypeNotConvertibleException("Type cannot be resolved"); TypeSymbol symbol = type.asElement(); List<Type> generics = type.getTypeArguments(); JCExpression replacement = null; if (symbol == null) throw new TypeNotConvertibleException("Null or compound type"); if (symbol.name.length() == 0) { // Anonymous inner class if (type instanceof ClassType) { List<Type> ifaces = ((ClassType) type).interfaces_field; Type supertype = ((ClassType) type).supertype_field; if (ifaces != null && ifaces.length() == 1) { return typeToJCTree(ifaces.get(0), ast, allowCompound, allowVoid); } if (supertype != null) return typeToJCTree(supertype, ast, allowCompound, allowVoid); } throw new TypeNotConvertibleException("Anonymous inner class"); } if (type instanceof CapturedType || type instanceof WildcardType) { Type lower, upper; if (type instanceof WildcardType) { upper = ((WildcardType)type).getExtendsBound(); lower = ((WildcardType)type).getSuperBound(); } else { lower = type.getLowerBound(); upper = type.getUpperBound(); } if (allowCompound) { if (lower == null || CTC_BOT.equals(typeTag(lower))) { if (upper == null || upper.toString().equals("java.lang.Object")) { return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null); } if (upper.getTypeArguments().contains(type)) { return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null); } return maker.Wildcard(maker.TypeBoundKind(BoundKind.EXTENDS), typeToJCTree(upper, ast, false, false)); } else { return maker.Wildcard(maker.TypeBoundKind(BoundKind.SUPER), typeToJCTree(lower, ast, false, false)); } } if (upper != null) { if (upper.getTypeArguments().contains(type)) { return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null); } return typeToJCTree(upper, ast, allowCompound, allowVoid); } return createJavaLangObject(ast); } String qName; if (symbol.isLocal()) { qName = symbol.getSimpleName().toString(); } else if (symbol.type != null && symbol.type.getEnclosingType() != null && typeTag(symbol.type.getEnclosingType()).equals(typeTag("CLASS"))) { replacement = typeToJCTree0(type.getEnclosingType(), ast, false, false); qName = symbol.getSimpleName().toString(); } else { qName = symbol.getQualifiedName().toString(); } if (qName.isEmpty()) throw new TypeNotConvertibleException("unknown type"); if (qName.startsWith("<")) throw new TypeNotConvertibleException(qName); String[] baseNames = qName.split("\\."); int i = 0; if (replacement == null) { replacement = maker.Ident(ast.toName(baseNames[0])); i = 1; } for (; i < baseNames.length; i++) { replacement = maker.Select(replacement, ast.toName(baseNames[i])); } return genericsToJCTreeNodes(generics, ast, replacement); }
Example #23
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Boolean visitCapturedType(CapturedType t, Void s) { return visit(t.getUpperBound()) || visit(t.getLowerBound()); }
Example #24
Source File: AbstractDiagnosticFormatter.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override protected String capturedVarId(CapturedType t, Locale locale) { return "" + (allCaptured.indexOf(t) + 1); }
Example #25
Source File: AbstractDiagnosticFormatter.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override protected String capturedVarId(CapturedType t, Locale locale) { return "" + (allCaptured.indexOf(t) + 1); }
Example #26
Source File: AbstractDiagnosticFormatter.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override protected String capturedVarId(CapturedType t, Locale locale) { return "" + (allCaptured.indexOf(t) + 1); }
Example #27
Source File: AbstractDiagnosticFormatter.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override protected String capturedVarId(CapturedType t, Locale locale) { return "" + (allCaptured.indexOf(t) + 1); }
Example #28
Source File: AbstractDiagnosticFormatter.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override protected String capturedVarId(CapturedType t, Locale locale) { return "" + (allCaptured.indexOf(t) + 1); }
Example #29
Source File: AbstractDiagnosticFormatter.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
@Override protected String capturedVarId(CapturedType t, Locale locale) { return "" + (allCaptured.indexOf(t) + 1); }
Example #30
Source File: AbstractDiagnosticFormatter.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override protected String capturedVarId(CapturedType t, Locale locale) { return "" + (allCaptured.indexOf(t) + 1); }