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


Java RefactoringBundle.getCannotRefactorMessage方法代码示例

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


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

示例1: invoke

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的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

示例2: invoke

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
@Override
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("the.caret.should.be.positioned.inside.a.class.to.pull.members.from"));
      CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MEMBERS_PULL_UP);
      return;
    }


    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, element)) return;


    if (element instanceof GrTypeDefinition || element instanceof GrField || element instanceof GrMethod) {
      invoke(project, new PsiElement[]{element}, dataContext);
      return;
    }

    element = element.getParent();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GrPullUpHandler.java

示例3: invoke

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的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.TURN_REFS_TO_SUPER);
      return;
    }
    if (element instanceof PsiClass && !(element instanceof PsiAnonymousClass)) {
      invoke(project, new PsiElement[]{element}, dataContext);
      return;
    }
    element = element.getParent();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:TurnRefsToSuperHandler.java

示例4: invoke

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的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: invokeOnElements

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的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

示例6: invoke

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
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.INHERITANCE_TO_DELEGATION);
      return;
    }

    if (element instanceof PsiClass && !(element instanceof PsiAnonymousClass)) {
      invoke(project, new PsiElement[]{element}, dataContext);
      return;
    }
    element = element.getParent();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:InheritanceToDelegationHandler.java

示例7: invokeImpl

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
protected boolean invokeImpl(final Project project, final PsiLocalVariable localVariable, final Editor editor) {
  final PsiElement parent = localVariable.getParent();
  if (!(parent instanceof PsiDeclarationStatement)) {
    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.local.or.expression.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, getHelpID());
    return false;
  }
  final LocalToFieldHandler localToFieldHandler = new LocalToFieldHandler(project, true){
    @Override
    protected Settings showRefactoringDialog(PsiClass aClass,
                                             PsiLocalVariable local,
                                             PsiExpression[] occurences,
                                             boolean isStatic) {
      return IntroduceConstantHandler.this.showRefactoringDialog(project, editor, aClass, local.getInitializer(), local.getType(), occurences, local, null);
    }
  };
  return localToFieldHandler.convertLocalToField(localVariable, editor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:IntroduceConstantHandler.java

示例8: validateTarget

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
@Nullable
public static String validateTarget(final PsiTypeParameterListOwner member) {
  final PsiClass containingClass = member.getContainingClass();

  // Checking various preconditions
  if(member instanceof PsiMethod && ((PsiMethod)member).isConstructor()) {
    return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("constructor.cannot.be.made.static"));
  }

  if(member.getContainingClass() == null) {
    return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("this.member.does.not.seem.to.belong.to.any.class"));
  }

  if(member.hasModifierProperty(PsiModifier.STATIC)) {
    return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("member.is.already.static"));
  }

  if(member instanceof PsiMethod && member.hasModifierProperty(PsiModifier.ABSTRACT)) {
    return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("cannot.make.abstract.method.static"));
  }

  if(containingClass instanceof PsiAnonymousClass || 
     (containingClass.getContainingClass() != null && !containingClass.hasModifierProperty(PsiModifier.STATIC))) {
    return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("inner.classes.cannot.have.static.members"));
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:MakeStaticHandler.java

示例9: checkAbstractClassOrInterfaceMessage

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
private boolean checkAbstractClassOrInterfaceMessage(PsiClass aClass, Editor editor) {
  if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT)) return true;
  String message = RefactoringBundle.getCannotRefactorMessage(aClass.isInterface() ?
                                                              RefactoringBundle.message("class.is.interface", aClass.getQualifiedName()) :
                                                              RefactoringBundle.message("class.is.abstract", aClass.getQualifiedName()));
  CommonRefactoringUtil.showErrorHint(myProject, editor, message, REFACTORING_NAME, HelpID.REPLACE_CONSTRUCTOR_WITH_FACTORY);
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ReplaceConstructorWithFactoryHandler.java

示例10: invoke

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
/**
 * called by an Action in AtomicAction when refactoring is invoked from Editor
 */
