Cleanup (duplicate method deprecated)

This commit is contained in:
Roman Shevchenko
2015-04-18 09:47:19 +02:00
parent ee73b46a58
commit b388a4b47c
4 changed files with 64 additions and 87 deletions
@@ -0,0 +1,48 @@
/*
* 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.
* 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.openapi.vfs;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class UrlSplittingTest {
@Test
public void testExtractProtocol() {
assertEquals(null, VirtualFileManager.extractProtocol(""));
assertEquals(null, VirtualFileManager.extractProtocol("file:/"));
assertEquals("file", VirtualFileManager.extractProtocol("file://"));
assertEquals("file", VirtualFileManager.extractProtocol("file:///some/path/file.rb:24"));
assertEquals("file", VirtualFileManager.extractProtocol("file://./some/path/file.rb:24"));
assertEquals("ruby_qn", VirtualFileManager.extractProtocol("ruby_qn://"));
assertEquals("ruby_qn", VirtualFileManager.extractProtocol("ruby_qn://A::B.method"));
}
@Test
public void testExtractPath() {
assertEquals("", VirtualFileManager.extractPath(""));
assertEquals("file:/", VirtualFileManager.extractPath("file:/"));
assertEquals("", VirtualFileManager.extractPath("file://"));
assertEquals("/some/path/file.rb:24", VirtualFileManager.extractPath("file:///some/path/file.rb:24"));
assertEquals("./some/path/file.rb:24", VirtualFileManager.extractPath("file://./some/path/file.rb:24"));
assertEquals("", VirtualFileManager.extractPath("ruby_qn://"));
assertEquals("A::B.method", VirtualFileManager.extractPath("ruby_qn://A::B.method"));
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 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.
@@ -26,8 +26,8 @@ import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.ex.temp.TempFileSystem;
import com.intellij.psi.PsiFile;
import com.intellij.util.io.URLUtil;
import com.intellij.util.text.StringTokenizer;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -40,19 +40,15 @@ import java.util.List;
* @author Roman Chernyatchik
*/
public class TestsLocationProviderUtil {
@NonNls private static final String PROTOCOL_SEPARATOR = "://";
private static final int MIN_PROXIMITY_THRESHOLD = 1;
private TestsLocationProviderUtil() {
}
private TestsLocationProviderUtil() { }
@Nullable
public static String extractPath(@NotNull final String locationUrl) {
final int index = locationUrl.indexOf(PROTOCOL_SEPARATOR);
if (index >= 0) {
return locationUrl.substring(index + PROTOCOL_SEPARATOR.length());
}
return null;
/** @deprecated to be removed in IDEA 16 */
@SuppressWarnings("unused")
public static String extractPath(@NotNull String locationUrl) {
int index = locationUrl.indexOf(URLUtil.SCHEME_SEPARATOR);
return index >= 0 ? locationUrl.substring(index + URLUtil.SCHEME_SEPARATOR.length()) : null;
}
public static List<VirtualFile> findSuitableFilesFor(final String filePath, final Project project) {
@@ -18,7 +18,6 @@ package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.Location;
import com.intellij.execution.testframework.*;
import com.intellij.execution.testframework.sm.SMStacktraceParser;
import com.intellij.execution.testframework.sm.TestsLocationProviderUtil;
import com.intellij.execution.testframework.sm.runner.states.*;
import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil;
import com.intellij.execution.testframework.stacktrace.DiffHyperlink;
@@ -247,18 +246,14 @@ public class SMTestProxy extends AbstractTestProxy {
@Nullable
public Location getLocation(final Project project, GlobalSearchScope searchScope) {
//determines location of test proxy
if (myLocationUrl == null || myLocator == null) {
return null;
}
final String protocolId = VirtualFileManager.extractProtocol(myLocationUrl);
final String path = TestsLocationProviderUtil.extractPath(myLocationUrl);
if (protocolId != null && path != null) {
List<Location> locations = myLocator.getLocation(protocolId, path, project);
if (!locations.isEmpty()) {
return locations.iterator().next();
if (myLocationUrl != null && myLocator != null) {
String protocolId = VirtualFileManager.extractProtocol(myLocationUrl);
if (protocolId != null) {
String path = VirtualFileManager.extractPath(myLocationUrl);
List<Location> locations = myLocator.getLocation(protocolId, path, project);
if (!locations.isEmpty()) {
return locations.get(0);
}
}
}
@@ -1,62 +0,0 @@
/*
* Copyright 2000-2009 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.execution.testframework.sm;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.testFramework.UsefulTestCase;
/**
* @author Roman Chernyatchik
*/
public class LocationProviderUtilTest extends UsefulTestCase {
public void testExtractProtocol() {
assertEquals(null,
VirtualFileManager.extractProtocol(""));
assertEquals(null,
VirtualFileManager.extractProtocol("file:/"));
assertEquals("file",
VirtualFileManager.extractProtocol("file://"));
assertEquals("file",
VirtualFileManager.extractProtocol("file:///some/path/file.rb:24"));
assertEquals("file",
VirtualFileManager.extractProtocol("file://./some/path/file.rb:24"));
assertEquals("ruby_qn",
VirtualFileManager.extractProtocol("ruby_qn://"));
assertEquals("ruby_qn",
VirtualFileManager.extractProtocol("ruby_qn://A::B.method"));
}
public void testExtractPath() {
assertEquals(null,
TestsLocationProviderUtil.extractPath(""));
assertEquals(null,
TestsLocationProviderUtil.extractPath("file:/"));
assertEquals("",
TestsLocationProviderUtil.extractPath("file://"));
assertEquals("/some/path/file.rb:24",
TestsLocationProviderUtil.extractPath("file:///some/path/file.rb:24"));
assertEquals("./some/path/file.rb:24",
TestsLocationProviderUtil.extractPath("file://./some/path/file.rb:24"));
assertEquals("",
TestsLocationProviderUtil.extractPath("ruby_qn://"));
assertEquals("A::B.method",
TestsLocationProviderUtil.extractPath("ruby_qn://A::B.method"));
}
}