Java Code Examples for com.intellij.openapi.util.io.FileUtilRt#toSystemIndependentName()

The following examples show how to use com.intellij.openapi.util.io.FileUtilRt#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: VirtualFilePointerManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static String cleanupPath(@Nonnull String path) {
  path = FileUtilRt.toSystemIndependentName(path);
  path = trimTrailingSeparators(path);
  for (int i = 0; i < path.length(); ) {
    int slash = path.indexOf('/', i);
    if (slash == -1 || slash == path.length() - 1) {
      break;
    }
    char next = path.charAt(slash + 1);

    if (next == '/' && !(i == 0 && SystemInfo.isWindows) || // additional condition for Windows UNC
        next == '.' && (slash == path.length() - 2 || path.charAt(slash + 2) == '/')) {
      return cleanupTail(path, slash);
    }
    i = slash + 1;
  }
  return path;
}
 
Example 2
Source File: HierarchicalFilePathComparator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(@Nonnull FilePath filePath1, @Nonnull FilePath filePath2) {
  final String path1 = FileUtilRt.toSystemIndependentName(filePath1.getPath());
  final String path2 = FileUtilRt.toSystemIndependentName(filePath2.getPath());

  int index1 = 0;
  int index2 = 0;

  int start = 0;

  while (index1 < path1.length() && index2 < path2.length()) {
    char c1 = path1.charAt(index1);
    char c2 = path2.charAt(index2);

    if (StringUtil.compare(c1, c2, myIgnoreCase) != 0) break;

    if (c1 == '/') start = index1;

    index1++;
    index2++;
  }

  if (index1 == path1.length() && index2 == path2.length()) return 0;
  if (index1 == path1.length()) return -1;
  if (index2 == path2.length()) return 1;

  int end1 = path1.indexOf('/', start + 1);
  int end2 = path2.indexOf('/', start + 1);

  String name1 = end1 == -1 ? path1.substring(start) : path1.substring(start, end1);
  String name2 = end2 == -1 ? path2.substring(start) : path2.substring(start, end2);

  boolean isDirectory1 = end1 != -1 || filePath1.isDirectory();
  boolean isDirectory2 = end2 != -1 || filePath2.isDirectory();

  if (isDirectory1 && !isDirectory2) return -1;
  if (!isDirectory1 && isDirectory2) return 1;

  return StringUtil.compare(name1, name2, myIgnoreCase);
}
 
Example 3
Source File: FlutterGeneratorPeer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
public String getSdkComboPath() {
  return FileUtilRt.toSystemIndependentName(getSdkEditor().getItem().toString().trim());
}
 
Example 4
Source File: FlutterSmallIDEGeneratorPeer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
private String getSdkComboPath() {
  return FileUtilRt.toSystemIndependentName(sdkPathComboWithBrowse.getComboBox().getEditor().getItem().toString().trim());
}
 
Example 5
Source File: FlutterSettingsConfigurable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean isModified() {
  final FlutterSdk sdk = FlutterSdk.getFlutterSdk(myProject);
  final FlutterSettings settings = FlutterSettings.getInstance();
  final String sdkPathInModel = sdk == null ? "" : sdk.getHomePath();
  final String sdkPathInUI = FileUtilRt.toSystemIndependentName(getSdkPathText());

  if (!sdkPathInModel.equals(sdkPathInUI)) {
    return true;
  }

  if (FlutterInitializer.getCanReportAnalytics() != myReportUsageInformationCheckBox.isSelected()) {
    return true;
  }

  if (settings.isReloadOnSave() != myHotReloadOnSaveCheckBox.isSelected()) {
    return true;
  }

  if (settings.isFormatCodeOnSave() != myFormatCodeOnSaveCheckBox.isSelected()) {
    return true;
  }

  if (settings.isOrganizeImportsOnSave() != myOrganizeImportsOnSaveCheckBox.isSelected()) {
    return true;
  }

  if (settings.isShowBuildMethodGuides() != myShowBuildMethodGuides.isSelected()) {
    return true;
  }

  if (settings.isShowClosingLabels() != myShowClosingLabels.isSelected()) {
    return true;
  }

  if (settings.isShowStructuredErrors() != myShowStructuredErrors.isSelected()) {
    return true;
  }

  if (settings.isOpenInspectorOnAppLaunch() != myOpenInspectorOnAppLaunchCheckBox.isSelected()) {
    return true;
  }

  if (settings.isDisableTrackWidgetCreation() != myDisableTrackWidgetCreationCheckBox.isSelected()) {
    return true;
  }

  if (settings.isVerboseLogging() != myEnableVerboseLoggingCheckBox.isSelected()) {
    return true;
  }

  if (settings.isSyncingAndroidLibraries() != mySyncAndroidLibrariesCheckBox.isSelected()) {
    return true;
  }

  if (settings.isEnableHotUi() != myEnableHotUiCheckBox.isSelected()) {
    return true;
  }

  //noinspection RedundantIfStatement
  if (settings.showAllRunConfigurationsInContext() != myShowAllRunConfigurationsInContextCheckBox.isSelected()) {
    return true;
  }

  return false;
}
 
