use of org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo in project intellij-community by JetBrains.
the class GrIntroduceConstantDialog method createUIComponents.
private void createUIComponents() {
myJavaVisibilityPanel = new JavaVisibilityPanel(false, true);
final GrVariable var = myContext.getVar();
final GrExpression expression = myContext.getExpression();
final StringPartInfo stringPart = myContext.getStringPart();
if (expression != null) {
myTypeCombo = GrTypeComboBox.createTypeComboBoxFromExpression(expression);
} else if (stringPart != null) {
myTypeCombo = GrTypeComboBox.createTypeComboBoxFromExpression(stringPart.getLiteral());
} else {
assert var != null;
myTypeCombo = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var);
}
List<String> names = new ArrayList<>();
if (var != null) {
names.add(var.getName());
}
if (expression != null) {
ContainerUtil.addAll(names, suggestNames());
}
myNameField = new NameSuggestionsField(ArrayUtil.toStringArray(names), myContext.getProject(), GroovyFileType.GROOVY_FILE_TYPE);
GrTypeComboBox.registerUpDownHint(myNameField, myTypeCombo);
}
use of org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo in project intellij-community by JetBrains.
the class GrIntroduceParameterDialog method suggestNames.
@NotNull
public LinkedHashSet<String> suggestNames() {
GrVariable var = GroovyIntroduceParameterUtil.findVar(myInfo);
GrExpression expr = GroovyIntroduceParameterUtil.findExpr(myInfo);
StringPartInfo stringPart = findStringPart();
return GroovyIntroduceParameterUtil.suggestNames(var, expr, stringPart, myInfo.getToReplaceIn(), myProject);
}
use of org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo in project intellij-community by JetBrains.
the class GrIntroduceParameterProcessor method processStringPart.
private void processStringPart() {
final StringPartInfo stringPartInfo = mySettings.getStringPartInfo();
if (stringPartInfo != null) {
final GrExpression expr = mySettings.getStringPartInfo().replaceLiteralWithConcatenation(mySettings.getName());
final Editor editor = PsiUtilBase.findEditor(expr);
if (editor != null) {
editor.getSelectionModel().removeSelection();
editor.getCaretModel().moveToOffset(expr.getTextRange().getEndOffset());
}
}
}
use of org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo in project intellij-community by JetBrains.
the class GrIntroduceFieldProcessor method getInitializer.
@Nullable
protected GrExpression getInitializer() {
if (mySettings.removeLocalVar()) {
return extractVarInitializer();
}
GrExpression expression = myContext.getExpression();
StringPartInfo stringPart = myContext.getStringPart();
if (expression != null) {
return expression;
} else if (stringPart != null) {
return stringPart.createLiteralFromSelected();
}
throw new IncorrectOperationException("cannot be here!");
}
use of org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo in project intellij-community by JetBrains.
the class GrIntroduceFieldDialog method createUIComponents.
private void createUIComponents() {
final GrExpression expression = myContext.getExpression();
final GrVariable var = myContext.getVar();
final StringPartInfo stringPart = myContext.getStringPart();
List<String> list = new ArrayList<>();
if (var != null) {
list.add(var.getName());
}
ContainerUtil.addAll(list, suggestNames());
myNameField = new NameSuggestionsField(ArrayUtil.toStringArray(list), myContext.getProject(), GroovyFileType.GROOVY_FILE_TYPE);
if (expression != null) {
myTypeComboBox = GrTypeComboBox.createTypeComboBoxFromExpression(expression);
} else if (stringPart != null) {
myTypeComboBox = GrTypeComboBox.createTypeComboBoxFromExpression(stringPart.getLiteral());
} else {
myTypeComboBox = GrTypeComboBox.createTypeComboBoxWithDefType(var.getDeclaredType(), var);
}
GrTypeComboBox.registerUpDownHint(myNameField, myTypeComboBox);
}
Aggregations