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


Java OccurrencesChooser类代码示例

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


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


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