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;
}
Aggregations