cleanup — reduce usage of getChildren

This commit is contained in:
Vladimir Krivosheev
2016-05-02 17:14:08 +02:00
parent f9830d6090
commit 236502bb35
3 changed files with 17 additions and 20 deletions
@@ -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.
@@ -109,7 +109,7 @@ public class JpsLibraryTableSerializer {
recursiveJarDirectories.putValue(rootType, url);
}
}
for (Element rootsElement : JDOMUtil.getChildren(libraryElement)) {
for (Element rootsElement : libraryElement.getChildren()) {
final String rootTypeId = rootsElement.getName();
if (!rootTypeId.equals(JAR_DIRECTORY_TAG)) {
final JpsOrderRootType rootType = getRootType(rootTypeId);
@@ -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.
@@ -26,10 +26,13 @@ import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.java.JpsJavaSdkType;
import org.jetbrains.jps.model.java.JpsJavaSdkTypeWrapper;
import org.jetbrains.jps.model.library.*;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsLibraryCollection;
import org.jetbrains.jps.model.library.JpsLibraryRoot;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.library.sdk.JpsSdk;
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
import org.jetbrains.jps.model.library.sdk.JpsSdkReference;
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
import org.jetbrains.jps.model.module.JpsSdkReferencesTable;
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension;
@@ -102,7 +105,7 @@ public class JpsSdkTableSerializer {
for (Element rootTypeElement : JDOMUtil.getChildren(roots)) {
JpsLibraryRootTypeSerializer rootTypeSerializer = getRootTypeSerializer(rootTypeElement.getName());
if (rootTypeSerializer != null) {
for (Element rootElement : JDOMUtil.getChildren(rootTypeElement)) {
for (Element rootElement : rootTypeElement.getChildren()) {
loadRoots(rootElement, library, rootTypeSerializer.getType());
}
}
@@ -158,7 +161,7 @@ public class JpsSdkTableSerializer {
private static void loadRoots(Element rootElement, JpsLibrary library, JpsOrderRootType rootType) {
final String type = rootElement.getAttributeValue(TYPE_ATTRIBUTE);
if (type.equals(COMPOSITE_TYPE)) {
for (Element element : JDOMUtil.getChildren(rootElement)) {
for (Element element : rootElement.getChildren()) {
loadRoots(element, library, rootType);
}
}
@@ -426,18 +426,13 @@ public class JDOMUtil {
}
@NotNull
public static String writeChildren(@Nullable final Element element, @NotNull final String lineSeparator) {
try {
final StringWriter writer = new StringWriter();
for (Element child : getChildren(element)) {
writeElement(child, writer, lineSeparator);
writer.append(lineSeparator);
}
return writer.toString();
}
catch (IOException e) {
throw new RuntimeException(e);
public static String writeChildren(@NotNull final Element element, @NotNull final String lineSeparator) throws IOException {
final StringWriter writer = new StringWriter();
for (Element child : element.getChildren()) {
writeElement(child, writer, lineSeparator);
writer.append(lineSeparator);
}
return writer.toString();
}
public static void writeDocument(@NotNull Document document, @NotNull Writer writer, String lineSeparator) throws IOException {
@@ -546,8 +541,7 @@ public class JDOMUtil {
System.err.println(prefix);
}
List<Element> children = getChildren(element);
for (final Element child : children) {
for (final Element child : element.getChildren()) {
printDiagnostics(child, prefix);
}
}