本文整理汇总了Java中com.sun.tools.javac.code.Scope.Entry方法的典型用法代码示例。如果您正苦于以下问题:Java Scope.Entry方法的具体用法?Java Scope.Entry怎么用?Java Scope.Entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.code.Scope
的用法示例。
在下文中一共展示了Scope.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iterator
import com.sun.tools.javac.code.Scope; //导入方法依赖的package包/类
public Iterator<Symbol> iterator() {
return new Iterator<Symbol>() {
/** The next entry to examine, or null if none. */
private Scope.Entry nextEntry = scope.elems;
private boolean hasNextForSure = false;
public boolean hasNext() {
if (hasNextForSure) {
return true;
}
while (nextEntry != null && unwanted(nextEntry.sym)) {
nextEntry = nextEntry.sibling;
}
hasNextForSure = (nextEntry != null);
return hasNextForSure;
}
public Symbol next() {
if (hasNext()) {
Symbol result = nextEntry.sym;
nextEntry = nextEntry.sibling;
hasNextForSure = false;
return result;
} else {
throw new NoSuchElementException();
}
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例2: getAllValues
import com.sun.tools.javac.code.Scope; //导入方法依赖的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;
}
示例3: findConstructor
import com.sun.tools.javac.code.Scope; //导入方法依赖的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;
}
示例4: getClasses
import com.sun.tools.javac.code.Scope; //导入方法依赖的package包/类
/**
* Return a list of all classes contained in this package, including
* member classes of those classes, and their member classes, etc.
*/
private List<ClassDocImpl> getClasses(boolean filtered) {
if (allClasses != null && !filtered) {
return allClasses;
}
if (allClassesFiltered != null && filtered) {
return allClassesFiltered;
}
ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
if (e.sym != null) {
ClassSymbol s = (ClassSymbol)e.sym;
ClassDocImpl c = env.getClassDoc(s);
if (c != null && !c.isSynthetic())
c.addAllClasses(classes, filtered);
}
}
if (filtered)
return allClassesFiltered = classes.toList();
else
return allClasses = classes.toList();
}
示例5: getDefinedSerializableFields
import com.sun.tools.javac.code.Scope; //导入方法依赖的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;
}
示例6: computeDefaultSerializableFields
import com.sun.tools.javac.code.Scope; //导入方法依赖的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);
}
}
}
}
示例7: addMethodIfExist
import com.sun.tools.javac.code.Scope; //导入方法依赖的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));
}
}
}
}
示例8: needsHeader
import com.sun.tools.javac.code.Scope; //导入方法依赖的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;
}
示例9: findConstructor
import com.sun.tools.javac.code.Scope; //导入方法依赖的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;
}
示例10: addMethodIfExist
import com.sun.tools.javac.code.Scope; //导入方法依赖的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));
}
}
}
}
示例11: mapSerialFieldTagImplsToFieldDocImpls
import com.sun.tools.javac.code.Scope; //导入方法依赖的package包/类
private void mapSerialFieldTagImplsToFieldDocImpls(FieldDocImpl spfDoc,
DocEnv env,
ClassSymbol def) {
Name.Table names = def.name.table;
SerialFieldTag[] sfTag = spfDoc.serialFieldTags();
for (int i = 0; i < sfTag.length; i++) {
Name fieldName = names.fromString(sfTag[i].fieldName());
// Look for a FieldDocImpl that is documented by serialFieldTagImpl.
for (Scope.Entry e = def.members().lookup(fieldName); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.VAR) {
VarSymbol f = (VarSymbol)e.sym;
FieldDocImpl fdi = env.getFieldDoc(f);
((SerialFieldTagImpl)(sfTag[i])).mapToFieldDocImpl(fdi);
break;
}
}
}
}
示例12: mapSerialFieldTagImplsToFieldDocImpls
import com.sun.tools.javac.code.Scope; //导入方法依赖的package包/类
private void mapSerialFieldTagImplsToFieldDocImpls(FieldDocImpl spfDoc,
DocEnv env,
ClassSymbol def) {
Names names = def.name.table.names;
SerialFieldTag[] sfTag = spfDoc.serialFieldTags();
for (int i = 0; i < sfTag.length; i++) {
Name fieldName = names.fromString(sfTag[i].fieldName());
// Look for a FieldDocImpl that is documented by serialFieldTagImpl.
for (Scope.Entry e = def.members().lookup(fieldName); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.VAR) {
VarSymbol f = (VarSymbol)e.sym;
FieldDocImpl fdi = env.getFieldDoc(f);
((SerialFieldTagImpl)(sfTag[i])).mapToFieldDocImpl(fdi);
break;
}
}
}
}
示例13: enumConstant
import com.sun.tools.javac.code.Scope; //导入方法依赖的package包/类
/** Return the selected enumeration constant symbol, or null. */
private Symbol enumConstant(JCTree tree, Type enumType) {
if (tree.getTag() != JCTree.IDENT) {
log.error(tree.pos(), "enum.label.must.be.unqualified.enum");
return syms.errSymbol;
}
JCIdent ident = (JCIdent)tree;
Name name = ident.name;
for (Scope.Entry e = enumType.tsym.members().lookup(name);
e.scope != null; e = e.next()) {
if (e.sym.kind == VAR) {
Symbol s = ident.sym = e.sym;
((VarSymbol)s).getConstValue(); // ensure initializer is evaluated
ident.type = s.type;
return ((s.flags_field & Flags.ENUM) == 0)
? null : s;
}
}
return null;
}
示例14: findConstructor
import com.sun.tools.javac.code.Scope; //导入方法依赖的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) {
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;
}
示例15: size
import com.sun.tools.javac.code.Scope; //导入方法依赖的package包/类
public int size() {
int cnt = 0;
for (Scope.Entry e = scope.elems; e != null; e = e.sibling) {
if (!unwanted(e.sym))
cnt++;
}
return cnt;
}