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


Java OccurrencesChooser.ReplaceChoice方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: getMockHandler

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入方法依赖的package包/类
@NotNull
private static IntroduceVariableHandler getMockHandler() {
  return new IntroduceVariableHandler() {
    // mock default settings
    @Override
    public final IntroduceVariableSettings getSettings(Project project, Editor editor, final PsiExpression expr,
                                                       PsiExpression[] occurrences, TypeSelectorManagerImpl typeSelectorManager,
                                                       boolean declareFinalIfAll, boolean anyAssignmentLHS, InputValidator validator,
                                                       PsiElement anchor, OccurrencesChooser.ReplaceChoice replaceChoice) {
      return new IntroduceVariableSettings() {
        @Override
        public String getEnteredName() {
          return "foo";
        }

        @Override
        public boolean isReplaceAllOccurrences() {
          return false;
        }

        @Override
        public boolean isDeclareFinal() {
          return false;
        }

        @Override
        public boolean isReplaceLValues() {
          return false;
        }

        @Override
        public PsiType getSelectedType() {
          return expr.getType();
        }

        @Override
        public boolean isOK() {
          return true;
        }
      };
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:IntroduceVariablePostfixTemplate.java

示例13: getOccurrencesChoice

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入方法依赖的package包/类
protected OccurrencesChooser.ReplaceChoice getOccurrencesChoice() {
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:IntroduceVariableBase.java

示例14: getIntroducer

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入方法依赖的package包/类
protected abstract GrAbstractInplaceIntroducer<Settings> getIntroducer(@NotNull GrIntroduceContext context,
OccurrencesChooser.ReplaceChoice choice);
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:3,代码来源:GrIntroduceHandlerBase.java

示例15: getSettings

import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入方法依赖的package包/类
@Override
public IntroduceVariableSettings getSettings(Project project, Editor editor,
                                             PsiExpression expr, final PsiExpression[] occurrences,
                                             TypeSelectorManagerImpl typeSelectorManager,
                                             final boolean declareFinalIfAll,
                                             boolean anyAssignmentLHS,
                                             InputValidator validator,
                                             PsiElement anchor, final OccurrencesChooser.ReplaceChoice replaceChoice) {
  final PsiType type = myLookForType ? findType(typeSelectorManager.getTypesForAll(), typeSelectorManager.getDefaultType())
                                     : typeSelectorManager.getDefaultType();
  assertTrue(type.getInternalCanonicalText(), type.getInternalCanonicalText().equals(myExpectedTypeCanonicalName));
  IntroduceVariableSettings introduceVariableSettings = new IntroduceVariableSettings() {
    @Override
    public String getEnteredName() {
      return myName;
    }

    @Override
    public boolean isReplaceAllOccurrences() {
      return myReplaceAll && occurrences.length > 1;
    }

    @Override
    public boolean isDeclareFinal() {
      return myDeclareFinal || isReplaceAllOccurrences() && declareFinalIfAll;
    }

    @Override
    public boolean isReplaceLValues() {
      return myReplaceLValues;
    }

    @Override
    public PsiType getSelectedType() {
      return type;
    }

    @Override
    public boolean isOK() {
      return true;
    }
  };
  final boolean validationResult = validator.isOK(introduceVariableSettings);
  assertValidationResult(validationResult);
  return introduceVariableSettings;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:MockIntroduceVariableHandler.java


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