• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ParsedLine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jline.reader.ParsedLine的典型用法代码示例。如果您正苦于以下问题:Java ParsedLine类的具体用法?Java ParsedLine怎么用?Java ParsedLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParsedLine类属于org.jline.reader包,在下文中一共展示了ParsedLine类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: complete

import org.jline.reader.ParsedLine; //导入依赖的package包/类
@Override
public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
    if (line.words().size() == 2) {
        String cmd = line.words().get(0);
        String word = line.word();

        if (COMMANDS.contains(cmd)) {
            // group is already specified; only provide artifacts now
            if (word.contains(":")) {
                String group = word.split(":")[0] + ":";
                archivesFromCache().stream().filter(a -> a.startsWith(group))
                        .collect(Collectors.toSet())
                        .forEach(a -> candidates.add(new Candidate(a)));
            }
            // sill completing group
            else {
                archivesFromCache().stream().map(a -> a.split(":")[0])
                        .collect(Collectors.toSet()).forEach(a -> candidates
                                .add(new Candidate(a + ":", a, null, null, null, null, false)));
            }
        }
    }
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:24,代码来源:ArchiveNameCompleter.java


示例2: parse

import org.jline.reader.ParsedLine; //导入依赖的package包/类
public ParsedLine parse(String line, int cursor,
                        ParseContext context) throws SyntaxError {
    if (context == ParseContext.COMPLETE)
        return parseForComplete(line, cursor);
    CharArrayInPort cin = CharArrayInPort.make(line, "\n");
    cin.setLineNumber(this.getLineNumber());
    cin.setPath(this.getPath());
    try {
        Lexer lexer = language.getLexer(cin, this.messages);
        lexer.setInteractive(true);
        Compilation comp =
            language.parse(lexer,
                           Language.PARSE_FOR_EVAL|Language.PARSE_INTERACTIVE_MODULE,
                           null);
        if (comp == null)
            throw new EndOfFileException();
        if (comp.getState() == Compilation.ERROR_SEEN && cin.eofSeen()) {
            messages.clear();
            throw new EOFError(-1, -1, "unexpected end-of-file", "");
        }
        return new KawaParsedLine(this, comp, line, cursor);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:26,代码来源:JLineInPort.java


示例3: parse

import org.jline.reader.ParsedLine; //导入依赖的package包/类
@Override
public ParsedLine parse(String line, int cursor, ParseContext context) throws SyntaxError {
    String input = line.trim();
    DefaultParsedLine defaultResult = new DefaultParsedLine(line, cursor);

    if (input.startsWith(Command.PREFIX)) {
        return defaultResult;
    }

    if (!input.endsWith(";")) {
        throw new EOFError(-1, -1, "Query not terminated");
    }
    return defaultResult;
}
 
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:15,代码来源:MultilineStatementParser.java


示例4: statements_end_with_semicolon

import org.jline.reader.ParsedLine; //导入依赖的package包/类
@Test
public void statements_end_with_semicolon() {
    thrown.expect(EOFError.class);
    ParsedLine parsedLine = parser.parse("MATCH (n)", 4);

    parser.parse("RETURN n;", 8);

    assertThat(parsedLine.cursor()).isEqualTo(8);
    assertThat(parsedLine.words()).containsExactly("MATCH (n)\nRETURN n;");
    assertThat(parsedLine.word()).isEqualTo("MATCH (n)\nRETURN n;");
    assertThat(parsedLine.wordCursor()).isEqualTo(8);
}
 
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:13,代码来源:MultilineStatementParserTest.java


示例5: complete

import org.jline.reader.ParsedLine; //导入依赖的package包/类
@Override
public void complete(LineReader reader, ParsedLine commandLine, List<Candidate> candidates) {
    if (commandLine.words().size() > 1) {
        String word = commandLine.words().get(commandLine.words().size() - 2);
        if ("-C".equals(word) || "--change-dir".equals(word)) {
            super.complete(reader, commandLine, candidates);
        }
        else if (commandLine.line().startsWith(Constants.SHELL_ESCAPE)) {
            super.complete(reader, commandLine, candidates);
        }
    }
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:13,代码来源:FileAndDirectoryNameCompleter.java


示例6: reserved_commands_are_handled

import org.jline.reader.ParsedLine; //导入依赖的package包/类
@Test
public void reserved_commands_are_handled() {
    ParsedLine line = parser.parse(":special-command", 15);

    assertThat(line.cursor()).isEqualTo(15);
}
 
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:7,代码来源:MultilineStatementParserTest.java


示例7: complete

import org.jline.reader.ParsedLine; //导入依赖的package包/类
@Override
public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
    if (line.words().size() >= 1) {

        String command = line.words().get(0);

        if (COMMANDS.contains(command)) {

            init();

            switch (command) {
            case "edit":
            case "ed":
                completeBasedOnJsonpathMatches("editors", line.words(), candidates);
                break;
            case "generate":
            case "gen":
                completeBasedOnJsonpathMatches("generators", line.words(), candidates);
                break;
            case "command":
                completeBasedOnJsonpathMatches("command_handlers", line.words(), candidates);
                break;
            case "trigger":
                completeBasedOnJsonpathMatches("event_handlers", line.words(), candidates);
                break;
            case "describe":
            case "desc":
                if (line.words().size() >= 2) {
                    String subCommand = line.words().get(1);
                    switch (subCommand) {
                    case "editor":
                        completeBasedOnJsonpathMatches("editors", line.words(), candidates);
                        break;
                    case "generator":
                        completeBasedOnJsonpathMatches("generators", line.words(), candidates);
                        break;
                    case "reviewer":
                        completeBasedOnJsonpathMatches("reviewers", line.words(), candidates);
                        break;
                    case "command-handler":
                        completeBasedOnJsonpathMatches("command_handlers", line.words(),
                                candidates);
                        break;
                    case "event-handler":
                        completeBasedOnJsonpathMatches("event_handlers", line.words(),
                                candidates);
                        break;
                    case "response-handler":
                        completeBasedOnJsonpathMatches("response_handlers", line.words(),
                                candidates);
                        break;
                    }
                }
                break;
            }
        }
    }
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:59,代码来源:OperationCompleter.java


示例8: complete

import org.jline.reader.ParsedLine; //导入依赖的package包/类
@Override
public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
    List<String> words = line.words();
    if (words.size() == 1) {
        registry.commands().forEach(c -> {
            candidates.add(new Candidate(c.name(), c.name(), null, null, null, c.name(), true));
            c.aliases().forEach(
                    a -> candidates.add(new Candidate(a, a, null, null, null, c.name(), true)));
        });
        candidates.add(new Candidate("exit", "exit", null, null, null, "q", true));
        candidates.add(new Candidate("quit", "quit", null, null, null, "q", true));
        candidates.add(new Candidate("q", "q", null, null, null, "q", true));
        candidates.add(new Candidate("/clear", "/clear", null, null, null, "cls", true));
        candidates.add(new Candidate("/cls", "/cls", null, null, null, "cls", true));
        candidates.add(new Candidate("/echo", "/echo", null, null, null, "echo", true));
    }
    else if (words.size() > 1) {
        String word = words.get(0);
        String l = StringUtils.join(words, " ");
        Optional<CommandInfo> info = registry.commands().stream()
                .filter(c -> c.name().startsWith(word) || c.aliases().contains(word))
                .findFirst();
        if (info.isPresent()) {

            String remaining = ShellUtils.removePrefix(info.get().name(), words);
            if (remaining != null && remaining.length() > 0
                    && !info.get().aliases().contains(word)) {
                candidates.add(new Candidate(remaining, info.get().name(), null, null, null,
                        null, true));
            }

            info.get().subCommands().stream()
                    .filter(s -> (info.get().name() + " " + s).startsWith(l) || info.get()
                            .aliases().stream().filter(a -> (a + " " + s).startsWith(l))
                            .findAny().isPresent())
                    .forEach(
                            s -> candidates.add(new Candidate(ShellUtils.removePrefix(s, words),
                                    info.get().name() + " " + s, null, null, null, null,
                                    true)));

            completeOptions(info.get().globalOptions().getOptions(), candidates, words, false);
            completeOptions(info.get().options().getOptions(), candidates, words, true);
        }
    }
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:46,代码来源:CommandInfoCompleter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Target类代码示例发布时间:2022-05-22
下一篇:
Java LiveAuthException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap