Java Code Examples for com.intellij.util.PathUtil#getLocalPath()

The following examples show how to use com.intellij.util.PathUtil#getLocalPath() . 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: CsvStorageHelper.java    From intellij-csv-validator with Apache License 2.0 5 votes vote down vote up
public static String getRelativeFileUrl(Project project, VirtualFile virtualFile) {
    if (project == null || virtualFile == null) {
        return null;
    }
    String url = virtualFile.getUserData(RELATIVE_FILE_URL);
    if (url == null && project.getBasePath() != null) {
        String projectDir = PathUtil.getLocalPath(project.getBasePath());
        url = PathUtil.getLocalPath(virtualFile.getPath())
                .replaceFirst("^" + Pattern.quote(projectDir), "");
        virtualFile.putUserData(RELATIVE_FILE_URL, url);
    }
    return url;
}
 
Example 2
Source File: ProgramParametersConfigurator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected String getDefaultWorkingDir(@Nonnull Module module) {
  for (WorkingDirectoryProvider provider : WORKING_DIRECTORY_PROVIDER_EP_NAME.getExtensions()) {
    @SystemIndependent String path = provider.getWorkingDirectoryPath(module);
    if (path != null) return path;
  }
  VirtualFile[] roots = ModuleRootManager.getInstance(module).getContentRoots();
  if (roots.length > 0) {
    return PathUtil.getLocalPath(roots[0]);
  }
  return null;
}
 
Example 3
Source File: ModuleSdkPathMacro.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
static String sdkPath(@Nullable Sdk anySdk) {
  if (anySdk == null) {
    return null;
  }
  String jdkHomePath = PathUtil.getLocalPath(anySdk.getHomeDirectory());
  if (jdkHomePath != null) {
    jdkHomePath = jdkHomePath.replace('/', File.separatorChar);
  }
  return jdkHomePath;
}
 
Example 4
Source File: ProgramParametersConfigurator.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
protected String getDefaultWorkingDir(@Nonnull Project project) {
  return PathUtil.getLocalPath(project.getBaseDir());
}