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


Java CommonRefactoringUtil.checkReadOnlyStatus方法代码示例

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


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

示例1: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
private void invoke(PsiClass aClass, Editor editor) {
  String qualifiedName = aClass.getQualifiedName();
  if(qualifiedName == null) {
    showJspOrLocalClassMessage(editor);
    return;
  }
  if (!checkAbstractClassOrInterfaceMessage(aClass, editor)) return;
  final PsiMethod[] constructors = aClass.getConstructors();
  if (constructors.length > 0) {
    String message =
            RefactoringBundle.message("class.does.not.have.implicit.default.constructor", aClass.getQualifiedName()) ;
    CommonRefactoringUtil.showErrorHint(myProject, editor, message, REFACTORING_NAME, HelpID.REPLACE_CONSTRUCTOR_WITH_FACTORY);
    return;
  }
  final int answer = Messages.showYesNoDialog(myProject,
                                              RefactoringBundle.message("would.you.like.to.replace.default.constructor.of.0.with.factory.method", aClass.getQualifiedName()),
                                              REFACTORING_NAME, Messages.getQuestionIcon()
  );
  if (answer != Messages.YES) return;
  if (!CommonRefactoringUtil.checkReadOnlyStatus(myProject, aClass)) return;
  new ReplaceConstructorWithFactoryDialog(myProject, null, aClass).show();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ReplaceConstructorWithFactoryHandler.java

示例2: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
private static void invoke(PsiMethod method, final Project project) {
  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, method)) return;
  if (method instanceof GrReflectedMethod) method = ((GrReflectedMethod)method).getBaseMethod();

  PsiMethod newMethod = SuperMethodWarningUtil.checkSuperMethod(method, RefactoringBundle.message("to.refactor"));
  if (newMethod == null) return;

  if (!newMethod.equals(method)) {
    ChangeSignatureUtil.invokeChangeSignatureOn(newMethod, project);
    return;
  }

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

  if (!(method instanceof GrMethod)) return; //todo
  final GrChangeSignatureDialog dialog = new GrChangeSignatureDialog(project, new GrMethodDescriptor((GrMethod)method), true, null);
  dialog.show();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GrChangeSignatureHandler.java

示例3: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(@NotNull final Project project, Editor editor, final PsiFile file, DataContext dataContext) {
  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) return;

  final int offset = editor.getCaretModel().getOffset();
  editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  final PsiAnonymousClass anonymousClass = findAnonymousClass(file, offset);
  if (anonymousClass == null) {
    showErrorMessage(editor, RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.anonymous")));
    return;
  }
  final PsiElement parent = anonymousClass.getParent();
  if (parent instanceof PsiEnumConstant) {
    showErrorMessage(editor, RefactoringBundle.getCannotRefactorMessage("Enum constant can't be converted to inner class"));
    return;
  }
  invoke(project, editor, anonymousClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AnonymousToInnerHandler.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包/类
public static void invoke(final Project project, Editor editor, final GrVariable local) {
  final PsiReference invocationReference = editor != null ? TargetElementUtil.findReference(editor) : null;

  final InlineLocalVarSettings localVarSettings = createSettings(local, editor, invocationReference != null);
  if (localVarSettings == null) return;

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

  final GroovyInlineLocalProcessor processor = new GroovyInlineLocalProcessor(project, localVarSettings, local);
  processor.setPrepareSuccessfulSwingThreadCallback(new Runnable() {
    @Override
    public void run() {
      //do nothing
    }
  });
  processor.run();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GroovyInlineLocalHandler.java

示例6: isWritable

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
private boolean isWritable() {
  final Collection<PyMemberInfo<PyElement>> infos = myView.getSelectedMemberInfos();
  if (infos.isEmpty()) {
    return true;
  }
  final PyElement element = infos.iterator().next().getMember();
  final Project project = element.getProject();
  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, myView.getSelectedParent())) return false;
  final PyClass container = PyUtil.getContainingClassOrSelf(element);
  if (container == null || !CommonRefactoringUtil.checkReadOnlyStatus(project, container)) return false;
  for (final PyMemberInfo<PyElement> info : infos) {
    final PyElement member = info.getMember();
    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, member)) return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PyPullUpPresenterImpl.java

示例7: applyFix

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
  final PsiElement element = descriptor.getPsiElement();
  final PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
  if (method == null) return;
  PsiParameter parameter = PsiTreeUtil.getParentOfType(element, PsiParameter.class, false);
  if (parameter == null) {
    final PsiParameter[] parameters = method.getParameterList().getParameters();
    for (PsiParameter psiParameter : parameters) {
      if (Comparing.strEqual(psiParameter.getName(), myParameterName)) {
        parameter = psiParameter;
        break;
      }
    }
  }
  if (parameter == null) return;
  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, parameter)) return;

  final PsiExpression defToInline;
  try {
    defToInline = JavaPsiFacade.getInstance(project).getElementFactory().createExpressionFromText(myValue, parameter);
  }
  catch (IncorrectOperationException e) {
    return;
  }
  final PsiParameter parameterToInline = parameter;
  inlineSameParameterValue(method, parameterToInline, defToInline);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:SameParameterValueInspection.java

