本文整理匯總了Java中com.sun.tools.javac.util.List.append方法的典型用法代碼示例。如果您正苦於以下問題:Java List.append方法的具體用法?Java List.append怎麽用?Java List.append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.tools.javac.util.List
的用法示例。
在下文中一共展示了List.append方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildReturnCheck
import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
@NotNull
private static Optional<List<JCTree.JCStatement>> buildReturnCheck(@NotNull ReturnToInstrumentInfo info) {
CompilationUnitProcessingContext context = info.getContext();
ExpressionTree returnExpression = info.getReturnExpression().getExpression();
if (!(returnExpression instanceof JCTree.JCExpression)) {
context.getLogger().reportDetails(String.format(
"find a 'return' expression of type %s but got %s",
JCTree.JCExpression.class.getName(), returnExpression.getClass().getName()
));
return Optional.empty();
}
JCTree.JCExpression returnJcExpression = (JCTree.JCExpression) returnExpression;
TreeMaker factory = context.getAstFactory();
Names symbolsTable = context.getSymbolsTable();
ExceptionTextGenerator<ReturnToInstrumentInfo> generator =
context.getExceptionTextGeneratorManager().getGenerator(METHOD_RETURN, context.getPluginSettings());
String errorMessage = generator.generate(info);
List<JCTree.JCStatement> result = List.of(
factory.VarDef(
factory.Modifiers(0),
symbolsTable.fromString(info.getTmpVariableName()),
info.getReturnType(),
returnJcExpression
)
);
String exceptionToThrow = info.getContext().getPluginSettings().getExceptionToThrow(METHOD_RETURN);
result = result.append(InstrumentationUtil.buildVarCheck(factory,
symbolsTable,
info.getTmpVariableName(),
errorMessage,
exceptionToThrow));
result = result.append(
factory.Return(
factory.Ident(symbolsTable.fromString(info.getTmpVariableName()))));
return Optional.of(result);
}
示例2: 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.<Type>nil(), Type.recoveryType,
List.of(syms.throwableType), syms.methodClass);
default:
Assert.error("Cannot get here!");
}
return null;
}
示例3: createBridgeParams
import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
Type bridgeType) {
List<VarSymbol> bridgeParams = null;
if (impl.params != null) {
bridgeParams = List.nil();
List<VarSymbol> implParams = impl.params;
Type.MethodType mType = (Type.MethodType)bridgeType;
List<Type> argTypes = mType.argtypes;
while (implParams.nonEmpty() && argTypes.nonEmpty()) {
VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER,
implParams.head.name, argTypes.head, bridge);
param.setAttributes(implParams.head);
bridgeParams = bridgeParams.append(param);
implParams = implParams.tail;
argTypes = argTypes.tail;
}
}
return bridgeParams;
}
示例4: 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;
}
示例5: mayBeInstrument
import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
@Override
protected boolean mayBeInstrument(@NotNull ParameterToInstrumentInfo info) {
String parameterName = info.getMethodParameter().getName().toString();
CompilationUnitProcessingContext context = info.getContext();
ExceptionTextGenerator<ParameterToInstrumentInfo> generator =
context.getExceptionTextGeneratorManager().getGenerator(METHOD_PARAMETER, context.getPluginSettings());
String errorMessage = generator.generate(info);
TreeMaker factory = context.getAstFactory();
Names symbolsTable = context.getSymbolsTable();
JCTree.JCBlock body = info.getBody();
String exceptionToThrow = info.getContext().getPluginSettings().getExceptionToThrow(METHOD_PARAMETER);
JCTree.JCIf varCheck = buildVarCheck(factory, symbolsTable, parameterName, errorMessage, exceptionToThrow);
if (info.isConstructor() && isFirstStatementThisOrSuperCall(body)) {
List<JCTree.JCStatement> newStatements = List.of(varCheck);
List<JCTree.JCStatement> statements = body.getStatements();
for (int i = 1; i < statements.size(); i++) {
newStatements = newStatements.append(statements.get(i));
}
newStatements = newStatements.prepend(statements.get(0));
body.stats = newStatements;
} else {
body.stats = body.stats.prepend(varCheck);
}
if (context.getPluginSettings().isVerboseMode()) {
String methodName = info.getQualifiedMethodName();
String methodNotice = methodName == null ? "" : " in the method " + methodName + "()";
context.getLogger().info(String.format(
"added a null-check for argument '%s'%s",
parameterName, methodNotice
));
}
return true;
}
示例6: mayBeInstrument
import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
@Override
protected boolean mayBeInstrument(@NotNull ReturnToInstrumentInfo info) {
ReturnInstrumentationAstParent parent
= info.getParent().accept(new MethodInstrumentationParentFinder(info), null);
if (parent == null) {
return false;
}
Optional<List<JCTree.JCStatement>> returnCheckOptional = buildReturnCheck(info);
if (!returnCheckOptional.isPresent()) {
return false;
}
List<JCTree.JCStatement> statements = parent.getStatements();
for (int i = 0; i < statements.size(); i++) {
JCTree.JCStatement statement = statements.get(i);
if (statement == info.getReturnExpression()) {
List<JCTree.JCStatement> newStatements = returnCheckOptional.get();
for (int j = i + 1; j < statements.size(); j++) {
newStatements = newStatements.append(statements.get(j));
}
for (int j = i - 1; j >= 0; j--) {
newStatements = newStatements.prepend(statements.get(j));
}
parent.setStatements(newStatements);
mayBeLogInstrumentation(info);
return true;
}
}
// When control flow reaches this place, that means that the AST parent doesn't contain any statments, so,
// we just populate it with new instructions.
parent.setStatements(returnCheckOptional.get());
mayBeLogInstrumentation(info);
return true;
}
示例7: accessConstructor
import com.sun.tools.javac.util.List; //導入方法依賴的package包/類
/** Return access constructor for a private constructor,
* or the constructor itself, if no access constructor is needed.
* @param pos The position to report diagnostics, if any.
* @param constr The private constructor.
*/
Symbol accessConstructor(DiagnosticPosition pos, Symbol constr) {
if (needsPrivateAccess(constr)) {
ClassSymbol accOwner = constr.owner.enclClass();
MethodSymbol aconstr = accessConstrs.get(constr);
if (aconstr == null) {
List<Type> argtypes = constr.type.getParameterTypes();
if ((accOwner.flags_field & ENUM) != 0)
argtypes = argtypes
.prepend(syms.intType)
.prepend(syms.stringType);
aconstr = new MethodSymbol(
SYNTHETIC,
names.init,
new MethodType(
argtypes.append(
accessConstructorTag().erasure(types)),
constr.type.getReturnType(),
constr.type.getThrownTypes(),
syms.methodClass),
accOwner);
enterSynthetic(pos, aconstr, accOwner.members());
accessConstrs.put(constr, aconstr);
accessed.append(constr);
}
return aconstr;
} else {
return constr;
}
}