mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Separate Java code style settings, Java code style panels grouped
This commit is contained in:
+63
-50
@@ -81,6 +81,7 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
public Icon getIcon() {
|
||||
return StdFileTypes.JAVA.getIcon();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*private JPanel createNamingPanel() {
|
||||
@@ -203,87 +204,99 @@ public class CodeStyleGenerationConfigurable implements Configurable {
|
||||
return optionGroup.createPanel();
|
||||
}*/
|
||||
|
||||
public void reset() {
|
||||
myCbPreferLongerNames.setSelected(mySettings.PREFER_LONGER_NAMES);
|
||||
public void reset(CodeStyleSettings settings) {
|
||||
myCbPreferLongerNames.setSelected(settings.PREFER_LONGER_NAMES);
|
||||
|
||||
myFieldPrefixField.setText(mySettings.FIELD_NAME_PREFIX);
|
||||
myStaticFieldPrefixField.setText(mySettings.STATIC_FIELD_NAME_PREFIX);
|
||||
myParameterPrefixField.setText(mySettings.PARAMETER_NAME_PREFIX);
|
||||
myLocalVariablePrefixField.setText(mySettings.LOCAL_VARIABLE_NAME_PREFIX);
|
||||
myFieldPrefixField.setText(settings.FIELD_NAME_PREFIX);
|
||||
myStaticFieldPrefixField.setText(settings.STATIC_FIELD_NAME_PREFIX);
|
||||
myParameterPrefixField.setText(settings.PARAMETER_NAME_PREFIX);
|
||||
myLocalVariablePrefixField.setText(settings.LOCAL_VARIABLE_NAME_PREFIX);
|
||||
|
||||
myFieldSuffixField.setText(mySettings.FIELD_NAME_SUFFIX);
|
||||
myStaticFieldSuffixField.setText(mySettings.STATIC_FIELD_NAME_SUFFIX);
|
||||
myParameterSuffixField.setText(mySettings.PARAMETER_NAME_SUFFIX);
|
||||
myLocalVariableSuffixField.setText(mySettings.LOCAL_VARIABLE_NAME_SUFFIX);
|
||||
myFieldSuffixField.setText(settings.FIELD_NAME_SUFFIX);
|
||||
myStaticFieldSuffixField.setText(settings.STATIC_FIELD_NAME_SUFFIX);
|
||||
myParameterSuffixField.setText(settings.PARAMETER_NAME_SUFFIX);
|
||||
myLocalVariableSuffixField.setText(settings.LOCAL_VARIABLE_NAME_SUFFIX);
|
||||
|
||||
myCbLineCommentAtFirstColumn.setSelected(mySettings.LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
myCbBlockCommentAtFirstColumn.setSelected(mySettings.BLOCK_COMMENT_AT_FIRST_COLUMN);
|
||||
myCbLineCommentAtFirstColumn.setSelected(settings.LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
myCbBlockCommentAtFirstColumn.setSelected(settings.BLOCK_COMMENT_AT_FIRST_COLUMN);
|
||||
|
||||
myCbGenerateFinalLocals.setSelected(mySettings.GENERATE_FINAL_LOCALS);
|
||||
myCbGenerateFinalParameters.setSelected(mySettings.GENERATE_FINAL_PARAMETERS);
|
||||
myCbGenerateFinalLocals.setSelected(settings.GENERATE_FINAL_LOCALS);
|
||||
myCbGenerateFinalParameters.setSelected(settings.GENERATE_FINAL_PARAMETERS);
|
||||
myMembersOrderList.reset(mySettings);
|
||||
|
||||
myCbUseExternalAnnotations.setSelected(mySettings.USE_EXTERNAL_ANNOTATIONS);
|
||||
myInsertOverrideAnnotationCheckBox.setSelected(mySettings.INSERT_OVERRIDE_ANNOTATION);
|
||||
myCbUseExternalAnnotations.setSelected(settings.USE_EXTERNAL_ANNOTATIONS);
|
||||
myInsertOverrideAnnotationCheckBox.setSelected(settings.INSERT_OVERRIDE_ANNOTATION);
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
mySettings.PREFER_LONGER_NAMES = myCbPreferLongerNames.isSelected();
|
||||
public void reset() {
|
||||
reset(mySettings);
|
||||
}
|
||||
|
||||
mySettings.FIELD_NAME_PREFIX = myFieldPrefixField.getText().trim();
|
||||
mySettings.STATIC_FIELD_NAME_PREFIX = myStaticFieldPrefixField.getText().trim();
|
||||
mySettings.PARAMETER_NAME_PREFIX = myParameterPrefixField.getText().trim();
|
||||
mySettings.LOCAL_VARIABLE_NAME_PREFIX = myLocalVariablePrefixField.getText().trim();
|
||||
public void apply(CodeStyleSettings settings) {
|
||||
settings.PREFER_LONGER_NAMES = myCbPreferLongerNames.isSelected();
|
||||
|
||||
mySettings.FIELD_NAME_SUFFIX = myFieldSuffixField.getText().trim();
|
||||
mySettings.STATIC_FIELD_NAME_SUFFIX = myStaticFieldSuffixField.getText().trim();
|
||||
mySettings.PARAMETER_NAME_SUFFIX = myParameterSuffixField.getText().trim();
|
||||
mySettings.LOCAL_VARIABLE_NAME_SUFFIX = myLocalVariableSuffixField.getText().trim();
|
||||
settings.FIELD_NAME_PREFIX = myFieldPrefixField.getText().trim();
|
||||
settings.STATIC_FIELD_NAME_PREFIX = myStaticFieldPrefixField.getText().trim();
|
||||
settings.PARAMETER_NAME_PREFIX = myParameterPrefixField.getText().trim();
|
||||
settings.LOCAL_VARIABLE_NAME_PREFIX = myLocalVariablePrefixField.getText().trim();
|
||||
|
||||
mySettings.LINE_COMMENT_AT_FIRST_COLUMN = myCbLineCommentAtFirstColumn.isSelected();
|
||||
mySettings.BLOCK_COMMENT_AT_FIRST_COLUMN = myCbBlockCommentAtFirstColumn.isSelected();
|
||||
settings.FIELD_NAME_SUFFIX = myFieldSuffixField.getText().trim();
|
||||
settings.STATIC_FIELD_NAME_SUFFIX = myStaticFieldSuffixField.getText().trim();
|
||||
settings.PARAMETER_NAME_SUFFIX = myParameterSuffixField.getText().trim();
|
||||
settings.LOCAL_VARIABLE_NAME_SUFFIX = myLocalVariableSuffixField.getText().trim();
|
||||
|
||||
mySettings.GENERATE_FINAL_LOCALS = myCbGenerateFinalLocals.isSelected();
|
||||
mySettings.GENERATE_FINAL_PARAMETERS = myCbGenerateFinalParameters.isSelected();
|
||||
settings.LINE_COMMENT_AT_FIRST_COLUMN = myCbLineCommentAtFirstColumn.isSelected();
|
||||
settings.BLOCK_COMMENT_AT_FIRST_COLUMN = myCbBlockCommentAtFirstColumn.isSelected();
|
||||
|
||||
mySettings.USE_EXTERNAL_ANNOTATIONS = myCbUseExternalAnnotations.isSelected();
|
||||
mySettings.INSERT_OVERRIDE_ANNOTATION = myInsertOverrideAnnotationCheckBox.isSelected();
|
||||
settings.GENERATE_FINAL_LOCALS = myCbGenerateFinalLocals.isSelected();
|
||||
settings.GENERATE_FINAL_PARAMETERS = myCbGenerateFinalParameters.isSelected();
|
||||
|
||||
myMembersOrderList.apply(mySettings);
|
||||
settings.USE_EXTERNAL_ANNOTATIONS = myCbUseExternalAnnotations.isSelected();
|
||||
settings.INSERT_OVERRIDE_ANNOTATION = myInsertOverrideAnnotationCheckBox.isSelected();
|
||||
|
||||
myMembersOrderList.apply(settings);
|
||||
|
||||
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
DaemonCodeAnalyzer.getInstance(project).settingsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
boolean isModified = isModified(myCbPreferLongerNames, mySettings.PREFER_LONGER_NAMES);
|
||||
public void apply() {
|
||||
apply(mySettings);
|
||||
}
|
||||
|
||||
isModified |= isModified(myFieldPrefixField, mySettings.FIELD_NAME_PREFIX);
|
||||
isModified |= isModified(myStaticFieldPrefixField, mySettings.STATIC_FIELD_NAME_PREFIX);
|
||||
isModified |= isModified(myParameterPrefixField, mySettings.PARAMETER_NAME_PREFIX);
|
||||
isModified |= isModified(myLocalVariablePrefixField, mySettings.LOCAL_VARIABLE_NAME_PREFIX);
|
||||
public boolean isModified(CodeStyleSettings settings) {
|
||||
boolean isModified = isModified(myCbPreferLongerNames, settings.PREFER_LONGER_NAMES);
|
||||
|
||||
isModified |= isModified(myFieldSuffixField, mySettings.FIELD_NAME_SUFFIX);
|
||||
isModified |= isModified(myStaticFieldSuffixField, mySettings.STATIC_FIELD_NAME_SUFFIX);
|
||||
isModified |= isModified(myParameterSuffixField, mySettings.PARAMETER_NAME_SUFFIX);
|
||||
isModified |= isModified(myLocalVariableSuffixField, mySettings.LOCAL_VARIABLE_NAME_SUFFIX);
|
||||
isModified |= isModified(myFieldPrefixField, settings.FIELD_NAME_PREFIX);
|
||||
isModified |= isModified(myStaticFieldPrefixField, settings.STATIC_FIELD_NAME_PREFIX);
|
||||
isModified |= isModified(myParameterPrefixField, settings.PARAMETER_NAME_PREFIX);
|
||||
isModified |= isModified(myLocalVariablePrefixField, settings.LOCAL_VARIABLE_NAME_PREFIX);
|
||||
|
||||
isModified |= isModified(myCbLineCommentAtFirstColumn, mySettings.LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
isModified |= isModified(myCbBlockCommentAtFirstColumn, mySettings.BLOCK_COMMENT_AT_FIRST_COLUMN);
|
||||
isModified |= isModified(myFieldSuffixField, settings.FIELD_NAME_SUFFIX);
|
||||
isModified |= isModified(myStaticFieldSuffixField, settings.STATIC_FIELD_NAME_SUFFIX);
|
||||
isModified |= isModified(myParameterSuffixField, settings.PARAMETER_NAME_SUFFIX);
|
||||
isModified |= isModified(myLocalVariableSuffixField, settings.LOCAL_VARIABLE_NAME_SUFFIX);
|
||||
|
||||
isModified |= isModified(myCbLineCommentAtFirstColumn, settings.LINE_COMMENT_AT_FIRST_COLUMN);
|
||||
isModified |= isModified(myCbBlockCommentAtFirstColumn, settings.BLOCK_COMMENT_AT_FIRST_COLUMN);
|
||||
|
||||
|
||||
isModified |= isModified(myCbGenerateFinalLocals, mySettings.GENERATE_FINAL_LOCALS);
|
||||
isModified |= isModified(myCbGenerateFinalParameters, mySettings.GENERATE_FINAL_PARAMETERS);
|
||||
isModified |= isModified(myCbGenerateFinalLocals, settings.GENERATE_FINAL_LOCALS);
|
||||
isModified |= isModified(myCbGenerateFinalParameters, settings.GENERATE_FINAL_PARAMETERS);
|
||||
|
||||
isModified |= isModified(myCbUseExternalAnnotations, mySettings.USE_EXTERNAL_ANNOTATIONS);
|
||||
isModified |= isModified(myInsertOverrideAnnotationCheckBox, mySettings.INSERT_OVERRIDE_ANNOTATION);
|
||||
isModified |= isModified(myCbUseExternalAnnotations, settings.USE_EXTERNAL_ANNOTATIONS);
|
||||
isModified |= isModified(myInsertOverrideAnnotationCheckBox, settings.INSERT_OVERRIDE_ANNOTATION);
|
||||
|
||||
isModified |= myMembersOrderList.isModified(mySettings);
|
||||
isModified |= myMembersOrderList.isModified(settings);
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return isModified(mySettings);
|
||||
}
|
||||
|
||||
private static boolean isModified(JCheckBox checkBox, boolean value) {
|
||||
return checkBox.isSelected() != value;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.application.options;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class CodeStyleGenerationWrapper extends CodeStyleAbstractPanel {
|
||||
private final CodeStyleGenerationConfigurable myConfigurable;
|
||||
|
||||
protected CodeStyleGenerationWrapper(CodeStyleSettings settings) {
|
||||
super(settings);
|
||||
myConfigurable = new CodeStyleGenerationConfigurable(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRightMargin() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EditorHighlighter createHighlighter(EditorColorsScheme scheme) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected FileType getFileType() {
|
||||
return JavaFileType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPreviewText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CodeStyleSettings settings) {
|
||||
myConfigurable.apply(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified(CodeStyleSettings settings) {
|
||||
return myConfigurable.isModified(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPanel() {
|
||||
return myConfigurable.createComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resetImpl(CodeStyleSettings settings) {
|
||||
myConfigurable.reset(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTabTitle() {
|
||||
return ApplicationBundle.message("title.code.generation");
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,9 @@ public class CodeStyleImportsPanel extends JPanel {
|
||||
myNamesCountField = new JTextField(3);
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
panel.add(new JLabel(ApplicationBundle.message("editbox.class.count.to.use.import.with.star")), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0));
|
||||
panel.add(myClassCountField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 1, 0, 0), 0, 0));
|
||||
panel.add(myClassCountField,
|
||||
new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
|
||||
new Insets(0, 1, 0, 0), 0, 0));
|
||||
panel.add(new JLabel(ApplicationBundle.message("editbox.names.count.to.use.static.import.with.star")), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0));
|
||||
panel.add(myNamesCountField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 1, 0, 0), 0, 0));
|
||||
|
||||
@@ -576,7 +578,7 @@ public class CodeStyleImportsPanel extends JPanel {
|
||||
private void updateButtons(){
|
||||
int selectedImport = myImportLayoutTable.getSelectedRow();
|
||||
myMoveUpButton.setEnabled(selectedImport >= 1);
|
||||
myMoveDownButton.setEnabled(selectedImport < myImportLayoutTable.getRowCount()-1);
|
||||
myMoveDownButton.setEnabled(selectedImport < myImportLayoutTable.getRowCount() - 1);
|
||||
PackageEntry entry = selectedImport < 0 ? null : myImportLayoutList.getEntryAt(selectedImport);
|
||||
boolean canRemove = entry != null && entry != PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY && entry != PackageEntry.ALL_OTHER_IMPORTS_ENTRY;
|
||||
myRemovePackageFromImportLayoutButton.setEnabled(canRemove);
|
||||
@@ -590,18 +592,18 @@ public class CodeStyleImportsPanel extends JPanel {
|
||||
return ScrollPaneFactory.createScrollPane(myImportLayoutTable);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
myCbUseFQClassNames.setSelected(mySettings.USE_FQ_CLASS_NAMES);
|
||||
myCbUseFQClassNamesInJavaDoc.setSelected(mySettings.USE_FQ_CLASS_NAMES_IN_JAVADOC);
|
||||
myCbUseSingleClassImports.setSelected(mySettings.USE_SINGLE_CLASS_IMPORTS);
|
||||
myCbInsertInnerClassImports.setSelected(mySettings.INSERT_INNER_CLASS_IMPORTS);
|
||||
myClassCountField.setText(Integer.toString(mySettings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND));
|
||||
myNamesCountField.setText(Integer.toString(mySettings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND));
|
||||
public void reset(CodeStyleSettings settings) {
|
||||
myCbUseFQClassNames.setSelected(settings.USE_FQ_CLASS_NAMES);
|
||||
myCbUseFQClassNamesInJavaDoc.setSelected(settings.USE_FQ_CLASS_NAMES_IN_JAVADOC);
|
||||
myCbUseSingleClassImports.setSelected(settings.USE_SINGLE_CLASS_IMPORTS);
|
||||
myCbInsertInnerClassImports.setSelected(settings.INSERT_INNER_CLASS_IMPORTS);
|
||||
myClassCountField.setText(Integer.toString(settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND));
|
||||
myNamesCountField.setText(Integer.toString(settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND));
|
||||
|
||||
myImportLayoutList.copyFrom(mySettings.IMPORT_LAYOUT_TABLE);
|
||||
myPackageList.copyFrom(mySettings.PACKAGES_TO_USE_IMPORT_ON_DEMAND);
|
||||
myImportLayoutList.copyFrom(settings.IMPORT_LAYOUT_TABLE);
|
||||
myPackageList.copyFrom(settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND);
|
||||
|
||||
myCbLayoutStaticImportsSeparately.setSelected(mySettings.LAYOUT_STATIC_IMPORTS_SEPARATELY);
|
||||
myCbLayoutStaticImportsSeparately.setSelected(settings.LAYOUT_STATIC_IMPORTS_SEPARATELY);
|
||||
|
||||
AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
|
||||
model.fireTableDataChanged();
|
||||
@@ -616,7 +618,7 @@ public class CodeStyleImportsPanel extends JPanel {
|
||||
myPackageTable.getSelectionModel().setSelectionInterval(0, 0);
|
||||
}
|
||||
|
||||
if (mySettings.JSP_PREFER_COMMA_SEPARATED_IMPORT_LIST) {
|
||||
if (settings.JSP_PREFER_COMMA_SEPARATED_IMPORT_LIST) {
|
||||
myJspImportCommaSeparated.doClick();
|
||||
}
|
||||
else {
|
||||
@@ -625,34 +627,42 @@ public class CodeStyleImportsPanel extends JPanel {
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
public void reset() {
|
||||
reset(mySettings);
|
||||
}
|
||||
|
||||
public void apply(CodeStyleSettings settings) {
|
||||
stopTableEditing();
|
||||
|
||||
mySettings.LAYOUT_STATIC_IMPORTS_SEPARATELY = areStaticImportsEnabled();
|
||||
mySettings.USE_FQ_CLASS_NAMES = myCbUseFQClassNames.isSelected();
|
||||
mySettings.USE_FQ_CLASS_NAMES_IN_JAVADOC = myCbUseFQClassNamesInJavaDoc.isSelected();
|
||||
mySettings.USE_SINGLE_CLASS_IMPORTS = myCbUseSingleClassImports.isSelected();
|
||||
mySettings.INSERT_INNER_CLASS_IMPORTS = myCbInsertInnerClassImports.isSelected();
|
||||
settings.LAYOUT_STATIC_IMPORTS_SEPARATELY = areStaticImportsEnabled();
|
||||
settings.USE_FQ_CLASS_NAMES = myCbUseFQClassNames.isSelected();
|
||||
settings.USE_FQ_CLASS_NAMES_IN_JAVADOC = myCbUseFQClassNamesInJavaDoc.isSelected();
|
||||
settings.USE_SINGLE_CLASS_IMPORTS = myCbUseSingleClassImports.isSelected();
|
||||
settings.INSERT_INNER_CLASS_IMPORTS = myCbInsertInnerClassImports.isSelected();
|
||||
try{
|
||||
mySettings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = Integer.parseInt(myClassCountField.getText());
|
||||
settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = Integer.parseInt(myClassCountField.getText());
|
||||
}
|
||||
catch(NumberFormatException e){
|
||||
//just a bad number
|
||||
}
|
||||
try{
|
||||
mySettings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND = Integer.parseInt(myNamesCountField.getText());
|
||||
settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND = Integer.parseInt(myNamesCountField.getText());
|
||||
}
|
||||
catch(NumberFormatException e){
|
||||
//just a bad number
|
||||
}
|
||||
|
||||
myImportLayoutList.removeEmptyPackages();
|
||||
mySettings.IMPORT_LAYOUT_TABLE.copyFrom(myImportLayoutList);
|
||||
settings.IMPORT_LAYOUT_TABLE.copyFrom(myImportLayoutList);
|
||||
|
||||
myPackageList.removeEmptyPackages();
|
||||
mySettings.PACKAGES_TO_USE_IMPORT_ON_DEMAND.copyFrom(myPackageList);
|
||||
settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND.copyFrom(myPackageList);
|
||||
|
||||
mySettings.JSP_PREFER_COMMA_SEPARATED_IMPORT_LIST = myJspImportCommaSeparated.isSelected();
|
||||
settings.JSP_PREFER_COMMA_SEPARATED_IMPORT_LIST = myJspImportCommaSeparated.isSelected();
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
apply(mySettings);
|
||||
}
|
||||
|
||||
|
||||
@@ -661,22 +671,26 @@ public class CodeStyleImportsPanel extends JPanel {
|
||||
TableUtil.stopEditing(myPackageTable);
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
public boolean isModified(CodeStyleSettings settings) {
|
||||
boolean
|
||||
isModified = isModified(myCbLayoutStaticImportsSeparately, mySettings.LAYOUT_STATIC_IMPORTS_SEPARATELY);
|
||||
isModified |= isModified(myCbUseFQClassNames, mySettings.USE_FQ_CLASS_NAMES);
|
||||
isModified |= isModified(myCbUseFQClassNamesInJavaDoc, mySettings.USE_FQ_CLASS_NAMES_IN_JAVADOC);
|
||||
isModified |= isModified(myCbUseSingleClassImports, mySettings.USE_SINGLE_CLASS_IMPORTS);
|
||||
isModified |= isModified(myCbInsertInnerClassImports, mySettings.INSERT_INNER_CLASS_IMPORTS);
|
||||
isModified |= isModified(myClassCountField, mySettings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND);
|
||||
isModified |= isModified(myNamesCountField, mySettings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND);
|
||||
isModified = isModified(myCbLayoutStaticImportsSeparately, settings.LAYOUT_STATIC_IMPORTS_SEPARATELY);
|
||||
isModified |= isModified(myCbUseFQClassNames, settings.USE_FQ_CLASS_NAMES);
|
||||
isModified |= isModified(myCbUseFQClassNamesInJavaDoc, settings.USE_FQ_CLASS_NAMES_IN_JAVADOC);
|
||||
isModified |= isModified(myCbUseSingleClassImports, settings.USE_SINGLE_CLASS_IMPORTS);
|
||||
isModified |= isModified(myCbInsertInnerClassImports, settings.INSERT_INNER_CLASS_IMPORTS);
|
||||
isModified |= isModified(myClassCountField, settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND);
|
||||
isModified |= isModified(myNamesCountField, settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND);
|
||||
|
||||
isModified |= isModified(myImportLayoutList, mySettings.IMPORT_LAYOUT_TABLE);
|
||||
isModified |= isModified(myPackageList, mySettings.PACKAGES_TO_USE_IMPORT_ON_DEMAND);
|
||||
isModified |= mySettings.JSP_PREFER_COMMA_SEPARATED_IMPORT_LIST != myJspImportCommaSeparated.isSelected();
|
||||
isModified |= isModified(myImportLayoutList, settings.IMPORT_LAYOUT_TABLE);
|
||||
isModified |= isModified(myPackageList, settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND);
|
||||
isModified |= settings.JSP_PREFER_COMMA_SEPARATED_IMPORT_LIST != myJspImportCommaSeparated.isSelected();
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return isModified(mySettings);
|
||||
}
|
||||
|
||||
private static boolean isModified(JTextField textField, int value) {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.application.options;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class CodeStyleImportsPanelWrapper extends CodeStyleAbstractPanel {
|
||||
|
||||
private CodeStyleImportsPanel myImporsPanel;
|
||||
|
||||
protected CodeStyleImportsPanelWrapper(CodeStyleSettings settings) {
|
||||
super(settings);
|
||||
myImporsPanel = new CodeStyleImportsPanel(settings);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getRightMargin() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EditorHighlighter createHighlighter(EditorColorsScheme scheme) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected FileType getFileType() {
|
||||
return JavaFileType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPreviewText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(CodeStyleSettings settings) {
|
||||
myImporsPanel.apply(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified(CodeStyleSettings settings) {
|
||||
return myImporsPanel.isModified(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPanel() {
|
||||
return myImporsPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resetImpl(CodeStyleSettings settings) {
|
||||
myImporsPanel.reset(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTabTitle() {
|
||||
return ApplicationBundle.message("title.imports");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.application.options;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class JavaCodeStyleMainPanel extends MultiTabCodeStyleAbstractPanel {
|
||||
protected JavaCodeStyleMainPanel(CodeStyleSettings settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Language getDefaultLanguage() {
|
||||
return JavaLanguage.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initTabs(CodeStyleSettings settings) {
|
||||
super.initTabs(settings);
|
||||
addTab(new JavaDocFormattingPanel(settings));
|
||||
addTab(new CodeStyleImportsPanelWrapper(settings));
|
||||
addTab(new CodeStyleGenerationWrapper(settings));
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.application.options;
|
||||
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider;
|
||||
import com.intellij.psi.codeStyle.DisplayPriority;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class JavaCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
|
||||
@NotNull
|
||||
@Override
|
||||
public Configurable createSettingsPage(CodeStyleSettings settings, CodeStyleSettings originalSettings) {
|
||||
return new CodeStyleAbstractConfigurable(settings, originalSettings, "Java") {
|
||||
protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) {
|
||||
return new JavaCodeStyleMainPanel(settings);
|
||||
}
|
||||
public String getHelpTopic() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayPriority getPriority() {
|
||||
return PlatformUtils.isIdea() ? DisplayPriority.KEY_LANGUAGE_SETTINGS : DisplayPriority.LANGUAGE_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigurableDisplayName() {
|
||||
return "Java";
|
||||
}
|
||||
}
|
||||
@@ -167,6 +167,20 @@ public class JavaDocFormattingPanel extends OptionTreeWithPreviewPanel {
|
||||
}
|
||||
|
||||
public boolean setPanelLanguage(Language language) {
|
||||
return super.setPanelLanguage(Language.findInstance(JavaLanguage.class));
|
||||
return super.setPanelLanguage(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customizeSettings() {
|
||||
resetDefaultNames();
|
||||
LanguageCodeStyleSettingsProvider provider = LanguageCodeStyleSettingsProvider.forLanguage(JavaLanguage.INSTANCE);
|
||||
if (provider != null) {
|
||||
provider.customizeSettings(this, getSettingsType());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTabTitle() {
|
||||
return ApplicationBundle.message("title.javadoc");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,14 @@ package com.intellij.ide;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.StdLanguages;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.DisplayPriority;
|
||||
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -75,6 +77,16 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
|
||||
return DisplayPriority.LANGUAGE_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonCodeStyleSettings getDefaultCommonSettings() {
|
||||
return new CommonCodeStyleSettings(JavaLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesSharedPreview() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String GENERAL_CODE_SAMPLE =
|
||||
"public class Foo {\n" +
|
||||
" public int[] X = new int[]{1, 3, 5 7, 9, 11};\n" +
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormattingDocumentModelImpl;
|
||||
import com.intellij.psi.formatter.java.AbstractJavaBlock;
|
||||
import com.intellij.psi.formatter.java.FormattingAstUtil;
|
||||
@@ -49,7 +50,8 @@ public class JavaFormattingModelBuilder implements FormattingModelBuilder {
|
||||
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
|
||||
final FileElement fileElement = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element));
|
||||
LOG.assertTrue(fileElement != null, "File element should not be null for " + element);
|
||||
Block block = AbstractJavaBlock.createJavaBlock(fileElement, settings);
|
||||
CommonCodeStyleSettings javaSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
Block block = AbstractJavaBlock.createJavaBlock(fileElement, javaSettings);
|
||||
FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
|
||||
return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), block, model);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
JavaElementType.MODIFIER_LIST, JavaElementType.TYPE, JavaTokenType.IDENTIFIER, JavaTokenType.EQ
|
||||
));
|
||||
|
||||
protected final CodeStyleSettings mySettings;
|
||||
protected final CommonCodeStyleSettings mySettings;
|
||||
protected final CodeStyleSettings.IndentOptions myIndentSettings;
|
||||
private final Indent myIndent;
|
||||
protected Indent myChildIndent;
|
||||
@@ -94,24 +94,24 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
private final AlignmentInColumnsHelper myAlignmentInColumnsHelper;
|
||||
|
||||
protected AbstractJavaBlock(final ASTNode node, final Wrap wrap, final Alignment alignment, final Indent indent,
|
||||
final CodeStyleSettings settings)
|
||||
final CommonCodeStyleSettings settings)
|
||||
{
|
||||
this(node, wrap, indent, settings, JavaWrapManager.INSTANCE, AlignmentStrategy.wrap(alignment), AlignmentInColumnsHelper.INSTANCE);
|
||||
}
|
||||
|
||||
protected AbstractJavaBlock(final ASTNode node, final Wrap wrap, final AlignmentStrategy alignmentStrategy, final Indent indent,
|
||||
final CodeStyleSettings settings)
|
||||
final CommonCodeStyleSettings settings)
|
||||
{
|
||||
this(node, wrap, indent, settings, JavaWrapManager.INSTANCE, alignmentStrategy, AlignmentInColumnsHelper.INSTANCE);
|
||||
}
|
||||
|
||||
protected AbstractJavaBlock(final ASTNode node, final Wrap wrap, final Indent indent,
|
||||
final CodeStyleSettings settings, final JavaWrapManager wrapManager,
|
||||
final CommonCodeStyleSettings settings, final JavaWrapManager wrapManager,
|
||||
@NotNull final AlignmentStrategy alignmentStrategy, AlignmentInColumnsHelper alignmentInColumnsHelper)
|
||||
{
|
||||
super(node, wrap, createBlockAlignment(alignmentStrategy, node));
|
||||
mySettings = settings;
|
||||
myIndentSettings = settings.getIndentOptions(StdFileTypes.JAVA);
|
||||
myIndentSettings = settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA);
|
||||
myIndent = indent;
|
||||
myWrapManager = wrapManager;
|
||||
myAlignmentStrategy = alignmentStrategy;
|
||||
@@ -129,7 +129,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
}
|
||||
|
||||
public static Block createJavaBlock(final ASTNode child,
|
||||
final CodeStyleSettings settings,
|
||||
final CommonCodeStyleSettings settings,
|
||||
final Indent indent,
|
||||
Wrap wrap,
|
||||
Alignment alignment) {
|
||||
@@ -137,7 +137,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
}
|
||||
|
||||
public static Block createJavaBlock(final ASTNode child,
|
||||
final CodeStyleSettings settings,
|
||||
final CommonCodeStyleSettings settings,
|
||||
final Indent indent,
|
||||
Wrap wrap,
|
||||
@NotNull AlignmentStrategy alignmentStrategy) {
|
||||
@@ -145,13 +145,13 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
}
|
||||
|
||||
public static Block createJavaBlock(final ASTNode child,
|
||||
final CodeStyleSettings settings,
|
||||
final CommonCodeStyleSettings settings,
|
||||
final Indent indent,
|
||||
Wrap wrap,
|
||||
AlignmentStrategy alignmentStrategy,
|
||||
int startOffset
|
||||
) {
|
||||
Indent actualIndent = indent == null ? getDefaultSubtreeIndent(child, settings.getIndentOptions(StdFileTypes.JAVA)) : indent;
|
||||
Indent actualIndent = indent == null ? getDefaultSubtreeIndent(child, settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA)) : indent;
|
||||
final IElementType elementType = child.getElementType();
|
||||
Alignment alignment = alignmentStrategy.getAlignment(elementType);
|
||||
|
||||
@@ -221,8 +221,8 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
|| elementType == JavaElementType.FOREACH_STATEMENT;
|
||||
}
|
||||
|
||||
public static Block createJavaBlock(final ASTNode child, final CodeStyleSettings settings) {
|
||||
return createJavaBlock(child, settings, getDefaultSubtreeIndent(child, settings.getIndentOptions(StdFileTypes.JAVA)),
|
||||
public static Block createJavaBlock(final ASTNode child, final CommonCodeStyleSettings settings) {
|
||||
return createJavaBlock(child, settings, getDefaultSubtreeIndent(child, settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA)),
|
||||
null, AlignmentStrategy.getNullStrategy());
|
||||
}
|
||||
|
||||
@@ -1346,7 +1346,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
return getChildIndent(myNode, myIndentSettings);
|
||||
}
|
||||
|
||||
public CodeStyleSettings getSettings() {
|
||||
public CommonCodeStyleSettings getSettings() {
|
||||
return mySettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.formatting.*;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
@@ -43,7 +44,7 @@ public class BlockContainingJavaBlock extends AbstractJavaBlock{
|
||||
|
||||
private final List<Indent> myIndentsBefore = new ArrayList<Indent>();
|
||||
|
||||
public BlockContainingJavaBlock(final ASTNode node, final Wrap wrap, final Alignment alignment, final Indent indent, CodeStyleSettings settings) {
|
||||
public BlockContainingJavaBlock(final ASTNode node, final Wrap wrap, final Alignment alignment, final Indent indent, CommonCodeStyleSettings settings) {
|
||||
super(node, wrap, alignment, indent, settings);
|
||||
}
|
||||
protected List<Block> buildChildren() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.formatter.common.AbstractBlock;
|
||||
import com.intellij.formatting.alignment.AlignmentStrategy;
|
||||
@@ -45,7 +46,7 @@ public class CodeBlockBlock extends AbstractJavaBlock {
|
||||
final Wrap wrap,
|
||||
final Alignment alignment,
|
||||
final Indent indent,
|
||||
final CodeStyleSettings settings) {
|
||||
final CommonCodeStyleSettings settings) {
|
||||
super(node, wrap, getAlignmentStrategy(alignment, node, settings), indent, settings);
|
||||
if (isSwitchCodeBlock() && !settings.INDENT_CASE_FROM_SWITCH) {
|
||||
myChildrenIndent = 0;
|
||||
@@ -63,7 +64,7 @@ public class CodeBlockBlock extends AbstractJavaBlock {
|
||||
* @param baseNode base AST node
|
||||
* @return alignment strategy to use for the given node
|
||||
*/
|
||||
private static AlignmentStrategy getAlignmentStrategy(Alignment alignment, ASTNode baseNode, @NotNull CodeStyleSettings settings) {
|
||||
private static AlignmentStrategy getAlignmentStrategy(Alignment alignment, ASTNode baseNode, @NotNull CommonCodeStyleSettings settings) {
|
||||
if (baseNode.getElementType() != JavaElementType.CLASS || !settings.ALIGN_MULTILINE_EXTENDS_LIST) {
|
||||
return AlignmentStrategy.wrap(alignment);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.formatting.*;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.common.InjectedLanguageBlockBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -31,7 +32,7 @@ import java.util.List;
|
||||
public class CommentWithInjectionBlock extends AbstractJavaBlock {
|
||||
private InjectedLanguageBlockBuilder myInjectedBlockBuilder;
|
||||
|
||||
public CommentWithInjectionBlock(ASTNode node, Wrap wrap, Alignment alignment, Indent indent, CodeStyleSettings settings) {
|
||||
public CommentWithInjectionBlock(ASTNode node, Wrap wrap, Alignment alignment, Indent indent, CommonCodeStyleSettings settings) {
|
||||
super(node, wrap, alignment, indent, settings);
|
||||
myInjectedBlockBuilder = new JavaCommentInjectedBlockBuilder();
|
||||
}
|
||||
@@ -62,7 +63,7 @@ public class CommentWithInjectionBlock extends AbstractJavaBlock {
|
||||
private class JavaCommentInjectedBlockBuilder extends InjectedLanguageBlockBuilder {
|
||||
@Override
|
||||
public CodeStyleSettings getSettings() {
|
||||
return mySettings;
|
||||
return mySettings.getRootSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.formatting.*;
|
||||
import com.intellij.formatting.alignment.AlignmentStrategy;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,7 +28,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DocCommentBlock extends AbstractJavaBlock{
|
||||
public DocCommentBlock(final ASTNode node, final Wrap wrap, final Alignment alignment, final Indent indent, CodeStyleSettings settings) {
|
||||
public DocCommentBlock(final ASTNode node, final Wrap wrap, final Alignment alignment, final Indent indent, CommonCodeStyleSettings settings) {
|
||||
super(node, wrap, alignment, indent, settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.formatting.Wrap;
|
||||
import com.intellij.formatting.alignment.AlignmentStrategy;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
|
||||
@@ -29,11 +30,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExtendsListBlock extends AbstractJavaBlock{
|
||||
public ExtendsListBlock(final ASTNode node, final Wrap wrap, final Alignment alignment, CodeStyleSettings settings) {
|
||||
public ExtendsListBlock(final ASTNode node, final Wrap wrap, final Alignment alignment, CommonCodeStyleSettings settings) {
|
||||
super(node, wrap, alignment, Indent.getNoneIndent(), settings);
|
||||
}
|
||||
|
||||
public ExtendsListBlock(final ASTNode node, final Wrap wrap, final AlignmentStrategy alignmentStrategy, CodeStyleSettings settings) {
|
||||
public ExtendsListBlock(final ASTNode node, final Wrap wrap, final AlignmentStrategy alignmentStrategy, CommonCodeStyleSettings settings) {
|
||||
super(node, wrap, alignmentStrategy, Indent.getNoneIndent(), settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.codeStyle.ImportHelper;
|
||||
@@ -52,7 +53,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
private PsiElement myParent;
|
||||
private int myRole1;
|
||||
private int myRole2;
|
||||
private CodeStyleSettings mySettings;
|
||||
private CommonCodeStyleSettings mySettings;
|
||||
|
||||
private Spacing myResult;
|
||||
private ASTNode myChild1;
|
||||
@@ -65,7 +66,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
|
||||
private static final ThreadLocal<JavaSpacePropertyProcessor> mySharedProcessorAllocator = new ThreadLocal<JavaSpacePropertyProcessor>();
|
||||
|
||||
private void doInit(final ASTNode child, final CodeStyleSettings settings) {
|
||||
private void doInit(final ASTNode child, final CommonCodeStyleSettings settings) {
|
||||
init(child);
|
||||
mySettings = settings;
|
||||
|
||||
@@ -511,7 +512,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
@Override public void visitImportList(PsiImportList list) {
|
||||
if (ElementType.IMPORT_STATEMENT_BASE_BIT_SET.contains(myChild1.getElementType()) &&
|
||||
ElementType.IMPORT_STATEMENT_BASE_BIT_SET.contains(myChild2.getElementType())) {
|
||||
if (myImportHelper == null) myImportHelper = new ImportHelper(mySettings);
|
||||
if (myImportHelper == null) myImportHelper = new ImportHelper(mySettings.getRootSettings());
|
||||
int emptyLines = myImportHelper.getEmptyLinesBetween(
|
||||
SourceTreeToPsiMap.<PsiImportStatementBase>treeToPsiNotNull(myChild1),
|
||||
SourceTreeToPsiMap.<PsiImportStatementBase>treeToPsiNotNull(myChild2)
|
||||
@@ -1539,7 +1540,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
@SuppressWarnings({"ConstantConditions"})
|
||||
public static Spacing getSpacing(ASTNode node, CodeStyleSettings settings) {
|
||||
public static Spacing getSpacing(ASTNode node, CommonCodeStyleSettings settings) {
|
||||
JavaSpacePropertyProcessor spacePropertyProcessor = mySharedProcessorAllocator.get();
|
||||
try {
|
||||
if (spacePropertyProcessor == null) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.formatting.alignment.AlignmentStrategy;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -32,7 +33,7 @@ public class LabeledJavaBlock extends AbstractJavaBlock{
|
||||
final Wrap wrap,
|
||||
final Alignment alignment,
|
||||
final Indent indent,
|
||||
final CodeStyleSettings settings) {
|
||||
final CommonCodeStyleSettings settings) {
|
||||
super(node, wrap, alignment, indent, settings);
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ public class LabeledJavaBlock extends AbstractJavaBlock{
|
||||
}
|
||||
|
||||
private Indent getLabelIndent() {
|
||||
if (mySettings.getIndentOptions(StdFileTypes.JAVA).LABEL_INDENT_ABSOLUTE) {
|
||||
if (mySettings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).LABEL_INDENT_ABSOLUTE) {
|
||||
return Indent.getAbsoluteLabelIndent();
|
||||
} else {
|
||||
return Indent.getLabelIndent();
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.formatting.Indent;
|
||||
import com.intellij.formatting.Wrap;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -35,7 +36,7 @@ public class PartialWhitespaceBlock extends SimpleJavaBlock {
|
||||
final Wrap wrap,
|
||||
final Alignment alignment,
|
||||
final Indent indent,
|
||||
CodeStyleSettings settings) {
|
||||
CommonCodeStyleSettings settings) {
|
||||
super(node, wrap, AlignmentStrategy.wrap(alignment), indent, settings);
|
||||
myRange = range;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
@@ -39,7 +40,7 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
|
||||
private int myStartOffset = -1;
|
||||
private final Map<IElementType, Wrap> myReservedWrap = new HashMap<IElementType, Wrap>();
|
||||
|
||||
public SimpleJavaBlock(final ASTNode node, final Wrap wrap, final AlignmentStrategy alignment, final Indent indent, CodeStyleSettings settings) {
|
||||
public SimpleJavaBlock(final ASTNode node, final Wrap wrap, final AlignmentStrategy alignment, final Indent indent, CommonCodeStyleSettings settings) {
|
||||
super(node, wrap, alignment, indent,settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.common.AbstractBlock;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -32,7 +33,7 @@ public class SyntheticCodeBlock implements Block, JavaBlock{
|
||||
private final List<Block> mySubBlocks;
|
||||
private final Alignment myAlignment;
|
||||
private final Indent myIndentContent;
|
||||
private final CodeStyleSettings mySettings;
|
||||
private final CommonCodeStyleSettings mySettings;
|
||||
private final Wrap myWrap;
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.formatter.newXmlFormatter.java.SyntheticCodeBlock");
|
||||
@@ -44,7 +45,7 @@ public class SyntheticCodeBlock implements Block, JavaBlock{
|
||||
|
||||
public SyntheticCodeBlock(final List<Block> subBlocks,
|
||||
final Alignment alignment,
|
||||
CodeStyleSettings settings,
|
||||
CommonCodeStyleSettings settings,
|
||||
Indent indent,
|
||||
Wrap wrap) {
|
||||
myIndentContent = indent;
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.formatting.Block;
|
||||
import com.intellij.formatting.Wrap;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.java.wrap.impl.JavaChildBlockWrapFactory;
|
||||
import com.intellij.psi.formatter.java.wrap.impl.JavaChildWrapArranger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -77,7 +78,7 @@ public class JavaWrapManager {
|
||||
* <code>null</code> otherwise
|
||||
*/
|
||||
@Nullable
|
||||
public Wrap arrangeChildWrap(ASTNode child, ASTNode parent, CodeStyleSettings settings, Wrap suggestedWrap,
|
||||
public Wrap arrangeChildWrap(ASTNode child, ASTNode parent, CommonCodeStyleSettings settings, Wrap suggestedWrap,
|
||||
ReservedWrapsProvider reservedWrapsProvider)
|
||||
{
|
||||
return myChildArranger.arrange(child, parent, settings, suggestedWrap, reservedWrapsProvider);
|
||||
@@ -94,7 +95,7 @@ public class JavaWrapManager {
|
||||
* @return wrap to use for the sub-blocks of the given block
|
||||
*/
|
||||
@Nullable
|
||||
public Wrap createChildBlockWrap(ASTBlock block, CodeStyleSettings settings, ReservedWrapsProvider reservedWrapsProvider) {
|
||||
public Wrap createChildBlockWrap(ASTBlock block, CommonCodeStyleSettings settings, ReservedWrapsProvider reservedWrapsProvider) {
|
||||
return myChildBlockFactory.create(block, settings, reservedWrapsProvider);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.intellij.formatting.Wrap;
|
||||
import com.intellij.formatting.WrapType;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiPolyadicExpression;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.java.FormattingAstUtil;
|
||||
import com.intellij.psi.formatter.java.wrap.ReservedWrapsProvider;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
@@ -49,7 +49,7 @@ public class JavaChildBlockWrapFactory {
|
||||
* @return wrap to use for the sub-blocks of the given block
|
||||
*/
|
||||
@Nullable
|
||||
public Wrap create(ASTBlock block, CodeStyleSettings settings, ReservedWrapsProvider reservedWrapsProvider) {
|
||||
public Wrap create(ASTBlock block, CommonCodeStyleSettings settings, ReservedWrapsProvider reservedWrapsProvider) {
|
||||
ASTNode node = block.getNode();
|
||||
Wrap wrap = block.getWrap();
|
||||
final IElementType nodeType = node.getElementType();
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.PsiPolyadicExpression;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.java.FormattingAstUtil;
|
||||
import com.intellij.psi.formatter.java.wrap.JavaWrapManager;
|
||||
import com.intellij.psi.formatter.java.wrap.ReservedWrapsProvider;
|
||||
@@ -63,7 +64,7 @@ public class JavaChildWrapArranger {
|
||||
*/
|
||||
@SuppressWarnings({"MethodMayBeStatic"})
|
||||
@Nullable
|
||||
public Wrap arrange(ASTNode child, ASTNode parent, CodeStyleSettings settings, Wrap suggestedWrap, ReservedWrapsProvider reservedWrapsProvider) {
|
||||
public Wrap arrange(ASTNode child, ASTNode parent, CommonCodeStyleSettings settings, Wrap suggestedWrap, ReservedWrapsProvider reservedWrapsProvider) {
|
||||
ASTNode directParent = child.getTreeParent();
|
||||
int role = ((CompositeElement)directParent).getChildRole(child);
|
||||
final IElementType nodeType = parent.getElementType();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.codeStyle;
|
||||
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
@@ -35,7 +36,7 @@ public class BraceEnforcer extends JavaJspRecursiveElementVisitor {
|
||||
private final PostFormatProcessorHelper myPostProcessor;
|
||||
|
||||
public BraceEnforcer(CodeStyleSettings settings) {
|
||||
myPostProcessor = new PostFormatProcessorHelper(settings);
|
||||
myPostProcessor = new PostFormatProcessorHelper(settings.getCommonSettings(JavaLanguage.INSTANCE));
|
||||
}
|
||||
|
||||
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
@@ -50,10 +51,10 @@ public class BraceEnforcer extends JavaJspRecursiveElementVisitor {
|
||||
if (statement == null) {
|
||||
return;
|
||||
}
|
||||
processStatement(statement, statement.getThenBranch(), myPostProcessor.mySettings.IF_BRACE_FORCE);
|
||||
processStatement(statement, statement.getThenBranch(), myPostProcessor.getSettings().IF_BRACE_FORCE);
|
||||
final PsiStatement elseBranch = statement.getElseBranch();
|
||||
if (!(elseBranch instanceof PsiIfStatement) || !myPostProcessor.mySettings.SPECIAL_ELSE_IF_TREATMENT) {
|
||||
processStatement(statement, elseBranch, myPostProcessor.mySettings.IF_BRACE_FORCE);
|
||||
if (!(elseBranch instanceof PsiIfStatement) || !myPostProcessor.getSettings().SPECIAL_ELSE_IF_TREATMENT) {
|
||||
processStatement(statement, elseBranch, myPostProcessor.getSettings().IF_BRACE_FORCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,28 +62,28 @@ public class BraceEnforcer extends JavaJspRecursiveElementVisitor {
|
||||
@Override public void visitForStatement(PsiForStatement statement) {
|
||||
if (checkElementContainsRange(statement)) {
|
||||
super.visitForStatement(statement);
|
||||
processStatement(statement, statement.getBody(), myPostProcessor.mySettings.FOR_BRACE_FORCE);
|
||||
processStatement(statement, statement.getBody(), myPostProcessor.getSettings().FOR_BRACE_FORCE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitForeachStatement(PsiForeachStatement statement) {
|
||||
if (checkElementContainsRange(statement)) {
|
||||
super.visitForeachStatement(statement);
|
||||
processStatement(statement, statement.getBody(), myPostProcessor.mySettings.FOR_BRACE_FORCE);
|
||||
processStatement(statement, statement.getBody(), myPostProcessor.getSettings().FOR_BRACE_FORCE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitWhileStatement(PsiWhileStatement statement) {
|
||||
if (checkElementContainsRange(statement)) {
|
||||
super.visitWhileStatement(statement);
|
||||
processStatement(statement, statement.getBody(), myPostProcessor.mySettings.WHILE_BRACE_FORCE);
|
||||
processStatement(statement, statement.getBody(), myPostProcessor.getSettings().WHILE_BRACE_FORCE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitDoWhileStatement(PsiDoWhileStatement statement) {
|
||||
if (checkElementContainsRange(statement)) {
|
||||
super.visitDoWhileStatement(statement);
|
||||
processStatement(statement, statement.getBody(), myPostProcessor.mySettings.DOWHILE_BRACE_FORCE);
|
||||
processStatement(statement, statement.getBody(), myPostProcessor.getSettings().DOWHILE_BRACE_FORCE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi.formatter.java;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -33,6 +34,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -82,12 +84,13 @@ public abstract class AbstractJavaFormatterTest extends LightIdeaTestCase {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
|
||||
}
|
||||
|
||||
public static CodeStyleSettings getSettings() {
|
||||
return CodeStyleSettingsManager.getSettings(getProject());
|
||||
public static CommonCodeStyleSettings getSettings() {
|
||||
CodeStyleSettings rootSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
return rootSettings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
public static CodeStyleSettings.IndentOptions getIndentOptions() {
|
||||
return getSettings().getIndentOptions(StdFileTypes.JAVA);
|
||||
return getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA);
|
||||
}
|
||||
|
||||
public void doTest() throws Exception {
|
||||
|
||||
+4
-4
@@ -32,13 +32,13 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest {
|
||||
// Inspired by IDEA-30369
|
||||
getSettings().ALIGN_MULTILINE_CHAINED_METHODS = true;
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 8;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 8;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMultipleMethodAnnotationsCommentedInTheMiddle() throws Exception {
|
||||
getSettings().BLANK_LINES_AFTER_CLASS_HEADER = 1;
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 4;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 4;
|
||||
|
||||
// Inspired by IDEA-53942
|
||||
doTextTest(
|
||||
@@ -71,8 +71,8 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest {
|
||||
public void testMethodCallArgumentsAndSmartTabs() throws IncorrectOperationException {
|
||||
// Inspired by IDEADEV-20144.
|
||||
getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
|
||||
doTextTest("class Foo {\n" +
|
||||
" void foo() {\n" +
|
||||
" bar(new Object[] {\n" +
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ public class JavaFormatterIndentationTest extends AbstractJavaFormatterTest {
|
||||
public void testNestedMethodsIndentation() throws Exception {
|
||||
// Inspired by IDEA-43962
|
||||
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 4;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 4;
|
||||
|
||||
doMethodTest(
|
||||
"BigDecimal.ONE\n" +
|
||||
@@ -89,7 +89,7 @@ public class JavaFormatterIndentationTest extends AbstractJavaFormatterTest {
|
||||
public void testShiftedChainedIfElse() throws Exception {
|
||||
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED2;
|
||||
getSettings().ELSE_ON_NEW_LINE = true;
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 4;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 4;
|
||||
doMethodTest(
|
||||
"long a = System.currentTimeMillis();\n" +
|
||||
" if (a == 0){\n" +
|
||||
@@ -127,7 +127,7 @@ public class JavaFormatterIndentationTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testAlignedSubBlockIndentation() {
|
||||
getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 8;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 8;
|
||||
|
||||
// Inspired by IDEA-54671
|
||||
doTextTest(
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ public class JavaFormatterNewLineTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testClassInitializationBlockBracesPlacement() throws Exception {
|
||||
// Inspired by IDEA-54191
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 4;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 4;
|
||||
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false;
|
||||
doMethodTest(
|
||||
"new Expectations() {\n" +
|
||||
|
||||
@@ -39,11 +39,11 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testLabel1() throws Exception {
|
||||
CodeStyleSettings settings = getSettings();
|
||||
CommonCodeStyleSettings settings = getSettings();
|
||||
|
||||
settings.LABELED_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
|
||||
settings.getIndentOptions(StdFileTypes.JAVA).LABEL_INDENT_ABSOLUTE = true;
|
||||
settings.getIndentOptions(StdFileTypes.JAVA).LABEL_INDENT_SIZE = 0;
|
||||
settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).LABEL_INDENT_ABSOLUTE = true;
|
||||
settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).LABEL_INDENT_SIZE = 0;
|
||||
|
||||
doTest("Label.java", "Label_after1.java");
|
||||
}
|
||||
@@ -54,20 +54,20 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testNullMethodParameter() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
|
||||
settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
doTest("NullMethodParameter.java", "NullMethodParameter_after.java");
|
||||
}
|
||||
|
||||
public void testNew() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
settings.getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 8;
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 8;
|
||||
doTest("New.java", "New_after.java");
|
||||
}
|
||||
|
||||
public void testJavaDoc() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.BLANK_LINES_AROUND_FIELD = 1;
|
||||
doTest("JavaDoc.java", "JavaDoc_after.java");
|
||||
}
|
||||
@@ -82,8 +82,8 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testCastInsideElse() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(StdFileTypes.JAVA);
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
final CodeStyleSettings.IndentOptions indentOptions = settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA);
|
||||
indentOptions.CONTINUATION_INDENT_SIZE = 2;
|
||||
indentOptions.INDENT_SIZE = 2;
|
||||
indentOptions.LABEL_INDENT_SIZE = 0;
|
||||
@@ -95,7 +95,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testAlignMultiLine() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION = true;
|
||||
settings.ALIGN_MULTILINE_BINARY_OPERATION = true;
|
||||
doTest();
|
||||
@@ -106,7 +106,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testSynchronizedBlock() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.SPACE_BEFORE_SYNCHRONIZED_PARENTHESES = false;
|
||||
settings.SPACE_WITHIN_SYNCHRONIZED_PARENTHESES = false;
|
||||
settings.SPACE_BEFORE_SYNCHRONIZED_LBRACE = false;
|
||||
@@ -114,8 +114,8 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testMethodCallInAssignment() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
settings.getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 8;
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 8;
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testIfElse() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.IF_BRACE_FORCE = CommonCodeStyleSettings.DO_NOT_FORCE;
|
||||
settings.FOR_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE;
|
||||
settings.WHILE_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE;
|
||||
@@ -159,7 +159,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testIfBraces() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
|
||||
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
|
||||
settings.KEEP_LINE_BREAKS = false;
|
||||
@@ -167,7 +167,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testTernaryExpression() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.ALIGN_MULTILINE_TERNARY_OPERATION = true;
|
||||
doTest();
|
||||
|
||||
@@ -177,14 +177,14 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testAlignAssignment() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.ALIGN_MULTILINE_ASSIGNMENT = true;
|
||||
settings.ALIGN_MULTILINE_BINARY_OPERATION = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAlignFor() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.ALIGN_MULTILINE_BINARY_OPERATION = true;
|
||||
settings.ALIGN_MULTILINE_FOR = true;
|
||||
doTest();
|
||||
@@ -199,7 +199,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testIf() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
doTest();
|
||||
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
|
||||
@@ -211,19 +211,19 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void test2() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBlocks() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.KEEP_LINE_BREAKS = false;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBinaryOperation() throws IncorrectOperationException {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
|
||||
@NonNls String text = "class Foo {\n" + " void foo () {\n" + " xxx = aaa + bbb \n" + " + ccc + eee + ddd;\n" + " }\n" + "}";
|
||||
|
||||
@@ -328,7 +328,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testStringBinaryOperation() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
|
||||
settings.ALIGN_MULTILINE_ASSIGNMENT = false;
|
||||
settings.ALIGN_MULTILINE_BINARY_OPERATION = false;
|
||||
@@ -354,7 +354,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testBraces() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
|
||||
@NonNls final String text =
|
||||
"class Foo {\n" +
|
||||
@@ -436,7 +436,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testExtendsList() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.ALIGN_MULTILINE_EXTENDS_LIST = true;
|
||||
doTextTest("class A extends B, \n" + "C {}", "class A extends B,\n" + " C {\n}");
|
||||
}
|
||||
@@ -491,7 +491,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testSpaceAroundField() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.BLANK_LINES_AROUND_FIELD = 1;
|
||||
|
||||
doTextTest("class Foo {\n" +
|
||||
@@ -517,7 +517,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testArray() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.SPACE_WITHIN_ARRAY_INITIALIZER_BRACES = true;
|
||||
settings.SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE = true;
|
||||
doTextTest("class a {\n" + " void f() {\n" + " final int[] i = new int[]{0};\n" + " }\n" + "}",
|
||||
@@ -633,7 +633,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testDoNotIndentCaseFromSwitch() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.INDENT_CASE_FROM_SWITCH = false;
|
||||
doTextTest("class A {\n" + "void foo() {\n" + "switch(a){\n" + "case 1: \n" + "break;\n" + "}\n" + "}\n" + "}", "class A {\n" +
|
||||
" void foo() {\n" +
|
||||
@@ -646,7 +646,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testClass2() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.KEEP_FIRST_COLUMN_COMMENT = false;
|
||||
doTextTest("class A {\n" + "// comment before\n" + "protected Object a;// comment after\n" + "}",
|
||||
"class A {\n" + " // comment before\n" + " protected Object a;// comment after\n" + "}");
|
||||
@@ -658,14 +658,14 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testParametersAlignment() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
settings.RIGHT_MARGIN = 140;
|
||||
settings.getRootSettings().RIGHT_MARGIN = 140;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testConditionalExpression() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.SPACE_BEFORE_QUEST = true;
|
||||
settings.SPACE_AFTER_QUEST = false;
|
||||
settings.SPACE_BEFORE_COLON = true;
|
||||
@@ -781,7 +781,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testLBraceAfterComment() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.KEEP_LINE_BREAKS = false;
|
||||
doTextTest("public class Foo {\n" +
|
||||
" public int foo() {\n" +
|
||||
@@ -803,7 +803,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testSpaces() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.SPACE_WITHIN_FOR_PARENTHESES = true;
|
||||
settings.SPACE_WITHIN_IF_PARENTHESES = true;
|
||||
settings.SPACE_WITHIN_METHOD_PARENTHESES = true;
|
||||
@@ -814,7 +814,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testSpacesBeforeLBrace() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.SPACE_BEFORE_CLASS_LBRACE = true;
|
||||
settings.SPACE_BEFORE_METHOD_LBRACE = true;
|
||||
settings.SPACE_BEFORE_IF_LBRACE = true;
|
||||
@@ -849,7 +849,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testCommentBeforeField() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.KEEP_LINE_BREAKS = false;
|
||||
settings.KEEP_FIRST_COLUMN_COMMENT = false;
|
||||
settings.KEEP_CONTROL_STATEMENT_IN_ONE_LINE = false;
|
||||
@@ -859,8 +859,8 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testLabel() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
settings.getIndentOptions(StdFileTypes.JAVA).LABEL_INDENT_ABSOLUTE = true;
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).LABEL_INDENT_ABSOLUTE = true;
|
||||
settings.SPECIAL_ELSE_IF_TREATMENT = true;
|
||||
settings.FOR_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
|
||||
myTextRange = new TextRange(59, 121);
|
||||
@@ -882,7 +882,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testSpacesInsideEmptyParentheses() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.SPACE_WITHIN_METHOD_PARENTHESES = true;
|
||||
settings.SPACE_WITHIN_METHOD_CALL_PARENTHESES = true;
|
||||
|
||||
@@ -909,7 +909,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
public void testBraceOnNewLineIfWrapped() throws Exception {
|
||||
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
|
||||
getSettings().RIGHT_MARGIN = 35;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 35;
|
||||
getSettings().ALIGN_MULTILINE_BINARY_OPERATION = true;
|
||||
|
||||
doTextTest("class Foo {\n" +
|
||||
@@ -934,7 +934,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testFirstArgumentWrapping() throws Exception {
|
||||
getSettings().RIGHT_MARGIN = 20;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 20;
|
||||
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
doTextTest("class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(1);" + " }\n" + "}",
|
||||
"class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(\n" + " 1);\n" + " }\n" + "}");
|
||||
@@ -962,7 +962,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
public void testAssertStatementWrapping() throws Exception {
|
||||
getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
|
||||
getSettings().RIGHT_MARGIN = 40;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 40;
|
||||
final JavaPsiFacade facade = getJavaFacade();
|
||||
final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
|
||||
try {
|
||||
@@ -1007,9 +1007,9 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
public void testAssertStatementWrapping2() throws Exception {
|
||||
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
|
||||
getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().RIGHT_MARGIN = 37;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 37;
|
||||
|
||||
final CodeStyleSettings.IndentOptions options = getSettings().getIndentOptions(StdFileTypes.JAVA);
|
||||
final CodeStyleSettings.IndentOptions options = getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA);
|
||||
options.INDENT_SIZE = 2;
|
||||
options.CONTINUATION_INDENT_SIZE = 2;
|
||||
|
||||
@@ -1048,9 +1048,9 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 2;
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 2;
|
||||
getSettings().RIGHT_MARGIN = 37;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 2;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 2;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 37;
|
||||
getSettings().ALIGN_MULTILINE_EXTENDS_LIST = true;
|
||||
|
||||
getSettings().EXTENDS_KEYWORD_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
@@ -1087,13 +1087,13 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testLBrace() throws Exception {
|
||||
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
|
||||
getSettings().RIGHT_MARGIN = 14;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 14;
|
||||
doTextTest("class Foo {\n" + " void foo() {\n" + " \n" + " }\n" + "}",
|
||||
"class Foo {\n" + " void foo() {\n" + "\n" + " }\n" + "}");
|
||||
}
|
||||
|
||||
public void testJavaDocLeadingAsterisksAreDisabled() throws Exception {
|
||||
getSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = false;
|
||||
getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = false;
|
||||
doTextTest("class Foo {\n" +
|
||||
" /**\n" +
|
||||
" @param i\n" +
|
||||
@@ -1196,7 +1196,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
public void testArrayInitializerWrapping() throws Exception {
|
||||
getSettings().ARRAY_INITIALIZER_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION = false;
|
||||
getSettings().RIGHT_MARGIN = 37;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 37;
|
||||
|
||||
doTextTest("class Foo{\n" +
|
||||
" public int[] i = new int[]{1,2,3,4,5,6,7,8,9};\n" +
|
||||
@@ -1236,11 +1236,11 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testJavaDocIndentation() throws Exception {
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 2;
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 2;
|
||||
getSettings().getIndentOptions(StdFileTypes.JAVA).TAB_SIZE = 4;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 2;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 2;
|
||||
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).TAB_SIZE = 4;
|
||||
|
||||
getSettings().ENABLE_JAVADOC_FORMATTING = false;
|
||||
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = false;
|
||||
|
||||
doTextTest("public interface PsiParser {\n" +
|
||||
" /**\n" +
|
||||
@@ -1539,7 +1539,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
getSettings().KEEP_CONTROL_STATEMENT_IN_ONE_LINE = true;
|
||||
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
|
||||
getSettings().ELSE_ON_NEW_LINE = false;
|
||||
getSettings().RIGHT_MARGIN = 110;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 110;
|
||||
getSettings().KEEP_LINE_BREAKS = false;
|
||||
doTextTest("class Foo {\n" +
|
||||
" void foo() {\n" +
|
||||
@@ -1692,7 +1692,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testFormatComments() throws Exception {
|
||||
getSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
doTextTest("public class Test {\n" + "\n" + " /**\n" + " * The s property.\n" + " */\n" + " private String s;\n" + "}",
|
||||
"public class Test {\n" + "\n" + " /**\n" + " * The s property.\n" + " */\n" + " private String s;\n" + "}");
|
||||
|
||||
@@ -1700,7 +1700,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testDoNotWrapLBrace() throws IncorrectOperationException {
|
||||
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
|
||||
getSettings().RIGHT_MARGIN = 66;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 66;
|
||||
doTextTest("public class Test {\n" +
|
||||
" void foo(){\n" +
|
||||
" if (veryLongIdentifier1 == 1 && veryLongIdentifier2 == 2) {\n" +
|
||||
@@ -1720,7 +1720,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
getSettings().ARRAY_INITIALIZER_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE = true;
|
||||
getSettings().ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE = true;
|
||||
getSettings().RIGHT_MARGIN = 40;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 40;
|
||||
doTextTest("class Foo {\n" + " int[] a = new int[]{1,2,0x0052,0x0053,0x0054,0x0054,0x0054};\n" + "}", "class Foo {\n" +
|
||||
" int[] a = new int[]{\n" +
|
||||
" 1, 2, 0x0052, 0x0053,\n" +
|
||||
@@ -1770,7 +1770,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testWrapExtendsList() throws Exception {
|
||||
getSettings().RIGHT_MARGIN = 50;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 50;
|
||||
getSettings().EXTENDS_LIST_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
|
||||
getSettings().EXTENDS_KEYWORD_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
|
||||
@@ -1781,7 +1781,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testWrapLongExpression() throws Exception {
|
||||
getSettings().RIGHT_MARGIN = 80;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 80;
|
||||
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().ALIGN_MULTILINE_BINARY_OPERATION = true;
|
||||
doTextTest("class Foo {\n" +
|
||||
@@ -1799,7 +1799,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testDoNotWrapCallChainIfParametersWrapped() throws Exception {
|
||||
getSettings().RIGHT_MARGIN = 87;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 87;
|
||||
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
@@ -1833,7 +1833,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testRightMargin_2() throws Exception {
|
||||
getSettings().RIGHT_MARGIN = 65;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 65;
|
||||
getSettings().ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE = true;
|
||||
getSettings().KEEP_LINE_BREAKS = false;
|
||||
@@ -1846,7 +1846,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testRightMargin_3() throws Exception {
|
||||
getSettings().RIGHT_MARGIN = 65;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 65;
|
||||
getSettings().ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE = false;
|
||||
getSettings().KEEP_LINE_BREAKS = false;
|
||||
@@ -1971,7 +1971,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testSCR429() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.KEEP_BLANK_LINES_IN_CODE = 2;
|
||||
settings.KEEP_BLANK_LINES_BEFORE_RBRACE = 2;
|
||||
settings.KEEP_BLANK_LINES_IN_DECLARATIONS = 2;
|
||||
@@ -1979,9 +1979,9 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testSCR548() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
settings.getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 4;
|
||||
settings.getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 2;
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 4;
|
||||
settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 2;
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -2030,7 +2030,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testSCR260() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
|
||||
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
|
||||
settings.KEEP_LINE_BREAKS = false;
|
||||
@@ -2038,7 +2038,7 @@ public void testSCR260() throws Exception {
|
||||
}
|
||||
|
||||
public void testSCR114() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
settings.CATCH_ON_NEW_LINE = true;
|
||||
doTest();
|
||||
@@ -2046,40 +2046,40 @@ public void testSCR260() throws Exception {
|
||||
|
||||
public void testSCR259() throws Exception {
|
||||
myTextRange = new TextRange(36, 60);
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
|
||||
settings.KEEP_LINE_BREAKS = false;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSCR279() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.ALIGN_MULTILINE_BINARY_OPERATION = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSCR395() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSCR11799() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
settings.getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 4;
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 4;
|
||||
settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSCR501() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.KEEP_FIRST_COLUMN_COMMENT = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSCR879() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
doTest();
|
||||
}
|
||||
@@ -2107,8 +2107,8 @@ public void testSCR260() throws Exception {
|
||||
}
|
||||
|
||||
public void testSCR479() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
settings.RIGHT_MARGIN = 80;
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.getRootSettings().RIGHT_MARGIN = 80;
|
||||
settings.TERNARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
doTextTest("public class Foo {\n" +
|
||||
" public static void main(String[] args) {\n" +
|
||||
@@ -2124,7 +2124,7 @@ public void testSCR260() throws Exception {
|
||||
}
|
||||
|
||||
public void testSCR190() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.KEEP_LINE_BREAKS = false;
|
||||
doTextTest("public class EntityObject \n" +
|
||||
"{ \n" +
|
||||
@@ -2153,7 +2153,7 @@ public void testSCR260() throws Exception {
|
||||
}
|
||||
|
||||
public void testSCR1535() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
@@ -2176,7 +2176,7 @@ public void testSCR260() throws Exception {
|
||||
}
|
||||
|
||||
public void testSCR970() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.THROWS_KEYWORD_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
|
||||
settings.THROWS_LIST_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
settings.METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
@@ -2192,7 +2192,7 @@ public void testSCR260() throws Exception {
|
||||
}
|
||||
|
||||
public void test1607() throws Exception {
|
||||
getSettings().RIGHT_MARGIN = 30;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 30;
|
||||
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
|
||||
getSettings().ALIGN_MULTILINE_PARAMETERS = true;
|
||||
@@ -2273,7 +2273,7 @@ public void testSCR260() throws Exception {
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
getSettings().RIGHT_MARGIN = 80;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 80;
|
||||
|
||||
getSettings().PREFER_PARAMETERS_WRAP = true;
|
||||
|
||||
@@ -2394,7 +2394,7 @@ public void testSCR260() throws Exception {
|
||||
}
|
||||
|
||||
public void test1980() throws Exception {
|
||||
getSettings().RIGHT_MARGIN = 144;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 144;
|
||||
getSettings().TERNARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().ALIGN_MULTILINE_TERNARY_OPERATION = true;
|
||||
@@ -2525,7 +2525,7 @@ public void testSCR260() throws Exception {
|
||||
public void testSCRIDEA_4783() throws IncorrectOperationException {
|
||||
getSettings().ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().RIGHT_MARGIN = 80;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 80;
|
||||
|
||||
doTextTest("class Foo{\n" +
|
||||
" void foo() {\n" +
|
||||
@@ -2657,7 +2657,7 @@ public void testSCR260() throws Exception {
|
||||
doTextTest("class Foo {\n" + " void foo() {\n" + " while(true) foo();\n" + " }\n" + "}",
|
||||
"class Foo {\n" + " void foo() {\n" + " while (true) foo();\n" + " }\n" + "}");
|
||||
|
||||
getSettings().RIGHT_MARGIN = 17;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 17;
|
||||
|
||||
doTextTest("class Foo {\n" + " void foo() {\n" + " if (a) foo();\n" + " else bar();\n" + " }\n" + "}",
|
||||
"class Foo {\n" +
|
||||
@@ -2669,7 +2669,7 @@ public void testSCR260() throws Exception {
|
||||
" }\n" +
|
||||
"}");
|
||||
|
||||
getSettings().RIGHT_MARGIN = 30;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 30;
|
||||
|
||||
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int i = 0; i < 10; i++) foo();\n" + " }\n" + "}",
|
||||
"class Foo {\n" +
|
||||
@@ -2679,12 +2679,12 @@ public void testSCR260() throws Exception {
|
||||
" }\n" +
|
||||
"}");
|
||||
|
||||
getSettings().RIGHT_MARGIN = 32;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 32;
|
||||
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int var : vars) foo();\n" + " }\n" + "}",
|
||||
"class Foo {\n" + " void foo() {\n" + " for (int var : vars)\n" + " foo();\n" + " }\n" + "}");
|
||||
|
||||
|
||||
getSettings().RIGHT_MARGIN = 12;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 12;
|
||||
doTextTest("class Foo {\n" + " void foo() {\n" + " do foo(); while (true);\n" + " }\n" + "}", "class Foo {\n" +
|
||||
" void foo() {\n" +
|
||||
" do\n" +
|
||||
@@ -2693,7 +2693,7 @@ public void testSCR260() throws Exception {
|
||||
" }\n" +
|
||||
"}");
|
||||
|
||||
getSettings().RIGHT_MARGIN = 23;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 23;
|
||||
|
||||
doTextTest("class Foo {\n" + " void foo() {\n" + " while(true) foo();\n" + " }\n" + "}",
|
||||
"class Foo {\n" + " void foo() {\n" + " while (true)\n" + " foo();\n" + " }\n" + "}");
|
||||
@@ -2707,7 +2707,7 @@ public void testSCR260() throws Exception {
|
||||
}
|
||||
|
||||
public void testSCR3115() throws Exception {
|
||||
final CodeStyleSettings.IndentOptions indentOptions = getSettings().getIndentOptions(StdFileTypes.JAVA);
|
||||
final CodeStyleSettings.IndentOptions indentOptions = getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA);
|
||||
indentOptions.USE_TAB_CHARACTER = true;
|
||||
indentOptions.SMART_TABS = true;
|
||||
|
||||
@@ -2731,7 +2731,7 @@ public void testSCR260() throws Exception {
|
||||
}
|
||||
|
||||
public void testIDEADEV_6239() throws Exception {
|
||||
getSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
doTextTest("public class Test {\n" +
|
||||
"\n" +
|
||||
" /**\n" +
|
||||
@@ -2809,7 +2809,7 @@ public void testSCR260() throws Exception {
|
||||
|
||||
public void testIDEADEV_12836() throws IncorrectOperationException {
|
||||
getSettings().SPECIAL_ELSE_IF_TREATMENT = true;
|
||||
getSettings().RIGHT_MARGIN = 80;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 80;
|
||||
doTextTest("class Foo {\n" +
|
||||
"void foo(){\n" +
|
||||
"if (true){\n" +
|
||||
@@ -2888,7 +2888,7 @@ public void testSCR260() throws Exception {
|
||||
public void testIDEADEV_23551() throws IncorrectOperationException {
|
||||
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
|
||||
|
||||
getSettings().RIGHT_MARGIN = 60;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 60;
|
||||
doTextTest("public class Wrapping {\n" +
|
||||
"public static void sample() {\n" +
|
||||
"System.out.println(\".\" + File.separator + \"..\" + File.separator + \"some-directory-name\" + File.separator + \"more-file-name\");\n" +
|
||||
|
||||
+11
-11
@@ -27,7 +27,7 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testWrappingAnnotationArrayParameters() throws Exception {
|
||||
getSettings().RIGHT_MARGIN = 80;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 80;
|
||||
getSettings().ARRAY_INITIALIZER_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
doTextTest(
|
||||
"@AttributeOverrides( { @AttributeOverride(name = \"id\", column = @Column(name = \"recovery_id\"))," +
|
||||
@@ -59,7 +59,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testAnnotationParamValueExceedingRightMargin() throws Exception {
|
||||
// Inspired by IDEA-18051
|
||||
getSettings().RIGHT_MARGIN = 80;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 80;
|
||||
doTextTest(
|
||||
"package formatting;\n" +
|
||||
"\n" +
|
||||
@@ -120,7 +120,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
public void testEnumConstantsWrapping() {
|
||||
// Inspired by IDEA-54667
|
||||
getSettings().ENUM_CONSTANTS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().RIGHT_MARGIN = 80;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 80;
|
||||
|
||||
// Don't expect the constants to be placed on new line.
|
||||
doTextTest(
|
||||
@@ -153,8 +153,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testWrapLongLine() {
|
||||
// Inspired by IDEA-55782
|
||||
getSettings().RIGHT_MARGIN = 50;
|
||||
getSettings().WRAP_LONG_LINES = true;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 50;
|
||||
getSettings().getRootSettings().WRAP_LONG_LINES = true;
|
||||
|
||||
doTextTest(
|
||||
"class TestClass {\n" +
|
||||
@@ -182,8 +182,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testWrapLongLineWithTabs() {
|
||||
// Inspired by IDEA-55782
|
||||
getSettings().RIGHT_MARGIN = 20;
|
||||
getSettings().WRAP_LONG_LINES = true;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 20;
|
||||
getSettings().getRootSettings().WRAP_LONG_LINES = true;
|
||||
getIndentOptions().USE_TAB_CHARACTER = true;
|
||||
getIndentOptions().TAB_SIZE = 4;
|
||||
|
||||
@@ -200,8 +200,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testWrapLongLineWithSelection() {
|
||||
// Inspired by IDEA-55782
|
||||
getSettings().RIGHT_MARGIN = 20;
|
||||
getSettings().WRAP_LONG_LINES = true;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 20;
|
||||
getSettings().getRootSettings().WRAP_LONG_LINES = true;
|
||||
|
||||
String initial =
|
||||
"class TestClass {\n" +
|
||||
@@ -227,7 +227,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testWrapMethodAnnotationBeforeParams() throws Exception {
|
||||
// Inspired by IDEA-59536
|
||||
getSettings().RIGHT_MARGIN = 90;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 90;
|
||||
getSettings().METHOD_ANNOTATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
getSettings().METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
|
||||
@@ -268,7 +268,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testResourceListWrap() throws Exception {
|
||||
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
|
||||
getSettings().RIGHT_MARGIN = 40;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 40;
|
||||
getSettings().RESOURCE_LIST_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
|
||||
doMethodTest("try (MyResource r1 = null; MyResource r2 = null) { }",
|
||||
"try (MyResource r1 = null;\n" +
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package com.intellij.psi.formatter.java;
|
||||
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
@@ -24,8 +25,8 @@ import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
public class JavadocFormatterTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testRightMargin() throws Exception {
|
||||
getSettings().WRAP_COMMENTS = true;
|
||||
getSettings().RIGHT_MARGIN = 35;// |
|
||||
getSettings().getRootSettings().WRAP_LONG_LINES = true;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 35;// |
|
||||
doTextTest(
|
||||
"/** Here is one-line java-doc comment */" +
|
||||
"class Foo {\n" +
|
||||
@@ -41,9 +42,9 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testLineFeedsArePreservedDuringWrap() {
|
||||
// Inspired by IDEA-61895
|
||||
getSettings().WRAP_COMMENTS = true;
|
||||
getSettings().JD_PRESERVE_LINE_FEEDS = true;
|
||||
getSettings().RIGHT_MARGIN = 48;
|
||||
getSettings().getRootSettings().WRAP_COMMENTS = true;
|
||||
getSettings().getRootSettings().JD_PRESERVE_LINE_FEEDS = true;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 48;
|
||||
|
||||
doTextTest(
|
||||
"/**\n" +
|
||||
@@ -63,19 +64,19 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest {
|
||||
}
|
||||
|
||||
public void testSCR11296() throws Exception {
|
||||
final CodeStyleSettings settings = getSettings();
|
||||
settings.RIGHT_MARGIN = 50;
|
||||
settings.WRAP_COMMENTS = true;
|
||||
settings.ENABLE_JAVADOC_FORMATTING = true;
|
||||
settings.JD_P_AT_EMPTY_LINES = false;
|
||||
settings.JD_KEEP_EMPTY_LINES = false;
|
||||
final CommonCodeStyleSettings settings = getSettings();
|
||||
settings.getRootSettings().RIGHT_MARGIN = 50;
|
||||
settings.getRootSettings().WRAP_COMMENTS = true;
|
||||
settings.getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
settings.getRootSettings().JD_P_AT_EMPTY_LINES = false;
|
||||
settings.getRootSettings().JD_KEEP_EMPTY_LINES = false;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSCR2632() throws Exception {
|
||||
getSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
getSettings().WRAP_COMMENTS = true;
|
||||
getSettings().RIGHT_MARGIN = 20;
|
||||
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
getSettings().getRootSettings().WRAP_COMMENTS = true;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 20;
|
||||
|
||||
doTextTest("/**\n" + " * <p />\n" + " * Another paragraph of the description placed after blank line.\n" + " */\n" + "class A{}",
|
||||
"/**\n" +
|
||||
@@ -91,8 +92,8 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testParagraphTagGeneration() {
|
||||
// Inspired by IDEA-61811
|
||||
getSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
getSettings().JD_P_AT_EMPTY_LINES = true;
|
||||
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
getSettings().getRootSettings().JD_P_AT_EMPTY_LINES = true;
|
||||
doTextTest(
|
||||
"/**\n" +
|
||||
" * line 1\n" +
|
||||
@@ -123,9 +124,9 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest {
|
||||
|
||||
public void testWrappedParameterDescription() throws Exception {
|
||||
// Inspired by IDEA-13072
|
||||
getSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
getSettings().WRAP_COMMENTS = true;
|
||||
getSettings().JD_PARAM_DESCRIPTION_ON_NEW_LINE = true;
|
||||
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
|
||||
getSettings().getRootSettings().WRAP_COMMENTS = true;
|
||||
getSettings().getRootSettings().JD_PARAM_DESCRIPTION_ON_NEW_LINE = true;
|
||||
doClassTest(
|
||||
"/**\n" +
|
||||
" * test description\n" +
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.DifferenceFilter;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -35,10 +36,20 @@ import java.lang.reflect.Modifier;
|
||||
public class CommonCodeStyleSettings {
|
||||
|
||||
private Language myLanguage;
|
||||
private CodeStyleSettings myRootSettings;
|
||||
|
||||
public CommonCodeStyleSettings(Language language) {
|
||||
myLanguage = language;
|
||||
}
|
||||
|
||||
public void setRootSettings(@NotNull CodeStyleSettings rootSettings) {
|
||||
myRootSettings = rootSettings;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CodeStyleSettings getRootSettings() {
|
||||
return myRootSettings;
|
||||
}
|
||||
|
||||
public CommonCodeStyleSettings clone() {
|
||||
CommonCodeStyleSettings commonSettings = new CommonCodeStyleSettings(myLanguage);
|
||||
|
||||
@@ -111,6 +111,7 @@ public class CommonCodeStyleSettingsManager implements JDOMExternalizable {
|
||||
|
||||
private void registerCommonSettings(@NotNull Language lang, @NotNull CommonCodeStyleSettings settings) {
|
||||
if (!myCommonSettingsMap.containsKey(lang)) {
|
||||
settings.setRootSettings(myParentSettings);
|
||||
myCommonSettingsMap.put(lang, settings);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-8
@@ -93,7 +93,9 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
mySettings = settings;
|
||||
myEditor = createEditor();
|
||||
|
||||
myUpdateAlarm.setActivationComponent(myEditor.getComponent());
|
||||
if (myEditor != null) {
|
||||
myUpdateAlarm.setActivationComponent(myEditor.getComponent());
|
||||
}
|
||||
myUserActivityWatcher.addUserActivityListener(new UserActivityListener() {
|
||||
public void stateChanged() {
|
||||
somethingChanged();
|
||||
@@ -129,7 +131,9 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
myUserActivityWatcher.register(component);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Editor createEditor() {
|
||||
if (getPreviewText() == null) return null;
|
||||
EditorFactory editorFactory = EditorFactory.getInstance();
|
||||
Document editorDocument = editorFactory.createDocument("");
|
||||
EditorEx editor = (EditorEx)editorFactory.createEditor(editorDocument);
|
||||
@@ -150,6 +154,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
}
|
||||
|
||||
protected void updatePreview(boolean useDefaultSample) {
|
||||
if (myEditor == null) return;
|
||||
updateEditor(useDefaultSample);
|
||||
updatePreviewHighlighter((EditorEx)myEditor);
|
||||
}
|
||||
@@ -383,6 +388,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
protected abstract FileType getFileType();
|
||||
|
||||
@NonNls
|
||||
@Nullable
|
||||
protected abstract String getPreviewText();
|
||||
|
||||
public abstract void apply(CodeStyleSettings settings);
|
||||
@@ -412,7 +418,9 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
|
||||
public void dispose() {
|
||||
myUpdateAlarm.cancelAllRequests();
|
||||
EditorFactory.getInstance().releaseEditor(myEditor);
|
||||
if (myEditor != null) {
|
||||
EditorFactory.getInstance().releaseEditor(myEditor);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void resetImpl(final CodeStyleSettings settings);
|
||||
@@ -462,11 +470,13 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
|
||||
public void onSomethingChanged() {
|
||||
setSomethingChanged(true);
|
||||
UiNotifyConnector.doWhenFirstShown(myEditor.getComponent(), new Runnable(){
|
||||
public void run() {
|
||||
addUpdatePreviewRequest();
|
||||
}
|
||||
});
|
||||
if (myEditor != null) {
|
||||
UiNotifyConnector.doWhenFirstShown(myEditor.getComponent(), new Runnable() {
|
||||
public void run() {
|
||||
addUpdatePreviewRequest();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void addUpdatePreviewRequest() {
|
||||
@@ -604,5 +614,5 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
|
||||
public boolean setPanelLanguage(Language language) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+7
-3
@@ -17,20 +17,24 @@ package com.intellij.psi.impl.source.codeStyle;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author lesya
|
||||
*/
|
||||
public class PostFormatProcessorHelper {
|
||||
public final CodeStyleSettings mySettings;
|
||||
private final CommonCodeStyleSettings mySettings;
|
||||
private TextRange myResultTextRange;
|
||||
|
||||
public PostFormatProcessorHelper(final CodeStyleSettings settings) {
|
||||
public PostFormatProcessorHelper(final CommonCodeStyleSettings settings) {
|
||||
mySettings = settings;
|
||||
}
|
||||
|
||||
public CommonCodeStyleSettings getSettings() {
|
||||
return mySettings;
|
||||
}
|
||||
|
||||
public void updateResultRange(final int oldTextLength, final int newTextLength) {
|
||||
if (myResultTextRange == null) return;
|
||||
|
||||
|
||||
@@ -535,9 +535,7 @@
|
||||
|
||||
<iconProvider implementation="com.intellij.psi.impl.JavaDirectoryIconProvider" id="javaDirectory"/>
|
||||
|
||||
<codeStyleSettingsProvider implementation="com.intellij.application.options.GenerationSettingsProvider"/>
|
||||
<codeStyleSettingsProvider implementation="com.intellij.application.options.ImportsSettingsProvider"/>
|
||||
<codeStyleSettingsProvider implementation="com.intellij.application.options.JavadocSettingsProvider"/>
|
||||
<codeStyleSettingsProvider implementation="com.intellij.application.options.JavaCodeStyleSettingsProvider"/>
|
||||
|
||||
<langCodeStyleSettingsProvider implementation="com.intellij.ide.JavaLanguageCodeStyleSettingsProvider"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user