示例8: checkWritable

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
private boolean checkWritable(PsiClass superClass, MemberInfo[] infos) {
  if (!CommonRefactoringUtil.checkReadOnlyStatus(myProject, superClass)) return false;
  for (MemberInfo info : infos) {
    if (info.getMember() instanceof PsiClass && info.getOverrides() != null) continue;
    if (!CommonRefactoringUtil.checkReadOnlyStatus(myProject, info.getMember())) return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaPullUpHandler.java

示例9: checkRemoveUnusedField

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public static void checkRemoveUnusedField(final RadRootContainer rootContainer, final String fieldName, final Object undoGroupId) {
  final PsiField oldBindingField = findBoundField(rootContainer, fieldName);
  if (oldBindingField == null) {
    return;
  }
  final Project project = oldBindingField.getProject();
  final PsiClass aClass = oldBindingField.getContainingClass();
  if (isFieldUnreferenced(oldBindingField)) {
    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) {
      return;
    }
    ApplicationManager.getApplication().runWriteAction(
      new Runnable() {
        public void run() {
          CommandProcessor.getInstance().executeCommand(
            project,
            new Runnable() {
              public void run() {
                try {
                  oldBindingField.delete();
                }
                catch (IncorrectOperationException e) {
                  Messages.showErrorDialog(project, UIDesignerBundle.message("error.cannot.delete.unused.field", e.getMessage()),
                                           CommonBundle.getErrorTitle());
                }
              }
            },
            UIDesignerBundle.message("command.delete.unused.field"), undoGroupId
          );
        }
      }
    );
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:BindingProperty.java

示例10: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
  if (elements.length != 1) return;

  myProject = project;
  myClass = (PsiClass)elements[0];


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

  final ExtractInterfaceDialog dialog = new ExtractInterfaceDialog(myProject, myClass);
  if (!dialog.showAndGet() || !dialog.isExtractSuperclass()) {
    return;
  }
  final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
  ExtractSuperClassUtil.checkSuperAccessible(dialog.getTargetDirectory(), conflicts, myClass);
  if (!ExtractSuperClassUtil.showConflicts(dialog, conflicts, myProject)) return;
  CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        public void run() {
          myInterfaceName = dialog.getExtractedSuperName();
          mySelectedMembers = ArrayUtil.toObjectArray(dialog.getSelectedMemberInfos(), MemberInfo.class);
          myTargetDir = dialog.getTargetDirectory();
          myJavaDocPolicy = new DocCommentPolicy(dialog.getDocCommentPolicy());
          try {
            doRefactoring();
          }
          catch (IncorrectOperationException e) {
            LOG.error(e);
          }
        }
      });
    }
  }, REFACTORING_NAME, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:ExtractInterfaceHandler.java

