Search in sources :

Example 6 with JavaRefactoringSettings

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();
    }
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings)

Example 7 with JavaRefactoringSettings

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);
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings)

Example 8 with JavaRefactoringSettings

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()));
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings)

Example 9 with JavaRefactoringSettings

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();
    }
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings) Project(com.intellij.openapi.project.Project) MoveDestination(com.intellij.refactoring.MoveDestination) IncorrectOperationException(com.intellij.util.IncorrectOperationException)

Example 10 with JavaRefactoringSettings

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();
    }
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings)

Aggregations

JavaRefactoringSettings (com.intellij.refactoring.JavaRefactoringSettings)14 Project (com.intellij.openapi.project.Project)1 PsiType (com.intellij.psi.PsiType)1 MoveDestination (com.intellij.refactoring.MoveDestination)1 InlineMethodProcessor (com.intellij.refactoring.inline.InlineMethodProcessor)1 NonFocusableCheckBox (com.intellij.ui.NonFocusableCheckBox)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 TableCellEditor (javax.swing.table.TableCellEditor)1 GrClosableBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock)1 GrParameter (org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter)1 ParameterInfo (org.jetbrains.plugins.groovy.refactoring.extract.ParameterInfo)1