Java Code Examples for com.intellij.openapi.vfs.VirtualFileManager#extractProtocol()

The following examples show how to use com.intellij.openapi.vfs.VirtualFileManager#extractProtocol() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazeWebJavascriptTestEventsHandlerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  if (protocol == null) {
    return null;
  }
  String path = VirtualFileManager.extractPath(url);
  assertThat(handler.getTestLocator()).isNotNull();
  @SuppressWarnings("rawtypes")
  List<Location> locations =
      handler
          .getTestLocator()
          .getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject()));
  assertThat(locations).hasSize(1);
  return locations.get(0);
}
 
Example 2
Source File: BlazeJavascriptWebTestEventsHandlerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  if (protocol == null) {
    return null;
  }
  String path = VirtualFileManager.extractPath(url);
  assertThat(handler.getTestLocator()).isNotNull();
  @SuppressWarnings("rawtypes")
  List<Location> locations =
      handler
          .getTestLocator()
          .getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject()));
  assertThat(locations).hasSize(1);
  return locations.get(0);
}
 
Example 3
Source File: BlazeGoWebTestEventsHandlerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  if (protocol == null) {
    return null;
  }
  String path = VirtualFileManager.extractPath(url);
  assertThat(handler.getTestLocator()).isNotNull();
  @SuppressWarnings("rawtypes")
  List<Location> locations =
      handler
          .getTestLocator()
          .getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject()));
  assertThat(locations).hasSize(1);
  return locations.get(0);
}
 
Example 4
Source File: BlazeWebGoTestEventsHandlerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  if (protocol == null) {
    return null;
  }
  String path = VirtualFileManager.extractPath(url);
  assertThat(handler.getTestLocator()).isNotNull();
  @SuppressWarnings("rawtypes")
  List<Location> locations =
      handler
          .getTestLocator()
          .getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject()));
  assertThat(locations).hasSize(1);
  return locations.get(0);
}
 
Example 5
Source File: BlazeGoTestEventsHandlerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  if (protocol == null) {
    return null;
  }
  String path = VirtualFileManager.extractPath(url);
  assertThat(handler.getTestLocator()).isNotNull();
  @SuppressWarnings("rawtypes")
  List<Location> locations =
      handler
          .getTestLocator()
          .getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject()));
  assertThat(locations).hasSize(1);
  return locations.get(0);
}
 
Example 6
Source File: SMTestProxy.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected Location getLocation(@Nonnull Project project, @Nonnull GlobalSearchScope searchScope, String locationUrl) {
  if (locationUrl != null && myLocator != null) {
    String protocolId = VirtualFileManager.extractProtocol(locationUrl);
    if (protocolId != null) {
      String path = VirtualFileManager.extractPath(locationUrl);
      if (!DumbService.isDumb(project) || DumbService.isDumbAware(myLocator)) {
        return DumbService.getInstance(project).computeWithAlternativeResolveEnabled(() -> {
          List<Location> locations = myLocator.getLocation(protocolId, path, myMetainfo, project, searchScope);
          return !locations.isEmpty() ? locations.get(0) : null;
        });
      }
    }
  }

  return null;
}
 
Example 7
Source File: BlazeAndroidTestEventsHandlerTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  String path = VirtualFileManager.extractPath(url);
  if (protocol == null) {
    return null;
  }
  return Iterables.getFirst(
      handler
          .getTestLocator()
          .getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject())),
      null);
}
 
Example 8
Source File: BlazeJavaWebTestEventsHandlerTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  String path = VirtualFileManager.extractPath(url);
  if (protocol == null) {
    return null;
  }
  SMTestLocator locator = handler.getTestLocator();
  assertThat(locator).isNotNull();
  return Iterables.getFirst(
      locator.getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject())),
      null);
}
 
Example 9
Source File: BlazeWebJavaTestEventsHandlerTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  String path = VirtualFileManager.extractPath(url);
  if (protocol == null) {
    return null;
  }
  SMTestLocator locator = handler.getTestLocator();
  assertThat(locator).isNotNull();
  return Iterables.getFirst(
      locator.getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject())),
      null);
}
 
Example 10
Source File: BlazeJavaTestEventsHandlerTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  String path = VirtualFileManager.extractPath(url);
  if (protocol == null) {
    return null;
  }
  return Iterables.getFirst(
      handler
          .getTestLocator()
          .getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject())),
      null);
}
 
Example 11
Source File: BlazePythonTestEventsHandlerTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
private Location<?> getLocation(String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  String path = VirtualFileManager.extractPath(url);
  if (protocol == null) {
    return null;
  }
  return Iterables.getFirst(
      handler
          .getTestLocator()
          .getLocation(protocol, path, getProject(), GlobalSearchScope.allScope(getProject())),
      null);
}
 
Example 12
Source File: RootsAsVirtualFilePointers.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void setNoCopyJars(@Nonnull String url) {
  String protocol = VirtualFileManager.extractProtocol(url);
  if (protocol == null) {
    return;
  }

  VirtualFileSystem fs = VirtualFileManager.getInstance().getFileSystem(protocol);
  if (fs instanceof ArchiveFileSystem) {
    ((ArchiveFileSystem)fs).addNoCopyArchiveForPath(url);
  }
}
 
Example 13
Source File: LightFilePointer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static String toPresentableUrl(@Nonnull String url) {
  String path = VirtualFileManager.extractPath(url);
  String protocol = VirtualFileManager.extractProtocol(url);
  VirtualFileSystem fileSystem = VirtualFileManager.getInstance().getFileSystem(protocol);
  return ObjectUtils.notNull(fileSystem, StandardFileSystems.local()).extractPresentableUrl(path);
}
 
Example 14
Source File: LibraryEditingUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void copyLibrary(LibraryEx from, Map<String, String> rootMapping, LibraryEx.ModifiableModelEx target) {
  target.setProperties(from.getProperties());
  for (OrderRootType type : OrderRootType.getAllTypes()) {
    final String[] urls = from.getUrls(type);
    for (String url : urls) {
      final String protocol = VirtualFileManager.extractProtocol(url);
      if (protocol == null) continue;
      final String fullPath = VirtualFileManager.extractPath(url);
      final int sep = fullPath.indexOf(ArchiveFileSystem.ARCHIVE_SEPARATOR);
      String localPath;
      String pathInJar;
      if (sep != -1) {
        localPath = fullPath.substring(0, sep);
        pathInJar = fullPath.substring(sep);
      }
      else {
        localPath = fullPath;
        pathInJar = "";
      }
      final String targetPath = rootMapping.get(localPath);
      String targetUrl = targetPath != null ? VirtualFileManager.constructUrl(protocol, targetPath + pathInJar) : url;

      if (from.isJarDirectory(url, type)) {
        target.addJarDirectory(targetUrl, false, type);
      }
      else {
        target.addRoot(targetUrl, type);
      }
    }
  }
}
 
Example 15
Source File: ExternalizablePath.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(final Element element) throws InvalidDataException {
  final String value = element.getAttributeValue(VALUE_ATTRIBUTE);
  myUrl = value != null ? value : "";
  final String protocol = VirtualFileManager.extractProtocol(myUrl);
  if (protocol == null) myUrl = urlValue(myUrl);
}