示例11: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
@Override
  public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
    if (elements.length != 1) return;


    myProject = project;
    myClass = (PsiClass)elements[0];


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

/* todo
    final JavaExtractSuperBaseDialog dialog = new ExtractInterfaceDialog(myProject, myClass);
    dialog.show();
    if (!dialog.isOK() || !dialog.isExtractSuperclass()) return;

    final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
    ExtractSuperClassUtil.checkSuperAccessible(dialog.getTargetDirectory(), conflicts, myClass);
    if (!ExtractSuperClassUtil.showConflicts(dialog, conflicts, myProject)) return;

    CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          public void run() {
            myInterfaceName = dialog.getExtractedSuperName();
            mySelectedMembers = ArrayUtil.toObjectArray(dialog.getSelectedMemberInfos(), MemberInfo.class);
            myTargetDir = dialog.getTargetDirectory();
            myJavaDocPolicy = new DocCommentPolicy(dialog.getDocCommentPolicy());
            try {
              doRefactoring();
            }
            catch (IncorrectOperationException e) {
              LOG.error(e);
            }
          }
        });
      }
    }, REFACTORING_NAME, null);*/
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:GrExtractInterfaceHandler.java

示例12: extractMethodObject

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
static void extractMethodObject(Project project, Editor editor, ExtractMethodObjectProcessor processor) throws PrepareFailedException {
  final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
  if (!extractProcessor.prepare()) return;
  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, extractProcessor.getTargetClass().getContainingFile())) return;
  if (extractProcessor.showDialog()) {
    run(project, editor, processor, extractProcessor);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ExtractMethodObjectHandler.java

示例13: invokeOnElements

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
private static boolean invokeOnElements(final Project project, final Editor editor, @NotNull final ExtractMethodProcessor processor, final boolean directTypes) {
  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, processor.getTargetClass().getContainingFile())) return false;
  if (processor.showDialog(directTypes)) {
    run(project, editor, processor);
    DuplicatesImpl.processDuplicates(processor, project, editor);
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ExtractMethodHandler.java

示例14: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void invoke(Project project, PsiExpression[] expressions) {
  for (PsiExpression expression : expressions) {
    final PsiFile file = expression.getContainingFile();
    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) return;
  }
  PsiDocumentManager.getInstance(project).commitAllDocuments();
  super.invoke(project, expressions, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:IntroduceConstantHandler.java

示例15: invoke

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
private boolean invoke(final Project project, final Editor editor, PsiFile file, int startOffset, int endOffset) {
  try {
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    if (!(file instanceof LuaPsiFileBase)) {
      throw new LuaIntroduceRefactoringError("Only Lua files");
    }
    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) {
      throw new LuaIntroduceRefactoringError("Read-only occurances found");
    }

    LuaExpression selectedExpr = findExpression((LuaPsiFileBase)file, startOffset, endOffset);
    final LuaSymbol variable = findVariable((LuaPsiFile)file, startOffset, endOffset);
    if (variable != null) {
      checkVariable(variable);
    }
    else if (selectedExpr != null) {
      checkExpression(selectedExpr);
    }
    else {
      throw new LuaIntroduceRefactoringError(null);
    }

    final LuaIntroduceContext context = getContext(project, editor, selectedExpr, variable);
    checkOccurrences(context.occurrences);
    final Settings settings = showDialog(context);
    if (settings == null) return false;

    CommandProcessor.getInstance().executeCommand(context.project, new Runnable() {
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Computable<LuaSymbol>() {
        public LuaSymbol compute() {
          return runRefactoring(context, settings);
        }
      });
    }
  }, getRefactoringName(), null);

    return true;
  }
  catch (LuaIntroduceRefactoringError e) {
    CommonRefactoringUtil
      .showErrorHint(project, editor, RefactoringBundle.getCannotRefactorMessage(e.getMessage()), getRefactoringName(), getHelpID());
    return false;
  }
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:46,代码来源:LuaIntroduceHandlerBase.java


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