本文整理汇总了Java中org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection.resolveElementAtOffset方法的典型用法代码示例。如果您正苦于以下问题:Java JavaTextSelection.resolveElementAtOffset方法的具体用法?Java JavaTextSelection.resolveElementAtOffset怎么用?Java JavaTextSelection.resolveElementAtOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection
的用法示例。
在下文中一共展示了JavaTextSelection.resolveElementAtOffset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isIntroduceFactoryAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isIntroduceFactoryAvailable(final JavaTextSelection selection)
throws JavaModelException {
final IJavaElement[] elements = selection.resolveElementAtOffset();
if (elements.length == 1 && elements[0] instanceof IMethod)
return isIntroduceFactoryAvailable((IMethod) elements[0]);
// there's no IMethod for the default constructor
if (!Checks.isAvailable(selection.resolveEnclosingElement())) return false;
ASTNode node = selection.resolveCoveringNode();
if (node == null) {
ASTNode[] selectedNodes = selection.resolveSelectedNodes();
if (selectedNodes != null && selectedNodes.length == 1) {
node = selectedNodes[0];
if (node == null) return false;
} else {
return false;
}
}
if (node.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) return true;
node = ASTNodes.getNormalizedNode(node);
if (node.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) return true;
return false;
}
示例2: isIntroduceIndirectionAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isIntroduceIndirectionAvailable(final JavaTextSelection selection)
throws JavaModelException {
final IJavaElement[] elements = selection.resolveElementAtOffset();
if (elements.length == 1)
return (elements[0] instanceof IMethod)
&& isIntroduceIndirectionAvailable(((IMethod) elements[0]));
ASTNode[] selectedNodes = selection.resolveSelectedNodes();
if (selectedNodes == null || selectedNodes.length != 1) return false;
switch (selectedNodes[0].getNodeType()) {
case ASTNode.METHOD_DECLARATION:
case ASTNode.METHOD_INVOCATION:
case ASTNode.SUPER_METHOD_INVOCATION:
return true;
default:
return false;
}
}
示例3: isIntroduceIndirectionAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isIntroduceIndirectionAvailable(final JavaTextSelection selection) throws JavaModelException {
final IJavaElement[] elements= selection.resolveElementAtOffset();
if (elements.length == 1)
return (elements[0] instanceof IMethod) && isIntroduceIndirectionAvailable(((IMethod) elements[0]));
ASTNode[] selectedNodes= selection.resolveSelectedNodes();
if (selectedNodes == null || selectedNodes.length != 1)
return false;
switch (selectedNodes[0].getNodeType()) {
case ASTNode.METHOD_DECLARATION:
case ASTNode.METHOD_INVOCATION:
case ASTNode.SUPER_METHOD_INVOCATION:
return true;
default:
return false;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:RefactoringAvailabilityTester.java
示例4: selectionChanged
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
@Override
public void selectionChanged(ITextSelection selection) {
if (selection instanceof JavaTextSelection) {
try {
JavaTextSelection javaTextSelection= (JavaTextSelection)selection;
IJavaElement[] elements= javaTextSelection.resolveElementAtOffset();
if (elements.length == 1) {
setEnabled(RefactoringAvailabilityTester.isRenameElementAvailable(elements[0]));
} else {
ASTNode node= javaTextSelection.resolveCoveringNode();
setEnabled(node instanceof SimpleName);
}
} catch (CoreException e) {
setEnabled(false);
}
} else {
setEnabled(true);
}
}
示例5: isChangeSignatureAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isChangeSignatureAvailable(final JavaTextSelection selection)
throws JavaModelException {
final IJavaElement[] elements = selection.resolveElementAtOffset();
if (elements.length == 1 && (elements[0] instanceof IMethod))
return isChangeSignatureAvailable((IMethod) elements[0]);
final IJavaElement element = selection.resolveEnclosingElement();
return (element instanceof IMethod) && isChangeSignatureAvailable((IMethod) element);
}
示例6: isInlineTempAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isInlineTempAvailable(final JavaTextSelection selection)
throws JavaModelException {
final IJavaElement[] elements = selection.resolveElementAtOffset();
if (elements.length != 1) return false;
return (elements[0] instanceof ILocalVariable)
&& isInlineTempAvailable((ILocalVariable) elements[0]);
}
示例7: isPromoteTempAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isPromoteTempAvailable(final JavaTextSelection selection)
throws JavaModelException {
final IJavaElement[] elements = selection.resolveElementAtOffset();
if (elements.length != 1) return false;
return (elements[0] instanceof ILocalVariable)
&& isPromoteTempAvailable((ILocalVariable) elements[0]);
}
示例8: isReplaceInvocationsAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isReplaceInvocationsAvailable(final JavaTextSelection selection)
throws JavaModelException {
final IJavaElement[] elements = selection.resolveElementAtOffset();
if (elements.length != 1) return false;
IJavaElement element = elements[0];
return (element instanceof IMethod) && isReplaceInvocationsAvailable(((IMethod) element));
}
示例9: isChangeSignatureAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isChangeSignatureAvailable(final JavaTextSelection selection) throws JavaModelException {
final IJavaElement[] elements= selection.resolveElementAtOffset();
if (elements.length == 1 && (elements[0] instanceof IMethod))
return isChangeSignatureAvailable((IMethod) elements[0]);
final IJavaElement element= selection.resolveEnclosingElement();
return (element instanceof IMethod) && isChangeSignatureAvailable((IMethod) element);
}
示例10: isIntroduceFactoryAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isIntroduceFactoryAvailable(final JavaTextSelection selection) throws JavaModelException {
final IJavaElement[] elements= selection.resolveElementAtOffset();
if (elements.length == 1 && elements[0] instanceof IMethod)
return isIntroduceFactoryAvailable((IMethod) elements[0]);
// there's no IMethod for the default constructor
if (!Checks.isAvailable(selection.resolveEnclosingElement()))
return false;
ASTNode node= selection.resolveCoveringNode();
if (node == null) {
ASTNode[] selectedNodes= selection.resolveSelectedNodes();
if (selectedNodes != null && selectedNodes.length == 1) {
node= selectedNodes[0];
if (node == null)
return false;
} else {
return false;
}
}
if (node.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION)
return true;
node= ASTNodes.getNormalizedNode(node);
if (node.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY)
return true;
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:RefactoringAvailabilityTester.java
示例11: isReplaceInvocationsAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isReplaceInvocationsAvailable(final JavaTextSelection selection) throws JavaModelException {
final IJavaElement[] elements= selection.resolveElementAtOffset();
if (elements.length != 1)
return false;
IJavaElement element= elements[0];
return (element instanceof IMethod) && isReplaceInvocationsAvailable(((IMethod) element));
}
示例12: run
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
@Override
public void run(JavaTextSelection selection) {
try {
IJavaElement[] elements= selection.resolveElementAtOffset();
if (elements.length != 1)
return;
if (!(elements[0] instanceof IMethod))
return;
run((IMethod) elements[0]);
} catch (CoreException e) {
ExceptionHandler.handle(e, getShell(), ActionMessages.IntroduceParameterObjectAction_exceptiondialog_title, ActionMessages.IntroduceParameterObjectAction_unexpected_exception);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:IntroduceParameterObjectAction.java
示例13: isGeneralizeTypeAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isGeneralizeTypeAvailable(final JavaTextSelection selection)
throws JavaModelException {
final IJavaElement[] elements = selection.resolveElementAtOffset();
if (elements.length != 1) return false;
return isGeneralizeTypeAvailable(elements[0]);
}
示例14: isInlineConstantAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isInlineConstantAvailable(final JavaTextSelection selection)
throws JavaModelException {
final IJavaElement[] elements = selection.resolveElementAtOffset();
if (elements.length != 1) return false;
return (elements[0] instanceof IField) && isInlineConstantAvailable(((IField) elements[0]));
}
示例15: isSelfEncapsulateAvailable
import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入方法依赖的package包/类
public static boolean isSelfEncapsulateAvailable(final JavaTextSelection selection)
throws JavaModelException {
final IJavaElement[] elements = selection.resolveElementAtOffset();
if (elements.length != 1) return false;
return (elements[0] instanceof IField) && isSelfEncapsulateAvailable((IField) elements[0]);
}