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

The following examples show how to use com.intellij.openapi.util.text.StringUtil#trimTrailing() . 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: BlazeAndroidTestEventsHandler.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public String testLocationUrl(
    Label label,
    @Nullable Kind kind,
    String parentSuite,
    String name,
    @Nullable String className) {
  // ignore initial value of className -- it's the test runner class.
  name = StringUtil.trimTrailing(name, '-');
  if (!name.contains("-")) {
    return SmRunnerUtils.GENERIC_SUITE_PROTOCOL + URLUtil.SCHEME_SEPARATOR + name;
  }
  int ix = name.lastIndexOf('-');
  className = name.substring(0, ix);
  String methodName = name.substring(ix + 1);
  return SmRunnerUtils.GENERIC_SUITE_PROTOCOL
      + URLUtil.SCHEME_SEPARATOR
      + className
      + SmRunnerUtils.TEST_NAME_PARTS_SPLITTER
      + methodName;
}
 
Example 2
Source File: BlazeAndroidTestEventsHandler.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public String testDisplayName(Label label, @Nullable Kind kind, String rawName) {
  String name = StringUtil.trimTrailing(rawName, '-');
  if (name.contains("-")) {
    int ix = name.lastIndexOf('-');
    return name.substring(ix + 1);
  }
  return name;
}
 
Example 3
Source File: LineLayout.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static String getLineCommentPrefix(IElementType token) {
  if (token == null) return null;
  Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(token.getLanguage());
  if (!(commenter instanceof CodeDocumentationAwareCommenter) || !token.equals(((CodeDocumentationAwareCommenter)commenter).getLineCommentTokenType())) return null;
  String prefix = commenter.getLineCommentPrefix();
  return prefix == null ? null : StringUtil.trimTrailing(prefix); // some commenters (e.g. for Python) include space in comment prefix
}
 
Example 4
Source File: VMOptions.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void writeGeneralOption(@Nonnull Pattern pattern, @Nonnull String value) {
  File file = getWriteFile();
  if (file == null) {
    LOG.warn("VM options file not configured");
    return;
  }

  try {
    String content = file.exists() ? FileUtil.loadFile(file) : read();

    if (!StringUtil.isEmptyOrSpaces(content)) {
      Matcher m = pattern.matcher(content);
      if (m.find()) {
        StringBuffer b = new StringBuffer();
        m.appendReplacement(b, Matcher.quoteReplacement(value));
        m.appendTail(b);
        content = b.toString();
      }
      else {
        content = StringUtil.trimTrailing(content) + SystemProperties.getLineSeparator() + value;
      }
    }
    else {
      content = value;
    }

    if (file.exists()) {
      FileUtil.setReadOnlyAttribute(file.getPath(), false);
    }
    else {
      FileUtil.ensureExists(file.getParentFile());
    }

    FileUtil.writeToFile(file, content);
  }
  catch (IOException e) {
    LOG.warn(e);
  }
}
 
Example 5
Source File: CommonTestConfigUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static String convertHttpServiceProtocolToWs(String url) {
  return StringUtil.trimTrailing(
    url.replaceFirst("http:", "ws:"), '/') + "/ws";
}
 
Example 6
Source File: CommonTestConfigUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static String convertHttpServiceProtocolToWs(String url) {
  return StringUtil.trimTrailing(
    url.replaceFirst("http:", "ws:"), '/') + "/ws";
}
 
Example 7
Source File: VirtualFilePointerManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static String trimTrailingSeparators(@Nonnull String path) {
  path = StringUtil.trimEnd(path, consulo.vfs.ArchiveFileSystem.ARCHIVE_SEPARATOR);
  path = StringUtil.trimTrailing(path, '/');
  return path;
}