当前位置: 首页>>代码示例>>Java>>正文


Java StringScanner.tryConsume方法代码示例

本文整理汇总了Java中git4idea.util.StringScanner.tryConsume方法的典型用法代码示例。如果您正苦于以下问题:Java StringScanner.tryConsume方法的具体用法?Java StringScanner.tryConsume怎么用?Java StringScanner.tryConsume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在git4idea.util.StringScanner的用法示例。


在下文中一共展示了StringScanner.tryConsume方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scanFiles

import git4idea.util.StringScanner; //导入方法依赖的package包/类
/**
 * Scan working tree and detect locally modified files
 *
 * @param project the project to scan
 * @param root    the root to scan
 * @param files   the collection with files
 * @throws VcsException if there problem with running git or working tree is dirty in unsupported way
 */
private static void scanFiles(Project project, VirtualFile root, List<String> files) throws VcsException {
  String rootPath = root.getPath();
  GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.DIFF);
  h.addParameters("--name-status");
  h.setSilent(true);
  h.setStdoutSuppressed(true);
  StringScanner s = new StringScanner(h.run());
  while (s.hasMoreData()) {
    if (s.isEol()) {
      s.line();
      continue;
    }
    if (s.tryConsume("M\t")) {
      String path = rootPath + "/" + GitUtil.unescapePath(s.line());
      files.add(path);
    }
    else {
      throw new VcsException("Working tree is dirty in unsupported way: " + s.line());
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:GitUpdateLocallyModifiedDialog.java

示例2: parseRemoteInternal

import git4idea.util.StringScanner; //导入方法依赖的package包/类
/**
 * Parse output of the remote (internal method)
 *
 * @param name   the name of the remote
 * @param output the output of "git remote show -n {name}" command
 * @return the parsed remote
 */
public static GitDeprecatedRemote parseRemoteInternal(String name, String output) {
  StringScanner in = new StringScanner(output);
  if (!in.tryConsume("* ")) {
    throw new IllegalStateException(unexpectedFormat(name, output));
  }
  String nameLine = in.line();
  if (!nameLine.endsWith(name)) {
    throw new IllegalStateException("Name line of 'git remote show' ends with wrong name: " + nameLine);
  }
  String fetch = null;
  String push = null;
  if (in.tryConsume(SHOW_URL_PREFIX)) {
    fetch = in.line();
    push = fetch;
  }
  else if (in.tryConsume(SHOW_FETCH_URL_PREFIX)) {
    fetch = in.line();
    if (in.tryConsume(SHOW_PUSH_URL_PREFIX)) {
      push = in.line();
    }
    else {
      push = fetch;
    }
  }
  else {
    throw new IllegalStateException(unexpectedFormat(name, output));
  }
  return new GitDeprecatedRemote(name, fetch, push);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:GitDeprecatedRemote.java


注:本文中的git4idea.util.StringScanner.tryConsume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。