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


Java JavaTextSelection类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection的典型用法代码示例。如果您正苦于以下问题:Java JavaTextSelection类的具体用法?Java JavaTextSelection怎么用?Java JavaTextSelection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaTextSelection类属于org.eclipse.jdt.internal.ui.javaeditor包,在下文中一共展示了JavaTextSelection类的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: 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

示例4: refactorMenuShown

import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入依赖的package包/类
private void refactorMenuShown(IMenuManager refactorSubmenu) {
	// we know that we have an MenuManager since we created it in
	// addRefactorSubmenu.
	Menu menu= ((MenuManager)refactorSubmenu).getMenu();
	menu.addMenuListener(new MenuAdapter() {
		@Override
		public void menuHidden(MenuEvent e) {
			refactorMenuHidden();
		}
	});
	ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
	JavaTextSelection javaSelection= new JavaTextSelection(getEditorInput(), getDocument(), textSelection.getOffset(), textSelection.getLength());

	for (Iterator<SelectionDispatchAction> iter= fActions.iterator(); iter.hasNext(); ) {
		SelectionDispatchAction action= iter.next();
		action.update(javaSelection);
	}
	refactorSubmenu.removeAll();
	if (fillRefactorMenu(refactorSubmenu) == 0)
		refactorSubmenu.add(fNoActionAvailable);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:RefactorActionGroup.java

示例5: 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-Juno38,代码行数:17,代码来源:RefactoringAvailabilityTester.java

示例6: 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

示例7: isExtractConstantAvailable

import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入依赖的package包/类
public static boolean isExtractConstantAvailable(final JavaTextSelection selection) {
  return (selection.resolveInClassInitializer()
          || selection.resolveInMethodBody()
          || selection.resolveInVariableInitializer()
          || selection.resolveInAnnotation())
      && Checks.isExtractableExpression(
          selection.resolveSelectedNodes(), selection.resolveCoveringNode());
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:RefactoringAvailabilityTester.java

示例8: isExtractMethodAvailable

import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入依赖的package包/类
public static boolean isExtractMethodAvailable(final JavaTextSelection selection) {
  return (selection.resolveInMethodBody()
          || selection.resolveInClassInitializer()
          || selection.resolveInVariableInitializer())
      && !selection.resolveInAnnotation()
      && RefactoringAvailabilityTester.isExtractMethodAvailable(selection.resolveSelectedNodes());
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例9: isExtractTempAvailable

import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入依赖的package包/类
public static boolean isExtractTempAvailable(final JavaTextSelection selection) {
  final ASTNode[] nodes = selection.resolveSelectedNodes();
  return (selection.resolveInMethodBody() || selection.resolveInClassInitializer())
      && !selection.resolveInAnnotation()
      && (Checks.isExtractableExpression(nodes, selection.resolveCoveringNode())
          || (nodes != null && nodes.length == 1 && nodes[0] instanceof ExpressionStatement));
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例10: 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

示例11: isMoveInnerAvailable

import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入依赖的package包/类
public static boolean isMoveInnerAvailable(final JavaTextSelection selection)
    throws JavaModelException {
  IType type =
      RefactoringAvailabilityTester.getDeclaringType(selection.resolveEnclosingElement());
  if (type == null) return false;
  return isMoveInnerAvailable(type);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例12: isMoveStaticAvailable

import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; //导入依赖的package包/类
public static boolean isMoveStaticAvailable(final JavaTextSelection selection)
    throws JavaModelException {
  final IJavaElement element = selection.resolveEnclosingElement();
  if (!(element instanceof IMember)) return false;
  return RefactoringAvailabilityTester.isMoveStaticMembersAvailable(
      new IMember[] {(IMember) element});
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例13: 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

示例14: 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

示例15: 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


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