当前位置: 首页>>代码示例>>Java>>正文


Java List.append方法代码示例

本文整理汇总了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);
}
 
开发者ID:denis-zhdanov,项目名称:traute,代码行数:39,代码来源:MethodReturnInstrumentator.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Attr.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:TransTypes.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Attr.java

示例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;
}
 
开发者ID:denis-zhdanov,项目名称:traute,代码行数:35,代码来源:ParameterInstrumentator.java

示例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;
}
 
开发者ID:denis-zhdanov,项目名称:traute,代码行数:34,代码来源:MethodReturnInstrumentator.java

示例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;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:35,代码来源:Lower.java


注:本文中的com.sun.tools.javac.util.List.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。