Search in sources :

Example 1 with IGrammarProvider

use of org.whole.lang.grammars.codebase.IGrammarProvider in project whole by wholeplatform.

the class GrammarsResourceBindingsContributor method addResourceBindings.

public void addResourceBindings(IBindingManager bm) {
    if (!bm.wIsSet("grammarProvider")) {
        Collection<Grammar> grammars = GrammarsRegistry.instance().grammars();
        if (!grammars.isEmpty()) {
            IGrammarProvider provider = new DialogGrammarProvider(bm);
            bm.wDefValue("grammarProvider", provider);
        }
    }
}
Also used : IGrammarProvider(org.whole.lang.grammars.codebase.IGrammarProvider) Grammar(org.whole.lang.grammars.model.Grammar)

Example 2 with IGrammarProvider

use of org.whole.lang.grammars.codebase.IGrammarProvider in project whole by wholeplatform.

the class GrammarsUtils method getGrammarUri.

public static String getGrammarUri(IBindingManager bm) {
    String grammarUri = null;
    boolean grammarFromBindings = bm.wIsSet("grammar");
    if (grammarFromBindings) {
        Grammar grammar = (Grammar) bm.wGet("grammar");
        InterpreterOperation.interpret(grammar, bm);
        grammarUri = grammar.getUri().getValue();
    } else if (bm.wIsSet("grammarURI"))
        grammarUri = bm.wStringValue("grammarURI");
    if (grammarUri == null && bm.wIsSet("grammarProvider")) {
        IGrammarProvider provider = (IGrammarProvider) bm.wGetValue("grammarProvider");
        grammarUri = provider.getGrammarUri(null);
    }
    return grammarUri;
}
Also used : IGrammarProvider(org.whole.lang.grammars.codebase.IGrammarProvider) Grammar(org.whole.lang.grammars.model.Grammar)

Aggregations

IGrammarProvider (org.whole.lang.grammars.codebase.IGrammarProvider)2 Grammar (org.whole.lang.grammars.model.Grammar)2