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


Java Kinds类代码示例

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


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

示例1: checkThis

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
private void checkThis(DiagnosticPosition pos, TypeSymbol c) {
    if (checkThis && currentClass != c) {
        List<Pair<TypeSymbol, Symbol>> ots = outerThisStack;
        if (ots.isEmpty()) {
            log.error(pos, "no.encl.instance.of.type.in.scope", c); //NOI18N
            return;
        }
        Pair<TypeSymbol, Symbol> ot = ots.head;
        TypeSymbol otc = ot.fst;
        while (otc != c) {
            do {
                ots = ots.tail;
                if (ots.isEmpty()) {
                    log.error(pos, "no.encl.instance.of.type.in.scope", c); //NOI18N
                    return;
                }
                ot = ots.head;
            } while (ot.snd != otc);
            if (otc.owner.kind != Kinds.Kind.PCK && !otc.hasOuterInstance()) {
                log.error(pos, "cant.ref.before.ctor.called", c); //NOI18N
                return;
            }
            otc = ot.fst;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:PostFlowAnalysis.java

示例2: isErroneous

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
/**
 * Checks whether 'e' contains error or is missing. If the passed element is null
 * it's assumed the element could not be resolved and this method returns true. Otherwise,
 * the element's type kind is checked against error constants and finally the erroneous
 * state of the element is checked. 
 * 
 * @param e Element to check or {@code null}
 * @return true, if the element is missing (is {@code null}) or contains errors.
 */
public boolean isErroneous(@NullAllowed Element e) {
    if (e == null) {
        return true;
    }
    if (e.getKind() == ElementKind.MODULE && ((Symbol)e).kind == Kinds.Kind.ERR) {
        return true;
    }
    final TypeMirror type = e.asType();
    if (type == null) {
        return false;
    }
    if (type.getKind() == TypeKind.ERROR || type.getKind() == TypeKind.OTHER) {
        return true;
    }
    if (type instanceof Type) {
        if (((Type)type).isErroneous()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ElementUtilities.java

示例3: getAllValues

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
/**
 * Returns a map from element symbols to their values.
 * Includes all elements, whether explicit or defaulted.
 */
private Map<MethodSymbol, Attribute> getAllValues() {
    Map<MethodSymbol, Attribute> res =
        new LinkedHashMap<MethodSymbol, Attribute>();

    // First find the default values.
    ClassSymbol sym = (ClassSymbol) anno.type.tsym;
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol m = (MethodSymbol) e.sym;
            Attribute def = m.getDefaultValue();
            if (def != null)
                res.put(m, def);
        }
    }
    // Next find the explicit values, possibly overriding defaults.
    for (Pair<MethodSymbol, Attribute> p : anno.values)
        res.put(p.fst, p.snd);
    return res;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:AnnotationProxyMaker.java

示例4: findConstructor

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
/**
 * Find constructor in this class.
 *
 * @param constrName the unqualified name to search for.
 * @param paramTypes the array of Strings for constructor parameters.
 * @return the first ConstructorDocImpl which matches, null if not found.
 */
public ConstructorDoc findConstructor(String constrName,
                                      String[] paramTypes) {
    Names names = tsym.name.table.names;
    for (Scope.Entry e = tsym.members().lookup(names.fromString("<init>")); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            if (hasParameterTypes((MethodSymbol)e.sym, paramTypes)) {
                return env.getConstructorDoc((MethodSymbol)e.sym);
            }
        }
    }

    //###(gj) As a temporary measure until type variables are better
    //### handled, try again without the parameter types.
    //### This will often find the right constructor, and occassionally
    //### find the wrong one.
    //if (paramTypes != null) {
    //    return findConstructor(constrName, null);
    //}

    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:ClassDocImpl.java

示例5: visitMethodDef

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
@Override
public void visitMethodDef(JCMethodDecl tree) {
    super.visitMethodDef(tree);
    MethodSymbol meth = tree.sym;
    if (meth == null || meth.kind != Kinds.MTH) return;
    TreePath treePath = docenv.getTreePath(env.toplevel, env.enclClass, tree);
    if (meth.isConstructor())
        docenv.makeConstructorDoc(meth, treePath);
    else if (isAnnotationTypeElement(meth))
        docenv.makeAnnotationTypeElementDoc(meth, treePath);
    else
        docenv.makeMethodDoc(meth, treePath);

    // release resources
    tree.body = null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:JavadocMemberEnter.java

示例6: visitVarDef

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
@Override
public void visitVarDef(JCVariableDecl tree) {
    if (tree.init != null) {
        boolean isFinal = (tree.mods.flags & FINAL) != 0
                || (env.enclClass.mods.flags & INTERFACE) != 0;
        if (!isFinal || containsNonConstantExpression(tree.init)) {
            // Avoid unnecessary analysis and release resources.
            // In particular, remove non-constant expressions
            // which may trigger Attr.attribClass, since
            // method bodies are also removed, in visitMethodDef.
            tree.init = null;
        }
    }
    super.visitVarDef(tree);
    if (tree.sym != null &&
            tree.sym.kind == Kinds.VAR &&
            !isParameter(tree.sym)) {
        docenv.makeFieldDoc(tree.sym, docenv.getTreePath(env.toplevel, env.enclClass, tree));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JavadocMemberEnter.java

示例7: getDefinedSerializableFields

import com.sun.tools.javac.code.Kinds; //导入依赖的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

示例8: computeDefaultSerializableFields

import com.sun.tools.javac.code.Kinds; //导入依赖的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

示例9: addMethodIfExist

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Names names = def.name.table.names;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:SerializedForm.java

示例10: needsHeader

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) {
    if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0)
        return false;

    for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) {
        if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0)
            return true;
        for (Attribute.Compound a: i.sym.getDeclarationAttributes()) {
            if (a.type.tsym == syms.nativeHeaderType.tsym)
                return true;
        }
    }
    if (checkNestedClasses) {
        for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) {
            if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true))
                return true;
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JNIWriter.java

示例11: visitVarDef

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
@Override
public void visitVarDef(JCVariableDecl tree) {
    boolean isJavacPack = tree.sym.outermostClass().fullname.toString()
            .contains(packageToCheck);
    if (isJavacPack &&
        (tree.sym.flags() & SYNTHETIC) == 0 &&
        tree.sym.owner.kind == Kinds.TYP) {
        if (!ignoreField(tree.sym.owner.flatName().toString(),
                tree.getName().toString())) {
            boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0;
            boolean nonFinalStaticEnumField =
                    (tree.sym.flags() & (ENUM | FINAL)) == 0;
            boolean nonFinalStaticField =
                    (tree.sym.flags() & STATIC) != 0 &&
                    (tree.sym.flags() & FINAL) == 0;
            if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
                messages.error(tree, "crules.err.var.must.be.final", tree);
            }
        }
    }
    super.visitVarDef(tree);
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:23,代码来源:MutableFieldsAnalyzer.java

示例12: noteAssign

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
protected void noteAssign (JCExpression tree)
{
    // if the lhs is an identifier, then we may be mutating an in-scope variable
    if (tree instanceof JCIdent) {
        Name vname = ((JCIdent)tree).name;
        noteAssigned(tree, findVar(vname));

    } else if (tree instanceof JCFieldAccess) {
        // if we're accessing an object member through the this reference, we want to treat
        // that as if we just referenced the member directly
        JCFieldAccess fa = (JCFieldAccess)tree;
        if (fa.selected.toString().equals("this")) {
            // we need to look the variable up in the scope of the enclosing class, not our
            // inner scope (which is probably shadowing that name, hence the use of 'this')
            noteAssigned(tree, lookup(_env.enclClass.sym.members_field, fa.name, Kinds.VAR));
        } else {
            // System.err.println("Look ma! Non-local mutation '" + tree + "'.");
        }

    } else if (tree instanceof JCArrayAccess) {
        // nothing to do here, array cells are always mutable

    } else {
        System.err.println("Asked to note mutable on '" + tree + "'?");
    }
}
 
开发者ID:samskivert,项目名称:immutablej,代码行数:27,代码来源:Imfer.java

示例13: findConstructor

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
/**
 * Find constructor in this class.
 *
 * @param constrName the unqualified name to search for.
 * @param paramTypeArray the array of Strings for constructor parameters.
 * @return the first ConstructorDocImpl which matches, null if not found.
 */
public ConstructorDoc findConstructor(String constrName,
                                      String[] paramTypes) {
    Name.Table names = tsym.name.table;
    for (Scope.Entry e = tsym.members().lookup(names.fromString("<init>")); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            if (hasParameterTypes((MethodSymbol)e.sym, paramTypes)) {
                return env.getConstructorDoc((MethodSymbol)e.sym);
            }
        }
    }

    //###(gj) As a temporary measure until type variables are better
    //### handled, try again without the parameter types.
    //### This will often find the right constructor, and occassionally
    //### find the wrong one.
    //if (paramTypes != null) {
    //    return findConstructor(constrName, null);
    //}

    return null;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:29,代码来源:ClassDocImpl.java

示例14: getDefinedSerializableFields

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

    /* 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:unktomi,项目名称:form-follows-function,代码行数:18,代码来源:SerializedForm.java

示例15: addMethodIfExist

import com.sun.tools.javac.code.Kinds; //导入依赖的package包/类
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
    Name.Table names = def.name.table;

    for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol md = (MethodSymbol)e.sym;
            if ((md.flags() & Flags.STATIC) == 0) {
                /*
                 * WARNING: not robust if unqualifiedMethodName is overloaded
                 *          method. Signature checking could make more robust.
                 * READOBJECT takes a single parameter, java.io.ObjectInputStream.
                 * WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
                 */
                methods.append(env.getMethodDoc(md));
            }
        }
    }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:19,代码来源:SerializedForm.java


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