本文整理汇总了Java中com.sun.tools.javac.code.Symbol.MethodSymbol.flags方法的典型用法代码示例。如果您正苦于以下问题:Java MethodSymbol.flags方法的具体用法?Java MethodSymbol.flags怎么用?Java MethodSymbol.flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.code.Symbol.MethodSymbol
的用法示例。
在下文中一共展示了MethodSymbol.flags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: overridesMethod
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的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;
}
示例2: addMethodIfExist
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的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));
}
}
}
}
示例3: addMethodIfExist
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
private void addMethodIfExist(ClassSymbol def, String methodName) {
Names names = def.name.table.names;
for (Symbol sym : def.members().getSymbolsByName(names.fromString(methodName))) {
if (sym.kind == MTH) {
MethodSymbol md = (MethodSymbol) 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.add(md);
}
}
}
}
示例4: addMethodIfExist
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
Names names = def.name.table.names;
for (Symbol sym : def.members().getSymbolsByName(names.fromString(methodName))) {
if (sym.kind == MTH) {
MethodSymbol md = (MethodSymbol)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));
}
}
}
}
示例5: addMethodIfExist
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的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));
}
}
}
}
示例6: getImplementationOf
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
public Element getImplementationOf(ExecutableElement method, TypeElement origin) {
MethodSymbol msym = (MethodSymbol)method;
MethodSymbol implmethod = (msym).implementation((TypeSymbol)origin, jctypes, true);
if ((msym.flags() & Flags.STATIC) != 0) {
// return null if outside of hierarchy, or the method itself if origin extends method's class
if (jctypes.isSubtype(((TypeSymbol)origin).type, ((TypeSymbol)((MethodSymbol)method).owner).type)) {
return method;
} else {
return null;
}
}
if (implmethod == null || implmethod == method) {
//look for default implementations
if (allowDefaultMethods) {
com.sun.tools.javac.util.List<MethodSymbol> candidates = jctypes.interfaceCandidates(((TypeSymbol) origin).type, (MethodSymbol) method);
X: for (com.sun.tools.javac.util.List<MethodSymbol> ptr = candidates; ptr.head != null; ptr = ptr.tail) {
MethodSymbol prov = ptr.head;
if (prov != null && prov.overrides((MethodSymbol) method, (TypeSymbol) origin, jctypes, true) &&
hasImplementation(prov)) {
// PENDING: even if `prov' overrides the method, there may be a different method, in different interface, that overrides `method'
// 'prov' must override all such compatible methods in order to present a valid implementation of `method'.
for (com.sun.tools.javac.util.List<MethodSymbol> sibling = candidates; sibling.head != null; sibling = sibling.tail) {
MethodSymbol redeclare = sibling.head;
// if the default method does not override the alternative candidate from an interface, then the default will be rejected
// as specified in JLS #8, par. 8.4.8
if (!prov.overrides(redeclare, (TypeSymbol)origin, jctypes, allowDefaultMethods)) {
break X;
}
}
implmethod = prov;
break;
}
}
}
}
return implmethod;
}
示例7: factoryMethod
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
MethodSymbol factoryMethod(ClassSymbol tsym) {
for (Symbol sym : tsym.members().getSymbolsByName(names.provider, sym -> sym.kind == MTH)) {
MethodSymbol mSym = (MethodSymbol)sym;
if (mSym.isStatic() && (mSym.flags() & Flags.PUBLIC) != 0 && mSym.params().isEmpty()) {
return mSym;
}
}
return null;
}
示例8: shouldDocument
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
/** Check whether this member should be documented. */
public boolean shouldDocument(MethodSymbol sym) {
long mod = sym.flags();
if ((mod & Flags.SYNTHETIC) != 0) {
return false;
}
return showAccess.checkModifier(translateModifiers(mod));
}
示例9: visitProvides
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
@Override
public void visitProvides(JCProvides tree) {
Type st = attr.attribType(tree.serviceName, env, syms.objectType);
Type it = attr.attribType(tree.implName, env, st);
ClassSymbol service = (ClassSymbol) st.tsym;
ClassSymbol impl = (ClassSymbol) it.tsym;
if ((impl.flags() & ABSTRACT) != 0) {
log.error(tree.implName.pos(), Errors.ServiceImplementationIsAbstract(impl));
} else if (impl.isInner()) {
log.error(tree.implName.pos(), Errors.ServiceImplementationIsInner(impl));
} else if (service.isInner()) {
log.error(tree.serviceName.pos(), Errors.ServiceDefinitionIsInner(service));
} else {
MethodSymbol constr = noArgsConstructor(impl);
if (constr == null) {
log.error(tree.implName.pos(), Errors.ServiceImplementationDoesntHaveANoArgsConstructor(impl));
} else if ((constr.flags() & PUBLIC) == 0) {
log.error(tree.implName.pos(), Errors.ServiceImplementationNoArgsConstructorNotPublic(impl));
}
}
if (st.hasTag(CLASS) && it.hasTag(CLASS)) {
Directive.ProvidesDirective d = new Directive.ProvidesDirective(service, impl);
if (!allProvides.add(d)) {
log.error(tree.pos(), Errors.DuplicateProvides(service, impl));
}
msym.provides = msym.provides.prepend(d);
msym.directives = msym.directives.prepend(d);
directiveToTreeMap.put(d, tree);
}
}
示例10: shouldDocument
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
/** Check whether this member should be documented. */
public boolean shouldDocument(MethodSymbol sym) {
long mod = sym.flags();
if (isSynthetic(mod)) {
return false;
}
return filter.checkModifier(translateModifiers(mod));
}
示例11: getExtension
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
public Extension getExtension(final JavacNode typeNode, final ClassType extensionMethodProviderType) {
List<MethodSymbol> extensionMethods = new ArrayList<MethodSymbol>();
TypeSymbol tsym = extensionMethodProviderType.asElement();
if (tsym != null) for (Symbol member : tsym.getEnclosedElements()) {
if (member.getKind() != ElementKind.METHOD) continue;
MethodSymbol method = (MethodSymbol) member;
if ((method.flags() & (STATIC | PUBLIC)) == 0) continue;
if (method.params().isEmpty()) continue;
extensionMethods.add(method);
}
return new Extension(extensionMethods, tsym);
}
示例12: hasExplicitConstructor
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
/**
* Determine whether the given class contains an explicit constructor.
*
* @param node A class tree.
* @return True, iff there is an explicit constructor.
*/
public static boolean hasExplicitConstructor(ClassTree node) {
TypeElement elem = TreeUtils.elementFromDeclaration(node);
for ( ExecutableElement ee : ElementFilter.constructorsIn(elem.getEnclosedElements())) {
MethodSymbol ms = (MethodSymbol) ee;
long mod = ms.flags();
if ((mod & Flags.SYNTHETIC) == 0) {
return true;
}
}
return false;
}
示例13: hasExplicitConstructor
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
/**
* Determine whether the given class contains an explicit constructor.
*
* @param node a class tree
* @return true, iff there is an explicit constructor
*/
public static boolean hasExplicitConstructor(ClassTree node) {
TypeElement elem = TreeUtils.elementFromDeclaration(node);
for (ExecutableElement ee : ElementFilter.constructorsIn(elem.getEnclosedElements())) {
MethodSymbol ms = (MethodSymbol) ee;
long mod = ms.flags();
if ((mod & Flags.SYNTHETIC) == 0) {
return true;
}
}
return false;
}
示例14: hasImplementation
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
private static boolean hasImplementation(MethodSymbol msym) {
long f = msym.flags();
return ((f & Flags.DEFAULT) != 0) || ((f & Flags.ABSTRACT) == 0);
}
示例15: visitProvides
import com.sun.tools.javac.code.Symbol.MethodSymbol; //导入方法依赖的package包/类
@Override
public void visitProvides(JCProvides tree) {
Type st = attr.attribType(tree.serviceName, env, syms.objectType);
ClassSymbol service = (ClassSymbol) st.tsym;
if (allProvides.containsKey(service)) {
log.error(tree.serviceName.pos(), Errors.RepeatedProvidesForService(service));
}
ListBuffer<ClassSymbol> impls = new ListBuffer<>();
for (JCExpression implName : tree.implNames) {
Type it;
boolean prevVisitingServiceImplementation = env.info.visitingServiceImplementation;
try {
env.info.visitingServiceImplementation = true;
it = attr.attribType(implName, env, syms.objectType);
} finally {
env.info.visitingServiceImplementation = prevVisitingServiceImplementation;
}
ClassSymbol impl = (ClassSymbol) it.tsym;
if ((impl.flags_field & PUBLIC) == 0) {
log.error(implName.pos(), Errors.NotDefPublic(impl, impl.location()));
}
//find provider factory:
MethodSymbol factory = factoryMethod(impl);
if (factory != null) {
Type returnType = factory.type.getReturnType();
if (!types.isSubtype(returnType, st)) {
log.error(implName.pos(), Errors.ServiceImplementationProviderReturnMustBeSubtypeOfServiceInterface);
}
} else {
if (!types.isSubtype(it, st)) {
log.error(implName.pos(), Errors.ServiceImplementationMustBeSubtypeOfServiceInterface);
} else if ((impl.flags() & ABSTRACT) != 0) {
log.error(implName.pos(), Errors.ServiceImplementationIsAbstract(impl));
} else if (impl.isInner()) {
log.error(implName.pos(), Errors.ServiceImplementationIsInner(impl));
} else {
MethodSymbol constr = noArgsConstructor(impl);
if (constr == null) {
log.error(implName.pos(), Errors.ServiceImplementationDoesntHaveANoArgsConstructor(impl));
} else if ((constr.flags() & PUBLIC) == 0) {
log.error(implName.pos(), Errors.ServiceImplementationNoArgsConstructorNotPublic(impl));
}
}
}
if (it.hasTag(CLASS)) {
if (allProvides.computeIfAbsent(service, s -> new HashSet<>()).add(impl)) {
impls.append(impl);
} else {
log.error(implName.pos(), Errors.DuplicateProvides(service, impl));
}
}
}
if (st.hasTag(CLASS) && !impls.isEmpty()) {
Directive.ProvidesDirective d = new Directive.ProvidesDirective(service, impls.toList());
msym.provides = msym.provides.prepend(d);
msym.directives = msym.directives.prepend(d);
directiveToTreeMap.put(d, tree);
}
}