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


Java VarSymbol类代码示例

本文整理汇总了Java中com.sun.tools.javac.code.Symbol.VarSymbol的典型用法代码示例。如果您正苦于以下问题:Java VarSymbol类的具体用法?Java VarSymbol怎么用?Java VarSymbol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VarSymbol类属于com.sun.tools.javac.code.Symbol包,在下文中一共展示了VarSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: javaDocFor

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
/**Get javadoc for given element.
 * @deprecated The new DocTree API should be used to traverse Javadoc comments.
 * Use {@link DocTrees#getDocCommentTree(javax.lang.model.element.Element)} instead.
 */
@Deprecated
public Doc javaDocFor(Element element) {
    if (element != null) {
        DocEnv env = DocEnv.instance(ctx);
        switch (element.getKind()) {
            case ANNOTATION_TYPE:
            case CLASS:
            case ENUM:
            case INTERFACE:
                return env.getClassDoc((ClassSymbol)element);
            case ENUM_CONSTANT:
            case FIELD:
                return env.getFieldDoc((VarSymbol)element);
            case METHOD:
                if (((MethodSymbol)element).enclClass().getKind() == ElementKind.ANNOTATION_TYPE)
                    return env.getAnnotationTypeElementDoc((MethodSymbol)element);
                return env.getMethodDoc((MethodSymbol)element);
            case CONSTRUCTOR:
                return env.getConstructorDoc((MethodSymbol)element);
            case PACKAGE:
                return env.getPackageDoc((PackageSymbol)element);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ElementUtilities.java

示例2: fillArtificalParamNames

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
private void fillArtificalParamNames(final ClassSymbol clazz) {
    for (Symbol s : clazz.getEnclosedElements()) {
        if (s instanceof MethodSymbol) {
            MethodSymbol ms = (MethodSymbol) s;

            if (ms.getParameters().isEmpty()) {
                continue;
            }
            
            Set<String> usedNames = new HashSet<String>();
            
            for (VarSymbol vs : ms.getParameters()) {
                String name = JavaSourceAccessor.getINSTANCE().generateReadableParameterName(vs.asType().toString(), usedNames);

                vs.setName(clazz.name.table.fromString(name));
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TreeLoader.java

示例3: getDefinedSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
    Names names = def.name.table.names;

    /* SERIALIZABLE_FIELDS can be private,
     * so must lookup by ClassSymbol, not by ClassDocImpl.
     */
    for (Scope.Entry e = def.members().lookup(names.fromString(SERIALIZABLE_FIELDS)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) != 0 &&
                (f.flags() & Flags.PRIVATE) != 0) {
                return f;
            }
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SerializedForm.java

示例4: computeDefaultSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
private void computeDefaultSerializableFields(DocEnv env,
                                              ClassSymbol def,
                                              ClassDocImpl cd) {
    for (Scope.Entry e = def.members().elems; e != null; e = e.sibling) {
        if (e.sym != null && e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) == 0 &&
                (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                FieldDocImpl fd = env.getFieldDoc(f);
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.prepend(fd);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SerializedForm.java

示例5: toString

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
@Override
public String toString() {
    String result = "";
    for (Entry<MethodSymbol, Map<JCTree, List<VarSymbol>>> mainEntry: aliveRangeClosingTrees.entrySet()) {
        result += "Method: \n" + mainEntry.getKey().flatName() + "\n";
        int i = 1;
        for (Entry<JCTree, List<VarSymbol>> treeEntry: mainEntry.getValue().entrySet()) {
            result += "    Tree " + i + ": \n" + treeEntry.getKey().toString() + "\n";
            result += "        Variables closed:\n";
            for (VarSymbol var: treeEntry.getValue()) {
                result += "            " + var.toString();
            }
            result += "\n";
            i++;
        }
    }
    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:LVTRanges.java

示例6: getAndRemoveNonFieldTAs

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
private List<Attribute.TypeCompound> getAndRemoveNonFieldTAs(VarSymbol sym) {
    List<TypeCompound> tas = sym.getRawTypeAttributes();
    ListBuffer<Attribute.TypeCompound> fieldTAs = new ListBuffer<Attribute.TypeCompound>();
    ListBuffer<Attribute.TypeCompound> nonfieldTAs = new ListBuffer<Attribute.TypeCompound>();
    for (TypeCompound ta : tas) {
        if (ta.getPosition().type == TargetType.FIELD) {
            fieldTAs.add(ta);
        } else {
            if (typeAnnoAsserts) {
                Assert.error("Type annotation does not have a valid positior");
            }

            nonfieldTAs.add(ta);
        }
    }
    sym.setTypeAttributes(fieldTAs.toList());
    return nonfieldTAs.toList();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Gen.java

示例7: visitIdent

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
public void visitIdent(JCIdent tree) {
    Symbol sym = tree.sym;
    if (tree.name == names._this || tree.name == names._super) {
        Item res = tree.name == names._this
            ? items.makeThisItem()
            : items.makeSuperItem();
        if (sym.kind == MTH) {
            // Generate code to address the constructor.
            res.load();
            res = items.makeMemberItem(sym, true);
        }
        result = res;
    } else if (sym.kind == VAR && sym.owner.kind == MTH) {
        result = items.makeLocalItem((VarSymbol)sym);
    } else if (isInvokeDynamic(sym)) {
        result = items.makeDynamicItem(sym);
    } else if ((sym.flags() & STATIC) != 0) {
        if (!isAccessSuper(env.enclMethod))
            sym = binaryQualifier(sym, env.enclClass.type);
        result = items.makeStaticItem(sym);
    } else {
        items.makeThisItem().load();
        sym = binaryQualifier(sym, env.enclClass.type);
        result = items.makeMemberItem(sym, (sym.flags() & PRIVATE) != 0);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:Gen.java

示例8: changed

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
/** This method will be called after any operation that causes a change to
 *  the bits. Subclasses can thus override it in order to extract information
 *  from the changes produced to the bits by the given operation.
 */
public void changed() {
    if (currentTree != null &&
            stateBeforeOp != BitsState.UNKNOWN &&
            trackTree(currentTree)) {
        List<VarSymbol> locals = lvtRanges
                .getVars(currentMethod, currentTree);
        locals = locals != null ?
                locals : List.<VarSymbol>nil();
        for (JCVariableDecl vardecl : vardecls) {
            //once the first is null, the rest will be so.
            if (vardecl == null) {
                break;
            }
            if (trackVar(vardecl.sym) && bitChanged(vardecl.sym.adr)) {
                locals = locals.prepend(vardecl.sym);
            }
        }
        if (!locals.isEmpty()) {
            lvtRanges.setEntry(currentMethod,
                    currentTree, locals);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:Gen.java

示例9: lambda

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
JCLambda lambda() {
    int prevPos = make.pos;
    try {
        make.at(tree);

        //body generation - this can be either a method call or a
        //new instance creation expression, depending on the member reference kind
        VarSymbol rcvr = addParametersReturnReceiver();
        JCExpression expr = (tree.getMode() == ReferenceMode.INVOKE)
                ? expressionInvoke(rcvr)
                : expressionNew();

        JCLambda slam = make.Lambda(params.toList(), expr);
        slam.targets = tree.targets;
        slam.type = tree.type;
        slam.pos = tree.pos;
        return slam;
    } finally {
        make.at(prevPos);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:LambdaToMethod.java

示例10: expressionInvoke

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
/**
 * determine the receiver of the method call - the receiver can
 * be a type qualifier, the synthetic receiver parameter or 'super'.
 */
private JCExpression expressionInvoke(VarSymbol rcvr) {
    JCExpression qualifier =
            tree.sym.isStatic() ?
                make.Type(tree.sym.owner.type) :
                (rcvr != null) ?
                    makeReceiver(rcvr) :
                    tree.getQualifierExpression();

    //create the qualifier expression
    JCFieldAccess select = make.Select(qualifier, tree.sym.name);
    select.sym = tree.sym;
    select.type = tree.sym.erasure(types);

    //create the method call expression
    JCExpression apply = make.Apply(List.<JCExpression>nil(), select,
            convertArgs(tree.sym, args.toList(), tree.varargsElement)).
            setType(tree.sym.erasure(types).getReturnType());

    apply = transTypes.coerce(apply, localContext.generatedRefSig().getReturnType());
    setVarargsIfNeeded(apply, tree.varargsElement);
    return apply;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:LambdaToMethod.java

示例11: expressionInvoke

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
/**
 * determine the receiver of the method call - the receiver can
 * be a type qualifier, the synthetic receiver parameter or 'super'.
 */
private JCExpression expressionInvoke(VarSymbol rcvr) {
    JCExpression qualifier =
            (rcvr != null) ?
                makeReceiver(rcvr) :
                tree.getQualifierExpression();

    //create the qualifier expression
    JCFieldAccess select = make.Select(qualifier, tree.sym.name);
    select.sym = tree.sym;
    select.type = tree.sym.erasure(types);

    //create the method call expression
    JCExpression apply = make.Apply(List.nil(), select,
            convertArgs(tree.sym, args.toList(), tree.varargsElement)).
            setType(tree.sym.erasure(types).getReturnType());

    apply = transTypes.coerce(attrEnv, apply,
            types.erasure(localContext.tree.referentType.getReturnType()));

    setVarargsIfNeeded(apply, tree.varargsElement);
    return apply;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:LambdaToMethod.java

示例12: getDefinedSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
    Names names = def.name.table.names;

    /* SERIALIZABLE_FIELDS can be private,
     */
    for (Symbol sym : def.members().getSymbolsByName(names.fromString(SERIALIZABLE_FIELDS))) {
        if (sym.kind == VAR) {
            VarSymbol f = (VarSymbol) sym;
            if ((f.flags() & Flags.STATIC) != 0
                    && (f.flags() & Flags.PRIVATE) != 0) {
                return f;
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:WorkArounds.java

示例13: getDefinedSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
    Names names = def.name.table.names;

    /* SERIALIZABLE_FIELDS can be private,
     * so must lookup by ClassSymbol, not by ClassDocImpl.
     */
    for (Symbol sym : def.members().getSymbolsByName(names.fromString(SERIALIZABLE_FIELDS))) {
        if (sym.kind == VAR) {
            VarSymbol f = (VarSymbol)sym;
            if ((f.flags() & Flags.STATIC) != 0 &&
                (f.flags() & Flags.PRIVATE) != 0) {
                return f;
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SerializedForm.java

示例14: computeDefaultSerializableFields

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
private void computeDefaultSerializableFields(DocEnv env,
                                              ClassSymbol def,
                                              ClassDocImpl cd) {
    for (Symbol sym : def.members().getSymbols(NON_RECURSIVE)) {
        if (sym != null && sym.kind == VAR) {
            VarSymbol f = (VarSymbol)sym;
            if ((f.flags() & Flags.STATIC) == 0 &&
                (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                FieldDocImpl fd = env.getFieldDoc(f);
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.prepend(fd);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SerializedForm.java

示例15: expressionInvoke

import com.sun.tools.javac.code.Symbol.VarSymbol; //导入依赖的package包/类
/**
 * determine the receiver of the method call - the receiver can
 * be a type qualifier, the synthetic receiver parameter or 'super'.
 */
private JCExpression expressionInvoke(VarSymbol rcvr) {
    JCExpression qualifier =
            (rcvr != null) ?
                makeReceiver(rcvr) :
                tree.getQualifierExpression();

    //create the qualifier expression
    JCFieldAccess select = make.Select(qualifier, tree.sym.name);
    select.sym = tree.sym;
    select.type = tree.sym.erasure(types);

    //create the method call expression
    JCExpression apply = make.Apply(List.<JCExpression>nil(), select,
            convertArgs(tree.sym, args.toList(), tree.varargsElement)).
            setType(tree.sym.erasure(types).getReturnType());

    apply = transTypes.coerce(attrEnv, apply,
            types.erasure(localContext.tree.referentType.getReturnType()));

    setVarargsIfNeeded(apply, tree.varargsElement);
    return apply;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:27,代码来源:LambdaToMethod.java


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