本文整理汇总了Java中org.eclipse.jdt.core.dom.BodyDeclaration.modifiers方法的典型用法代码示例。如果您正苦于以下问题:Java BodyDeclaration.modifiers方法的具体用法?Java BodyDeclaration.modifiers怎么用?Java BodyDeclaration.modifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.BodyDeclaration
的用法示例。
在下文中一共展示了BodyDeclaration.modifiers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkModifiers
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static void checkModifiers(ProblemCollector collector, BodyDeclaration elem,
Predicate<Modifier> allowSpecific) {
for (Object obj : elem.modifiers()) {
if (!(obj instanceof Modifier)) {
continue;
}
Modifier modifier = (Modifier) obj;
boolean valid;
if (allowSpecific.test(modifier)) {
valid = true;
} else {
valid = modifier.isPrivate() || modifier.isPublic() || modifier.isProtected() || modifier.isFinal();
}
if (!valid) {
collector.report(new InvalidModifier(collector.getSourceInfo(), modifier));
}
}
}
示例2: _createMember
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
private Member _createMember(BodyDeclaration declaration) {
List<String> modifiers = new ArrayList<>();
for (Object modifier : declaration.modifiers()) {
modifiers.add(modifier.toString());
}
StringBuilder sb = new StringBuilder();
_getVisibility(sb, modifiers);
_getModifiers(sb, modifiers);
if (declaration instanceof FieldDeclaration) {
return _getFieldType((FieldDeclaration)declaration, sb);
}
if (declaration instanceof MethodDeclaration) {
return _getMethodType((MethodDeclaration)declaration, sb);
}
if (declaration instanceof TypeDeclaration) {
return _getClassType((TypeDeclaration)declaration, sb);
}
if (declaration instanceof Initializer) {
return _getInitializerType((Initializer)declaration, sb);
}
if (declaration instanceof EnumDeclaration) {
return _getEnumType((EnumDeclaration)declaration, sb);
}
return new Member("-nodata", "-nodata");
}
示例3: findPrivateModifier
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static Modifier findPrivateModifier(BodyDeclaration decl) {
List<IExtendedModifier> modifiers = decl.modifiers();
for (IExtendedModifier m : modifiers) {
if (m.isModifier()) {
Modifier modifier = (Modifier) m;
if (modifier.isPrivate()) {
return modifier;
}
}
}
return null;
}
示例4: obtainAnnotation
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
/**
* @return the annotation node if it is present on the declaration or null
*/
public static Annotation obtainAnnotation(BodyDeclaration declaration, Class<?> annotationClass) {
for (Object mod : declaration.modifiers()) {
IExtendedModifier modifier = (IExtendedModifier) mod;
if (modifier.isAnnotation()) {
Annotation annotation = (Annotation) modifier;
if (identicalAnnotations(annotation, annotationClass)) {
return annotation;
}
}
}
return null;
}