本文整理汇总了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());
}
}
}
示例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);
}