From 1d7ace6226264b242ff298c164c8c746cd984741 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 18 Feb 2015 13:18:13 +0100 Subject: [PATCH] cleanup --- .../fileTypes/impl/AbstractFileType.java | 40 +++++++++---------- .../openapi/options/SchemesManagerImpl.java | 2 +- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/AbstractFileType.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/AbstractFileType.java index 168c18258f15..9fd097e091dc 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/AbstractFileType.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/AbstractFileType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -36,8 +36,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; -import java.util.*; - +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Set; public class AbstractFileType extends UserFileType implements ExternalizableFileType, ExternalizableScheme, CustomSyntaxTableFileType { @@ -112,13 +114,10 @@ public class AbstractFileType extends UserFileType implements } @Override - public void readExternal(final Element typeElement) throws InvalidDataException { + public void readExternal(@NotNull Element typeElement) throws InvalidDataException { Element element = typeElement.getChild(ELEMENT_HIGHLIGHTING); if (element != null) { - SyntaxTable table = readSyntaxTable(element); - if (table != null) { - setSyntaxTable(table); - } + setSyntaxTable(readSyntaxTable(element)); } } @@ -329,8 +328,8 @@ public class AbstractFileType extends UserFileType implements @NonNls private static final String ATTRIBUTE_TYPE = "type"; @NotNull - public static List> readAssociations(@NotNull Element e) { - List children = e.getChildren(ELEMENT_MAPPING); + public static List> readAssociations(@NotNull Element element) { + List children = element.getChildren(ELEMENT_MAPPING); if (children.isEmpty()) { return Collections.emptyList(); } @@ -347,19 +346,18 @@ public class AbstractFileType extends UserFileType implements } @NotNull - public static List> readRemovedAssociations(@NotNull Element e) { - ArrayList> result = new ArrayList>(); - List removedMappings = e.getChildren(ELEMENT_REMOVED_MAPPING); - for (Object removedMapping : removedMappings) { - Element mapping = (Element)removedMapping; - String ext = mapping.getAttributeValue(ATTRIBUTE_EXT); - String pattern = mapping.getAttributeValue(ATTRIBUTE_PATTERN); - String approved = mapping.getAttributeValue(ATTRIBUTE_APPROVED); - - FileNameMatcher matcher = ext != null ? new ExtensionFileNameMatcher(ext) : FileTypeManager.parseFromString(pattern); - result.add(new Trinity(matcher, mapping.getAttributeValue(ATTRIBUTE_TYPE), Boolean.parseBoolean(approved))); + public static List> readRemovedAssociations(@NotNull Element element) { + List> result = new SmartList>(); + List children = element.getChildren(ELEMENT_REMOVED_MAPPING); + if (children.isEmpty()) { + return Collections.emptyList(); } + for (Element mapping : children) { + String ext = mapping.getAttributeValue(ATTRIBUTE_EXT); + FileNameMatcher matcher = ext == null ? FileTypeManager.parseFromString(mapping.getAttributeValue(ATTRIBUTE_PATTERN)) : new ExtensionFileNameMatcher(ext); + result.add(Trinity.create(matcher, mapping.getAttributeValue(ATTRIBUTE_TYPE), Boolean.parseBoolean(mapping.getAttributeValue(ATTRIBUTE_APPROVED)))); + } return result; } diff --git a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java index 612faa102f71..7d7cd1b517fd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java @@ -414,7 +414,7 @@ public class SchemesManagerImpl)myProcessor).readScheme(element);