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


Java CommonRefactoringUtil.showErrorHint方法代码示例

本文整理汇总了Java中com.intellij.refactoring.util.CommonRefactoringUtil.showErrorHint方法的典型用法代码示例。如果您正苦于以下问题:Java CommonRefactoringUtil.showErrorHint方法的具体用法?Java CommonRefactoringUtil.showErrorHint怎么用?Java CommonRefactoringUtil.showErrorHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.refactoring.util.CommonRefactoringUtil的用法示例。


在下文中一共展示了CommonRefactoringUtil.showErrorHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invokeOnElements

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
private static void invokeOnElements(@NotNull final Project project,
                                     @NotNull final Editor editor,
                                     @NotNull PsiFile file,
                                     @NotNull PsiElement[] elements) {
  if (elements.length == 0) {
      String message = RefactoringBundle
        .getCannotRefactorMessage(RefactoringBundle.message("selected.block.should.represent.a.set.of.statements.or.an.expression"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, ExtractMethodObjectProcessor.REFACTORING_NAME, HelpID.EXTRACT_METHOD_OBJECT);
    return;
  }

  try {
    extractMethodObject(project, editor, new ExtractMethodObjectProcessor(project, editor, elements, ""));
  }
  catch (PrepareFailedException e) {
    CommonRefactoringUtil.showErrorHint(project, editor, e.getMessage(), ExtractMethodObjectProcessor.REFACTORING_NAME, HelpID.EXTRACT_METHOD_OBJECT);
    ExtractMethodHandler.highlightPrepareError(e, file, editor, project);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ExtractMethodObjectHandler.java

示例2: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  PsiElement element1 = null;
  PsiElement element2 = null;
  final SelectionModel selectionModel = editor.getSelectionModel();
  if (selectionModel.hasSelection()) {
    element1 = file.findElementAt(selectionModel.getSelectionStart());
    element2 = file.findElementAt(selectionModel.getSelectionEnd() - 1);
  }
  else {
    final CaretModel caretModel = editor.getCaretModel();
    final Document document = editor.getDocument();
    int lineNumber = document.getLineNumber(caretModel.getOffset());
    if ((lineNumber >= 0) && (lineNumber < document.getLineCount())) {
      element1 = file.findElementAt(document.getLineStartOffset(lineNumber));
      element2 = file.findElementAt(document.getLineEndOffset(lineNumber) - 1);
    }
  }
  if (element1 == null || element2 == null) {
    CommonRefactoringUtil.showErrorHint(project, editor, PyBundle.message("refactoring.introduce.selection.error"), getTitle(),
                                        "members.pull.up");
    return;
  }
  doRefactor(project, element1, element2, editor, file, dataContext);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PyClassRefactoringHandler.java

示例3: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  final int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
  final PsiElement element = file.findElementAt(offset);
  PsiTypeElement typeElement = PsiTreeUtil.getParentOfType(element, PsiTypeElement.class);
  while (typeElement != null) {
    final PsiElement parent = typeElement.getParent();
    if (parent instanceof PsiVariable || (parent instanceof PsiMember && !(parent instanceof PsiClass)) || isClassArgument(parent)) {
      invoke(project, parent, null, editor);
      return;
    }
    typeElement = PsiTreeUtil.getParentOfType(parent, PsiTypeElement.class, false);
  }
  CommonRefactoringUtil.showErrorHint(project, editor,
                                      "The caret should be positioned on type of field, variable, method or method parameter to be refactored",
                                      REFACTORING_NAME, "refactoring.migrateType");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ChangeTypeSignatureHandler.java

示例4: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
private static void invoke(final PsiClass aClass, Editor editor) {
  final PsiTypeParameterList typeParameterList = aClass.getTypeParameterList();
  Project project = aClass.getProject();
  if (typeParameterList == null) {
    final String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("changeClassSignature.no.type.parameters"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.CHANGE_CLASS_SIGNATURE);
    return;
  }
  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) return;

  ChangeClassSignatureDialog dialog = new ChangeClassSignatureDialog(aClass, true);
  //if (!ApplicationManager.getApplication().isUnitTestMode()){
  dialog.show();
  //}else {
  //  dialog.showAndGetOk()
  //}
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaChangeSignatureHandler.java

示例5: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  int offset = editor.getCaretModel().getOffset();
  PsiElement element = file.findElementAt(offset);
  while (true) {
    if (element == null || element instanceof PsiFile) {
      String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.class"));
      CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.EXTRACT_SUPERCLASS);
      return;
    }
    if (element instanceof PsiClass) {
      invoke(project, new PsiElement[]{element}, dataContext);
      return;
    }
    element = element.getParent();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ExtractSuperclassHandler.java

示例6: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  int offset = editor.getCaretModel().getOffset();
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  PsiElement element = file.findElementAt(offset);
  while (true) {
    if (element == null || element instanceof PsiFile) {
      String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.class"));
      CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.EXTRACT_INTERFACE);
      return;
    }
    if (element instanceof PsiClass && !(element instanceof PsiAnonymousClass)) {
      invoke(project, new PsiElement[]{element}, dataContext);
      return;
    }
    element = element.getParent();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ExtractInterfaceHandler.java

示例7: prepareInlineElement

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
@Override
@Nullable
public Settings prepareInlineElement(@NotNull final PsiElement element, @Nullable Editor editor, boolean invokedOnReference) {
  if (element instanceof GrField) {
    return GrInlineFieldUtil.inlineFieldSettings((GrField)element, editor, invokedOnReference);
  }
  else if (element instanceof GrMethod) {
    return GroovyInlineMethodUtil.inlineMethodSettings((GrMethod)element, editor, invokedOnReference);
  }
  else {
    if (element instanceof GrTypeDefinition || element instanceof GrClassSubstitution) {
      return null;      //todo inline to anonymous class, push members from super class
    }
  }

  if (element instanceof PsiMember) {
    String message = GroovyRefactoringBundle.message("cannot.inline.0.", getFullName(element));
    CommonRefactoringUtil.showErrorHint(element.getProject(), editor, message, "", HelpID.INLINE_FIELD);
    return InlineHandler.Settings.CANNOT_INLINE_SETTINGS;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GroovyInlineHandler.java

示例8: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  if (element == null) {
    element = file.findElementAt(editor.getCaretModel().getOffset());
  }

  if (element == null) return;
  if (element instanceof PsiIdentifier) element = element.getParent();

  if (!(element instanceof PsiMethod)) {
    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MOVE_INSTANCE_METHOD);
    return;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("Move Instance Method invoked");
  }
  invoke(project, new PsiElement[]{element}, dataContext);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MoveInstanceMethodHandler.java

示例9: showNothingSelectedErrorMessage

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public static void showNothingSelectedErrorMessage(final Editor editor,
                                                   final String refactoringName,
                                                   final String helpId,
                                                   final Project project) {
  String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.local.or.expression.name"));
  CommonRefactoringUtil.showErrorHint(project, editor, message, refactoringName, helpId);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ElementToWorkOn.java

示例10: checkIntroduceContext

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
@Override
protected boolean checkIntroduceContext(PsiFile file, Editor editor, PsiElement element) {
  if (element != null && isInStaticMethod(element)) {
    CommonRefactoringUtil.showErrorHint(file.getProject(), editor, "Introduce Field refactoring cannot be used in static methods",
                                        RefactoringBundle.message("introduce.field.title"),
                                        "refactoring.extractMethod");
    return false;
  }
  return super.checkIntroduceContext(file, editor, element);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PyIntroduceFieldHandler.java

示例11: checkIntroduceContext

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected boolean checkIntroduceContext(PsiFile file, Editor editor, PsiElement element) {
  if (!isValidIntroduceContext(element)) {
    CommonRefactoringUtil.showErrorHint(file.getProject(), editor, PyBundle.message("refactoring.introduce.selection.error"),
                                        myDialogTitle, "refactoring.extractMethod");
    return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:IntroduceHandler.java

示例12: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  final ScrollingModel scrollingModel = editor.getScrollingModel();
  scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
  PsiMethod selectedMethod = getSelectedMethod(editor, file, dataContext);
  if (selectedMethod == null) {
    final String message = RefactorJBundle.message("cannot.perform.the.refactoring") +
                           RefactorJBundle.message("the.caret.should.be.positioned.at.the.name.of.the.method.to.be.refactored");
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.IntroduceParameterObject);
    return;
  }
  invoke(project, selectedMethod, editor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:IntroduceParameterObjectHandler.java

示例13: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
  PsiElement namedElement = adjustElement(element, project, editor);
  if (namedElement == null) {
    CommonRefactoringUtil.showErrorHint(project, editor, RefactoringBundle.getCannotRefactorMessage(
      RefactoringBundle.message("error.wrong.caret.position.method.or.variable.name")), REFACTORING_NAME, INVERT_BOOLEAN_HELP_ID);
    return;
  }
  new InvertBooleanDialog(namedElement).show();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:InvertBooleanHandler.java

示例14: doRefactorImpl

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
@Override
protected void doRefactorImpl(@NotNull final Project project,
                              @NotNull final PyClass classUnderRefactoring,
                              @NotNull final PyMemberInfoStorage infoStorage,
                              @NotNull final Editor editor) {
  //TODO: Move to presenter
  if (PyUtil.filterOutObject(infoStorage.getClassMemberInfos(classUnderRefactoring)).isEmpty()) {
    CommonRefactoringUtil.showErrorHint(project, editor, PyBundle
      .message("refactoring.extract.super.class.no.members.allowed"), RefactoringBundle.message("extract.superclass.elements.header"),
                                        null);
    return;
  }

  ViewPresenterUtils.linkViewWithPresenterAndLaunch(PyExtractSuperclassPresenter.class, PyExtractSuperclassView.class,
                                                    new Creator<PyExtractSuperclassView, PyExtractSuperclassPresenter>() {
                                                      @NotNull
                                                      @Override
                                                      public PyExtractSuperclassPresenter createPresenter(@NotNull final PyExtractSuperclassView view) {
                                                        return new PyExtractSuperclassPresenterImpl(view, classUnderRefactoring,
                                                                                                    infoStorage);
                                                      }

                                                      @NotNull
                                                      @Override
                                                      public PyExtractSuperclassView createView(@NotNull final PyExtractSuperclassPresenter presenter) {
                                                        return new PyExtractSuperclassViewSwingImpl(classUnderRefactoring, project,
                                                                                                    presenter);
                                                      }
                                                    }
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:PyExtractSuperclassHandler.java

示例15: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  final ScrollingModel scrollingModel = editor.getScrollingModel();
  scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
  final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
  if (!(element instanceof PsiField)) {
    CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message(
        "the.caret.should.be.positioned.at.the.name.of.the.field.to.be.refactored"), null, getHelpID());
    return;
  }
  invoke((PsiField)element, editor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:RemoveMiddlemanHandler.java


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