GrIntroduceConstantSettings (@NotNull final GrIntroduceContext context, @NotNull final OccurrencesChooser.ReplaceChoice choice, final String[] names) { return new GrIntroduceConstantSettings() { @Override public String getVisibilityModifier() { return PsiModifier.PUBLIC; } @Nullable @Override public PsiClass getTargetClass() { return (PsiClass)context.getScope(); } @Nullable @Override public String getName() { return names[0]; } @Override public boolean replaceAllOccurrences() { return isReplaceAllOccurrences(); } @Nullable @Override public PsiType getSelectedType() { GrExpression expression = context.getExpression(); GrVariable var = context.getVar(); StringPartInfo stringPart = context.getStringPart(); return var != null ? var.getDeclaredType() : expression != null ? expression.getType() : stringPart != null ? stringPart.getLiteral().getType() : null; } }; }