本文整理汇总了Java中org.eclipse.jdt.core.dom.BodyDeclaration.getModifiers方法的典型用法代码示例。如果您正苦于以下问题:Java BodyDeclaration.getModifiers方法的具体用法?Java BodyDeclaration.getModifiers怎么用?Java BodyDeclaration.getModifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.BodyDeclaration
的用法示例。
在下文中一共展示了BodyDeclaration.getModifiers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assignModifiersForElementBasedOnDeclaration
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static void assignModifiersForElementBasedOnDeclaration(NamedElement element, BodyDeclaration declaration) {
int modifiers = declaration.getModifiers();
VisibilityKind visibility = VisibilityProvider.getVisibilityOfNamedElementFromModifiers(element, modifiers);
element.setVisibility(visibility);
boolean isAbstract = Modifier.isAbstract(modifiers);
boolean isStatic = Modifier.isStatic(modifiers);
if (element instanceof Classifier) {
Classifier classifierElem = (Classifier) element;
classifierElem.setIsAbstract(isAbstract);
}
if (element instanceof BehavioralFeature) {
BehavioralFeature featureElem = (BehavioralFeature) element;
featureElem.setIsStatic(isStatic);
featureElem.setIsAbstract(isAbstract);
}
if (element instanceof Property) {
Property propertyElem = (Property) element;
propertyElem.setIsStatic(isStatic);
}
}
示例2: getOrderPreference
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
private static int getOrderPreference(BodyDeclaration member, MemberSortOrder sortOrder) {
int memberType= member.getNodeType();
int modifiers= member.getModifiers();
switch (memberType) {
case ASTNode.TYPE_DECLARATION:
case ASTNode.ENUM_DECLARATION :
case ASTNode.ANNOTATION_TYPE_DECLARATION :
return sortOrder.getCategoryIndex(MemberSortOrder.TYPE_INDEX) * 2;
case ASTNode.FIELD_DECLARATION:
if (Modifier.isStatic(modifiers)) {
int index = sortOrder.getCategoryIndex(MemberSortOrder.STATIC_FIELDS_INDEX) * 2;
if (Modifier.isFinal(modifiers)) {
return index; // first final static, then static
}
return index + 1;
}
return sortOrder.getCategoryIndex(MemberSortOrder.FIELDS_INDEX) * 2;
case ASTNode.INITIALIZER:
if (Modifier.isStatic(modifiers)) {
return sortOrder.getCategoryIndex(MemberSortOrder.STATIC_INIT_INDEX) * 2;
}
return sortOrder.getCategoryIndex(MemberSortOrder.INIT_INDEX) * 2;
case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
return sortOrder.getCategoryIndex(MemberSortOrder.METHOD_INDEX) * 2;
case ASTNode.METHOD_DECLARATION:
if (Modifier.isStatic(modifiers)) {
return sortOrder.getCategoryIndex(MemberSortOrder.STATIC_METHODS_INDEX) * 2;
}
if (((MethodDeclaration) member).isConstructor()) {
return sortOrder.getCategoryIndex(MemberSortOrder.CONSTRUCTORS_INDEX) * 2;
}
return sortOrder.getCategoryIndex(MemberSortOrder.METHOD_INDEX) * 2;
default:
return 100;
}
}