diff --git a/java/compiler/impl/src/com/intellij/compiler/options/ProcessorProfilePanel.java b/java/compiler/impl/src/com/intellij/compiler/options/ProcessorProfilePanel.java index 02a850bbfff9..df8237a83e55 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/ProcessorProfilePanel.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/ProcessorProfilePanel.java @@ -182,9 +182,9 @@ public class ProcessorProfilePanel extends JPanel { myProcessorPathField.setText(FileUtil.toSystemDependentName(config.getProcessorPath())); final String productionDirName = config.getGeneratedSourcesDirectoryName(false); - myGeneratedProductionDirField.setText(productionDirName != null? productionDirName.trim() : ""); + myGeneratedProductionDirField.setText(productionDirName.trim()); final String testsDirName = config.getGeneratedSourcesDirectoryName(true); - myGeneratedTestsDirField.setText(testsDirName != null? testsDirName.trim() : ""); + myGeneratedTestsDirField.setText(testsDirName.trim()); if (config.isOutputRelativeToContentRoot()) { myRbRelativeToContentRoot.setSelected(true); } @@ -239,11 +239,11 @@ public class ProcessorProfilePanel extends JPanel { } private void updateEnabledState() { - final boolean enabled = myCbEnableProcessing.isSelected(); - final boolean useProcessorpath = !myRbClasspath.isSelected(); + final boolean enabled = myCbEnableProcessing.isSelected(); + final boolean useProcessorPath = !myRbClasspath.isSelected(); myRbClasspath.setEnabled(enabled); myRbProcessorsPath.setEnabled(enabled); - myProcessorPathField.setEnabled(enabled && useProcessorpath); + myProcessorPathField.setEnabled(enabled && useProcessorPath); updateTable(myProcessorPanel, myProcessorTable, enabled); updateTable(myOptionsPanel, myOptionsTable, enabled); myGeneratedProductionDirField.setEnabled(enabled); @@ -370,7 +370,7 @@ public class ProcessorProfilePanel extends JPanel { } public Map getOptions() { - final Map map = new java.util.HashMap<>(); + final Map map = new HashMap<>(); for (KeyValuePair pair : myRows) { map.put(pair.key.trim(), pair.value.trim()); } @@ -398,8 +398,8 @@ public class ProcessorProfilePanel extends JPanel { @Override public String getColumnName(int column) { - switch (column) { - case 0: return "Processor FQ Name"; + if (column == 0) { + return "Processor FQ Name"; } return super.getColumnName(column); } @@ -426,20 +426,16 @@ public class ProcessorProfilePanel extends JPanel { @Override public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: return myRows.get(rowIndex); + if (columnIndex == 0) { + return myRows.get(rowIndex); } return null; } @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - if (aValue != null) { - switch (columnIndex) { - case 0: - myRows.set(rowIndex, (String)aValue); - break; - } + if (aValue != null && columnIndex == 0) { + myRows.set(rowIndex, (String)aValue); } } @@ -468,10 +464,8 @@ public class ProcessorProfilePanel extends JPanel { public void setProcessors(Collection processors) { clear(); if (!processors.isEmpty()) { - for (String processor : processors) { - myRows.add(processor); - } - Collections.sort(myRows, (o1, o2) -> o1.compareToIgnoreCase(o2)); + myRows.addAll(processors); + Collections.sort(myRows, String.CASE_INSENSITIVE_ORDER); fireTableRowsInserted(0, processors.size()-1); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java index a947d8101042..da17a5ac1d5d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java @@ -444,11 +444,7 @@ public class CaptureConfigurable implements SearchableConfigurable { @Override public Class getColumnClass(int columnIndex) { - switch (columnIndex) { - case ENABLED_COLUMN: - return Boolean.class; - } - return String.class; + return columnIndex == ENABLED_COLUMN ? Boolean.class : String.class; } CapturePoint get(int idx) { diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/Combined.java b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/Combined.java index 5497d2bde52b..aae4ccdb831e 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/Combined.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/Combined.java @@ -702,20 +702,20 @@ final class NegationAnalysis { insnIndex = controlFlow.transitions[insnIndex][0]; break; default: - switch (insnNode.getOpcode()) { - case IRETURN: - BasicValue returnValue = frame.pop(); - if (branchValue) { - trueBranchValue = returnValue; - } - else { - falseBranchValue = returnValue; - } - return; - default: - checkAssertion(controlFlow.transitions[insnIndex].length == 1); - frame.execute(insnNode, interpreter); - insnIndex = controlFlow.transitions[insnIndex][0]; + if (insnNode.getOpcode() == IRETURN) { + BasicValue returnValue = frame.pop(); + if (branchValue) { + trueBranchValue = returnValue; + } + else { + falseBranchValue = returnValue; + } + return; + } + else { + checkAssertion(controlFlow.transitions[insnIndex].length == 1); + frame.execute(insnNode, interpreter); + insnIndex = controlFlow.transitions[insnIndex][0]; } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java b/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java index 15fe9620068a..47b320ad19d0 100644 --- a/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/SimplifyStreamApiCallChainsInspection.java @@ -844,12 +844,10 @@ public class SimplifyStreamApiCallChainsInspection extends AbstractBaseJavaLocal @Override public String getName() { - switch (myMode) { - case OPTIONAL: - return "Replace with 'Optional.of'"; - default: - return "Use Stream element explicitly"; + if (myMode == ReplacementMode.OPTIONAL) { + return "Replace with 'Optional.of'"; } + return "Use Stream element explicitly"; } @Override diff --git a/java/java-impl/src/com/intellij/pom/java/AcceptedLanguageLevelsSettings.java b/java/java-impl/src/com/intellij/pom/java/AcceptedLanguageLevelsSettings.java index 7837112fcca3..b2f5a131dac5 100644 --- a/java/java-impl/src/com/intellij/pom/java/AcceptedLanguageLevelsSettings.java +++ b/java/java-impl/src/com/intellij/pom/java/AcceptedLanguageLevelsSettings.java @@ -75,10 +75,8 @@ public class AcceptedLanguageLevelsSettings implements PersistentStateComponent< NotificationType.WARNING, (notification, event) -> { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - switch (event.getDescription()) { - case "accept": - acceptAndRestore(project, unacceptedLevels.get(level), level); - break; + if (event.getDescription().equals("accept")) { + acceptAndRestore(project, unacceptedLevels.get(level), level); } notification.expire(); } diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/ExceptionsTableModel.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/ExceptionsTableModel.java index a88165d65018..f73d6a8f99c5 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/ExceptionsTableModel.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/ExceptionsTableModel.java @@ -94,23 +94,18 @@ public class ExceptionsTableModel extends AbstractTableModel implements Editable @Override public String getColumnName(int column) { - switch (column) { - case 0: - return RefactoringBundle.message("column.name.type"); - default: - throw new IllegalArgumentException(); + if (column == 0) { + return RefactoringBundle.message("column.name.type"); } + throw new IllegalArgumentException(); } @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - return true; - - default: - throw new IllegalArgumentException(); + if (columnIndex == 0) { + return true; } + throw new IllegalArgumentException(); } public void setTypeInfos(PsiMethod method) { diff --git a/java/java-impl/src/com/intellij/refactoring/safeDelete/OverridingMethodsDialog.java b/java/java-impl/src/com/intellij/refactoring/safeDelete/OverridingMethodsDialog.java index 291bfcf26914..59167f8e799f 100644 --- a/java/java-impl/src/com/intellij/refactoring/safeDelete/OverridingMethodsDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/safeDelete/OverridingMethodsDialog.java @@ -199,22 +199,15 @@ class OverridingMethodsDialog extends DialogWrapper { @Override public String getColumnName(int column) { - switch(column) { - case CHECK_COLUMN: - return " "; - default: - return RefactoringBundle.message("method.column"); - } + return column == CHECK_COLUMN ? " " : RefactoringBundle.message("method.column"); } @Override public Class getColumnClass(int columnIndex) { - switch(columnIndex) { - case CHECK_COLUMN: - return Boolean.class; - default: - return String.class; + if (columnIndex == CHECK_COLUMN) { + return Boolean.class; } + return String.class; } diff --git a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/resolver/BindingFactory.java b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/resolver/BindingFactory.java index 6b56d0693087..5a48c5edb72e 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/resolver/BindingFactory.java +++ b/java/java-impl/src/com/intellij/refactoring/typeCook/deductive/resolver/BindingFactory.java @@ -48,7 +48,7 @@ public class BindingFactory { private final Project myProject; private final PsiTypeVariableFactory myFactory; - private PsiClass[] getGreatestLowerClasses(final PsiClass aClass, final PsiClass bClass) { + private static PsiClass[] getGreatestLowerClasses(final PsiClass aClass, final PsiClass bClass) { if (InheritanceUtil.isInheritorOrSelf(aClass, bClass, true)) { return new PsiClass[]{aClass}; } @@ -835,61 +835,58 @@ public class BindingFactory { private Binding unify(final PsiType x, final PsiType y, final Unifier unifier) { final int indicator = (x instanceof PsiTypeVariable ? 1 : 0) + (y instanceof PsiTypeVariable ? 2 : 0); - switch (indicator) { - case 0: - if (x instanceof PsiWildcardType || y instanceof PsiWildcardType) { - return unifier.unify(x, y); - } - else if (x instanceof PsiArrayType || y instanceof PsiArrayType) { - final PsiType xType = x instanceof PsiArrayType ? ((PsiArrayType)x).getComponentType() : x; - final PsiType yType = y instanceof PsiArrayType ? ((PsiArrayType)y).getComponentType() : y; + if (indicator == 0) { + if (x instanceof PsiWildcardType || y instanceof PsiWildcardType) { + return unifier.unify(x, y); + } + else if (x instanceof PsiArrayType || y instanceof PsiArrayType) { + final PsiType xType = x instanceof PsiArrayType ? ((PsiArrayType)x).getComponentType() : x; + final PsiType yType = y instanceof PsiArrayType ? ((PsiArrayType)y).getComponentType() : y; - return unify(xType, yType, unifier); - } - else if (x instanceof PsiClassType && y instanceof PsiClassType) { - final PsiClassType.ClassResolveResult resultX = Util.resolveType(x); - final PsiClassType.ClassResolveResult resultY = Util.resolveType(y); + return unify(xType, yType, unifier); + } + else if (x instanceof PsiClassType && y instanceof PsiClassType) { + final PsiClassType.ClassResolveResult resultX = Util.resolveType(x); + final PsiClassType.ClassResolveResult resultY = Util.resolveType(y); - final PsiClass xClass = resultX.getElement(); - final PsiClass yClass = resultY.getElement(); + final PsiClass xClass = resultX.getElement(); + final PsiClass yClass = resultY.getElement(); - if (xClass != null && yClass != null) { - final PsiSubstitutor ySubst = resultY.getSubstitutor(); + if (xClass != null && yClass != null) { + final PsiSubstitutor ySubst = resultY.getSubstitutor(); - final PsiSubstitutor xSubst = resultX.getSubstitutor(); + final PsiSubstitutor xSubst = resultX.getSubstitutor(); - if (!xClass.equals(yClass)) { - return null; - } + if (!xClass.equals(yClass)) { + return null; + } - Binding b = create(); + Binding b = create(); - for (final PsiTypeParameter aParm : xSubst.getSubstitutionMap().keySet()) { - final PsiType xType = xSubst.substitute(aParm); - final PsiType yType = ySubst.substitute(aParm); + for (final PsiTypeParameter aParm : xSubst.getSubstitutionMap().keySet()) { + final PsiType xType = xSubst.substitute(aParm); + final PsiType yType = ySubst.substitute(aParm); - final Binding b1 = unify(xType, yType, unifier); + final Binding b1 = unify(xType, yType, unifier); - if (b1 == null) { - return null; - } + if (b1 == null) { + return null; + } - b = b.compose(b1); - } + b = b.compose(b1); + } - return b; - } - } - else if (y instanceof Bottom) { - return create(); - } - else { - return null; - } - - default: - return unifier.unify(x, y); + return b; + } + } + else if (y instanceof Bottom) { + return create(); + } + else { + return null; + } } + return unifier.unify(x, y); } public Binding riseWithWildcard(final PsiType x, final PsiType y, final Set constraints) { diff --git a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ReturnInstruction.java b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ReturnInstruction.java index 9936f60085c9..624ffa0ffcd5 100644 --- a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ReturnInstruction.java +++ b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ReturnInstruction.java @@ -82,7 +82,7 @@ public class ReturnInstruction extends GoToInstruction { @Override public int getNext(int index, int no) { - if (offset == 0) + if (offset == 0) { switch (no) { case 0: return getProcBegin() - 5; // call normal case 1: return getProcBegin() - 3; // call return @@ -91,13 +91,12 @@ public class ReturnInstruction extends GoToInstruction { LOG.assertTrue (false); return -1; } - else - switch (no) { - case 0: return offset; // call normal - default: - LOG.assertTrue (false); - return -1; - } + } + if (no == 0) { + return offset; // call normal + } + LOG.assertTrue(false); + return -1; } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStatementElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStatementElement.java index c9f50479ba4b..6ad10ca88fc1 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStatementElement.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStatementElement.java @@ -28,11 +28,9 @@ public class ImportStatementElement extends ImportStatementBaseElement { public ASTNode findChildByRole(int role) { final ASTNode result = super.findChildByRole(role); if (result != null) return result; - switch (role) { - default: - return null; - case ChildRole.IMPORT_REFERENCE: - return findChildByType(JavaElementType.JAVA_CODE_REFERENCE); + if (role == ChildRole.IMPORT_REFERENCE) { + return findChildByType(JavaElementType.JAVA_CODE_REFERENCE); } + return null; } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStaticStatementElement.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStaticStatementElement.java index fb20edf5c950..a24f6d3df714 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStaticStatementElement.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/ImportStaticStatementElement.java @@ -31,19 +31,16 @@ public class ImportStaticStatementElement extends ImportStatementBaseElement { public ASTNode findChildByRole(int role) { final ASTNode result = super.findChildByRole(role); if (result != null) return result; - switch (role) { - default: - return null; - - case ChildRole.IMPORT_REFERENCE: - final ASTNode importStaticReference = findChildByType(JavaElementType.IMPORT_STATIC_REFERENCE); - if (importStaticReference != null) { - return importStaticReference; - } - else { - return findChildByType(JavaElementType.JAVA_CODE_REFERENCE); - } + if (role == ChildRole.IMPORT_REFERENCE) { + final ASTNode importStaticReference = findChildByType(JavaElementType.IMPORT_STATIC_REFERENCE); + if (importStaticReference != null) { + return importStaticReference; + } + else { + return findChildByType(JavaElementType.JAVA_CODE_REFERENCE); + } } + return null; } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBlockStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBlockStatementImpl.java index 0b74f963fd96..f8afa02f3572 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBlockStatementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiBlockStatementImpl.java @@ -44,13 +44,10 @@ public class PsiBlockStatementImpl extends CompositePsiElement implements PsiBlo @Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); - switch(role){ - default: - return null; - - case ChildRole.BLOCK: - return findChildByType(JavaElementType.CODE_BLOCK); + if (role == ChildRole.BLOCK) { + return findChildByType(JavaElementType.CODE_BLOCK); } + return null; } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPolyadicExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPolyadicExpressionImpl.java index c50b1de7324b..9f09ce87908b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPolyadicExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiPolyadicExpressionImpl.java @@ -82,13 +82,10 @@ public class PsiPolyadicExpressionImpl extends ExpressionPsiElement implements P @Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); - switch (role) { - default: - return null; - - case ChildRole.OPERATION_SIGN: - return findChildByType(OUR_OPERATIONS_BIT_SET); + if (role == ChildRole.OPERATION_SIGN) { + return findChildByType(OUR_OPERATIONS_BIT_SET); } + return null; } @Override diff --git a/json/src/com/jetbrains/jsonSchema/settings/mappings/JsonMappingsTableCellEditor.java b/json/src/com/jetbrains/jsonSchema/settings/mappings/JsonMappingsTableCellEditor.java index 0edda4cf5eeb..e2fc93658af3 100644 --- a/json/src/com/jetbrains/jsonSchema/settings/mappings/JsonMappingsTableCellEditor.java +++ b/json/src/com/jetbrains/jsonSchema/settings/mappings/JsonMappingsTableCellEditor.java @@ -84,12 +84,8 @@ class JsonMappingsTableCellEditor extends AbstractTableCellEditor { myComponent.getTextField().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { - switch (e.getKeyCode()) { - case KeyEvent.VK_ENTER: - if (finalField == null || !finalField.isPopupDisplayed()) { - stopCellEditing(); - } - break; + if (e.getKeyCode() == KeyEvent.VK_ENTER && (finalField == null || !finalField.isPopupDisplayed())) { + stopCellEditing(); } } }); diff --git a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeChange.java b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeChange.java index 9f4b877cee11..2cfa249e18ce 100644 --- a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeChange.java +++ b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeChange.java @@ -275,13 +275,11 @@ public class TextMergeChange extends ThreesideDiffChangeBase { myShiftPressed = myViewer.getModifierProvider().isShiftPressed(); if (mySide == ThreeSide.BASE) { - switch (myType) { - case RESOLVE: - if (!Registry.is("diff.merge.resolve.conflict.action.visible")) return null; - return createResolveRenderer(); - default: - throw new IllegalArgumentException(myType.name()); + if (myType == OperationType.RESOLVE) { + if (!Registry.is("diff.merge.resolve.conflict.action.visible")) return null; + return createResolveRenderer(); } + throw new IllegalArgumentException(myType.name()); } else { Side versionSide = mySide.select(Side.LEFT, null, Side.RIGHT); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java index 3fbe5b5dc2e9..7f0423fb5028 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java @@ -186,7 +186,7 @@ public class IncrementalSearchHandler { data.hint = hint; editor.putUserData(SEARCH_DATA_IN_EDITOR_VIEW_KEY, data); - if (hintData.label.getText().length() > 0) { + if (!hintData.label.getText().isEmpty()) { updatePosition(editor, hintData, true, false); } } @@ -195,8 +195,8 @@ public class IncrementalSearchHandler { final int len = pattern.length(); for(int i=0;i 0){ + if (!text.isEmpty()){ text = text.substring(0, text.length() - 1); } hintData.label.setText(text); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java index cf6a24cd2c00..c572cf3c0b8e 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java @@ -672,10 +672,7 @@ public class CodeFormatterFacade { boolean wrapLine = false; for (int i = startLineOffset; i < Math.min(endLineOffset, targetRangeEndOffset); i++) { char c = text.charAt(i); - switch (c) { - case '\t': symbolWidth = tabSize - (width % tabSize); break; - default: symbolWidth = 1; - } + symbolWidth = c == '\t' ? tabSize - (width % tabSize) : 1; if (width + symbolWidth + reservedWidthInColumns >= myRightMargin && (Math.min(endLineOffset, targetRangeEndOffset) - i) >= reservedWidthInColumns) { @@ -707,16 +704,17 @@ public class CodeFormatterFacade { boolean wrapLine = false; for (int i = startLineOffset; i < Math.min(endLineOffset, targetRangeEndOffset); i++) { char c = text.charAt(i); - switch (c) { - case '\t': - newX = EditorUtil.nextTabStop(x, editor); - int diffInPixels = newX - x; - symbolWidth = diffInPixels / spaceSize; - if (diffInPixels % spaceSize > 0) { - symbolWidth++; - } - break; - default: newX = x + EditorUtil.charWidth(c, Font.PLAIN, editor); symbolWidth = 1; + if (c == '\t') { + newX = EditorUtil.nextTabStop(x, editor); + int diffInPixels = newX - x; + symbolWidth = diffInPixels / spaceSize; + if (diffInPixels % spaceSize > 0) { + symbolWidth++; + } + } + else { + newX = x + EditorUtil.charWidth(c, Font.PLAIN, editor); + symbolWidth = 1; } if (width + symbolWidth + reservedWidthInColumns >= myRightMargin && (Math.min(endLineOffset, targetRangeEndOffset) - i) >= reservedWidthInColumns) diff --git a/platform/lang-impl/src/com/intellij/refactoring/ui/AbstractMemberSelectionTable.java b/platform/lang-impl/src/com/intellij/refactoring/ui/AbstractMemberSelectionTable.java index 59dff79a694b..d7e825df69e6 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/ui/AbstractMemberSelectionTable.java +++ b/platform/lang-impl/src/com/intellij/refactoring/ui/AbstractMemberSelectionTable.java @@ -161,7 +161,7 @@ public abstract class AbstractMemberSelectionTable memberInfos = getSelectedMemberInfos(); - if (memberInfos.size() > 0) { + if (!memberInfos.isEmpty()) { sink.put(CommonDataKeys.PSI_ELEMENT, memberInfos.iterator().next().getMember()); } } @@ -376,23 +376,17 @@ public abstract class AbstractMemberSelectionTable i) - { - char newch = ch; - String entity = text.substring(i, semi + 1); - if (entity.equals("$")) - { - newch = '$'; - } - else if (entity.equals("&")) - { - newch = '&'; - i = semi; - } - if (newch != ch) - { - ch = newch; - i = semi; - } - } - res.append(ch); - break; - default: - res.append(ch); + if (ch == '&') { + int semi = text.indexOf(';', i); + if (semi > i) { + char newch = '&'; + String entity = text.substring(i, semi + 1); + if (entity.equals("$")) { + newch = '$'; + } + else if (entity.equals("&")) { + i = semi; + } + if (newch != ch) { + ch = newch; + i = semi; + } + } } + res.append(ch); } return res.toString(); diff --git a/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/build/GradleArtifactBuildTaskProvider.java b/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/build/GradleArtifactBuildTaskProvider.java index e3980d91c2cd..039c78fd945a 100644 --- a/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/build/GradleArtifactBuildTaskProvider.java +++ b/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/build/GradleArtifactBuildTaskProvider.java @@ -45,12 +45,10 @@ public class GradleArtifactBuildTaskProvider extends ArtifactBuildTaskProvider { @Nullable private static JpsGradleArtifactExtension getArtifactExtension(JpsArtifact artifact, ArtifactBuildPhase buildPhase) { - switch (buildPhase) { - case PRE_PROCESSING: - return JpsGradleExtensionService.getArtifactExtension(artifact); - default: - return null; + if (buildPhase == ArtifactBuildPhase.PRE_PROCESSING) { + return JpsGradleExtensionService.getArtifactExtension(artifact); } + return null; } private abstract static class GradleGenerationBuildTask extends BuildTask { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrNullVoidConverter.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrNullVoidConverter.java index 94ca23158109..b8257bf86fab 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrNullVoidConverter.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrNullVoidConverter.java @@ -60,13 +60,12 @@ public class GrNullVoidConverter extends GrTypeConverter { } } else if (actualType == PsiType.NULL) { - switch (currentPosition) { - case RETURN_VALUE: - // We can return null from method returning primitive type, but runtime error will occur. - if (targetType instanceof PsiPrimitiveType) return WARNING; - break; - default: - return targetType instanceof PsiPrimitiveType ? ERROR : OK; + if (currentPosition == ApplicableTo.RETURN_VALUE) { + // We can return null from method returning primitive type, but runtime error will occur. + if (targetType instanceof PsiPrimitiveType) return WARNING; + } + else { + return targetType instanceof PsiPrimitiveType ? ERROR : OK; } } return null; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java index ef502b2a52e5..d0f82925a36c 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java @@ -23,6 +23,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrRefere import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.*; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl; +import java.util.Locale; + /** * @author Maxim.Medvedev */ @@ -189,17 +191,16 @@ public class GrStringUtil { final int length = str.length(); for (int idx = 0; idx < length; idx++) { char ch = str.charAt(idx); - switch (ch) { - case '/': - buffer.append("\\/"); - break; - default: - if (Character.isISOControl(ch) || ch == '$') { - appendUnicode(buffer, ch); - } - else { - buffer.append(ch); - } + if (ch == '/') { + buffer.append("\\/"); + } + else { + if (Character.isISOControl(ch) || ch == '$') { + appendUnicode(buffer, ch); + } + else { + buffer.append(ch); + } } } } @@ -214,26 +215,24 @@ public class GrStringUtil { final int length = str.length(); for (int idx = 0; idx < length; idx++) { char ch = str.charAt(idx); - switch (ch) { - case '/': - if (idx + 1 < length && str.charAt(idx + 1) == '$') { - appendUnicode(buffer, '/'); - appendUnicode(buffer, '$'); - break; - } - default: - if (Character.isISOControl(ch)) { - appendUnicode(buffer, ch); - } - else { - buffer.append(ch); - } + if (ch == '/') { + if (idx + 1 < length && str.charAt(idx + 1) == '$') { + appendUnicode(buffer, '/'); + appendUnicode(buffer, '$'); + continue; + } + } + if (Character.isISOControl(ch)) { + appendUnicode(buffer, ch); + } + else { + buffer.append(ch); } } } private static void appendUnicode(StringBuilder buffer, char ch) { - String hexCode = Integer.toHexString(ch).toUpperCase(); + String hexCode = Integer.toHexString(ch).toUpperCase(Locale.ENGLISH); buffer.append("\\u"); int paddingCount = 4 - hexCode.length(); while (paddingCount-- > 0) { diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/ExitHelper.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/ExitHelper.java index 81c61d04576c..3b9847f569e2 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/ExitHelper.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/ExitHelper.java @@ -80,32 +80,31 @@ public class ExitHelper { } } - switch (stat.type) { - case Statement.TYPE_IF: - IfStatement ifst = (IfStatement)stat; - if (ifst.getIfstat() == null) { - StatEdge ifedge = ifst.getIfEdge(); - dest = isExitEdge(ifedge); - if (dest != null) { - BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( - DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); - bstat.setExprents(DecHelper.copyExprentList(dest.getExprents())); + if (stat.type == Statement.TYPE_IF) { + IfStatement ifst = (IfStatement)stat; + if (ifst.getIfstat() == null) { + StatEdge ifedge = ifst.getIfEdge(); + dest = isExitEdge(ifedge); + if (dest != null) { + BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( + DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); + bstat.setExprents(DecHelper.copyExprentList(dest.getExprents())); - ifst.getFirst().removeSuccessor(ifedge); - StatEdge newedge = new StatEdge(StatEdge.TYPE_REGULAR, ifst.getFirst(), bstat); - ifst.getFirst().addSuccessor(newedge); - ifst.setIfEdge(newedge); - ifst.setIfstat(bstat); - ifst.getStats().addWithKey(bstat, bstat.id); - bstat.setParent(ifst); + ifst.getFirst().removeSuccessor(ifedge); + StatEdge newedge = new StatEdge(StatEdge.TYPE_REGULAR, ifst.getFirst(), bstat); + ifst.getFirst().addSuccessor(newedge); + ifst.setIfEdge(newedge); + ifst.setIfstat(bstat); + ifst.getStats().addWithKey(bstat, bstat.id); + bstat.setParent(ifst); - StatEdge oldexitedge = dest.getAllSuccessorEdges().get(0); - StatEdge newexitedge = new StatEdge(StatEdge.TYPE_BREAK, bstat, oldexitedge.getDestination()); - bstat.addSuccessor(newexitedge); - oldexitedge.closure.addLabeledEdge(newexitedge); - ret = 1; - } + StatEdge oldexitedge = dest.getAllSuccessorEdges().get(0); + StatEdge newexitedge = new StatEdge(StatEdge.TYPE_BREAK, bstat, oldexitedge.getDestination()); + bstat.addSuccessor(newexitedge); + oldexitedge.closure.addLabeledEdge(newexitedge); + ret = 1; } + } } } diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/MergeHelper.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/MergeHelper.java index 779aeb8ca465..ed9f368b5913 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/MergeHelper.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/MergeHelper.java @@ -376,14 +376,13 @@ public class MergeHelper { return stat; } - switch (stat.type) { - case Statement.TYPE_SEQUENCE: - for (int i = stat.getStats().size() - 1; i >= 0; i--) { - Statement tmp = getLastDirectData(stat.getStats().get(i)); - if (tmp == null || !tmp.getExprents().isEmpty()) { - return tmp; - } + if (stat.type == Statement.TYPE_SEQUENCE) { + for (int i = stat.getStats().size() - 1; i >= 0; i--) { + Statement tmp = getLastDirectData(stat.getStats().get(i)); + if (tmp == null || !tmp.getExprents().isEmpty()) { + return tmp; } + } } return null; } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/ConfigureClientPropertiesDialog.java b/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/ConfigureClientPropertiesDialog.java index 0564270900c0..3030676e72b3 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/ConfigureClientPropertiesDialog.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/clientProperties/ConfigureClientPropertiesDialog.java @@ -120,7 +120,7 @@ public class ConfigureClientPropertiesDialog extends DialogWrapper { dlg.show(); if (dlg.getExitCode() == OK_EXIT_CODE) { String className = dlg.getClassName(); - if (className.length() == 0) return; + if (className.isEmpty()) return; final Class aClass; try { aClass = Class.forName(className, true, LoaderFactory.getInstance(myProject).getProjectClassLoader()); @@ -192,23 +192,18 @@ public class ConfigureClientPropertiesDialog extends DialogWrapper { return mySplitter; } + private static int getInheritanceLevel(Class aClass) { + int level = 0; + while (aClass.getSuperclass() != null) { + level++; + aClass = aClass.getSuperclass(); + } + return level; + } + private void fillClassTree() { List configuredClasses = myManager.getConfiguredClasses(myProject); - Collections.sort(configuredClasses, new Comparator() { - @Override - public int compare(final Class o1, final Class o2) { - return getInheritanceLevel(o1) - getInheritanceLevel(o2); - } - - private int getInheritanceLevel(Class aClass) { - int level = 0; - while (aClass.getSuperclass() != null) { - level++; - aClass = aClass.getSuperclass(); - } - return level; - } - }); + Collections.sort(configuredClasses, Comparator.comparingInt(ConfigureClientPropertiesDialog::getInheritanceLevel)); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); DefaultTreeModel treeModel = new DefaultTreeModel(root); @@ -254,22 +249,18 @@ public class ConfigureClientPropertiesDialog extends DialogWrapper { @Override public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - return mySelectedProperties.get(rowIndex).getName(); - default: - return mySelectedProperties.get(rowIndex).getValueClass(); + if (columnIndex == 0) { + return mySelectedProperties.get(rowIndex).getName(); } + return mySelectedProperties.get(rowIndex).getValueClass(); } @Override public String getColumnName(int column) { - switch (column) { - case 0: - return UIDesignerBundle.message("client.properties.name"); - default: - return UIDesignerBundle.message("client.properties.class"); + if (column == 0) { + return UIDesignerBundle.message("client.properties.name"); } + return UIDesignerBundle.message("client.properties.class"); } } } diff --git a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSettings.java b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSettings.java index db3c4efce379..5c3603c46275 100644 --- a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSettings.java +++ b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSettings.java @@ -117,13 +117,11 @@ public class PyDebuggerSettings extends XDebuggerSettings im @NotNull @Override public Collection createConfigurables(@NotNull DebuggerSettingsCategory category) { - switch (category) { - case STEPPING: - return singletonList(SimpleConfigurable.create("python.debug.configurable", "Python", - PyDebuggerSteppingConfigurableUi.class, this)); - default: - return Collections.emptyList(); + if (category == DebuggerSettingsCategory.STEPPING) { + return singletonList(SimpleConfigurable.create("python.debug.configurable", "Python", + PyDebuggerSteppingConfigurableUi.class, this)); } + return Collections.emptyList(); } @Override diff --git a/xml/impl/src/com/intellij/xml/impl/XmlBraceMatcher.java b/xml/impl/src/com/intellij/xml/impl/XmlBraceMatcher.java index c2714dd3547e..c30c2038c53a 100644 --- a/xml/impl/src/com/intellij/xml/impl/XmlBraceMatcher.java +++ b/xml/impl/src/com/intellij/xml/impl/XmlBraceMatcher.java @@ -177,14 +177,11 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { @Override public boolean isStrictTagMatching(final FileType fileType, final int braceGroupId) { - switch(braceGroupId){ - case XML_TAG_TOKEN_GROUP: - // Other xml languages may have nonbalanced tag names - return isStrictTagMatchingForFileType(fileType); - - default: - return false; + if (braceGroupId == XML_TAG_TOKEN_GROUP) { + // Other xml languages may have nonbalanced tag names + return isStrictTagMatchingForFileType(fileType); } + return false; } protected boolean isStrictTagMatchingForFileType(final FileType fileType) { @@ -194,12 +191,7 @@ public class XmlBraceMatcher implements XmlAwareBraceMatcher { @Override public boolean areTagsCaseSensitive(final FileType fileType, final int braceGroupId) { - switch(braceGroupId){ - case XML_TAG_TOKEN_GROUP: - return fileType == StdFileTypes.XML; - default: - return false; - } + return braceGroupId == XML_TAG_TOKEN_GROUP && fileType == StdFileTypes.XML; } private static boolean findEndTagStart(HighlighterIterator iterator) {