Java Code Examples for com.intellij.util.Url#getPath()

The following examples show how to use com.intellij.util.Url#getPath() . 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: FlutterSdkUtil.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@VisibleForTesting
public static String parseFlutterSdkPath(String packagesFileContent) {
  for (String line : packagesFileContent.split("\n")) {
    // flutter:file:///Users/.../flutter/packages/flutter/lib/
    line = line.trim();

    if (line.isEmpty() || line.startsWith("#")) {
      continue;
    }

    final String flutterPrefix = "flutter:";
    if (line.startsWith(flutterPrefix)) {
      final String urlString = line.substring(flutterPrefix.length());

      if (urlString.startsWith("file:")) {
        final Url url = Urls.parseEncoded(urlString);
        if (url == null) {
          continue;
        }
        final String path = url.getPath();
        // go up three levels
        final File file = new File(url.getPath());
        return file.getParentFile().getParentFile().getParentFile().getPath();
      }
    }
  }

  return null;
}
 
Example 2
Source File: FlutterSdkUtil.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@VisibleForTesting
public static String parseFlutterSdkPath(String packagesFileContent) {
  for (String line : packagesFileContent.split("\n")) {
    // flutter:file:///Users/.../flutter/packages/flutter/lib/
    line = line.trim();

    if (line.isEmpty() || line.startsWith("#")) {
      continue;
    }

    final String flutterPrefix = "flutter:";
    if (line.startsWith(flutterPrefix)) {
      final String urlString = line.substring(flutterPrefix.length());

      if (urlString.startsWith("file:")) {
        final Url url = Urls.parseEncoded(urlString);
        if (url == null) {
          continue;
        }
        final String path = url.getPath();
        // go up three levels
        final File file = new File(url.getPath());
        return file.getParentFile().getParentFile().getParentFile().getPath();
      }
    }
  }

  return null;
}
 
Example 3
Source File: BuiltInServerManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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());
}