本文整理汇总了Java中org.eclipse.jdt.core.dom.BodyDeclaration.getNodeType方法的典型用法代码示例。如果您正苦于以下问题:Java BodyDeclaration.getNodeType方法的具体用法?Java BodyDeclaration.getNodeType怎么用?Java BodyDeclaration.getNodeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.BodyDeclaration
的用法示例。
在下文中一共展示了BodyDeclaration.getNodeType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static ITypeBinding[] perform(BodyDeclaration enclosingNode, Selection selection) {
ExceptionAnalyzer analyzer = new ExceptionAnalyzer(selection);
enclosingNode.accept(analyzer);
List<ITypeBinding> exceptions = analyzer.getCurrentExceptions();
if (enclosingNode.getNodeType() == ASTNode.METHOD_DECLARATION) {
List<Type> thrownExceptions = ((MethodDeclaration) enclosingNode).thrownExceptionTypes();
for (Iterator<Type> thrown = thrownExceptions.iterator(); thrown.hasNext(); ) {
ITypeBinding thrownException = thrown.next().resolveBinding();
if (thrownException != null) {
for (Iterator<ITypeBinding> excep = exceptions.iterator(); excep.hasNext(); ) {
ITypeBinding exception = excep.next();
if (exception.isAssignmentCompatible(thrownException)) excep.remove();
}
}
}
}
Collections.sort(exceptions, new ExceptionComparator());
return exceptions.toArray(new ITypeBinding[exceptions.size()]);
}
示例2: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
/**
* Computes the maximum number of local variable declarations in the given
* body declaration.
*
* @param declaration
* the body declaration. Must either be a method declaration, or
* an initializer, or a field declaration.
* @return the maximum number of local variables
*/
public static int perform(BodyDeclaration declaration) {
Assert.isTrue(declaration != null);
switch (declaration.getNodeType()) {
case ASTNode.METHOD_DECLARATION:
case ASTNode.FIELD_DECLARATION:
case ASTNode.INITIALIZER:
return internalPerform(declaration);
default:
throw new IllegalArgumentException(declaration.toString());
}
}
示例3: 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;
}
}
示例4: perform
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
/**
* Computes the maximum number of local variable declarations in the given body declaration.
*
* @param declaration the body declaration. Must either be a method declaration, or an
* initializer, or a field declaration.
* @return the maximum number of local variables
*/
public static int perform(BodyDeclaration declaration) {
Assert.isTrue(declaration != null);
switch (declaration.getNodeType()) {
case ASTNode.METHOD_DECLARATION:
case ASTNode.FIELD_DECLARATION:
case ASTNode.INITIALIZER:
return internalPerform(declaration);
default:
throw new IllegalArgumentException(declaration.toString());
}
}
示例5: isStatic
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public static boolean isStatic(BodyDeclaration bodyDeclaration) {
if (isNestedInterfaceOrAnnotation(bodyDeclaration)) return true;
int nodeType = bodyDeclaration.getNodeType();
if (!(nodeType == ASTNode.METHOD_DECLARATION
|| nodeType == ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION)
&& isInterfaceOrAnnotationMember(bodyDeclaration)) return true;
if (bodyDeclaration instanceof EnumConstantDeclaration) return true;
if (bodyDeclaration instanceof EnumDeclaration
&& bodyDeclaration.getParent() instanceof AbstractTypeDeclaration) return true;
return Modifier.isStatic(bodyDeclaration.getModifiers());
}
示例6: initialize
import org.eclipse.jdt.core.dom.BodyDeclaration; //导入方法依赖的package包/类
public void initialize(BodyDeclaration declaration) {
fBodyDeclaration = declaration;
fRootScope =
CodeScopeBuilder.perform(declaration, fSourceProvider.getDeclaration().resolveBinding());
fNumberOfLocals = 0;
switch (declaration.getNodeType()) {
case ASTNode.METHOD_DECLARATION:
case ASTNode.INITIALIZER:
fNumberOfLocals = LocalVariableIndex.perform(declaration);
break;
}
}