Search in sources :

Example 1 with ManchesterOWLSyntax

use of org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax in project webprotege by protegeproject.

the class GetManchesterSyntaxFrameCompletionsActionHandler method getKeywordAutoCompletionChoices.

private List<AutoCompletionChoice> getKeywordAutoCompletionChoices(ParserException e, EditorPosition fromPos, EditorPosition toPos, String lastWordPrefix) {
    Set<String> expectedKeywords = e.getExpectedKeywords();
    List<AutoCompletionChoice> expectedKeywordChoices = Lists.newArrayList();
    for (String expectedKeyword : expectedKeywords) {
        if (lastWordPrefix.isEmpty() || expectedKeyword.toLowerCase().contains(lastWordPrefix)) {
            Optional<ManchesterOWLSyntax> kw = syntaxStyles.getKeyword(expectedKeyword);
            String style = "";
            if (kw.isPresent()) {
                style = syntaxStyles.getStyleName(kw.get());
            }
            expectedKeywordChoices.add(new AutoCompletionChoice(expectedKeyword, expectedKeyword, style, fromPos, toPos));
        }
    }
    expectedKeywordChoices.sort(new Comparator<AutoCompletionChoice>() {

        private ManchesterSyntaxKeywords.KeywordComparator keywordComparator = new ManchesterSyntaxKeywords.KeywordComparator();

        @Override
        public int compare(AutoCompletionChoice autoCompletionChoice, AutoCompletionChoice autoCompletionChoice2) {
            return keywordComparator.compare(autoCompletionChoice.getDisplayText(), autoCompletionChoice2.getDisplayText());
        }
    });
    return expectedKeywordChoices;
}
Also used : ManchesterOWLSyntax(org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax) ManchesterSyntaxKeywords(edu.stanford.bmir.protege.web.server.renderer.ManchesterSyntaxKeywords) AutoCompletionChoice(edu.stanford.bmir.gwtcodemirror.client.AutoCompletionChoice)

Aggregations

AutoCompletionChoice (edu.stanford.bmir.gwtcodemirror.client.AutoCompletionChoice)1 ManchesterSyntaxKeywords (edu.stanford.bmir.protege.web.server.renderer.ManchesterSyntaxKeywords)1 ManchesterOWLSyntax (org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntax)1