本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil.getMainType方法的典型用法代码示例。如果您正苦于以下问题:Java JavaElementUtil.getMainType方法的具体用法?Java JavaElementUtil.getMainType怎么用?Java JavaElementUtil.getMainType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil
的用法示例。
在下文中一共展示了JavaElementUtil.getMainType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDestinationNode
import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private ASTNode getDestinationNode(IJavaElement destination, CompilationUnit target) throws JavaModelException {
switch (destination.getElementType()) {
case IJavaElement.INITIALIZER:
return ASTNodeSearchUtil.getInitializerNode((IInitializer) destination, target);
case IJavaElement.FIELD:
return ASTNodeSearchUtil.getFieldOrEnumConstantDeclaration((IField) destination, target);
case IJavaElement.METHOD:
return ASTNodeSearchUtil.getMethodOrAnnotationTypeMemberDeclarationNode((IMethod) destination, target);
case IJavaElement.TYPE:
IType typeDestination= (IType) destination;
if (typeDestination.isAnonymous()) {
return ASTNodeSearchUtil.getClassInstanceCreationNode(typeDestination, target).getAnonymousClassDeclaration();
} else {
return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(typeDestination, target);
}
case IJavaElement.COMPILATION_UNIT:
IType mainType= JavaElementUtil.getMainType((ICompilationUnit) destination);
if (mainType != null) {
return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(mainType, target);
}
//$FALL-THROUGH$
default:
return null;
}
}
示例2: getSingleSelectedType
import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
public static IType getSingleSelectedType(IStructuredSelection selection)
throws JavaModelException {
Object first = selection.getFirstElement();
if (first instanceof IType) return (IType) first;
if (first instanceof ICompilationUnit) {
final ICompilationUnit unit = (ICompilationUnit) first;
if (unit.exists()) return JavaElementUtil.getMainType(unit);
}
return null;
}
示例3: getDestinationNode
import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private ASTNode getDestinationNode(IJavaElement destination, CompilationUnit target)
throws JavaModelException {
switch (destination.getElementType()) {
case IJavaElement.INITIALIZER:
return ASTNodeSearchUtil.getInitializerNode((IInitializer) destination, target);
case IJavaElement.FIELD:
return ASTNodeSearchUtil.getFieldOrEnumConstantDeclaration((IField) destination, target);
case IJavaElement.METHOD:
return ASTNodeSearchUtil.getMethodOrAnnotationTypeMemberDeclarationNode(
(IMethod) destination, target);
case IJavaElement.TYPE:
IType typeDestination = (IType) destination;
if (typeDestination.isAnonymous()) {
return ASTNodeSearchUtil.getClassInstanceCreationNode(typeDestination, target)
.getAnonymousClassDeclaration();
} else {
return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(typeDestination, target);
}
case IJavaElement.COMPILATION_UNIT:
IType mainType = JavaElementUtil.getMainType((ICompilationUnit) destination);
if (mainType != null) {
return ASTNodeSearchUtil.getAbstractTypeDeclarationNode(mainType, target);
}
// $FALL-THROUGH$
default:
return null;
}
}
示例4: getSingleSelectedType
import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
public static IType getSingleSelectedType(IStructuredSelection selection) throws JavaModelException {
Object first= selection.getFirstElement();
if (first instanceof IType)
return (IType) first;
if (first instanceof ICompilationUnit) {
final ICompilationUnit unit= (ICompilationUnit) first;
if (unit.exists())
return JavaElementUtil.getMainType(unit);
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:RefactoringAvailabilityTester.java
示例5: getSingleSelectedType
import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private static IType getSingleSelectedType(IStructuredSelection selection) throws JavaModelException {
if (selection.isEmpty() || selection.size() != 1)
return null;
Object first= selection.getFirstElement();
if (first instanceof IType)
return (IType)first;
if (first instanceof ICompilationUnit)
return JavaElementUtil.getMainType((ICompilationUnit)first);
return null;
}
示例6: getSingleSelectedType
import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private static IType getSingleSelectedType(IStructuredSelection selection) throws JavaModelException{
if (selection.isEmpty() || selection.size() != 1)
return null;
Object first= selection.getFirstElement();
if (first instanceof IType)
return (IType)first;
if (first instanceof ICompilationUnit)
return JavaElementUtil.getMainType((ICompilationUnit)first);
return null;
}