Empty array constant used

This commit is contained in:
Tagir Valeev
2018-09-26 13:07:57 +07:00
parent ade5fe39aa
commit c8e4fbf305
9 changed files with 11 additions and 12 deletions

View File

@@ -22,7 +22,6 @@ import com.intellij.openapi.util.TextRange;
import java.util.EventObject;
public class SelectionEvent extends EventObject {
private static final TextRange[] EMPTY_RANGES = new TextRange[0];
private final Pair<TextRange[], TextRange> myOldRanges;
private final Pair<TextRange[], TextRange> myNewRanges;
@@ -70,7 +69,7 @@ public class SelectionEvent extends EventObject {
private static Pair<TextRange[], TextRange> getRanges(int[] starts, int[] ends) {
if (starts.length == 0) {
return Pair.create(EMPTY_RANGES, TextRange.EMPTY_RANGE);
return Pair.create(TextRange.EMPTY_ARRAY, TextRange.EMPTY_RANGE);
}
final TextRange[] ranges = new TextRange[starts.length];
int startOffset = Integer.MAX_VALUE;

View File

@@ -180,7 +180,7 @@ public class PsiElementListNavigator {
listUpdaterTask.init(popup, new ListComponentUpdater() {
@Override
public void replaceModel(@NotNull List<? extends PsiElement> data) {
updatedTargetsList.set(data.toArray(new NavigatablePsiElement[0]));
updatedTargetsList.set(data.toArray(NavigatablePsiElement.EMPTY_NAVIGATABLE_ELEMENT_ARRAY));
popupUpdater.replaceModel(data);
}

View File

@@ -278,7 +278,7 @@ public class SelectTemplateDialog extends DialogWrapper {
else {
TreePath[] paths = existingTemplatesComponent.getPatternTree().getSelectionModel().getSelectionPaths();
if (paths == null) {
return new Configuration[0];
return Configuration.EMPTY_ARRAY;
}
Collection<Configuration> configurations = new ArrayList<>();
for (TreePath path : paths) {
@@ -289,7 +289,7 @@ public class SelectTemplateDialog extends DialogWrapper {
configurations.add((Configuration)userObject);
}
}
return configurations.toArray(new Configuration[0]);
return configurations.toArray(Configuration.EMPTY_ARRAY);
}
}

View File

@@ -490,7 +490,7 @@ public class CharArrayUtil {
if (lastTextFound < result.size()) {
result = result.subList(0, lastTextFound);
}
return result.toArray(new TextRange[0]);
return result.toArray(TextRange.EMPTY_ARRAY);
}
public static boolean containLineBreaks(@NotNull CharSequence seq) {

View File

@@ -43,8 +43,8 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.*;
public class CvsTree extends JPanel implements CvsTabbedWindow.DeactivateListener, ChildrenLoader<CvsElement> {
private CvsElement[] myCurrentSelection = CvsElement.EMPTY_ARRAY;
@@ -104,7 +104,7 @@ public class CvsTree extends JPanel implements CvsTabbedWindow.DeactivateListene
selection.add(cvsElement);
}
}
myCurrentSelection = selection.toArray(new CvsElement[0]);
myCurrentSelection = selection.toArray(CvsElement.EMPTY_ARRAY);
mySelectionObservable.notifyObservers(SELECTION_CHANGED);
}

View File

@@ -114,7 +114,7 @@ public class GithubRepository extends BaseRepositoryImpl {
return getIssues(query, offset + limit, withClosed);
}
catch (GithubRateLimitExceededException e) {
return new Task[0];
return Task.EMPTY_ARRAY;
}
catch (GithubAuthenticationException | GithubStatusCodeException e) {
throw new Exception(e.getMessage(), e); // Wrap to show error message

View File

@@ -71,7 +71,7 @@ public class FormEditorErrorCollector extends FormErrorCollector {
final ErrorInfo errorInfo = new ErrorInfo(myComponent, prop == null ? null : prop.getName(), errorMessage,
myProfile.getErrorLevel(HighlightDisplayKey.find(inspectionId), myFormPsiFile),
quickFixes.toArray(new QuickFix[0]));
quickFixes.toArray(QuickFix.EMPTY_ARRAY));
errorInfo.setInspectionId(inspectionId);
myResults.add(errorInfo);
}

View File

@@ -63,7 +63,7 @@ public class XmlSurroundDescriptor implements SurroundDescriptor {
@Override
@NotNull public Surrounder[] getSurrounders() {
return new Surrounder[0]; //everything is in live templates now
return Surrounder.EMPTY_ARRAY; //everything is in live templates now
}
@Override

View File

@@ -227,7 +227,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag, HintedReferenc
list.add(TextRange.from(psi.getStartOffsetInParent(), psi.getTextLength()));
}
}
myTextElements = elements = list.toArray(new TextRange[0]);
myTextElements = elements = list.toArray(TextRange.EMPTY_ARRAY);
}
return elements;
}