本文整理汇总了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);
}
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
}
示例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();
}
示例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;
}
};
}
示例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;
}
};
}
};
}
示例13: getOccurrencesChoice
import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入方法依赖的package包/类
protected OccurrencesChooser.ReplaceChoice getOccurrencesChoice() {
return null;
}
示例14: getIntroducer
import com.intellij.refactoring.introduce.inplace.OccurrencesChooser; //导入方法依赖的package包/类
protected abstract GrAbstractInplaceIntroducer<Settings> getIntroducer(@NotNull GrIntroduceContext context,
OccurrencesChooser.ReplaceChoice choice);
示例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;
}