• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OccurrencesChooser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testNameSuggestion

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
public void testNameSuggestion() {
  final String expectedTypeName = "Path";
  doTest(new MockIntroduceVariableHandler("path", true, false, false, expectedTypeName) {
    @Override
    public IntroduceVariableSettings getSettings(Project project, Editor editor,
                                                 PsiExpression expr, PsiExpression[] occurrences,
                                                 TypeSelectorManagerImpl typeSelectorManager,
                                                 boolean declareFinalIfAll,
                                                 boolean anyAssignmentLHS,
                                                 InputValidator validator,
                                                 PsiElement anchor, final OccurrencesChooser.ReplaceChoice replaceChoice) {
      final PsiType type = typeSelectorManager.getDefaultType();
      assertTrue(type.getPresentableText(), type.getPresentableText().equals(expectedTypeName));
      assertEquals("path", IntroduceVariableBase.getSuggestedName(type, expr).names[0]);
      return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS,
                               validator, anchor, replaceChoice);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:IntroduceVariableTest.java


示例2: testSiblingInnerClassType

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
public void testSiblingInnerClassType() {
  doTest(new MockIntroduceVariableHandler("vari", true, false, false, "A.B") {
    @Override
    public IntroduceVariableSettings getSettings(Project project, Editor editor,
                                                 PsiExpression expr, PsiExpression[] occurrences,
                                                 TypeSelectorManagerImpl typeSelectorManager,
                                                 boolean declareFinalIfAll,
                                                 boolean anyAssignmentLHS,
                                                 InputValidator validator,
                                                 PsiElement anchor, final OccurrencesChooser.ReplaceChoice replaceChoice) {
      final PsiType type = typeSelectorManager.getDefaultType();
      assertTrue(type.getPresentableText(), type.getPresentableText().equals("B"));
      return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS,
                               validator, anchor, replaceChoice);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:IntroduceVariableTest.java


示例3: doTestReplaceChoice

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
private void doTestReplaceChoice(OccurrencesChooser.ReplaceChoice choice, Pass<AbstractInplaceIntroducer> pass) {
  String name = getTestName(true);
  configureByFile(getBasePath() + name + getExtension());
  final boolean enabled = getEditor().getSettings().isVariableInplaceRenameEnabled();
  try {
    TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
    getEditor().getSettings().setVariableInplaceRenameEnabled(true);

    MyIntroduceHandler handler = createIntroduceHandler();
    ((MyIntroduceVariableHandler)handler).setChoice(choice);
    final AbstractInplaceIntroducer introducer = invokeRefactoring(handler);
    if (pass != null) {
      pass.pass(introducer);
    }
    TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
    assert state != null;
    state.gotoEnd(false);
    checkResultByFile(getBasePath() + name + "_after" + getExtension());
  }
  finally {
    getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:InplaceIntroduceVariableTest.java


示例4: performActionOnElementOccurrences

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
protected void performActionOnElementOccurrences(final IntroduceOperation operation) {
  final Editor editor = operation.getEditor();
  if (editor.getSettings().isVariableInplaceRenameEnabled()) {
    ensureName(operation);
    if (operation.isReplaceAll() != null) {
      performInplaceIntroduce(operation);
    }
    else {
      OccurrencesChooser.simpleChooser(editor).showChooser(operation.getElement(), operation.getOccurrences(), new Pass<OccurrencesChooser.ReplaceChoice>() {
        @Override
        public void pass(OccurrencesChooser.ReplaceChoice replaceChoice) {
          operation.setReplaceAll(replaceChoice == OccurrencesChooser.ReplaceChoice.ALL);
          performInplaceIntroduce(operation);
        }
      });
    }
  }
  else {
    performIntroduceWithDialog(operation);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:IntroduceHandler.java


示例5: GrInplaceConstantIntroducer

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
public GrInplaceConstantIntroducer(GrIntroduceContext context, OccurrencesChooser.ReplaceChoice choice) {
  super(IntroduceConstantHandler.REFACTORING_NAME, choice, context);

  myContext = context;

  myPanel = new GrInplaceIntroduceConstantPanel();

  GrVariable localVar = GrIntroduceHandlerBase.resolveLocalVar(context);
  if (localVar != null) {
    ArrayList<String> result = ContainerUtil.newArrayList(localVar.getName());

    GrExpression initializer = localVar.getInitializerGroovy();
    if (initializer != null) {
      ContainerUtil.addAll(result, GroovyNameSuggestionUtil.suggestVariableNames(initializer, new GroovyInplaceFieldValidator(context), true));
    }
    mySuggestedNames = ArrayUtil.toStringArray(result);
  }
  else {
    GrExpression expression = context.getExpression();
    assert expression != null;
    mySuggestedNames = GroovyNameSuggestionUtil.suggestVariableNames(expression, new GroovyInplaceFieldValidator(context), true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GrInplaceConstantIntroducer.java


示例6: getOccurrenceOptions

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
@NotNull
@Override
protected Map<OccurrencesChooser.ReplaceChoice, List<Object>> getOccurrenceOptions(@NotNull GrIntroduceContext context) {
  HashMap<OccurrencesChooser.ReplaceChoice, List<Object>> map = ContainerUtil.newLinkedHashMap();

  GrVariable localVar = resolveLocalVar(context);
  if (localVar != null) {
    map.put(OccurrencesChooser.ReplaceChoice.ALL, Arrays.<Object>asList(context.getOccurrences()));
    return map;
  }

  if (context.getExpression() != null) {
    map.put(OccurrencesChooser.ReplaceChoice.NO, Collections.<Object>singletonList(context.getExpression()));
  }
  else if (context.getStringPart() != null) {
    map.put(OccurrencesChooser.ReplaceChoice.NO, Collections.<Object>singletonList(context.getStringPart()));
  }

  PsiElement[] occurrences = context.getOccurrences();
  if (occurrences.length > 1) {
    map.put(OccurrencesChooser.ReplaceChoice.ALL, Arrays.<Object>asList(occurrences));
  }
  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GrIntroduceConstantHandler.java


示例7: getInitialSettingsForInplace

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
@Nullable
@Override
protected GrIntroduceParameterSettings getInitialSettingsForInplace(@NotNull GrIntroduceContext context,
                                                                    @NotNull OccurrencesChooser.ReplaceChoice choice,
                                                                    String[] names) {
  GrExpression expression = context.getExpression();
  GrVariable var = context.getVar();
  PsiType type = var != null ? var.getDeclaredType() :
                 expression != null ? expression.getType() :
                 null;

  return new GrIntroduceExpressionSettingsImpl(myInfo, names[0], false, new TIntArrayList(), false,
                                               IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, expression,
                                               var, type, false, false, false);

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


示例8: GrInplaceFieldIntroducer

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
public GrInplaceFieldIntroducer(GrIntroduceContext context, OccurrencesChooser.ReplaceChoice choice) {
  super(IntroduceFieldHandler.REFACTORING_NAME, choice, context);

  finalListener = new GrFinalListener(myEditor);

  myLocalVar = GrIntroduceHandlerBase.resolveLocalVar(context);
  if (myLocalVar != null) {
    //myLocalVariable = myLocalVar;
    ArrayList<String> result = ContainerUtil.newArrayList(myLocalVar.getName());

    GrExpression initializer = myLocalVar.getInitializerGroovy();
    if (initializer != null) {
      ContainerUtil.addAll(result, GroovyNameSuggestionUtil.suggestVariableNames(initializer, new GroovyInplaceFieldValidator(getContext()), false));
    }
    mySuggestedNames = ArrayUtil.toStringArray(result);
  }
  else {
    mySuggestedNames = GroovyNameSuggestionUtil.suggestVariableNames(context.getExpression(), new GroovyInplaceFieldValidator(getContext()), false);
  }
  myApplicablePlaces = getApplicableInitPlaces();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GrInplaceFieldIntroducer.java


示例9: fillChoice

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
public static Map<OccurrencesChooser.ReplaceChoice, List<Object>> fillChoice(GrIntroduceContext context) {
  HashMap<OccurrencesChooser.ReplaceChoice, List<Object>> map = ContainerUtil.newLinkedHashMap();

  if (context.getExpression() != null) {
    map.put(OccurrencesChooser.ReplaceChoice.NO, Collections.<Object>singletonList(context.getExpression()));
  }
  else if (context.getStringPart() != null) {
    map.put(OccurrencesChooser.ReplaceChoice.NO, Collections.<Object>singletonList(context.getStringPart()));
    return map;
  }
  else if (context.getVar() != null) {
    map.put(OccurrencesChooser.ReplaceChoice.ALL, Collections.<Object>singletonList(context.getVar()));
    return map;
  }

  PsiElement[] occurrences = context.getOccurrences();
  if (occurrences.length > 1) {
    map.put(OccurrencesChooser.ReplaceChoice.ALL, Arrays.<Object>asList(occurrences));
  }
  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GrIntroduceHandlerBase.java


示例10: fillChoices

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
/**
 * @return true if write usages found
 */
private static boolean fillChoices(final PsiExpression expr,
                                   final PsiExpression[] occurrences,
                                   final LinkedHashMap<OccurrencesChooser.ReplaceChoice, List<PsiExpression>> occurrencesMap) {
  occurrencesMap.put(OccurrencesChooser.ReplaceChoice.NO, Collections.singletonList(expr));

  final List<PsiExpression> nonWrite = new ArrayList<PsiExpression>();
  boolean cantReplaceAll = false;
  for (PsiExpression occurrence : occurrences) {
    if (!RefactoringUtil.isAssignmentLHS(occurrence)) {
      nonWrite.add(occurrence);
    } else if (isFinalVariableOnLHS(occurrence)) {
      cantReplaceAll = true;
    }
  }
  final boolean hasWriteAccess = occurrences.length > nonWrite.size() && occurrences.length > 1;
  if (hasWriteAccess) {
    occurrencesMap.put(OccurrencesChooser.ReplaceChoice.NO_WRITE, nonWrite);
  }

  if (occurrences.length > 1 && !cantReplaceAll) {
    occurrencesMap.put(OccurrencesChooser.ReplaceChoice.ALL, Arrays.asList(occurrences));
  }
  return hasWriteAccess;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:IntroduceVariableBase.java


示例11: testNameSuggestion

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
public void testNameSuggestion() throws Exception {
  final String expectedTypeName = "Path";
  doTest(new MockIntroduceVariableHandler("path", true, false, false, expectedTypeName) {
    @Override
    public IntroduceVariableSettings getSettings(Project project, Editor editor,
                                                 PsiExpression expr, PsiExpression[] occurrences,
                                                 TypeSelectorManagerImpl typeSelectorManager,
                                                 boolean declareFinalIfAll,
                                                 boolean anyAssignmentLHS,
                                                 InputValidator validator,
                                                 PsiElement anchor, final OccurrencesChooser.ReplaceChoice replaceChoice) {
      final PsiType type = typeSelectorManager.getDefaultType();
      Assert.assertTrue(type.getPresentableText(), type.getPresentableText().equals(expectedTypeName));
      Assert.assertEquals("path", IntroduceVariableBase.getSuggestedName(type, expr).names[0]);
      return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS,
                               validator, anchor, replaceChoice);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:IntroduceVariableTest.java


示例12: testSiblingInnerClassType

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
public void testSiblingInnerClassType() throws Exception {
  doTest(new MockIntroduceVariableHandler("vari", true, false, false, "A.B") {
    @Override
    public IntroduceVariableSettings getSettings(Project project, Editor editor,
                                                 PsiExpression expr, PsiExpression[] occurrences,
                                                 TypeSelectorManagerImpl typeSelectorManager,
                                                 boolean declareFinalIfAll,
                                                 boolean anyAssignmentLHS,
                                                 InputValidator validator,
                                                 PsiElement anchor, final OccurrencesChooser.ReplaceChoice replaceChoice) {
      final PsiType type = typeSelectorManager.getDefaultType();
      Assert.assertTrue(type.getPresentableText(), type.getPresentableText().equals("B"));
      return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS,
                               validator, anchor, replaceChoice);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:IntroduceVariableTest.java


示例13: fillChoice

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
protected Map<OccurrencesChooser.ReplaceChoice, List<Object>> fillChoice(GrIntroduceContext context) {
  HashMap<OccurrencesChooser.ReplaceChoice, List<Object>> map = ContainerUtil.newLinkedHashMap();

  if (context.getExpression() != null) {
    map.put(OccurrencesChooser.ReplaceChoice.NO, Collections.<Object>singletonList(context.getExpression()));
  }
  else if (context.getStringPart() != null) {
    map.put(OccurrencesChooser.ReplaceChoice.NO, Collections.<Object>singletonList(context.getStringPart()));
  }

  PsiElement[] occurrences = context.getOccurrences();
  if (occurrences.length > 1) {
    map.put(OccurrencesChooser.ReplaceChoice.ALL, Arrays.<Object>asList(occurrences));
  }
  return map;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:GrIntroduceHandlerBase.java


示例14: performActionOnElementOccurrences

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
protected void performActionOnElementOccurrences(final HaxeIntroduceOperation operation) {
  final Editor editor = operation.getEditor();
  if (editor.getSettings().isVariableInplaceRenameEnabled()) {
    ensureName(operation);
    if (operation.isReplaceAll() != null) {
      performInplaceIntroduce(operation);
    }
    else {
      OccurrencesChooser.simpleChooser(editor).showChooser(
        operation.getElement(),
        operation.getOccurrences(),
        new Pass<OccurrencesChooser.ReplaceChoice>() {
          @Override
          public void pass(OccurrencesChooser.ReplaceChoice replaceChoice) {
            operation.setReplaceAll(replaceChoice == OccurrencesChooser.ReplaceChoice.ALL);
            performInplaceIntroduce(operation);
          }
        });
    }
  }
  else {
    performIntroduceWithDialog(operation);
  }
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:25,代码来源:HaxeIntroduceHandler.java


示例15: getIntroducer

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
@Override
protected GrAbstractInplaceIntroducer<GrIntroduceConstantSettings> getIntroducer(@NotNull GrIntroduceContext context, @NotNull OccurrencesChooser.ReplaceChoice choice) {
  final Ref<GrIntroduceContext> contextRef = Ref.create(context);

  if (context.getStringPart() != null) {
    extractStringPart(contextRef);
  }

  return new GrInplaceConstantIntroducer(contextRef.get(), choice);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GrIntroduceConstantHandler.java


示例16: GrInplaceParameterIntroducer

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
public GrInplaceParameterIntroducer(IntroduceParameterInfo info, GrIntroduceContext context, OccurrencesChooser.ReplaceChoice choice) {
  super(GrIntroduceParameterHandler.REFACTORING_NAME, choice, context);
  myInfo = info;

  GrVariable localVar = GrIntroduceHandlerBase.resolveLocalVar(context);
  mySuggestedNames = GroovyIntroduceParameterUtil.suggestNames(localVar, context.getExpression(), context.getStringPart(), info.getToReplaceIn(), context.getProject());

  myParametersToRemove = new TIntArrayList(GroovyIntroduceParameterUtil.findParametersToRemove(info).getValues());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GrInplaceParameterIntroducer.java


示例17: showDialogOrStartInplace

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
protected void showDialogOrStartInplace(@NotNull final IntroduceParameterInfo info, @NotNull final Editor editor) {
  if (isInplace(info, editor)) {
    final GrIntroduceContext context = createContext(info, editor);
    Map<OccurrencesChooser.ReplaceChoice, List<Object>> occurrencesMap = GrIntroduceHandlerBase.fillChoice(context);
    new IntroduceOccurrencesChooser(editor).showChooser(new Pass<OccurrencesChooser.ReplaceChoice>() {
      @Override
      public void pass(OccurrencesChooser.ReplaceChoice choice) {
        startInplace(info, context, choice);
      }
    }, occurrencesMap);
  }
  else {
    showDialog(info);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:GrIntroduceParameterHandler.java


示例18: GrAbstractInplaceIntroducer

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
public GrAbstractInplaceIntroducer(String title,
                                   OccurrencesChooser.ReplaceChoice replaceChoice,
                                   GrIntroduceContext context) {
  super(context.getProject(), context.getEditor(), context.getExpression(), context.getVar(), context.getOccurrences(), title, GroovyFileType.GROOVY_FILE_TYPE);
  myReplaceChoice = replaceChoice;
  myContext = context;
  myFile = context.getPlace().getContainingFile();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:GrAbstractInplaceIntroducer.java


示例19: getIntroducer

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
@Override
protected GrAbstractInplaceIntroducer<GrIntroduceFieldSettings> getIntroducer(@NotNull GrIntroduceContext context,
                                                                              OccurrencesChooser.ReplaceChoice choice) {

  final Ref<GrIntroduceContext> contextRef = Ref.create(context);

  if (context.getStringPart() != null) {
    extractStringPart(contextRef);
  }

  return new GrInplaceFieldIntroducer(contextRef.get(), choice);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GrIntroduceFieldHandler.java


示例20: getSettingsForInplace

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入依赖的package包/类
@Override
protected GroovyIntroduceVariableSettings getSettingsForInplace(final GrIntroduceContext context, final OccurrencesChooser.ReplaceChoice choice) {
  return new GroovyIntroduceVariableSettings() {
    @Override
    public boolean isDeclareFinal() {
      return false;
    }

    @Nullable
    @Override
    public String getName() {
      return new GrVariableNameSuggester(context, new GroovyVariableValidator(context)).suggestNames().iterator().next();
    }

    @Override
    public boolean replaceAllOccurrences() {
      return choice == OccurrencesChooser.ReplaceChoice.ALL;
    }

    @Nullable
    @Override
    public PsiType getSelectedType() {
      GrExpression expression = context.getExpression();
      StringPartInfo stringPart = context.getStringPart();
      GrVariable var = context.getVar();
      return expression != null ? expression.getType() :
             var != null ? var.getType() :
             stringPart != null ? stringPart.getLiteral().getType() :
             null;
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:GrIntroduceVariableHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BasicColumnFamilyDefinition类代码示例发布时间:2022-05-22
下一篇:
Java OperationMetrics类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap