Java Code Examples for com.sun.tools.javac.util.List#nil()
The following examples show how to use
com.sun.tools.javac.util.List#nil() .
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: DocCommentParser.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example 2
Source File: JavaCompiler.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
/** * Parses a list of files. */ public List<JCCompilationUnit> parseFiles(Iterable<JavaFileObject> fileObjects) { if (shouldStop(CompileState.PARSE)) return List.nil(); //parse all files ListBuffer<JCCompilationUnit> trees = lb(); Set<JavaFileObject> filesSoFar = new HashSet<JavaFileObject>(); for (JavaFileObject fileObject : fileObjects) { if (!filesSoFar.contains(fileObject)) { filesSoFar.add(fileObject); trees.append(parse(fileObject)); } } return trees.toList(); }
Example 3
Source File: JavacParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * {@literal * TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"] * } */ protected List<JCTypeParameter> typeParametersOpt() { if (token.kind == LT) { ListBuffer<JCTypeParameter> typarams = new ListBuffer<>(); nextToken(); typarams.append(typeParameter()); while (token.kind == COMMA) { nextToken(); typarams.append(typeParameter()); } accept(GT); return typarams.toList(); } else { return List.nil(); } }
Example 4
Source File: JavacParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * {@literal * TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"] * } */ List<JCTypeParameter> typeParametersOpt() { if (token.kind == LT) { checkGenerics(); ListBuffer<JCTypeParameter> typarams = new ListBuffer<JCTypeParameter>(); nextToken(); typarams.append(typeParameter()); while (token.kind == COMMA) { nextToken(); typarams.append(typeParameter()); } accept(GT); return typarams.toList(); } else { return List.nil(); } }
Example 5
Source File: DocCommentParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example 6
Source File: Infer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void dumpGraphsIfNeeded(DiagnosticPosition pos, Symbol msym, Resolve.MethodResolutionContext rsContext) { int round = 0; try { for (String graph : pendingGraphs.reverse()) { Assert.checkNonNull(dependenciesFolder); Name name = msym.name == msym.name.table.names.init ? msym.owner.name : msym.name; String filename = String.format("%s@%s[mode=%s,step=%s]_%d.dot", name, pos.getStartPosition(), rsContext.attrMode(), rsContext.step, round); Path dotFile = Paths.get(dependenciesFolder, filename); try (Writer w = Files.newBufferedWriter(dotFile)) { w.append(graph); } round++; } } catch (IOException ex) { Assert.error("Error occurred when dumping inference graph: " + ex.getMessage()); } finally { pendingGraphs = List.nil(); } }
Example 7
Source File: DocCommentParser.java From hottub with GNU General Public License v2.0 | 6 votes |
List<JCTree> parseParams(String s) throws ParseException { if (s.trim().isEmpty()) return List.nil(); JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false); ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); while (p.token().kind == TokenKind.COMMA) { p.nextToken(); paramTypes.add(p.parseType()); if (p.token().kind == TokenKind.IDENTIFIER) p.nextToken(); } if (p.token().kind != TokenKind.EOF) throw new ParseException("dc.ref.unexpected.input"); return paramTypes.toList(); }
Example 8
Source File: JavacProcessingEnvironment.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** Create a round (common code). */ private Round(Context context, int number, int priorErrors, int priorWarnings, Log.DeferredDiagnosticHandler deferredDiagnosticHandler) { this.context = context; this.number = number; compiler = JavaCompiler.instance(context); log = Log.instance(context); log.nerrors = priorErrors; log.nwarnings = priorWarnings; if (number == 1) { Assert.checkNonNull(deferredDiagnosticHandler); this.deferredDiagnosticHandler = deferredDiagnosticHandler; } else { this.deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log); } // the following is for the benefit of JavacProcessingEnvironment.getContext() JavacProcessingEnvironment.this.context = context; // the following will be populated as needed topLevelClasses = List.nil(); packageInfoFiles = List.nil(); }
Example 9
Source File: JavacTaskImpl.java From javaide with GNU General Public License v3.0 | 5 votes |
static private List<JavaFileObject> toList(Iterable<? extends JavaFileObject> fileObjects) { if (fileObjects == null) return List.nil(); ListBuffer<JavaFileObject> result = new ListBuffer<JavaFileObject>(); for (JavaFileObject fo : fileObjects) result.append(fo); return result.toList(); }
Example 10
Source File: SymbolMetadata.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) { super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(), ctx.isTypeCompound ? ((Attribute.TypeCompound)placeholderFor.head).position : new TypeAnnotationPosition()); this.ctx = ctx; this.placeholderFor = placeholderFor; this.on = on; }
Example 11
Source File: JavacProcessingEnvironment.java From hottub with GNU General Public License v2.0 | 5 votes |
private List<ClassSymbol> getTopLevelClassesFromClasses(List<? extends ClassSymbol> syms) { List<ClassSymbol> classes = List.nil(); for (ClassSymbol sym : syms) { if (!isPkgInfo(sym)) { classes = classes.prepend(sym); } } return classes.reverse(); }
Example 12
Source File: TypeEnter.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void runPhase(Env<AttrContext> env) { JCClassDecl tree = env.enclClass; ClassSymbol sym = tree.sym; ClassType ct = (ClassType)sym.type; Env<AttrContext> baseEnv = baseEnv(tree, env); attribSuperTypes(env, baseEnv); if (sym.fullname == names.java_lang_Object) { if (tree.extending != null) { chk.checkNonCyclic(tree.extending.pos(), ct.supertype_field); ct.supertype_field = Type.noType; } else if (tree.implementing.nonEmpty()) { chk.checkNonCyclic(tree.implementing.head.pos(), ct.interfaces_field.head); ct.interfaces_field = List.nil(); } } markDeprecated(sym, tree.mods.annotations, baseEnv); chk.checkNonCyclicDecl(tree); }
Example 13
Source File: ListBufferTest.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void assertEndsWithNil(List<?> list) { while (!list.isEmpty()) { list = list.tail; } if (list != List.nil()) throw new IllegalStateException("Not ending with List.nil()"); }
Example 14
Source File: Lower.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
JCClassDecl makeEmptyClass(long flags, ClassSymbol owner, Name flatname, boolean addToDefs) { // Create class symbol. ClassSymbol c = reader.defineClass(names.empty, owner); if (flatname != null) { c.flatname = flatname; } else { c.flatname = chk.localClassName(c); } c.sourcefile = owner.sourcefile; c.completer = null; c.members_field = new Scope(c); c.flags_field = flags; ClassType ctype = (ClassType) c.type; ctype.supertype_field = syms.objectType; ctype.interfaces_field = List.nil(); JCClassDecl odef = classDef(owner); // Enter class symbol in owner scope and compiled table. enterSynthetic(odef.pos(), c, owner.members()); chk.compiled.put(c.flatname, c); // Create class definition tree. JCClassDecl cdef = make.ClassDef( make.Modifiers(flags), names.empty, List.<JCTypeParameter>nil(), null, List.<JCExpression>nil(), List.<JCTree>nil()); cdef.sym = c; cdef.type = c.type; // Append class definition tree to owner's definitions. if (addToDefs) odef.defs = odef.defs.prepend(cdef); return cdef; }
Example 15
Source File: WildcardTypeImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private static List<Type> getSuperBounds(Type.WildcardType wild) { return wild.isExtendsBound() ? List.<Type>nil() : List.of(wild.type); }
Example 16
Source File: JavacParser.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
List<JCExpression> annotationFieldValuesOpt() { return (S.token() == LPAREN) ? annotationFieldValues() : List.<JCExpression>nil(); }
Example 17
Source File: Lower.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** Translate a toplevel class and return a list consisting of * the translated class and translated versions of all inner classes. * @param env The attribution environment current at the class definition. * We need this for resolving some additional symbols. * @param cdef The tree representing the class definition. */ public List<JCTree> translateTopLevelClass(Env<AttrContext> env, JCTree cdef, TreeMaker make) { ListBuffer<JCTree> translated = null; try { attrEnv = env; this.make = make; endPosTable = env.toplevel.endPositions; currentClass = null; currentMethodDef = null; outermostClassDef = (cdef.hasTag(CLASSDEF)) ? (JCClassDecl)cdef : null; outermostMemberDef = null; this.translated = new ListBuffer<JCTree>(); classdefs = new HashMap<ClassSymbol,JCClassDecl>(); actualSymbols = new HashMap<Symbol,Symbol>(); freevarCache = new HashMap<ClassSymbol,List<VarSymbol>>(); proxies = new Scope(syms.noSymbol); twrVars = new Scope(syms.noSymbol); outerThisStack = List.nil(); accessNums = new HashMap<Symbol,Integer>(); accessSyms = new HashMap<Symbol,MethodSymbol[]>(); accessConstrs = new HashMap<Symbol,MethodSymbol>(); accessConstrTags = List.nil(); accessed = new ListBuffer<Symbol>(); translate(cdef, (JCExpression)null); for (List<Symbol> l = accessed.toList(); l.nonEmpty(); l = l.tail) makeAccessible(l.head); for (EnumMapping map : enumSwitchMap.values()) map.translate(); checkConflicts(this.translated.toList()); checkAccessConstructorTags(); translated = this.translated; } finally { // note that recursive invocations of this method fail hard attrEnv = null; this.make = null; endPosTable = null; currentClass = null; currentMethodDef = null; outermostClassDef = null; outermostMemberDef = null; this.translated = null; classdefs = null; actualSymbols = null; freevarCache = null; proxies = null; outerThisStack = null; accessNums = null; accessSyms = null; accessConstrs = null; accessConstrTags = null; accessed = null; enumSwitchMap.clear(); assertionsDisabledClassCache = null; } return translated.toList(); }
Example 18
Source File: Lower.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** Return access symbol for a private or protected symbol from an inner class. * @param sym The accessed private symbol. * @param tree The accessing tree. * @param enclOp The closest enclosing operation node of tree, * null if tree is not a subtree of an operation. * @param protAccess Is access to a protected symbol in another * package? * @param refSuper Is access via a (qualified) C.super? */ MethodSymbol accessSymbol(Symbol sym, JCTree tree, JCTree enclOp, boolean protAccess, boolean refSuper) { ClassSymbol accOwner = refSuper && protAccess // For access via qualified super (T.super.x), place the // access symbol on T. ? (ClassSymbol)((JCFieldAccess) tree).selected.type.tsym // Otherwise pretend that the owner of an accessed // protected symbol is the enclosing class of the current // class which is a subclass of the symbol's owner. : accessClass(sym, protAccess, tree); Symbol vsym = sym; if (sym.owner != accOwner) { vsym = sym.clone(accOwner); actualSymbols.put(vsym, sym); } Integer anum // The access number of the access method. = accessNums.get(vsym); if (anum == null) { anum = accessed.length(); accessNums.put(vsym, anum); accessSyms.put(vsym, new MethodSymbol[NCODES]); accessed.append(vsym); // System.out.println("accessing " + vsym + " in " + vsym.location()); } int acode; // The access code of the access method. List<Type> argtypes; // The argument types of the access method. Type restype; // The result type of the access method. List<Type> thrown; // The thrown exceptions of the access method. switch (vsym.kind) { case VAR: acode = accessCode(tree, enclOp); if (acode >= FIRSTASGOPcode) { OperatorSymbol operator = binaryAccessOperator(acode); if (operator.opcode == string_add) argtypes = List.of(syms.objectType); else argtypes = operator.type.getParameterTypes().tail; } else if (acode == ASSIGNcode) argtypes = List.of(vsym.erasure(types)); else argtypes = List.nil(); restype = vsym.erasure(types); thrown = List.nil(); break; case MTH: acode = DEREFcode; argtypes = vsym.erasure(types).getParameterTypes(); restype = vsym.erasure(types).getReturnType(); thrown = vsym.type.getThrownTypes(); break; default: throw new AssertionError(); } // For references via qualified super, increment acode by one, // making it odd. if (protAccess && refSuper) acode++; // Instance access methods get instance as first parameter. // For protected symbols this needs to be the instance as a member // of the type containing the accessed symbol, not the class // containing the access method. if ((vsym.flags() & STATIC) == 0) { argtypes = argtypes.prepend(vsym.owner.erasure(types)); } MethodSymbol[] accessors = accessSyms.get(vsym); MethodSymbol accessor = accessors[acode]; if (accessor == null) { accessor = new MethodSymbol( STATIC | SYNTHETIC, accessName(anum.intValue(), acode), new MethodType(argtypes, restype, thrown, syms.methodClass), accOwner); enterSynthetic(tree.pos(), accessor, accOwner.members()); accessors[acode] = accessor; } return accessor; }
Example 19
Source File: Check.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** Check that all non-override equivalent methods accessible from 'site' * are mutually compatible (JLS 8.4.8/9.4.1). * * @param pos Position to be used for error reporting. * @param site The class whose methods are checked. * @param sym The method symbol to be checked. */ void checkOverrideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) { ClashFilter cf = new ClashFilter(site); //for each method m1 that is overridden (directly or indirectly) //by method 'sym' in 'site'... List<MethodSymbol> potentiallyAmbiguousList = List.nil(); boolean overridesAny = false; for (Symbol m1 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { if (!sym.overrides(m1, site.tsym, types, false)) { if (m1 == sym) { continue; } if (!overridesAny) { potentiallyAmbiguousList = potentiallyAmbiguousList.prepend((MethodSymbol)m1); } continue; } if (m1 != sym) { overridesAny = true; potentiallyAmbiguousList = List.nil(); } //...check each method m2 that is a member of 'site' for (Symbol m2 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { if (m2 == m1) continue; //if (i) the signature of 'sym' is not a subsignature of m1 (seen as //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error if (!types.isSubSignature(sym.type, types.memberType(site, m2), allowStrictMethodClashCheck) && types.hasSameArgs(m2.erasure(types), m1.erasure(types))) { sym.flags_field |= CLASH; String key = m1 == sym ? "name.clash.same.erasure.no.override" : "name.clash.same.erasure.no.override.1"; log.error(pos, key, sym, sym.location(), m2, m2.location(), m1, m1.location()); return; } } } if (!overridesAny) { for (MethodSymbol m: potentiallyAmbiguousList) { checkPotentiallyAmbiguousOverloads(pos, site, sym, m); } } }
Example 20
Source File: Type.java From javaide with GNU General Public License v3.0 | 2 votes |
/** Return all parameters of this type and all its outer types in order * outer (first) to inner (last). */ public List<Type> allparams() { return List.nil(); }