import java.util.*;
public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColorSettingsPage {
- private static final AttributesDescriptor[] ourDescriptors = new AttributesDescriptor[] {
+ private static final AttributesDescriptor[] ourDescriptors = {
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.keyword"), SyntaxHighlighterColors.KEYWORD),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.number"), SyntaxHighlighterColors.NUMBER),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.annotation.attribute.name"), CodeInsightColors.ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES)
};
- private static final ColorDescriptor[] ourColorDescriptors = new ColorDescriptor[0];
-
@NonNls private static final Map<String, TextAttributesKey> ourTags = new HashMap<String, TextAttributesKey>();
static {
ourTags.put("field", CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES);
@NotNull
public ColorDescriptor[] getColorDescriptors() {
- return ourColorDescriptors;
+ return ColorDescriptor.EMPTY_ARRAY;
}
@NotNull
* _inside_, not outside of the read action
*/
public class FileTemplateManagerImpl extends FileTemplateManager implements ExportableComponent, JDOMExternalizable {
+ private static final FileTemplateManagerImpl[] EMPTY_ARRAY = new FileTemplateManagerImpl[0];
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.fileTemplates.impl.FileTemplateManagerImpl");
@NonNls private static final String DEFAULT_TEMPLATE_EXTENSION = "ft";
@NonNls private static final String TEMPLATES_DIR = "fileTemplates";
myPatternsManager = patternsManager;
myCodeTemplatesManager = codeTemplatesManager;
myJ2eeTemplatesManager = j2eeTemplatesManager;
- myChildren = internalTemplatesManager == null ? new FileTemplateManagerImpl[0] : new FileTemplateManagerImpl[]{internalTemplatesManager,patternsManager,codeTemplatesManager,j2eeTemplatesManager};
+ myChildren = internalTemplatesManager == null ? EMPTY_ARRAY : new FileTemplateManagerImpl[]{internalTemplatesManager,patternsManager,codeTemplatesManager,j2eeTemplatesManager};
if (ApplicationManager.getApplication().isUnitTestMode() && defaultTemplatesDirName.equals(INTERNAL_DIR)) {
for (String tname : Arrays.asList("Class", "AnnotationType", "Enum", "Interface")) {
import java.util.Map;
public class CustomColorsPage implements ColorSettingsPage {
- private static final ColorDescriptor[] COLORS = new ColorDescriptor[0];
- private static final AttributesDescriptor[] ATTRS = new AttributesDescriptor[] {
+ private static final AttributesDescriptor[] ATTRS = {
new AttributesDescriptor(OptionsBundle.message("options.custom.attribute.descriptor.keyword1"), CustomHighlighterColors.CUSTOM_KEYWORD1_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.custom.attribute.descriptor.keyword2"), CustomHighlighterColors.CUSTOM_KEYWORD2_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.custom.attribute.descriptor.keyword3"), CustomHighlighterColors.CUSTOM_KEYWORD3_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.custom.attribute.descriptor.invalid.string.escape"), CustomHighlighterColors.CUSTOM_INVALID_STRING_ESCAPE),
};
- @NonNls private final static SyntaxTable SYNTAX_TABLE = new SyntaxTable();
+ @NonNls private static final SyntaxTable SYNTAX_TABLE = new SyntaxTable();
static {
SYNTAX_TABLE.setLineComment("#");
SYNTAX_TABLE.setStartComment("/*");
@NotNull
public ColorDescriptor[] getColorDescriptors() {
- return COLORS;
+ return ColorDescriptor.EMPTY_ARRAY;
}
@NotNull
private boolean myEnabledInModalContext;
- private static final ShortcutSet ourEmptyShortcutSet = new CustomShortcutSet(new Shortcut[0]);
+ private static final ShortcutSet ourEmptyShortcutSet = new CustomShortcutSet();
private boolean myIsDefaultIcon = true;
private boolean myWorksInInjected;
* @param shortcuts keyboard shortcuts
*/
public CustomShortcutSet(Shortcut... shortcuts){
- myShortcuts = (Shortcut[])shortcuts.clone();
+ myShortcuts = shortcuts.length == 0 ? Shortcut.EMPTY_ARRAY : shortcuts.clone();
}
public Shortcut[] getShortcuts(){
- return (Shortcut[])myShortcuts.clone();
+ return myShortcuts.length == 0 ? Shortcut.EMPTY_ARRAY : myShortcuts.clone();
}
}
\ No newline at end of file
* @see ShortcutSet
*/
public abstract class Shortcut {
+ public static final Shortcut[] EMPTY_ARRAY = new Shortcut[0];
Shortcut(){
}
import java.io.InputStream;
public interface StreamProvider {
+ StreamProvider[] EMPTY_ARRAY = new StreamProvider[0];
StreamProvider DEFAULT = new StreamProvider(){
public void saveContent(final String fileSpec, final InputStream content, final long size, final RoamingType roamingType, boolean async) throws IOException {
public StreamProvider[] getStreamProviders(RoamingType type) {
synchronized (myStreamProviders) {
final Collection<StreamProvider> providers = myStreamProviders.get(type);
- return providers.toArray(new StreamProvider[providers.size()]);
+ return providers.isEmpty() ? EMPTY_ARRAY : providers.toArray(new StreamProvider[providers.size()]);
}
}
}
}
- myCachedVisible = visible.toArray(new FoldRegion[visible.size()]);
+ myCachedVisible = visible.isEmpty() ? FoldRegion.EMPTY_ARRAY : visible.toArray(new FoldRegion[visible.size()]);
Arrays.sort(myCachedVisible, BY_END_OFFSET_REVERSE);
return ourEmptyShortcutsArray;
}
}
- return shortcuts.toArray(new Shortcut[shortcuts.size()]);
+ return shortcuts.isEmpty() ? ourEmptyShortcutsArray : shortcuts.toArray(new Shortcut[shortcuts.size()]);
}
private KeymapManagerEx getKeymapManager() {
if (baseDirPath != null) {
- SchemesManagerImpl<T, E> manager = new SchemesManagerImpl<T,E>(fileSpec, processor, roamingType,
- ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager().getStreamProviders(roamingType),
- new File(baseDirPath));
+ StreamProvider[] providers =
+ ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager().getStreamProviders(roamingType);
+ SchemesManagerImpl<T, E> manager = new SchemesManagerImpl<T,E>(fileSpec, processor, roamingType, providers, new File(baseDirPath));
myRegisteredManagers.add(manager);
return manager;
}
for (final XmlTagChild element : myElements) {
if (element instanceof XmlText) textElementsList.add((XmlText)element);
}
- return myTextElements = ContainerUtil.toArray(textElementsList, new XmlText[textElementsList.size()]);
+ return myTextElements = textElementsList.isEmpty() ? XmlText.EMPTY_ARRAY : ContainerUtil.toArray(textElementsList, new XmlText[textElementsList.size()]);
}
@NotNull
@Nullable
XmlText split(int displayIndex);
+ XmlText[] EMPTY_ARRAY = new XmlText[0];
}