Search in sources :

Example 1 with JavaRefactoringSettings

use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.

the class InlineGroovyFieldDialog method doAction.

@Override
protected void doAction() {
    if (getOKAction().isEnabled()) {
        JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
        if (myRbInlineThisOnly.isEnabled() && myRbInlineAll.isEnabled()) {
            settings.INLINE_FIELD_THIS = isInlineThisOnly();
        }
        close(OK_EXIT_CODE);
    }
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings)

Example 2 with JavaRefactoringSettings

use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.

the class IntroduceParameterDialog method createNorthPanel.

protected JComponent createNorthPanel() {
    GridBagConstraints gbConstraints = new GridBagConstraints();
    JPanel panel = new JPanel(new GridBagLayout());
    gbConstraints.anchor = GridBagConstraints.WEST;
    gbConstraints.fill = GridBagConstraints.NONE;
    gbConstraints.gridx = 0;
    gbConstraints.insets = JBUI.insets(4, 4, 4, 0);
    gbConstraints.gridwidth = 1;
    gbConstraints.weightx = 0;
    gbConstraints.weighty = 0;
    gbConstraints.gridy = 0;
    JLabel type = new JLabel(RefactoringBundle.message("parameter.of.type"));
    panel.add(type, gbConstraints);
    gbConstraints.insets = JBUI.insets(4, 4, 4, 8);
    gbConstraints.gridx++;
    gbConstraints.weightx = 1;
    gbConstraints.fill = GridBagConstraints.BOTH;
    myTypeSelector = myTypeSelectorManager.getTypeSelector();
    panel.add(myTypeSelector.getComponent(), gbConstraints);
    gbConstraints.insets = JBUI.insets(4, 4, 4, 8);
    gbConstraints.gridwidth = 1;
    gbConstraints.weightx = 0;
    gbConstraints.gridx = 0;
    gbConstraints.gridy = 1;
    gbConstraints.fill = GridBagConstraints.NONE;
    myParameterNameField = new NameSuggestionsField(myProject);
    final JLabel nameLabel = new JLabel(RefactoringBundle.message("name.prompt"));
    nameLabel.setLabelFor(myParameterNameField.getComponent());
    panel.add(nameLabel, gbConstraints);
    /*
    if (myNameSuggestions.length > 1) {
      myParameterNameField = createComboBoxForName();
    }
    else {
      myParameterNameField = createTextFieldForName();
    }
*/
    gbConstraints.gridx++;
    gbConstraints.insets = JBUI.insets(4, 4, 4, 8);
    gbConstraints.weightx = 1;
    gbConstraints.fill = GridBagConstraints.BOTH;
    panel.add(myParameterNameField.getComponent(), gbConstraints);
    myParameterNameChangedListener = () -> validateButtons();
    myParameterNameField.addDataChangedListener(myParameterNameChangedListener);
    myNameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myParameterNameField, myNameSuggestionsGenerator);
    myNameSuggestionsManager.setLabelsFor(type, nameLabel);
    gbConstraints.gridx = 0;
    gbConstraints.insets = JBUI.insets(4, 0, 4, 8);
    gbConstraints.gridwidth = 2;
    if (myOccurenceNumber > 1 && !myPanel.myIsInvokedOnDeclaration) {
        gbConstraints.gridy++;
        myPanel.createOccurrencesCb(gbConstraints, panel, myOccurenceNumber);
    }
    if (myPanel.myCbReplaceAllOccurences != null) {
        gbConstraints.insets = JBUI.insets(0, 16, 4, 8);
    }
    JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
    myPanel.createLocalVariablePanel(gbConstraints, panel, settings);
    myPanel.createRemoveParamsPanel(gbConstraints, panel);
    gbConstraints.insets = JBUI.insets(4, 0, 4, 8);
    gbConstraints.gridy++;
    myCbDeclareFinal = new NonFocusableCheckBox(RefactoringBundle.message("declare.final"));
    final Boolean settingsFinals = settings.INTRODUCE_PARAMETER_CREATE_FINALS;
    myCbDeclareFinal.setSelected(settingsFinals == null ? CodeStyleSettingsManager.getSettings(myProject).GENERATE_FINAL_PARAMETERS : settingsFinals.booleanValue());
    panel.add(myCbDeclareFinal, gbConstraints);
    if (myMustBeFinal) {
        myCbDeclareFinal.setSelected(true);
        myCbDeclareFinal.setEnabled(false);
    } else if (myHasWriteAccess && myPanel.isReplaceAllOccurences()) {
        myCbDeclareFinal.setSelected(false);
        myCbDeclareFinal.setEnabled(false);
    }
    gbConstraints.gridy++;
    myPanel.createDelegateCb(gbConstraints, panel);
    myCbCollapseToLambda = new NonFocusableCheckBox(RefactoringBundle.message("introduce.parameter.convert.lambda"));
    final PsiAnonymousClass anonymClass = myExpression instanceof PsiNewExpression ? ((PsiNewExpression) myExpression).getAnonymousClass() : null;
    myCbCollapseToLambda.setVisible(anonymClass != null && AnonymousCanBeLambdaInspection.canBeConvertedToLambda(anonymClass, false, Collections.emptySet()));
    myCbCollapseToLambda.setSelected(PropertiesComponent.getInstance(myProject).getBoolean(INTRODUCE_PARAMETER_LAMBDA));
    gbConstraints.gridy++;
    panel.add(myCbCollapseToLambda, gbConstraints);
    return panel;
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox)

Example 3 with JavaRefactoringSettings

use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.

the class InlineCallFix method inline.

protected void inline(Project project, PsiReferenceExpression methodExpression, PsiMethod method) {
    final JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
    final InlineMethodProcessor processor = new InlineMethodProcessor(project, method, methodExpression, null, true, settings.RENAME_SEARCH_IN_COMMENTS_FOR_METHOD, settings.RENAME_SEARCH_FOR_TEXT_FOR_METHOD);
    processor.inlineMethodCall(processor.addBracesWhenNeeded(new PsiReferenceExpression[] { methodExpression })[0]);
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings) InlineMethodProcessor(com.intellij.refactoring.inline.InlineMethodProcessor)

Example 4 with JavaRefactoringSettings

use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.

the class InlineFieldDialog method doAction.

protected void doAction() {
    super.doAction();
    invokeRefactoring(new InlineConstantFieldProcessor(myField, getProject(), myReferenceExpression, isInlineThisOnly(), isSearchInCommentsAndStrings(), isSearchForTextOccurrences(), !isKeepTheDeclaration()));
    JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
    if (myRbInlineThisOnly.isEnabled() && myRbInlineAll.isEnabled()) {
        settings.INLINE_FIELD_THIS = isInlineThisOnly();
    }
}
Also used : JavaRefactoringSettings(com.intellij.refactoring.JavaRefactoringSettings)

Example 5 with JavaRefactoringSettings

use of com.intellij.refactoring.JavaRefactoringSettings in project intellij-community by JetBrains.

the class InlineLocalDialog method doAction.

@Override
protected void doAction() {
    JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
    if (myRbInlineThisOnly.isEnabled() && myRbInlineAll.isEnabled()) {
        settings.INLINE_LOCAL_THIS = isInlineThisOnly();
    }
    close(OK_EXIT_CODE);
}
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