本文整理匯總了Java中com.sun.tools.javac.code.Flags類的典型用法代碼示例。如果您正苦於以下問題:Java Flags類的具體用法?Java Flags怎麽用?Java Flags使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Flags類屬於com.sun.tools.javac.code包,在下文中一共展示了Flags類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: rewriteChildren
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
protected final MethodTree rewriteChildren(MethodTree tree) {
ModifiersTree mods = (ModifiersTree)translate(tree.getModifiers());
ExpressionTree restype = (ExpressionTree)translateClassRef(tree.getReturnType());
List<? extends TypeParameterTree> typarams = translateStable(tree.getTypeParameters());
List<? extends VariableTree> params = translateStable(tree.getParameters());
List<? extends ExpressionTree> thrown = translate(tree.getThrows());
ExpressionTree defaultValue = (ExpressionTree)translate(tree.getDefaultValue());
BlockTree body = (BlockTree)translate(tree.getBody());
if (restype!=tree.getReturnType() || !typarams.equals(tree.getTypeParameters()) ||
!params.equals(tree.getParameters()) || !thrown.equals(tree.getThrows()) ||
mods!=tree.getModifiers() || defaultValue!=tree.getDefaultValue() ||
body!=tree.getBody()) {
if ((((JCModifiers) mods).flags & Flags.GENERATEDCONSTR) != 0) {
mods = make.Modifiers(((JCModifiers) mods).flags & ~Flags.GENERATEDCONSTR, mods.getAnnotations());
}
MethodTree n = make.Method(mods, tree.getName().toString(), restype, typarams,
params, thrown, body, defaultValue);
copyCommentTo(tree,n);
copyPosTo(tree,n);
tree = n;
}
return tree;
}
示例2: isSynthetic
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
private boolean isSynthetic(CompilationUnitTree cut, Tree leaf) {
JCTree tree = (JCTree) leaf;
if (tree.pos == (-1))
return true;
if (leaf.getKind() == Tree.Kind.METHOD) {
//check for synthetic constructor:
return (((JCMethodDecl)leaf).mods.flags & Flags.GENERATEDCONSTR) != 0L;
}
//check for synthetic superconstructor call:
if (leaf.getKind() == Tree.Kind.EXPRESSION_STATEMENT) {
ExpressionStatementTree est = (ExpressionStatementTree) leaf;
if (est.getExpression().getKind() == Tree.Kind.METHOD_INVOCATION) {
MethodInvocationTree mit = (MethodInvocationTree) est.getExpression();
if (mit.getMethodSelect().getKind() == Tree.Kind.IDENTIFIER) {
IdentifierTree it = (IdentifierTree) mit.getMethodSelect();
if ("super".equals(it.getName().toString())) {
return sp.getEndPosition(cut, leaf) == (-1);
}
}
}
}
return false;
}
示例3: modifiersToFlags
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
public static long modifiersToFlags(Set<Modifier> flagset) {
long flags = 0L;
for (Modifier mod : flagset)
switch (mod) {
case PUBLIC: flags |= Flags.PUBLIC; break;
case PROTECTED: flags |= Flags.PROTECTED; break;
case PRIVATE: flags |= Flags.PRIVATE; break;
case ABSTRACT: flags |= Flags.ABSTRACT; break;
case STATIC: flags |= Flags.STATIC; break;
case FINAL: flags |= Flags.FINAL; break;
case TRANSIENT: flags |= Flags.TRANSIENT; break;
case VOLATILE: flags |= Flags.VOLATILE; break;
case SYNCHRONIZED: flags |= Flags.SYNCHRONIZED; break;
case NATIVE: flags |= Flags.NATIVE; break;
case STRICTFP: flags |= Flags.STRICTFP; break;
case DEFAULT: flags |= Flags.DEFAULT; break;
default:
throw new AssertionError("Unknown Modifier: " + mod); //NOI18N
}
return flags;
}
示例4: overridesMethod
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
/**
* Returns true if this element represents a method which overrides a
* method in one of its superclasses.
*/
public boolean overridesMethod(ExecutableElement element) {
MethodSymbol m = (MethodSymbol)element;
if ((m.flags() & Flags.STATIC) == 0) {
ClassSymbol owner = (ClassSymbol) m.owner;
for (Type sup = jctypes.supertype(m.owner.type);
sup.hasTag(TypeTag.CLASS);
sup = jctypes.supertype(sup)) {
for (Symbol sym : sup.tsym.members().getSymbolsByName(m.name)) {
if (m.overrides(sym, owner, jctypes, true))
return true;
}
}
}
return false;
}
示例5: addModifiersModifier
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
public ModifiersTree addModifiersModifier(ModifiersTree modifiers, Modifier modifier) {
long c = ((JCModifiers) modifiers).flags & ~Flags.GENERATEDCONSTR;
switch (modifier) {
case ABSTRACT: c = c | Flags.ABSTRACT; break;
case FINAL: c = c | Flags.FINAL; break;
case NATIVE: c = c | Flags.NATIVE; break;
case PRIVATE: c = c | Flags.PRIVATE; break;
case PROTECTED: c = c | Flags.PROTECTED; break;
case PUBLIC: c = c | Flags.PUBLIC; break;
case STATIC: c = c | Flags.STATIC; break;
case STRICTFP: c = c | Flags.STRICTFP; break;
case SYNCHRONIZED: c = c | Flags.SYNCHRONIZED; break;
case TRANSIENT: c = c | Flags.TRANSIENT; break;
case VOLATILE: c = c | Flags.VOLATILE; break;
case DEFAULT: c = c | Flags.DEFAULT; break;
default:
break;
}
return Modifiers(c, modifiers.getAnnotations());
}
示例6: removeModifiersModifier
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
public ModifiersTree removeModifiersModifier(ModifiersTree modifiers, Modifier modifier) {
long c = ((JCModifiers) modifiers).flags & ~Flags.GENERATEDCONSTR;
switch (modifier) {
case ABSTRACT: c = c & ~Flags.ABSTRACT; break;
case FINAL: c = c & ~Flags.FINAL; break;
case NATIVE: c = c & ~Flags.NATIVE; break;
case PRIVATE: c = c & ~Flags.PRIVATE; break;
case PROTECTED: c = c & ~Flags.PROTECTED; break;
case PUBLIC: c = c & ~Flags.PUBLIC; break;
case STATIC: c = c & ~Flags.STATIC; break;
case STRICTFP: c = c & ~Flags.STRICTFP; break;
case SYNCHRONIZED: c = c & ~Flags.SYNCHRONIZED; break;
case TRANSIENT: c = c & ~Flags.TRANSIENT; break;
case VOLATILE: c = c & ~Flags.VOLATILE; break;
case DEFAULT: c = c & ~Flags.DEFAULT; break;
default:
break;
}
return Modifiers(c, modifiers.getAnnotations());
}
示例7: visitClass
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
@Override
public Void visitClass(ClassTree node, Void aVoid) {
String className = node.getSimpleName().toString();
if (className.isEmpty()) {
className = "$" + ++anonymousClassCounter;
}
ModifiersTree modifiers = node.getModifiers();
final boolean processingInterface;
if (modifiers instanceof JCTree.JCModifiers) {
processingInterface = (((JCTree.JCModifiers) modifiers).flags & Flags.INTERFACE) != 0;
} else {
processingInterface = modifiers.toString().contains("interface");
}
classNames.push(className);
this.processingInterface.push(processingInterface);
try {
return withDefaultNotNullAnnotations(modifiers,
className + " class",
() -> super.visitClass(node, aVoid));
} finally {
classNames.pop();
this.processingInterface.pop();
}
}
示例8: findSuperConstructorInType
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
/**
* based heavily on {@link ASTHelpers#findSuperMethodInType(Symbol.MethodSymbol, Type, Types)},
* but works for constructors
*/
@Nullable
private static Symbol.MethodSymbol findSuperConstructorInType(
Symbol.MethodSymbol methodSymbol, Type superType, Types types) {
Preconditions.checkArgument(methodSymbol.isConstructor(), "only accepts constructor methods");
Scope scope = superType.tsym.members();
for (Symbol sym : scope.getSymbolsByName(methodSymbol.name)) {
if (sym != null
&& sym.isConstructor()
&& ((sym.flags() & Flags.SYNTHETIC) == 0)
&& hasSameArgTypes((Symbol.MethodSymbol) sym, methodSymbol, types)) {
return (Symbol.MethodSymbol) sym;
}
}
return null;
}
示例9: getElement
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
public Element getElement(TreePath path) {
JCTree tree = (JCTree) path.getLeaf();
Symbol sym = TreeInfo.symbolFor(tree);
if (sym == null && TreeInfo.isDeclaration(tree)) {
for (TreePath p = path; p != null; p = p.getParentPath()) {
JCTree t = (JCTree) p.getLeaf();
if (t.getTag() == JCTree.CLASSDEF) {
JCClassDecl ct = (JCClassDecl) t;
if (ct.sym != null) {
if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) {
attr.attribClass(ct.pos(), ct.sym);
sym = TreeInfo.symbolFor(tree);
}
break;
}
}
}
}
return sym;
}
示例10: getDefinedSerializableFields
import com.sun.tools.javac.code.Flags; //導入依賴的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;
}
示例11: computeDefaultSerializableFields
import com.sun.tools.javac.code.Flags; //導入依賴的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);
}
}
}
}
示例12: addMethodIfExist
import com.sun.tools.javac.code.Flags; //導入依賴的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));
}
}
}
}
示例13: needsHeader
import com.sun.tools.javac.code.Flags; //導入依賴的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;
}
示例14: getElement
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
public Symbol getElement(TreePath path) {
JCTree tree = (JCTree) path.getLeaf();
Symbol sym = TreeInfo.symbolFor(tree);
if (sym == null) {
if (TreeInfo.isDeclaration(tree)) {
for (TreePath p = path; p != null; p = p.getParentPath()) {
JCTree t = (JCTree) p.getLeaf();
if (t.hasTag(JCTree.Tag.CLASSDEF)) {
JCClassDecl ct = (JCClassDecl) t;
if (ct.sym != null) {
if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) {
attr.attribClass(ct.pos(), ct.sym);
sym = TreeInfo.symbolFor(tree);
}
break;
}
}
}
}
}
return sym;
}
示例15: visitMethodDef
import com.sun.tools.javac.code.Flags; //導入依賴的package包/類
/**
* methods: remove method bodies, make methods native
*/
@Override
public void visitMethodDef(JCMethodDecl tree) {
tree.mods = translate(tree.mods);
tree.restype = translate(tree.restype);
tree.typarams = translateTypeParams(tree.typarams);
tree.params = translateVarDefs(tree.params);
tree.thrown = translate(tree.thrown);
if (tree.body != null) {
if ((currClassMods & Flags.INTERFACE) != 0) {
tree.mods.flags &= ~(Flags.DEFAULT | Flags.STATIC);
} else {
tree.mods.flags |= Flags.NATIVE;
}
tree.body = null;
}
result = tree;
}