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

The following examples show how to use com.intellij.util.PathUtil#toSystemIndependentName() . 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: PantsTargetReferenceSet.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
public static PartialTargetAddress parse(String value) {
  final int colonIndex = value.indexOf(':');
  final int valueLength = value.length();

  //substringAfter may return empty string if colon is the last character, so null is need in this case
  final String explicitTarget = StringUtil.nullize(StringUtil.substringAfter(value, ":"));
  //substringBefore may return null if colon does not exist, so rawPath is value in this case
  final String rawPath = ObjectUtils.notNull(StringUtil.substringBefore(value, ":"), value);

  String normalizedPath;
  if (rawPath.isEmpty()) {
    normalizedPath = rawPath;
  }
  else {
    final String normalized = PathUtil.toSystemIndependentName(rawPath);
    normalizedPath = normalized.charAt(normalized.length() - 1) == '/' ? normalized : normalized + "/";
  }

  return new PartialTargetAddress(explicitTarget, normalizedPath, valueLength, colonIndex);
}
 
Example 2
Source File: ConfigDiscovery.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
private String calculateCanonicalPath(@NotNull PsiClass psiClass) {
  String canonicalPath = null;
  final PsiFile psiFile;
  if (psiClass instanceof LombokLightClassBuilder) {
    // Use containing class for all LombokLightClasses
    final PsiClass containingClass = psiClass.getContainingClass();
    if (null != containingClass) {
      psiFile = containingClass.getContainingFile();
    } else {
      psiFile = null;
    }
  } else {
    psiFile = psiClass.getContainingFile();
  }

  if (null != psiFile) {
    canonicalPath = getDirectoryCanonicalPath(psiFile);
    if (null == canonicalPath) {
      canonicalPath = getDirectoryCanonicalPath(psiFile.getOriginalFile());
    }
  }
  return PathUtil.toSystemIndependentName(canonicalPath);
}
 
Example 3
Source File: Util.java    From DarkyenusTimeTracker with The Unlicense 5 votes vote down vote up
@Nullable
public static VirtualFile getProjectBaseDir(@Nullable Project project) {
	if (project == null) {
		return null;
	}
	final String basePath = PathUtil.toSystemIndependentName(project.getBasePath());
	if (basePath == null) {
		return null;
	}
	return LocalFileSystem.getInstance().findFileByPath(basePath);
}
 
Example 4
Source File: AbstractFilePatchInProgress.java    From consulo with Apache License 2.0 5 votes vote down vote up
private FilePatchStatus getStatus(final T patch) {
  final String beforeName = PathUtil.toSystemIndependentName(patch.getBeforeName());
  final String afterName = PathUtil.toSystemIndependentName(patch.getAfterName());

  if (patch.isNewFile() || (beforeName == null)) {
    return FilePatchStatus.ADDED;
  }
  else if (patch.isDeletedFile() || (afterName == null)) {
    return FilePatchStatus.DELETED;
  }

  if (beforeName.equals(afterName)) return FilePatchStatus.MODIFIED;
  return FilePatchStatus.MOVED_OR_RENAMED;
}
 
Example 5
Source File: AbstractFilePatchInProgress.java    From consulo with Apache License 2.0 5 votes vote down vote up
private StripCapablePath(final String path) {
  final String corrected = PathUtil.toSystemIndependentName(path.trim());
  mySourcePath = new StringBuilder(corrected);
  final String[] steps = corrected.split("/");
  myStripMax = steps.length - 1;
  myParts = new int[steps.length];
  int pos = 0;
  for (int i = 0; i < steps.length; i++) {
    final String step = steps[i];
    myParts[i] = pos;
    pos += step.length() + 1; // plus 1 for separator
  }
  myCurrentStrip = 0;
}
 
Example 6
Source File: ExternalSystemTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@SystemIndependent
protected String path(@NotNull String relativePath) {
  return PathUtil.toSystemIndependentName(file(relativePath).getPath());
}
 
Example 7
Source File: LombokTestUtil.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void loadLibrary(@NotNull Disposable projectDisposable, @NotNull Module module, String libraryName,
                                String libraryJarName) {
  final String lombokLibPath = PathUtil.toSystemIndependentName(new File(THIRD_PARTY_LIB_DIRECTORY).getAbsolutePath());
  VfsRootAccess.allowRootAccess(projectDisposable, lombokLibPath);
  PsiTestUtil.addLibrary(projectDisposable, module, libraryName, lombokLibPath, libraryJarName);
}
 
Example 8
Source File: JavaPropertiesProvider.java    From EclipseCodeFormatter with Apache License 2.0 4 votes vote down vote up
public boolean isSameFile(VirtualFile fileB) {
	String path = PathUtil.toSystemIndependentName(fileB.getPath());
	String current = getModifiableFile().getSystemIndependentPath();
	return current.equals(path);
}
 
Example 9
Source File: ModifiableFile.java    From EclipseCodeFormatter with Apache License 2.0 4 votes vote down vote up
@NotNull
public String getSystemIndependentPath() {
	return PathUtil.toSystemIndependentName(getAbsolutePath());
}
 
Example 10
Source File: FirefoxSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setProfilesIniPath(@Nullable String value) {
  myProfilesIniPath = PathUtil.toSystemIndependentName(StringUtil.nullize(value));
}
 
Example 11
Source File: FirefoxSettingsConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
private String getConfiguredProfileIniPath() {
  String path = PathUtil.toSystemIndependentName(StringUtil.nullize(myProfilesIniPathField.getText()));
  return myDefaultProfilesIniPath.equals(path) ? null : path;
}
 
Example 12
Source File: ChromeSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setUserDataDirectoryPath(@Nullable String value) {
  myUserDataDirectoryPath = PathUtil.toSystemIndependentName(StringUtil.nullize(value));
}
 
Example 13
Source File: ConfigurableWebBrowser.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setPath(@Nullable String value) {
  path = PathUtil.toSystemIndependentName(StringUtil.nullize(value));
}