diff --git a/platform/platform-tests/testSrc/com/intellij/util/JDOMUtilTest.kt b/platform/platform-tests/testSrc/com/intellij/util/JDOMUtilTest.kt index 3228856b449c..8bf5b047ff2b 100644 --- a/platform/platform-tests/testSrc/com/intellij/util/JDOMUtilTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/util/JDOMUtilTest.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util import com.intellij.openapi.application.ex.PathManagerEx @@ -340,6 +340,6 @@ internal class JDOMUtilTest { } private fun assertElementText(actual: Element, expected: String) { - assertThat(JDOMUtil.createOutputter("").outputString(actual)).isEqualTo(expected) + assertThat(JDOMUtil.writeElement(actual)).isEqualTo(expected) } } diff --git a/platform/tasks-platform-impl/src/com/intellij/tasks/impl/TaskUtil.java b/platform/tasks-platform-impl/src/com/intellij/tasks/impl/TaskUtil.java index 409b1d7f14e4..48077b501b81 100644 --- a/platform/tasks-platform-impl/src/com/intellij/tasks/impl/TaskUtil.java +++ b/platform/tasks-platform-impl/src/com/intellij/tasks/impl/TaskUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.tasks.impl; import com.google.gson.Gson; @@ -16,12 +16,11 @@ import com.intellij.tasks.LocalTask; import com.intellij.tasks.Task; import com.intellij.tasks.TaskRepository; import com.intellij.util.containers.ContainerUtil; -import org.jdom.Element; +import com.intellij.util.text.Matcher; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.InputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.time.Instant; @@ -165,38 +164,13 @@ public final class TaskUtil { return tasksEqual(Arrays.asList(task1), Arrays.asList(task2)); } - /** - * Print pretty-formatted XML to {@code logger}, if its level is DEBUG or below. - */ - public static void prettyFormatXmlToLog(@NotNull Logger logger, @NotNull Element element) { - if (logger.isDebugEnabled()) { - // alternatively - //new XMLOutputter(Format.getPrettyFormat()).outputString(root) - logger.debug("\n" + JDOMUtil.createOutputter("\n").outputString(element)); - } - } - - /** - * Parse and print pretty-formatted XML to {@code logger}, if its level is DEBUG or below. - */ - public static void prettyFormatXmlToLog(@NotNull Logger logger, @NotNull InputStream xml) { - if (logger.isDebugEnabled()) { - try { - logger.debug("\n" + JDOMUtil.createOutputter("\n").outputString(JDOMUtil.load(xml))); - } - catch (Exception e) { - logger.debug(e); - } - } - } - /** * Parse and print pretty-formatted XML to {@code logger}, if its level is DEBUG or below. */ public static void prettyFormatXmlToLog(@NotNull Logger logger, @NotNull String xml) { if (logger.isDebugEnabled()) { try { - logger.debug("\n" + JDOMUtil.createOutputter("\n").outputString(JDOMUtil.load(xml))); + logger.debug("\n" + JDOMUtil.write(JDOMUtil.load(xml))); } catch (Exception e) { logger.debug(e); @@ -219,21 +193,6 @@ public final class TaskUtil { } } - /** - * Parse and print pretty-formatted Json to {@code logger}, if its level is DEBUG or below. - */ - public static void prettyFormatJsonToLog(@NotNull Logger logger, @NotNull JsonElement json) { - if (logger.isDebugEnabled()) { - try { - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - logger.debug("\n" + gson.toJson(json)); - } - catch (JsonSyntaxException e) { - logger.debug("Malformed JSON\n" + json); - } - } - } - /** * Perform standard {@code application/x-www-urlencoded} translation for string {@code s}. * @@ -244,12 +203,12 @@ public final class TaskUtil { } public static List filterTasks(final String pattern, final List tasks) { - final com.intellij.util.text.Matcher matcher = getMatcher(pattern); + final Matcher matcher = getMatcher(pattern); return ContainerUtil.mapNotNull(tasks, task -> matcher.matches(task.getPresentableId()) || matcher.matches(task.getSummary()) ? task : null); } - private static com.intellij.util.text.Matcher getMatcher(String pattern) { + private static Matcher getMatcher(String pattern) { StringTokenizer tokenizer = new StringTokenizer(pattern, " "); StringBuilder builder = new StringBuilder(); while (tokenizer.hasMoreTokens()) { diff --git a/platform/util/testSrc/com/intellij/util/XMLOutputterTest.java b/platform/util/testSrc/com/intellij/util/XMLOutputterTest.java index 2b35e560644a..1c8bf4aa3b5e 100644 --- a/platform/util/testSrc/com/intellij/util/XMLOutputterTest.java +++ b/platform/util/testSrc/com/intellij/util/XMLOutputterTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util; import com.intellij.openapi.util.JDOMUtil; @@ -27,7 +27,7 @@ public class XMLOutputterTest extends TestCase { private static String printElement(Element root) throws IOException { XMLOutputter xmlOutputter = JDOMUtil.createOutputter("\n"); - final Format format = xmlOutputter.getFormat().setOmitDeclaration(true).setOmitEncoding(true).setExpandEmptyElements(true); + Format format = xmlOutputter.getFormat().setOmitDeclaration(true).setOmitEncoding(true).setExpandEmptyElements(true); xmlOutputter.setFormat(format); CharArrayWriter writer = new CharArrayWriter();