Java 类com.intellij.util.UrlImpl 实例源码

项目:Intellij-Plugin    文件:GaugeWebBrowserPreview.java   
@Nullable
private Url previewUrl(OpenInBrowserRequest request, VirtualFile virtualFile, GaugeSettingsModel settings) throws IOException, InterruptedException {
    ProcessBuilder builder = new ProcessBuilder(settings.getGaugePath(), Constants.DOCS, Spectacle.NAME, virtualFile.getPath());
    String projectName = request.getProject().getName();
    builder.environment().put("spectacle_out_dir", createOrGetTempDirectory(projectName).getPath() + "/docs");
    builder.directory(GaugeUtil.moduleDir(GaugeUtil.moduleForPsiElement(request.getFile())));
    GaugeUtil.setGaugeEnvironmentsTo(builder, settings);
    Process docsProcess = builder.start();
    int exitCode = docsProcess.waitFor();
    if (exitCode != 0) {
        String docsOutput = String.format("<pre>%s</pre>", GaugeUtil.getOutput(docsProcess.getInputStream(), " ").replace("<", "&lt;").replace(">", "&gt;"));
        Notifications.Bus.notify(new Notification("Specification Preview", "Error: Specification Preview", docsOutput, NotificationType.ERROR));
        return null;
    }
    return new UrlImpl(FileUtil.join(createOrGetTempDirectory(projectName).getPath(), "docs/html/specs/" + virtualFile.getNameWithoutExtension() + ".html"));
}
项目:intellij-ce-playground    文件:SourceResolver.java   
protected Url canonicalizeUrl(@NotNull String url, @Nullable Url baseUrl, boolean trimFileScheme, int sourceIndex, boolean baseUrlIsFile) {
  if (trimFileScheme && url.startsWith(StandardFileSystems.FILE_PROTOCOL_PREFIX)) {
    return Urls.newLocalFileUrl(FileUtil.toCanonicalPath(VfsUtilCore.toIdeaUrl(url, true).substring(StandardFileSystems.FILE_PROTOCOL_PREFIX.length()), '/'));
  }
  else if (baseUrl == null || url.contains(URLUtil.SCHEME_SEPARATOR) || url.startsWith("data:") || url.startsWith("blob:") || url.startsWith("javascript:")) {
    return Urls.parseEncoded(url);
  }

  String path = canonicalizePath(url, baseUrl, baseUrlIsFile);
  if (baseUrl.getScheme() == null && baseUrl.isInLocalFileSystem()) {
    return Urls.newLocalFileUrl(path);
  }

  // browserify produces absolute path in the local filesystem
  if (isAbsolute(path)) {
    VirtualFile file = LocalFileFinder.findFile(path);
    if (file != null) {
      if (absoluteLocalPathToSourceIndex == null) {
        // must be linked, on iterate original path must be first
        absoluteLocalPathToSourceIndex = createStringIntMap(rawSources.size());
        sourceIndexToAbsoluteLocalPath = new String[rawSources.size()];
      }
      absoluteLocalPathToSourceIndex.put(path, sourceIndex);
      sourceIndexToAbsoluteLocalPath[sourceIndex] = path;
      String canonicalPath = file.getCanonicalPath();
      if (canonicalPath != null && !canonicalPath.equals(path)) {
        absoluteLocalPathToSourceIndex.put(canonicalPath, sourceIndex);
      }
      return Urls.newLocalFileUrl(path);
    }
  }
  return new UrlImpl(baseUrl.getScheme(), baseUrl.getAuthority(), path, null);
}
项目:consulo    文件:BuiltInServerManagerImpl.java   
@Override
public Url addAuthToken(@Nonnull Url url) {
  if (url.getParameters() != null) {
    // built-in server url contains query only if token specified
    return url;
  }
  return new UrlImpl(url.getScheme(), url.getAuthority(), url.getPath(), "?" + BuiltInWebServerKt.TOKEN_PARAM_NAME + "=" + BuiltInWebServerKt.acquireToken());
}