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


Java RefactorJBundle类代码示例

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


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

示例1: invoke

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
private void invoke(final Project project, PsiMethod method, Editor editor) {
  if(method.isConstructor()){
    CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message("constructor.returns.can.not.be.wrapped"), null,
                                        this.getHelpID());
    return;
  }
  final PsiType returnType = method.getReturnType();
  if(PsiType.VOID.equals(returnType)){
    CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message("method.selected.returns.void"), null, this.getHelpID());
    return;
  }
  method = SuperMethodWarningUtil.checkSuperMethod(method, RefactoringBundle.message("to.refactor"));
  if (method == null) return;

  if(method instanceof PsiCompiledElement){
    CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message(
        "the.selected.method.cannot.be.wrapped.because.it.is.defined.in.a.non.project.class"), null, this.getHelpID());
    return;
  }

  new WrapReturnValueDialog(method).show();


}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:WrapReturnValueHandler.java

示例2: invoke

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
private static void invoke(final PsiField field, Editor editor) {
  final Project project = field.getProject();
  final Set<PsiMethod> delegating = DelegationUtils.getDelegatingMethodsForField(field);
  if (delegating.isEmpty()) {
    final String message =
      RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message("field.selected.is.not.used.as.a.delegate");
    CommonRefactoringUtil.showErrorHint(project, editor, message, null, getHelpID());
    return;
  }

  MemberInfo[] infos = new MemberInfo[delegating.size()];
  int i = 0;
  for (PsiMethod method : delegating) {
    final MemberInfo memberInfo = new MemberInfo(method);
    memberInfo.setChecked(true);
    memberInfo.setToAbstract(method.findDeepestSuperMethods().length == 0);
    infos[i++] = memberInfo;
  }
  new RemoveMiddlemanDialog(field, infos).show();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:RemoveMiddlemanHandler.java

示例3: createNorthPanel

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
protected JComponent createNorthPanel() {
  final JPanel checkboxPanel = new JPanel(new BorderLayout());
  checkboxPanel.add(createInner, BorderLayout.WEST);
  checkboxPanel.add(extractAsEnum, BorderLayout.EAST);
  FormBuilder builder = FormBuilder.createFormBuilder()
    .addComponent(
      JBLabelDecorator.createJBLabelDecorator(RefactorJBundle.message("extract.class.from.label", sourceClass.getQualifiedName()))
        .setBold(true))
    .addLabeledComponent(RefactorJBundle.message("name.for.new.class.label"), classNameField, UIUtil.LARGE_VGAP)
    .addLabeledComponent(new JLabel(), checkboxPanel)
    .addLabeledComponent(RefactorJBundle.message("package.for.new.class.label"), packageTextField);

  if (JavaProjectRootsUtil.getSuitableDestinationSourceRoots(myProject).size() > 1) {
    builder.addLabeledComponent(RefactoringBundle.message("target.destination.folder"), myDestinationFolderComboBox);
  }

  return builder.addVerticalGap(5).getPanel();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ExtractClassDialog.java

示例4: getCannotRefactorMessage

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
private static String getCannotRefactorMessage(PsiClass containingClass) {
  if (containingClass == null) {
    return RefactorJBundle.message("the.caret.should.be.positioned.within.a.class.to.be.refactored");
  }
  if (containingClass.isInterface()) {
    return RefactorJBundle.message("the.selected.class.is.an.interface");
  }
  if (containingClass.isEnum()) {
    return RefactorJBundle.message("the.selected.class.is.an.enumeration");
  }
  if (containingClass.isAnnotationType()) {
    return RefactorJBundle.message("the.selected.class.is.an.annotation.type");
  }
  if (classIsInner(containingClass) && !containingClass.hasModifierProperty(PsiModifier.STATIC)) {
    return RefactorJBundle.message("the.refactoring.is.not.supported.on.non.static.inner.classes");
  }
  if (classIsTrivial(containingClass)) {
    return RefactorJBundle.message("the.selected.class.has.no.members.to.extract");
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ExtractClassHandler.java

示例5: invoke

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

示例6: getErrorMessage

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
private static String getErrorMessage(PsiMethod newMethod) {
  final PsiParameter[] parameters = newMethod.getParameterList().getParameters();
  if (parameters.length == 0) {
   return RefactorJBundle.message("cannot.perform.the.refactoring") +
          RefactorJBundle.message("method.selected.has.no.parameters");
  }
  if (newMethod instanceof PsiCompiledElement) {
    return RefactorJBundle.message("cannot.perform.the.refactoring") +
           RefactorJBundle.message("the.selected.method.cannot.be.wrapped.because.it.is.defined.in.a.non.project.class");
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:IntroduceParameterObjectHandler.java

示例7: getConflictMessage

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
@Override
public String getConflictMessage() {
  if (!myGenerateAccessors && (!paramsNeedingSetters.isEmpty() || !paramsNeedingGetters.isEmpty())) {
    final StringBuffer buf = new StringBuffer();
    appendConflicts(buf, paramsNeedingGetters);
    appendConflicts(buf, paramsNeedingSetters);
    return RefactorJBundle.message("cannot.perform.the.refactoring") + buf.toString();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:AppendAccessorsUsageInfo.java

示例8: preprocessUsages

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
@Override
protected boolean preprocessUsages(@NotNull final Ref<UsageInfo[]> refUsages) {
  MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
  if (myUseExistingClass) {
    if (existingClass == null) {
      conflicts.putValue(null, RefactorJBundle.message("cannot.perform.the.refactoring") + "Could not find the selected class");
    }
    if (myExistingClassCompatibleConstructor == null) {
      conflicts.putValue(existingClass, RefactorJBundle.message("cannot.perform.the.refactoring") + "Selected class has no compatible constructors");
    }
  }
  else {
    if (existingClass != null) {
      conflicts.putValue(existingClass,
                         RefactorJBundle.message("cannot.perform.the.refactoring") +
                         RefactorJBundle.message("there.already.exists.a.class.with.the.chosen.name"));
    }
    if (myMoveDestination != null) {
      if (!myMoveDestination.isTargetAccessible(myProject, method.getContainingFile().getVirtualFile())) {
        conflicts.putValue(method, "Created class won't be accessible");
      }
    }
  }
  for (UsageInfo usageInfo : refUsages.get()) {
    if (usageInfo instanceof FixableUsageInfo) {
      final String conflictMessage = ((FixableUsageInfo)usageInfo).getConflictMessage();
      if (conflictMessage != null) {
        conflicts.putValue(usageInfo.getElement(), conflictMessage);
      }
    }
  }
  return showConflicts(conflicts, refUsages.get());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:IntroduceParameterObjectProcessor.java

示例9: RemoveMiddlemanDialog

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
RemoveMiddlemanDialog(PsiField field, MemberInfo[] delegateMethods) {
  super(field.getProject(), true);
  myField = field;
  this.delegateMethods = Arrays.asList(delegateMethods);
  fieldNameLabel = new JTextField();
  fieldNameLabel.setText(
    PsiFormatUtil.formatVariable(myField, PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_NAME, PsiSubstitutor.EMPTY));
  setTitle(RefactorJBundle.message("remove.middleman.title"));
  init();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:RemoveMiddlemanDialog.java

示例10: invoke

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
  final ScrollingModel scrollingModel = editor.getScrollingModel();
  scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
  final CaretModel caretModel = editor.getCaretModel();
  final int position = caretModel.getOffset();
  final PsiElement element = file.findElementAt(position);

  final PsiMember selectedMember = PsiTreeUtil.getParentOfType(element, PsiMember.class, true);
  if (selectedMember == null) {
    //todo
    return;
  }
  
  PsiClass containingClass = selectedMember.getContainingClass();

  if (containingClass == null && selectedMember instanceof PsiClass) {
    containingClass = (PsiClass)selectedMember;
  }

  final String cannotRefactorMessage = getCannotRefactorMessage(containingClass);
  if (cannotRefactorMessage != null)  {
    CommonRefactoringUtil.showErrorHint(project, editor, 
                                        RefactorJBundle.message("cannot.perform.the.refactoring") + cannotRefactorMessage, 
                                        null, getHelpID());
    return;
  }
  new ExtractClassDialog(containingClass, selectedMember).show();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ExtractClassHandler.java

示例11: invoke

import com.intellij.refactoring.RefactorJBundle; //导入依赖的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 = LangDataKeys.PSI_ELEMENT.getData(dataContext);
  PsiMethod selectedMethod = null;
  if (element instanceof PsiMethod) {
    selectedMethod = (PsiMethod)element;
  }
  else if (element instanceof PsiParameter && ((PsiParameter)element).getDeclarationScope() instanceof PsiMethod){
    selectedMethod = (PsiMethod)((PsiParameter)element).getDeclarationScope();
  }
  else {
    final CaretModel caretModel = editor.getCaretModel();
    final int position = caretModel.getOffset();
    final PsiElement elementAt = file.findElementAt(position);
    final PsiMethodCallExpression methodCallExpression =
     PsiTreeUtil.getParentOfType(elementAt, PsiMethodCallExpression.class);
    if (methodCallExpression != null) {
      selectedMethod = methodCallExpression.resolveMethod();
    } else {
      final PsiParameterList parameterList = PsiTreeUtil.getParentOfType(elementAt, PsiParameterList.class);
      if (parameterList != null && parameterList.getParent() instanceof PsiMethod) {
        selectedMethod = (PsiMethod)parameterList.getParent();
      }
    }
  }
  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:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:IntroduceParameterObjectHandler.java

示例12: preprocessUsages

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
@Override
protected boolean preprocessUsages(final Ref<UsageInfo[]> refUsages) {
  MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
  if (myUseExistingClass) {
    if (existingClass == null) {
      conflicts.putValue(null, RefactorJBundle.message("cannot.perform.the.refactoring") + "Could not find the selected class");
    }
    if (myExistingClassCompatibleConstructor == null) {
      conflicts.putValue(existingClass, RefactorJBundle.message("cannot.perform.the.refactoring") + "Selected class has no compatible constructors");
    }
  }
  else {
    if (existingClass != null) {
      conflicts.putValue(existingClass,
                         RefactorJBundle.message("cannot.perform.the.refactoring") +
                         RefactorJBundle.message("there.already.exists.a.class.with.the.chosen.name"));
    }
    if (myMoveDestination != null) {
      if (!myMoveDestination.isTargetAccessible(myProject, method.getContainingFile().getVirtualFile())) {
        conflicts.putValue(method, "Created class won't be accessible");
      }
    }
  }
  for (UsageInfo usageInfo : refUsages.get()) {
    if (usageInfo instanceof FixableUsageInfo) {
      final String conflictMessage = ((FixableUsageInfo)usageInfo).getConflictMessage();
      if (conflictMessage != null) {
        conflicts.putValue(usageInfo.getElement(), conflictMessage);
      }
    }
  }
  return showConflicts(conflicts, refUsages.get());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:34,代码来源:IntroduceParameterObjectProcessor.java

示例13: createNorthPanel

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
protected JComponent createNorthPanel() {
  FormBuilder builder = FormBuilder.createFormBuilder()
    .addComponent(
      JBLabelDecorator.createJBLabelDecorator(RefactorJBundle.message("extract.class.from.label", sourceClass.getQualifiedName()))
        .setBold(true))
    .addLabeledComponent(RefactorJBundle.message("name.for.new.class.label"), classNameField, UIUtil.LARGE_VGAP)
    .addLabeledComponent(new JLabel(), extractAsEnum)
    .addLabeledComponent(RefactorJBundle.message("package.for.new.class.label"), packageTextField);

  if (ProjectRootManager.getInstance(myProject).getContentSourceRoots().length > 1) {
    builder.addLabeledComponent(RefactoringBundle.message("target.destination.folder"), myDestinationFolderComboBox);
  }

  return builder.addVerticalGap(5).getPanel();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:ExtractClassDialog.java

示例14: invoke

import com.intellij.refactoring.RefactorJBundle; //导入依赖的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 = dataContext.getData(LangDataKeys.PSI_ELEMENT);
  PsiMethod selectedMethod = null;
  if (element instanceof PsiMethod) {
    selectedMethod = (PsiMethod)element;
  }
  else if (element instanceof PsiParameter && ((PsiParameter)element).getDeclarationScope() instanceof PsiMethod){
    selectedMethod = (PsiMethod)((PsiParameter)element).getDeclarationScope();
  }
  else {
    final CaretModel caretModel = editor.getCaretModel();
    final int position = caretModel.getOffset();
    final PsiElement elementAt = file.findElementAt(position);
    final PsiMethodCallExpression methodCallExpression =
     PsiTreeUtil.getParentOfType(elementAt, PsiMethodCallExpression.class);
    if (methodCallExpression != null) {
      selectedMethod = methodCallExpression.resolveMethod();
    } else {
      final PsiParameterList parameterList = PsiTreeUtil.getParentOfType(elementAt, PsiParameterList.class);
      if (parameterList != null && parameterList.getParent() instanceof PsiMethod) {
        selectedMethod = (PsiMethod)parameterList.getParent();
      }
    }
  }
  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:consulo,项目名称:consulo-java,代码行数:35,代码来源:IntroduceParameterObjectHandler.java

示例15: getCommandName

import com.intellij.refactoring.RefactorJBundle; //导入依赖的package包/类
protected String getCommandName() {
  final PsiClass containingClass = myMethod.getContainingClass();
  return RefactorJBundle.message("wrapped.return.command.name", myClassName, containingClass.getName(), '.', myMethod.getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:WrapReturnValueProcessor.java


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