本文整理汇总了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;
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
}
示例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;
}
示例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);
}
}
}
}
示例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));
}
}
}
}
示例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;
}
示例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);
}
示例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 + "'?");
}
}
示例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;
}
示例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;
}
示例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));
}
}
}
}