make loadDocument(@NotNull Reader reader) private

This commit is contained in:
Vladimir Krivosheev
2017-02-14 17:14:36 +01:00
parent c0bd98bc6e
commit bb03983d9a
3 changed files with 24 additions and 8 deletions
@@ -1,13 +1,27 @@
/*
* Copyright 2000-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.jarFinder;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.StreamUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.JdomKt;
import com.intellij.util.io.HttpRequests;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -52,14 +66,14 @@ public abstract class SourceSearcher {
}
@NotNull
protected static Document readDocumentCancelable(final ProgressIndicator indicator, String url) throws IOException {
protected static Element readDocumentCancelable(final ProgressIndicator indicator, String url) throws IOException {
return HttpRequests.request(url)
.accept("application/xml")
.connect(new HttpRequests.RequestProcessor<Document>() {
.connect(new HttpRequests.RequestProcessor<Element>() {
@Override
public Document process(@NotNull HttpRequests.Request request) throws IOException {
public Element process(@NotNull HttpRequests.Request request) throws IOException {
try {
return JDOMUtil.loadDocument(request.getReader(indicator));
return JdomKt.loadElement(request.getReader(indicator));
}
catch (JDOMException e) {
throw new IOException(e);
@@ -69,8 +69,10 @@ fun Parent.write(file: Path, lineSeparator: String = "\n") {
@Throws(IOException::class, JDOMException::class)
fun loadElement(chars: CharSequence) = loadElement(CharSequenceReader(chars))
@Throws(IOException::class, JDOMException::class)
fun loadElement(reader: Reader): Element = loadDocument(reader).detachRootElement()
@Throws(IOException::class, JDOMException::class)
fun loadElement(stream: InputStream): Element = loadDocument(stream.reader()).detachRootElement()
@Throws(IOException::class, JDOMException::class)
@@ -285,7 +285,7 @@ public class JDOMUtil {
}
@NotNull
public static Document loadDocument(@NotNull Reader reader) throws IOException, JDOMException {
private static Document loadDocument(@NotNull Reader reader) throws IOException, JDOMException {
try {
return getSaxBuilder().build(reader);
}