@Override
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);
  if (element == null) {
    element = file;
  }
  while(true){
    if (element == null) {
      String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("the.caret.should.be.positioned.at.the.class.method.or.field.to.be.refactored"));
      CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null);
      return;
    }

    if (tryToMoveElement(element, project, dataContext, null, editor)) {
      return;
    }
    final TextRange range = element.getTextRange();
    if (range != null) {
      int relative = offset - range.getStartOffset();
      final PsiReference reference = element.findReferenceAt(relative);
      if (reference != null) {
        final PsiElement refElement = reference.resolve();
        if (refElement != null && tryToMoveElement(refElement, project, dataContext, reference, editor)) return;
      }
    }

    element = element.getParent();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:MoveHandler.java

示例11: invoke

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file, DataContext dataContext) {
  final int offset = editor.getCaretModel().getOffset();
  final PsiElement element = file.findElementAt(offset);
  final PsiMember member = PsiTreeUtil.getParentOfType(element, PsiMember.class);
  final String cannotRefactorMessage = getCannotRefactorMessage(member);
  if (cannotRefactorMessage != null) {
    String message = RefactoringBundle.getCannotRefactorMessage(cannotRefactorMessage);
    showErrorMessage(message, project, editor);
    return;
  }

  final AnalysisScope scope = new AnalysisScope(file);
  final Module module = ModuleUtilCore.findModuleForPsiElement(file);
  final BaseAnalysisActionDialog dlg =
    new BaseAnalysisActionDialog(RefactoringBundle.message("replace.method.duplicates.scope.chooser.title", REFACTORING_NAME),
                                 RefactoringBundle.message("replace.method.duplicates.scope.chooser.message"),
                                 project, scope, module != null ? module.getName() : null, false,
                                 AnalysisUIOptions.getInstance(project), element);
  if (dlg.showAndGet()) {
    ProgressManager.getInstance().run(new Task.Backgroundable(project, "Locate duplicates", true) {
      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        indicator.setIndeterminate(true);
        invokeOnScope(project, member, dlg.getScope(AnalysisUIOptions.getInstance(project), scope, project, module));
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:MethodDuplicatesHandler.java

示例12: invoke

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file, DataContext dataContext) {
  PsiElement element = TargetElementUtil.findTargetElement(editor, TargetElementUtil
                                                                     .ELEMENT_NAME_ACCEPTED |
                                                                   TargetElementUtil
                                                                     .LOOKUP_ITEM_ACCEPTED |
                                                                   TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  if (!(element instanceof PsiLocalVariable)) {
    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.local.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.REPLACE_TEMP_WITH_QUERY);
    return;
  }

  invokeOnVariable(file, project, (PsiLocalVariable)element, editor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:TempWithQueryHandler.java

示例13: invokeOnElement

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
private static void invokeOnElement(Project project, Editor editor, PsiElement element) {
  if (element instanceof PsiMethod) {
    invoke((PsiMethod)element, project);
  }
  else {
    String message =
      RefactoringBundle.getCannotRefactorMessage(GroovyRefactoringBundle.message("error.wrong.caret.position.method.name"));
    CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.CHANGE_SIGNATURE);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GrChangeSignatureHandler.java

示例14: testAugmentedAssignment

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
public void testAugmentedAssignment() throws Exception {
  String exception = null;
  try {
    doTest(false);
  }
  catch(RuntimeException ex) {
    exception = ex.getMessage();
  }
  String error = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("variable.is.accessed.for.writing", "text"));
  assertEquals(error, exception);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:InlineLocalTest.java

示例15: showMultipleExitPointsMessage

import com.intellij.refactoring.RefactoringBundle; //导入方法依赖的package包/类
private void showMultipleExitPointsMessage() {
  if (myShowErrorDialogs) {
    HighlightManager highlightManager = HighlightManager.getInstance(myProject);
    PsiStatement[] exitStatementsArray = myExitStatements.toArray(new PsiStatement[myExitStatements.size()]);
    EditorColorsManager manager = EditorColorsManager.getInstance();
    TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
    highlightManager.addOccurrenceHighlights(myEditor, exitStatementsArray, attributes, true, null);
    String message = RefactoringBundle
      .getCannotRefactorMessage(RefactoringBundle.message("there.are.multiple.exit.points.in.the.selected.code.fragment"));
    CommonRefactoringUtil.showErrorHint(myProject, myEditor, message, myRefactoringName, myHelpId);
    WindowManager.getInstance().getStatusBar(myProject).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ExtractMethodProcessor.java


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