Filtering kind of speedsearch for more list choosers + fix filtering performance...
[fedora-idea.git] / platform / smRunner / src / com / intellij / execution / testframework / sm / LocationProviderUtil.java
bloba83b0a432cbdd3377407ead6cedb7f5dd34f72b8
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.execution.testframework.sm;
18 import org.jetbrains.annotations.NotNull;
19 import org.jetbrains.annotations.Nullable;
20 import org.jetbrains.annotations.NonNls;
21 import com.intellij.openapi.vfs.VirtualFile;
22 import com.intellij.openapi.vfs.LocalFileSystem;
23 import com.intellij.openapi.vfs.ex.temp.TempFileSystem;
24 import com.intellij.openapi.application.ApplicationManager;
26 import java.util.List;
27 import java.util.Collections;
29 /**
30 * @author Roman Chernyatchik
32 public class LocationProviderUtil {
33 @NonNls private static final String PROTOCOL_SEPARATOR = "://";
35 private LocationProviderUtil() {
38 @Nullable
39 public static String extractProtocol(@NotNull final String locationUrl) {
40 final int index = locationUrl.indexOf(PROTOCOL_SEPARATOR);
41 if (index >= 0) {
42 return locationUrl.substring(0, index);
44 return null;
47 @Nullable
48 public static String extractPath(@NotNull final String locationUrl) {
49 final int index = locationUrl.indexOf(PROTOCOL_SEPARATOR);
50 if (index >= 0) {
51 return locationUrl.substring(index + PROTOCOL_SEPARATOR.length());
53 return null;
56 public static List<VirtualFile> findSuitableFilesFor(final String filePath) {
57 final VirtualFile fileByPath = LocalFileSystem.getInstance().findFileByPath(filePath);
58 if (fileByPath != null) {
59 return Collections.singletonList(fileByPath);
61 // if we are in UnitTest mode probably TempFileSystem is used instead of LocaFileSystem
62 if (ApplicationManager.getApplication().isUnitTestMode()) {
63 final VirtualFile tempFileByPath = TempFileSystem.getInstance().findFileByPath(filePath);
64 return Collections.singletonList(tempFileByPath);
66 return Collections.emptyList();