本文整理汇总了Java中com.sun.tools.javac.util.List.of方法的典型用法代码示例。如果您正苦于以下问题:Java List.of方法的具体用法?Java List.of怎么用?Java List.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.util.List
的用法示例。
在下文中一共展示了List.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fallbackDescriptorType
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private Type fallbackDescriptorType(JCExpression tree) {
switch (tree.getTag()) {
case LAMBDA:
JCLambda lambda = (JCLambda)tree;
List<Type> argtypes = List.nil();
for (JCVariableDecl param : lambda.params) {
argtypes = param.vartype != null ?
argtypes.append(param.vartype.type) :
argtypes.append(syms.errType);
}
return new MethodType(argtypes, Type.recoveryType,
List.of(syms.throwableType), syms.methodClass);
case REFERENCE:
return new MethodType(List.nil(), Type.recoveryType,
List.of(syms.throwableType), syms.methodClass);
default:
Assert.error("Cannot get here!");
}
return null;
}
示例2: enterUnop
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Enter a unary operation into symbol table.
* @param name The name of the operator.
* @param arg The type of the operand.
* @param res The operation's result type.
* @param opcode The operation's bytecode instruction.
*/
private OperatorSymbol enterUnop(String name,
Type arg,
Type res,
int opcode) {
OperatorSymbol sym =
new OperatorSymbol(makeOperatorName(name),
new MethodType(List.of(arg),
res,
List.<Type>nil(),
methodClass),
opcode,
predefClass);
predefClass.members().enter(sym);
return sym;
}
示例3: enterUnop
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** Enter a unary operation into symbol table.
* @param name The name of the operator.
* @param arg The type of the operand.
* @param res The operation's result type.
* @param opcode The operation's bytecode instruction.
*/
private OperatorSymbol enterUnop(String name,
Type arg,
Type res,
int opcode) {
OperatorSymbol sym =
new OperatorSymbol(names.fromString(name),
new MethodType(List.of(arg),
res,
List.<Type>nil(),
methodClass),
opcode,
predefClass);
predefClass.members().enter(sym);
return sym;
}
示例4: classOrInterfaceOrEnumDeclaration
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/** ClassOrInterfaceOrEnumDeclaration = ModifiersOpt
* (ClassDeclaration | InterfaceDeclaration | EnumDeclaration)
* @param mods Any modifiers starting the class or interface declaration
* @param dc The documentation comment for the class, or null.
*/
protected JCStatement classOrInterfaceOrEnumDeclaration(JCModifiers mods, Comment dc) {
if (token.kind == CLASS) {
return classDeclaration(mods, dc);
} else if (token.kind == INTERFACE) {
return interfaceDeclaration(mods, dc);
} else if (token.kind == ENUM) {
return enumDeclaration(mods, dc);
} else {
int pos = token.pos;
List<JCTree> errs;
if (LAX_IDENTIFIER.accepts(token.kind)) {
errs = List.of(mods, toP(F.at(pos).Ident(ident())));
setErrorEndPos(token.pos);
} else {
errs = List.of(mods);
}
final JCErroneous erroneousTree;
if (parseModuleInfo) {
erroneousTree = syntaxError(pos, errs, "expected.module.or.open");
} else {
erroneousTree = syntaxError(pos, errs, "expected3", CLASS, INTERFACE, ENUM);
}
return toP(F.Exec(erroneousTree));
}
}
示例5: appendScope
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private Scope appendScope(Scope newScope) {
List<Scope> existingScopes = this.subScopes.reverse();
subScopes = List.of(existingScopes.head);
subScopes = subScopes.prepend(newScope);
for (Scope s : existingScopes.tail) {
subScopes = subScopes.prepend(s);
}
return newScope;
}
示例6: makeTwrFinallyClause
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) {
// primaryException.addSuppressed(catchException);
VarSymbol catchException =
new VarSymbol(SYNTHETIC, make.paramName(2),
syms.throwableType,
currentMethodSym);
JCStatement addSuppressionStatement =
make.Exec(makeCall(make.Ident(primaryException),
names.addSuppressed,
List.<JCExpression>of(make.Ident(catchException))));
// try { resource.close(); } catch (e) { primaryException.addSuppressed(e); }
JCBlock tryBlock =
make.Block(0L, List.<JCStatement>of(makeResourceCloseInvocation(resource)));
JCVariableDecl catchExceptionDecl = make.VarDef(catchException, null);
JCBlock catchBlock = make.Block(0L, List.<JCStatement>of(addSuppressionStatement));
List<JCCatch> catchClauses = List.<JCCatch>of(make.Catch(catchExceptionDecl, catchBlock));
JCTry tryTree = make.Try(tryBlock, catchClauses, null);
tryTree.finallyCanCompleteNormally = true;
// if (primaryException != null) {try...} else resourceClose;
JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)),
tryTree,
makeResourceCloseInvocation(resource));
// if (#resource != null) { if (primaryException ... }
return make.Block(0L,
List.<JCStatement>of(make.If(makeNonNullCheck(resource),
closeIfStatement,
null)));
}
示例7: typeArguments
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/**
* {@literal
* TypeArguments = "<" TypeArgument {"," TypeArgument} ">"
* }
*/
List<JCExpression> typeArguments(boolean diamondAllowed) {
if (token.kind == LT) {
nextToken();
if (token.kind == GT && diamondAllowed) {
checkDiamond();
mode |= DIAMOND;
nextToken();
return List.nil();
} else {
ListBuffer<JCExpression> args = new ListBuffer<>();
args.append(((mode & EXPR) == 0) ? typeArgument() : parseType());
while (token.kind == COMMA) {
nextToken();
args.append(((mode & EXPR) == 0) ? typeArgument() : parseType());
}
switch (token.kind) {
case GTGTGTEQ: case GTGTEQ: case GTEQ:
case GTGTGT: case GTGT:
token = S.split();
break;
case GT:
nextToken();
break;
default:
args.append(syntaxError(token.pos, "expected", GT));
break;
}
return args.toList();
}
} else {
return List.<JCExpression>of(syntaxError(token.pos, "expected", LT));
}
}
示例8: visitTypeVar
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
@Override
public List<Type> visitTypeVar(TypeVar t, Void ignored) {
if (t.bound.isCompound())
return interfaces(t.bound);
if (t.bound.isInterface())
return List.of(t.bound);
return List.nil();
}
示例9: getLocation
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
public Iterable<? extends File> getLocation(Location location) {
nullCheck(location);
paths.lazy();
if (location == CLASS_OUTPUT) {
return (getClassOutDir() == null ? null : List.of(getClassOutDir()));
} else if (location == SOURCE_OUTPUT) {
return (getSourceOutDir() == null ? null : List.of(getSourceOutDir()));
} else
return paths.getPathForLocation(location);
}
示例10: makeTwrFinallyClause
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) {
// primaryException.addSuppressed(catchException);
VarSymbol catchException =
new VarSymbol(0, make.paramName(2),
syms.throwableType,
currentMethodSym);
JCStatement addSuppressionStatement =
make.Exec(makeCall(make.Ident(primaryException),
names.addSuppressed,
List.<JCExpression>of(make.Ident(catchException))));
// try { resource.close(); } catch (e) { primaryException.addSuppressed(e); }
JCBlock tryBlock =
make.Block(0L, List.<JCStatement>of(makeResourceCloseInvocation(resource)));
JCVariableDecl catchExceptionDecl = make.VarDef(catchException, null);
JCBlock catchBlock = make.Block(0L, List.<JCStatement>of(addSuppressionStatement));
List<JCCatch> catchClauses = List.<JCCatch>of(make.Catch(catchExceptionDecl, catchBlock));
JCTry tryTree = make.Try(tryBlock, catchClauses, null);
// if (primaryException != null) {try...} else resourceClose;
JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)),
tryTree,
makeResourceCloseInvocation(resource));
// if (#resource != null) { if (primaryException ... }
return make.Block(0L,
List.<JCStatement>of(make.If(makeNonNullCheck(resource),
closeIfStatement,
null)));
}
示例11: visitArrayForeachLoop
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
/**
* A statement of the form
*
* <pre>
* for ( T v : arrayexpr ) stmt;
* </pre>
*
* (where arrayexpr is of an array type) gets translated to
*
* <pre>{@code
* for ( { arraytype #arr = arrayexpr;
* int #len = array.length;
* int #i = 0; };
* #i < #len; i$++ ) {
* T v = arr$[#i];
* stmt;
* }
* }</pre>
*
* where #arr, #len, and #i are freshly named synthetic local variables.
*/
private void visitArrayForeachLoop(JCEnhancedForLoop tree) {
make_at(tree.expr.pos());
VarSymbol arraycache = new VarSymbol(SYNTHETIC,
names.fromString("arr" + target.syntheticNameChar()),
tree.expr.type,
currentMethodSym);
JCStatement arraycachedef = make.VarDef(arraycache, tree.expr);
VarSymbol lencache = new VarSymbol(SYNTHETIC,
names.fromString("len" + target.syntheticNameChar()),
syms.intType,
currentMethodSym);
JCStatement lencachedef = make.
VarDef(lencache, make.Select(make.Ident(arraycache), syms.lengthVar));
VarSymbol index = new VarSymbol(SYNTHETIC,
names.fromString("i" + target.syntheticNameChar()),
syms.intType,
currentMethodSym);
JCVariableDecl indexdef = make.VarDef(index, make.Literal(INT, 0));
indexdef.init.type = indexdef.type = syms.intType.constType(0);
List<JCStatement> loopinit = List.of(arraycachedef, lencachedef, indexdef);
JCBinary cond = makeBinary(LT, make.Ident(index), make.Ident(lencache));
JCExpressionStatement step = make.Exec(makeUnary(PREINC, make.Ident(index)));
Type elemtype = types.elemtype(tree.expr.type);
JCExpression loopvarinit = make.Indexed(make.Ident(arraycache),
make.Ident(index)).setType(elemtype);
JCVariableDecl loopvardef = (JCVariableDecl)make.VarDef(tree.var.mods,
tree.var.name,
tree.var.vartype,
loopvarinit).setType(tree.var.type);
loopvardef.sym = tree.var.sym;
JCBlock body = make.
Block(0, List.of(loopvardef, tree.body));
result = translate(make.
ForLoop(loopinit,
cond,
List.of(step),
body));
patchTargets(body, tree, result);
}
示例12: getSuperBounds
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
private static List<Type> getSuperBounds(Type.WildcardType wild) {
return wild.isExtendsBound()
? List.nil()
: List.of(wild.type);
}
示例13: getCloseable
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
@Override
public List<TestAcloseable> getCloseable() {
return List.of(_ASSERT_NOT_NULL, _ASSERT_NOT_NULL_2, _ASSERT_NOT_NULL_3);
}
示例14: getCloseable
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
@Override
public List<TestAcloseable> getCloseable() {
return List.of(this._ASSERT_NOT_NULL);
}
示例15: addComment
import com.sun.tools.javac.util.List; //导入方法依赖的package包/类
List<Comment> addComment(List<Comment> comments, Comment comment) {
return comments == null ?
List.of(comment) :
comments.prepend(comment);
}