use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.
the class InlineMethodDialog method doAction.
@Override
protected void doAction() {
super.doAction();
invokeRefactoring(new InlineMethodProcessor(getProject(), myMethod, myReferenceElement, myEditor, isInlineThisOnly(), isSearchInCommentsAndStrings(), isSearchForTextOccurrences(), !isKeepTheDeclaration()));
JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
if (myRbInlineThisOnly.isEnabled() && myRbInlineAll.isEnabled()) {
settings.INLINE_METHOD_THIS = isInlineThisOnly();
}
}
use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.
the class IntroduceParameterDialog method doAction.
protected void doAction() {
final JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS = myPanel.getReplaceFieldsWithGetters();
if (myCbDeclareFinal != null && myCbDeclareFinal.isEnabled()) {
settings.INTRODUCE_PARAMETER_CREATE_FINALS = Boolean.valueOf(myCbDeclareFinal.isSelected());
}
if (myCbCollapseToLambda.isVisible()) {
PropertiesComponent.getInstance(myProject).setValue(INTRODUCE_PARAMETER_LAMBDA, myCbCollapseToLambda.isSelected());
}
myPanel.saveSettings(settings);
myNameSuggestionsManager.nameSelected();
boolean isDeleteLocalVariable = false;
PsiExpression parameterInitializer = myExpression;
if (myLocalVar != null) {
if (myPanel.isUseInitializer()) {
parameterInitializer = myLocalVar.getInitializer();
}
isDeleteLocalVariable = myPanel.isDeleteLocalVariable();
}
final PsiType selectedType = getSelectedType();
final IntroduceParameterProcessor processor = new IntroduceParameterProcessor(myProject, myMethodToReplaceIn, myMethodToSearchFor, parameterInitializer, myExpression, myLocalVar, isDeleteLocalVariable, getParameterName(), myPanel.isReplaceAllOccurences(), myPanel.getReplaceFieldsWithGetters(), isDeclareFinal(), myPanel.isGenerateDelegate(), selectedType, myPanel.getParametersToRemove());
if (myCbCollapseToLambda.isVisible() && myCbCollapseToLambda.isSelected() && parameterInitializer != null) {
PsiExpression lambda = AnonymousCanBeLambdaInspection.replaceAnonymousWithLambda(parameterInitializer, selectedType);
if (lambda != null) {
lambda = LambdaCanBeMethodReferenceInspection.replaceLambdaWithMethodReference((PsiLambdaExpression) lambda);
processor.setParameterInitializer(lambda);
}
}
invokeRefactoring(processor);
}
use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.
the class InlineSuperClassRefactoringDialog method doAction.
protected void doAction() {
JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
if (myRbInlineThisOnly.isEnabled() && myRbInlineAll.isEnabled()) {
settings.INLINE_SUPER_CLASS_THIS = isInlineThisOnly();
}
invokeRefactoring(new InlineSuperClassRefactoringProcessor(getProject(), isInlineThisOnly() ? myCurrentInheritor : null, mySuperClass, myDocPanel.getPolicy()));
}
use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.
the class JavaMoveClassesOrPackagesHandler method moveAsDirectory.
private static void moveAsDirectory(Project project, PsiElement targetContainer, final MoveCallback callback, final PsiDirectory[] directories) {
if (targetContainer instanceof PsiDirectory) {
final JavaRefactoringSettings refactoringSettings = JavaRefactoringSettings.getInstance();
final MoveDirectoryWithClassesProcessor processor = new MoveDirectoryWithClassesProcessor(project, directories, (PsiDirectory) targetContainer, refactoringSettings.RENAME_SEARCH_IN_COMMENTS_FOR_PACKAGE, refactoringSettings.RENAME_SEARCH_IN_COMMENTS_FOR_PACKAGE, true, callback);
processor.setPrepareSuccessfulSwingThreadCallback(() -> {
});
processor.run();
} else {
final boolean containsJava = hasJavaFiles(directories[0]);
if (!containsJava) {
MoveFilesOrDirectoriesUtil.doMove(project, directories, new PsiElement[] { targetContainer }, callback);
return;
}
final MoveClassesOrPackagesToNewDirectoryDialog dlg = new MoveClassesOrPackagesToNewDirectoryDialog(directories[0], PsiElement.EMPTY_ARRAY, false, callback) {
@Override
protected BaseRefactoringProcessor createRefactoringProcessor(Project project, final PsiDirectory targetDirectory, PsiPackage aPackage, boolean searchInComments, boolean searchForTextOccurences) {
final MoveDestination destination = createDestination(aPackage, targetDirectory);
try {
for (PsiDirectory dir : directories) {
MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(dir, WriteAction.compute(() -> destination.getTargetDirectory(dir)));
}
} catch (IncorrectOperationException e) {
Messages.showErrorDialog(project, e.getMessage(), RefactoringBundle.message("cannot.move"));
return null;
}
return new MoveDirectoryWithClassesProcessor(project, directories, null, searchInComments, searchForTextOccurences, true, callback) {
@Override
public TargetDirectoryWrapper getTargetDirectory(PsiDirectory dir) {
final PsiDirectory targetDirectory = destination.getTargetDirectory(dir);
return new TargetDirectoryWrapper(targetDirectory);
}
@Override
protected String getTargetName() {
return targetDirectory.getName();
}
};
}
};
dlg.show();
}
}
use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.
the class GrIntroduceParameterDialog method saveSettings.
private void saveSettings() {
final JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
settings.INTRODUCE_PARAMETER_CREATE_FINALS = myDeclareFinalCheckBox.isSelected();
if (myGetterPanel.isVisible()) {
settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS = getReplaceFieldsWithGetter();
}
if (myForceReturnCheckBox.isEnabled() && mySignaturePanel.isVisible()) {
GroovyApplicationSettings.getInstance().FORCE_RETURN = myForceReturnCheckBox.isSelected();
}
}
Aggregations