Java Code Examples for com.intellij.openapi.util.text.StringUtil#tokenize()

The following examples show how to use com.intellij.openapi.util.text.StringUtil#tokenize() . 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: VfsImplUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private static Pair<NewVirtualFile, Iterable<String>> prepare(@Nonnull NewVirtualFileSystem vfs, @Nonnull String path) {
  String normalizedPath = normalize(vfs, path);
  if (StringUtil.isEmptyOrSpaces(normalizedPath)) {
    return null;
  }

  String basePath = vfs.extractRootPath(normalizedPath);
  if (basePath.length() > normalizedPath.length()) {
    LOG.error(vfs + " failed to extract root path '" + basePath + "' from '" + normalizedPath + "' (original '" + path + "')");
    return null;
  }

  NewVirtualFile root = ManagingFS.getInstance().findRoot(basePath, vfs);
  if (root == null || !root.exists()) {
    return null;
  }

  Iterable<String> parts = StringUtil.tokenize(normalizedPath.substring(basePath.length()), FILE_SEPARATORS);
  return Pair.create(root, parts);
}
 
Example 2
Source File: UnwrapTestCase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected String indent(String code) {
  String result = "";
  for (String line : StringUtil.tokenize(code, "\n")) {
    result += "    " + line + "\n";
  }
  return result;
}
 
Example 3
Source File: Paths.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static Iterable<String> split(String path) {
  Iterable<String> result = StringUtil.tokenize(path, String.valueOf(DELIM));
  if (path.indexOf(DELIM) == 0) {
    result = ContainerUtil.concat(Collections.singleton(String.valueOf(DELIM)), result);
  }
  return result;
}
 
Example 4
Source File: SuppressionUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean isInspectionToolIdMentioned(@Nonnull String inspectionsList, String inspectionToolID) {
  Iterable<String> ids = StringUtil.tokenize(inspectionsList, "[, ]");

  for (@NonNls String id : ids) {
    @NonNls String trim = id.trim();
    if (trim.equals(inspectionToolID) || trim.equalsIgnoreCase(ALL)) return true;
  }
  return false;
}
 
Example 5
Source File: DirectoryAccessChecker.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("SpellCheckingInspection")
private static Pair<String, String> parseOptions(String fsOptions) {
  String version = null, transport = null;
  for (String o : StringUtil.tokenize(fsOptions, ",")) {
    if (o.startsWith("vers")) {
      version = getValue(o);
      int p = version.indexOf('.');
      if (p > 0) version = version.substring(0, p);
    }
    else if (o.startsWith("proto")) transport = getValue(o);
  }
  return version != null && transport != null ? pair(version, transport) : null;
}