当前位置: 首页>>代码示例>>Java>>正文


Java JavaTextSelection.resolveElementAtOffset方法代码示例

本文整理汇总了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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:RefactoringAvailabilityTester.java

示例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;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RefactoringAvailabilityTester.java

示例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);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:RenameJavaElementAction.java

示例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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:RefactoringAvailabilityTester.java

示例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]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例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]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例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));
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例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));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例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]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:RefactoringAvailabilityTester.java

示例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]));
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:RefactoringAvailabilityTester.java

示例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]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:RefactoringAvailabilityTester.java


注:本文中的org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection.resolveElementAtOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。