From 476a7f3ce89868d4334331d96c539cf4733ec9df Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 2 Nov 2016 11:20:40 +0100 Subject: [PATCH] cleanup --- .../openapi/application/impl/ApplicationInfoImpl.java | 9 ++++----- .../intellij/conversion/impl/ConversionContextImpl.java | 8 +++----- .../com/intellij/openapi/util/JDOMExternalizerUtil.java | 5 +++-- .../converter/AppEngineFacetConverterProvider.java | 8 +++----- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java b/platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java index ad42214fa69c..245a881e623f 100644 --- a/platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -869,12 +869,11 @@ public class ApplicationInfoImpl extends ApplicationInfoEx { } myPluginChooserPages = new ArrayList(); - final List children = parentNode.getChildren(PLUGINS_PAGE_ELEMENT_NAME); - for(Object child: children) { - myPluginChooserPages.add(new PluginChooserPageImpl((Element) child)); + for (Element child : parentNode.getChildren(PLUGINS_PAGE_ELEMENT_NAME)) { + myPluginChooserPages.add(new PluginChooserPageImpl(child)); } - List essentialPluginsElements = JDOMUtil.getChildren(parentNode, ESSENTIAL_PLUGIN); + List essentialPluginsElements = parentNode.getChildren(ESSENTIAL_PLUGIN); Collection essentialPluginsIds = ContainerUtil.mapNotNull(essentialPluginsElements, new Function() { @Override public String fun(Element element) { diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java index 0696a70597d2..1bc0357d4d40 100644 --- a/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/conversion/impl/ConversionContextImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -33,7 +33,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.impl.libraries.LibraryImpl; import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; import com.intellij.openapi.util.Condition; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileFilters; import com.intellij.openapi.util.io.FileUtil; @@ -152,7 +151,7 @@ public class ConversionContextImpl implements ConversionContext { final ExpandMacroToPathMap macros = createExpandMacroMap(); List files = new ArrayList<>(); - for (Element module : JDOMUtil.getChildren(modules, ModuleManagerImpl.ELEMENT_MODULE)) { + for (Element module : modules.getChildren(ModuleManagerImpl.ELEMENT_MODULE)) { String filePath = module.getAttributeValue(ModuleManagerImpl.ATTRIBUTE_FILEPATH); filePath = macros.substitute(filePath, true); files.add(new File(FileUtil.toSystemDependentName(filePath))); @@ -228,9 +227,8 @@ public class ConversionContextImpl implements ConversionContext { //todo[nik] support jar directories final Element classesChild = libraryElement.getChild("CLASSES"); if (classesChild != null) { - final List roots = JDOMUtil.getChildren(classesChild, "root"); final ExpandMacroToPathMap pathMap = createExpandMacroMap(moduleSettings); - for (Element root : roots) { + for (Element root : classesChild.getChildren("root")) { final String url = root.getAttributeValue("url"); final String path = VfsUtilCore.urlToPath(url); files.add(new File(PathUtil.getLocalPath(pathMap.substitute(path, true)))); diff --git a/platform/util/src/com/intellij/openapi/util/JDOMExternalizerUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMExternalizerUtil.java index 6c6df9a3481e..468d82e7185b 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMExternalizerUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMExternalizerUtil.java @@ -27,6 +27,7 @@ import java.util.List; @SuppressWarnings({"HardCodedStringLiteral"}) public class JDOMExternalizerUtil { + private static final String VALUE_ATTR_NAME = "value"; public static void writeField(@NotNull Element root, @NotNull @NonNls String fieldName, String value) { @@ -44,7 +45,7 @@ public class JDOMExternalizerUtil { @Nullable public static String readField(@NotNull Element parent, @NotNull @NonNls String fieldName) { - for (Element element : JDOMUtil.getChildren(parent, "option")) { + for (Element element : parent.getChildren("option")) { String childName = element.getAttributeValue("name"); if (Comparing.strEqual(childName, fieldName)) { return element.getAttributeValue("value"); @@ -54,7 +55,7 @@ public class JDOMExternalizerUtil { } public static Element getOption(@NotNull Element parent, @NotNull @NonNls String fieldName) { - for (Element element : JDOMUtil.getChildren(parent, "option")) { + for (Element element : parent.getChildren("option")) { String childName = element.getAttributeValue("name"); if (Comparing.strEqual(childName, fieldName)) { return element; diff --git a/plugins/google-app-engine/source/com/intellij/appengine/converter/AppEngineFacetConverterProvider.java b/plugins/google-app-engine/source/com/intellij/appengine/converter/AppEngineFacetConverterProvider.java index fb764b60119b..9ca46d319198 100644 --- a/plugins/google-app-engine/source/com/intellij/appengine/converter/AppEngineFacetConverterProvider.java +++ b/plugins/google-app-engine/source/com/intellij/appengine/converter/AppEngineFacetConverterProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -17,7 +17,6 @@ package com.intellij.appengine.converter; import com.intellij.appengine.facet.AppEngineFacetType; import com.intellij.conversion.*; -import com.intellij.openapi.util.JDOMUtil; import com.intellij.util.containers.ContainerUtil; import org.jdom.Element; import org.jetbrains.annotations.NotNull; @@ -54,7 +53,6 @@ public class AppEngineFacetConverterProvider extends ConverterProvider { } private static class GoogleAppEngineFacetConversionProcessor extends ConversionProcessor { - @Override public boolean isConversionNeeded(ModuleSettings settings) { return !getAppEngineFacetTags(settings).isEmpty(); @@ -70,7 +68,7 @@ public class AppEngineFacetConverterProvider extends ConverterProvider { if (facetTag != null) { String facetName = facetTag.getAttributeValue(JpsFacetSerializer.NAME_ATTRIBUTE); Element configuration = facetTag.getChild(JpsFacetSerializer.CONFIGURATION_TAG); - settings.addFacetElement(AppEngineFacetType.STRING_ID, facetName, (Element)configuration.clone()); + settings.addFacetElement(AppEngineFacetType.STRING_ID, facetName, configuration.clone()); } } @@ -78,7 +76,7 @@ public class AppEngineFacetConverterProvider extends ConverterProvider { private static List getAppEngineFacetTags(@NotNull ModuleSettings settings) { List appEngineFacetTags = new ArrayList<>(); for (Element webFacetTag : settings.getFacetElements("web")) { - for (Element childFacetTag : JDOMUtil.getChildren(webFacetTag, JpsFacetSerializer.FACET_TAG)) { + for (Element childFacetTag : webFacetTag.getChildren(JpsFacetSerializer.FACET_TAG)) { if (AppEngineFacetType.STRING_ID.equals(childFacetTag.getAttributeValue(JpsFacetSerializer.TYPE_ATTRIBUTE))) { appEngineFacetTags.add(childFacetTag); }