protected final <T> Queue<T> stopIfError(CompileState cs, Queue<T> queue) { return shouldStop(cs) ? ListBuffer.<T>lb() : queue; }
void run(Queue<Env<AttrContext>> list, Iterable<? extends TypeElement> classes) { Set<TypeElement> set = new HashSet<TypeElement>(); for (TypeElement item: classes) set.add(item); ListBuffer<Env<AttrContext>> defer = ListBuffer.<Env<AttrContext>>lb(); while (list.peek() != null) { Env<AttrContext> env = list.remove(); ClassSymbol csym = env.enclClass.sym; if (csym != null && set.contains(csym.outermostClass())) process(env); else defer = defer.append(env); } list.addAll(defer); }
/** * Perform dataflow checks on an attributed parse tree. */ public List<Env<AttrContext>> flow(Env<AttrContext> env) { ListBuffer<Env<AttrContext>> results = lb(); flow(env, results); return stopIfError(results); }
/** * Perform dataflow checks on an attributed parse tree. */ public Queue<Env<AttrContext>> flow(Env<AttrContext> env) { ListBuffer<Env<AttrContext>> results = lb(); flow(env, results); return stopIfError(CompileState.FLOW, results); }
/** * Prepare attributed parse trees, in conjunction with their attribution contexts, * for source or code generation. * If any errors occur, an empty list will be returned. * @returns a list containing the classes to be generated */ public Queue<Pair<Env<AttrContext>, JCClassDecl>> desugar(Queue<Env<AttrContext>> envs) { ListBuffer<Pair<Env<AttrContext>, JCClassDecl>> results = lb(); for (Env<AttrContext> env: envs) desugar(env, results); return stopIfError(CompileState.FLOW, results); }
/** * Attribute a list of parse trees, such as found on the "todo" list. * Note that attributing classes may cause additional files to be * parsed and entered via the SourceCompleter. * Attribution of the entries in the list does not stop if any errors occur. * @returns a list of environments for attributd classes. */ public Queue<Env<AttrContext>> attribute(Queue<Env<AttrContext>> envs) { ListBuffer<Env<AttrContext>> results = lb(); while (!envs.isEmpty()) results.append(attribute(envs.remove())); return stopIfError(CompileState.ATTR, results); }
/** * Perform dataflow checks on attributed parse trees. * These include checks for definite assignment and unreachable statements. * If any errors occur, an empty list will be returned. * @returns the list of attributed parse trees */ public Queue<Env<AttrContext>> flow(Queue<Env<AttrContext>> envs) { ListBuffer<Env<AttrContext>> results = lb(); for (Env<AttrContext> env: envs) { flow(env, results); } return stopIfError(CompileState.FLOW, results); }
public List<TypeSymbol> getTypeParameters() { ListBuffer<TypeSymbol> l = ListBuffer.lb(); for (Type t : type.getTypeArguments()) { l.append(t.tsym); } return l.toList(); }
/** * Prepare attributed parse trees, in conjunction with their attribution contexts, * for source or code generation. * If any errors occur, an empty list will be returned. * @returns a list containing the classes to be generated */ public List<Pair<Env<AttrContext>, JCClassDecl>> desugar(List<Env<AttrContext>> envs) { ListBuffer<Pair<Env<AttrContext>, JCClassDecl>> results = lb(); for (List<Env<AttrContext>> l = envs; l.nonEmpty(); l = l.tail) desugar(l.head, results); return stopIfError(results); }
public List<TypeSymbol> getTypeParameters() { ListBuffer<TypeSymbol> l = ListBuffer.lb(); for (Type t : type.getTypeArguments()) { l.append(t.tsym); } return l.toList(); }
/** * Perform dataflow checks on attributed parse trees. * These include checks for definite assignment and unreachable statements. * If any errors occur, an empty list will be returned. * @returns the list of attributed parse trees */ public List<Env<AttrContext>> flow(List<Env<AttrContext>> envs) { ListBuffer<Env<AttrContext>> results = lb(); for (List<Env<AttrContext>> l = envs; l.nonEmpty(); l = l.tail) { flow(l.head, results); } return stopIfError(results); }
/** * Parses a list of files. */ public List<JCCompilationUnit> parseFiles(List<JavaFileObject> fileObjects) throws IOException { if (shouldStop(CompileState.PARSE)) return List.nil(); //parse all files ListBuffer<JCCompilationUnit> trees = lb(); for (JavaFileObject fileObject : fileObjects) trees.append(parse(fileObject)); return trees.toList(); }
/** * Parses a list of files. */ public List<JCCompilationUnit> parseFiles(List<JavaFileObject> fileObjects) throws IOException { if (errorCount() > 0) return List.nil(); //parse all files ListBuffer<JCCompilationUnit> trees = lb(); for (JavaFileObject fileObject : fileObjects) trees.append(parse(fileObject)); return trees.toList(); }
/** * Attribute a list of parse trees, such as found on the "todo" list. * Note that attributing classes may cause additional files to be * parsed and entered via the SourceCompleter. * Attribution of the entries in the list does not stop if any errors occur. * @returns a list of environments for attributd classes. */ public List<Env<AttrContext>> attribute(ListBuffer<Env<AttrContext>> envs) { ListBuffer<Env<AttrContext>> results = lb(); while (envs.nonEmpty()) results.append(attribute(envs.next())); return results.toList(); }
private List<Type> freshTypeVariables(List<Type> types) { ListBuffer<Type> result = lb(); for (Type t : types) { if (t.tag == WILDCARD) { Type bound = ((WildcardType)t).getExtendsBound(); if (bound == null) bound = syms.objectType; result.append(new CapturedType(capturedName, syms.noSymbol, bound, syms.botType, (WildcardType)t)); } else { result.append(t); } } return result.toList(); } // </editor-fold>
private List<Type> freshTypeVariables(List<Type> types) { ListBuffer<Type> result = lb(); for (Type t : types) { if (t.tag == WILDCARD) { Type bound = ((WildcardType)t).getExtendsBound(); if (bound == null) bound = syms.objectType; result.append(new CapturedType(capturedName, syms.noSymbol, bound, syms.botType, (WildcardType)t)); } else { result.append(t); } } return result.toList(); } // </editor-fold>
/** Arguments = "(" [Expression { COMMA Expression }] ")" */ List<JCExpression> arguments() { ListBuffer<JCExpression> args = lb(); if (S.token() == LPAREN) { S.nextToken(); if (S.token() != RPAREN) { args.append(expression()); while (S.token() == COMMA) { S.nextToken(); args.append(expression()); } } accept(RPAREN); } else { syntaxError(S.pos(), "expected", keywords.token2string(LPAREN)); } return args.toList(); }
/** Arguments = "(" [Expression { COMMA Expression }] ")" */ List<JCExpression> arguments() { ListBuffer<JCExpression> args = lb(); if (S.token() == LPAREN) { S.nextToken(); if (S.token() != RPAREN) { args.append(expression()); while (S.token() == COMMA) { S.nextToken(); args.append(expression()); } } accept(RPAREN); } else { syntaxError(S.pos(), "expected", keywords.token2string(LPAREN)); } return args.toList(); }
/** ForInit = StatementExpression MoreStatementExpressions * | { FINAL | '@' Annotation } Type VariableDeclarators */ List<JCStatement> forInit() { ListBuffer<JCStatement> stats = lb(); int pos = S.pos(); if (S.token() == FINAL || S.token() == MONKEYS_AT) { return variableDeclarators(optFinal(0), type(), stats).toList(); } else { JCExpression t = term(EXPR | TYPE); if ((lastmode & TYPE) != 0 && (S.token() == IDENTIFIER || S.token() == ASSERT || S.token() == ENUM)) return variableDeclarators(modifiersOpt(), t, stats).toList(); else return moreStatementExpressions(pos, t, stats).toList(); } }
/** ForInit = StatementExpression MoreStatementExpressions * | { FINAL | '@' Annotation } Type VariableDeclarators */ List<JCStatement> forInit() { ListBuffer<JCStatement> stats = lb(); int pos = S.pos(); if (S.token() == FINAL || S.token() == MONKEYS_AT) { return variableDeclarators(optFinal(0), type(), stats).toList(); } else { JCExpression t = term(EXPR | TYPE); if ((lastmode & TYPE) != 0 && (S.token() == IDENTIFIER || S.token() == ASSERT || S.token() == ENUM)) return variableDeclarators(modifiersOpt(), t, stats).toList(); else return moreStatementExpressions(pos, t, stats).toList(); } }