Use Arrays.fill where possible; other warnings fixes

GitOrigin-RevId: e213e3218b16cf1e23f73d94d232ead7aca818d6
This commit is contained in:
Tagir Valeev
2020-04-29 07:50:12 +00:00
committed by intellij-monorepo-bot
parent 07a5377470
commit b49093fdec
7 changed files with 33 additions and 52 deletions
@@ -371,7 +371,7 @@ public class AutomaticUsageRenamingDialog<T> extends DialogWrapper {
public String getColumnName(int column) {
switch(column) {
case OLD_NAME_COLUMN:
return RefactoringBundle.message("automatic.renamer.enity.name.column", myRenamer.getEntityName());
return RefactoringBundle.message("automatic.renamer.entity.name.column", myRenamer.getEntityName());
case NEW_NAME_COLUMN:
return RefactoringBundle.message("automatic.renamer.rename.to.column");
default:
@@ -17,6 +17,7 @@ package com.intellij.uiDesigner.core;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
/**
* public for test purposes
@@ -51,18 +52,16 @@ public abstract class DimensionInfo {
}
myStretches = new int[getCellCount()];
for (int i = 0; i < myStretches.length; i++) {
myStretches[i] = 1;
}
Arrays.fill(myStretches, 1);
//TODO[anton,vova] handle stretches
final ArrayList elimitated = new ArrayList();
mySpansAfterElimination = (int[])mySpan.clone();
Util.eliminate((int[])myCell.clone(), mySpansAfterElimination, elimitated);
final ArrayList<Integer> eliminated = new ArrayList<Integer>();
mySpansAfterElimination = mySpan.clone();
Util.eliminate(myCell.clone(), mySpansAfterElimination, eliminated);
myCellSizePolicies = new int[getCellCount()];
for (int i = 0; i < myCellSizePolicies.length; i++) {
myCellSizePolicies[i] = getCellSizePolicyImpl(i, elimitated);
myCellSizePolicies[i] = getCellSizePolicyImpl(i, eliminated);
}
}
@@ -117,13 +116,13 @@ public abstract class DimensionInfo {
return myCellSizePolicies[cellIndex];
}
private int getCellSizePolicyImpl(final int cellIndex, final ArrayList eliminatedCells){
private int getCellSizePolicyImpl(final int cellIndex, final ArrayList<Integer> eliminatedCells){
int policyFromChild = getCellSizePolicyFromInheriting(cellIndex);
if (policyFromChild != -1) {
return policyFromChild;
}
for (int i = eliminatedCells.size() - 1; i >= 0; i--) {
if (cellIndex == ((Integer)eliminatedCells.get(i)).intValue()) {
if (cellIndex == eliminatedCells.get(i).intValue()) {
return GridConstraints.SIZEPOLICY_CAN_SHRINK;
}
}
@@ -72,7 +72,7 @@ public final class GridLayoutManager extends AbstractLayout {
* Key for accessing client property which is set on the root Swing component of the design-time component
* hierarchy and specifies the value of extra insets added to all components.
*/
public static Object DESIGN_TIME_INSETS = new Object();
public static final Object DESIGN_TIME_INSETS = new Object();
private static final int SKIP_ROW = 1;
private static final int SKIP_COL = 2;
@@ -235,14 +235,11 @@ public final class GridLayoutManager extends AbstractLayout {
private static void makeSameSizes(int[] widths) {
int max = widths[0];
for (int i = 0; i < widths.length; i++) {
int width = widths[i];
for (int width : widths) {
max = Math.max(width, max);
}
for (int i = 0; i < widths.length; i++) {
widths[i] = max;
}
Arrays.fill(widths, max);
}
private static int[] getSameSizes(DimensionInfo info, int totalWidth) {
@@ -632,9 +629,7 @@ public final class GridLayoutManager extends AbstractLayout {
private int[] getMinOrPrefSizes(final DimensionInfo info, final boolean min) {
final int[] widths = new int[info.getCellCount()];
for (int i = 0; i < widths.length; i++) {
widths[i] = myMinCellSize;
}
Arrays.fill(widths, myMinCellSize);
// single spaned components
for (int i = info.getComponentCount() - 1; i >= 0; i--) {
@@ -907,22 +902,20 @@ public final class GridLayoutManager extends AbstractLayout {
}
public int[] getHorizontalGridLines() {
int[] result = new int [myYs.length+1];
result [0] = myYs [0];
for(int i=0; i<myYs.length-1; i++) {
result [i+1] = (myYs[i] + myHeights[i] + myYs[i + 1]) / 2;
}
result [myYs.length] = myYs [myYs.length-1] + myHeights [myYs.length-1];
return result;
return getGridLines(myYs, myHeights);
}
public int[] getVerticalGridLines() {
int[] result = new int [myXs.length+1];
result [0] = myXs [0];
for(int i=0; i<myXs.length-1; i++) {
result [i+1] = (myXs[i] + myWidths[i] + myXs[i + 1]) / 2;
return getGridLines(myXs, myWidths);
}
private static int[] getGridLines(int[] pos, int[] heights) {
int[] result = new int [pos.length + 1];
result [0] = pos[0];
for(int i = 0; i < pos.length - 1; i++) {
result [i+1] = (pos[i] + heights[i] + pos[i + 1]) / 2;
}
result [myXs.length] = myXs [myXs.length-1] + myWidths [myXs.length-1];
result [pos.length] = pos[pos.length - 1] + heights[pos.length - 1];
return result;
}
@@ -337,7 +337,7 @@ directory.chooser.hide.non.existent.checkBox.text=&Hide non-existent
safe.delete.command=Deleting {0}
select.all.button=Select &all
unselect.all.button=&Unselect all
automatic.renamer.enity.name.column={0} name
automatic.renamer.entity.name.column={0} name
automatic.renamer.rename.to.column=Rename to
rename.0.and.its.usages.to=Rename {0} and its usages to:
rename.variables=Rename &variables
@@ -87,9 +87,7 @@ public class AutomaticRenamingDialog extends DialogWrapper {
myShouldRename = new boolean[myRenames.length];
if (renamer.isSelectedByDefault()) {
for (int i = 0; i < myShouldRename.length; i++) {
myShouldRename[i] = true;
}
Arrays.fill(myShouldRename, true);
}
myTableModel = new MyTableModel(renamer.allowChangeSuggestedName());
@@ -164,16 +162,12 @@ public class AutomaticRenamingDialog extends DialogWrapper {
columnModel.getColumn(NEW_NAME_COLUMN).setCellEditor(new StringTableCellEditor(myProject));
mySelectAllButton.addActionListener(e -> {
for (int i = 0; i < myShouldRename.length; i++) {
myShouldRename[i] = true;
}
Arrays.fill(myShouldRename, true);
fireDataChanged();
});
myUnselectAllButton.addActionListener(e -> {
for (int i = 0; i < myShouldRename.length; i++) {
myShouldRename[i] = false;
}
Arrays.fill(myShouldRename, false);
fireDataChanged();
});
@@ -333,12 +327,11 @@ public class AutomaticRenamingDialog extends DialogWrapper {
}
@Override
public Class getColumnClass(int columnIndex) {
public Class<?> getColumnClass(int columnIndex) {
switch (columnIndex) {
case CHECK_COLUMN:
return Boolean.class;
case OLD_NAME_COLUMN:
return String.class;
case NEW_NAME_COLUMN:
return String.class;
default:
@@ -350,7 +343,7 @@ public class AutomaticRenamingDialog extends DialogWrapper {
public String getColumnName(int column) {
switch (column) {
case OLD_NAME_COLUMN:
return RefactoringBundle.message("automatic.renamer.enity.name.column", myRenamer.entityName());
return RefactoringBundle.message("automatic.renamer.entity.name.column", myRenamer.entityName());
case NEW_NAME_COLUMN:
return RefactoringBundle.message("automatic.renamer.rename.to.column");
default:
@@ -29,6 +29,7 @@ import org.jetbrains.plugins.groovy.lang.resolve.ast.builder.BuilderAnnotationCo
import org.jetbrains.plugins.groovy.lang.resolve.ast.builder.BuilderHelperLightPsiClass;
import org.jetbrains.plugins.groovy.transformations.TransformationContext;
import java.util.Arrays;
import java.util.Objects;
import static org.jetbrains.plugins.groovy.lang.resolve.ast.builder.strategy.DefaultBuilderStrategySupport.getBuilderClassName;
@@ -175,9 +176,7 @@ public class InitializerBuilderStrategySupport extends BuilderAnnotationContribu
builderClass.getResolveScope()
);
final PsiType[] mappings = PsiType.createArray(builderClass.getTypeParameters().length);
for (int i = 0; i < mappings.length; i++) {
mappings[i] = type;
}
Arrays.fill(mappings, type);
return myElementFactory.createType(builderClass, mappings);
}
}
@@ -92,9 +92,8 @@ public class HighlighterUtil {
return false;
}
@SuppressWarnings({"RawUseOfParameterizedType"})
private static boolean purgeInvalidHighlighters(Editor editor, List<RangeHighlighter> hl) {
final Set set = ContainerUtil.newIdentityTroveSet(Arrays.asList(editor.getMarkupModel().getAllHighlighters()));
final Set<RangeHighlighter> set = ContainerUtil.newIdentityTroveSet(Arrays.asList(editor.getMarkupModel().getAllHighlighters()));
boolean hasHighlighter = false;
for (Iterator<RangeHighlighter> iterator = hl.iterator(); iterator.hasNext();) {
final RangeHighlighter h = iterator.next();
@@ -165,9 +164,7 @@ public class HighlighterUtil {
final int tabSize = CodeStyle.getSettings(element.getProject()).getTabSize(FileTypeManager.getInstance().getFileTypeByExtension("xml"));
final char[] spaces = new char[tabSize];
for (int i = 0; i < spaces.length; i++) {
spaces[i] = ' ';
}
Arrays.fill(spaces, ' ');
final int textOffset = element.getTextOffset();
final int lineStartOffset = e.logicalPositionToOffset(new LogicalPosition(e.offsetToLogicalPosition(textOffset).line, 0));