Example 6
Source File: FlutterSettingsConfigurable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
private String getSdkPathText() {
  return FileUtilRt.toSystemIndependentName(mySdkCombo.getComboBox().getEditor().getItem().toString().trim());
}
 
Example 7
Source File: FlutterGeneratorPeer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
public String getSdkComboPath() {
  return FileUtilRt.toSystemIndependentName(getSdkEditor().getItem().toString().trim());
}
 
Example 8
Source File: FlutterSmallIDEGeneratorPeer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
private String getSdkComboPath() {
  return FileUtilRt.toSystemIndependentName(sdkPathComboWithBrowse.getComboBox().getEditor().getItem().toString().trim());
}
 
Example 9
Source File: FlutterSettingsConfigurable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean isModified() {
  final FlutterSdk sdk = FlutterSdk.getFlutterSdk(myProject);
  final FlutterSettings settings = FlutterSettings.getInstance();
  final String sdkPathInModel = sdk == null ? "" : sdk.getHomePath();
  final String sdkPathInUI = FileUtilRt.toSystemIndependentName(getSdkPathText());

  if (!sdkPathInModel.equals(sdkPathInUI)) {
    return true;
  }

  if (FlutterInitializer.getCanReportAnalytics() != myReportUsageInformationCheckBox.isSelected()) {
    return true;
  }

  if (settings.isReloadOnSave() != myHotReloadOnSaveCheckBox.isSelected()) {
    return true;
  }

  if (settings.isFormatCodeOnSave() != myFormatCodeOnSaveCheckBox.isSelected()) {
    return true;
  }

  if (settings.isOrganizeImportsOnSave() != myOrganizeImportsOnSaveCheckBox.isSelected()) {
    return true;
  }

  if (settings.isShowBuildMethodGuides() != myShowBuildMethodGuides.isSelected()) {
    return true;
  }

  if (settings.isShowClosingLabels() != myShowClosingLabels.isSelected()) {
    return true;
  }

  if (settings.isShowStructuredErrors() != myShowStructuredErrors.isSelected()) {
    return true;
  }

  if (settings.isOpenInspectorOnAppLaunch() != myOpenInspectorOnAppLaunchCheckBox.isSelected()) {
    return true;
  }

  if (settings.isDisableTrackWidgetCreation() != myDisableTrackWidgetCreationCheckBox.isSelected()) {
    return true;
  }

  if (settings.isVerboseLogging() != myEnableVerboseLoggingCheckBox.isSelected()) {
    return true;
  }

  if (settings.isSyncingAndroidLibraries() != mySyncAndroidLibrariesCheckBox.isSelected()) {
    return true;
  }

  if (settings.isEnableHotUi() != myEnableHotUiCheckBox.isSelected()) {
    return true;
  }

  //noinspection RedundantIfStatement
  if (settings.showAllRunConfigurationsInContext() != myShowAllRunConfigurationsInContextCheckBox.isSelected()) {
    return true;
  }

  return false;
}
 
Example 10
Source File: FlutterSettingsConfigurable.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
private String getSdkPathText() {
  return FileUtilRt.toSystemIndependentName(mySdkCombo.getComboBox().getEditor().getItem().toString().trim());
}
 
Example 11
Source File: PathUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Contract("null -> null; !null -> !null")
public static String toSystemIndependentName(@Nullable String path) {
  return path == null ? null : FileUtilRt.toSystemIndependentName(path);
}