Search in sources :

Example 6 with Codetemplates

use of org.eclipse.xtext.ui.codetemplates.templates.Codetemplates in project xtext-eclipse by eclipse.

the class CodetemplatesScopeProvider method scope_Codetemplate_context.

public IScope scope_Codetemplate_context(Codetemplate template, EReference reference) {
    Codetemplates root = EcoreUtil2.getContainerOfType(template, Codetemplates.class);
    if (root != null && root.getLanguage() != null) {
        Grammar grammar = root.getLanguage();
        if (!grammar.eIsProxy()) {
            LinkedHashSet<AbstractRule> usedRules = Sets.newLinkedHashSet();
            new UsedRulesFinder(usedRules).compute(grammar);
            return Scopes.scopeFor(Iterables.filter(usedRules, ParserRule.class));
        }
    }
    return IScope.NULLSCOPE;
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Codetemplates(org.eclipse.xtext.ui.codetemplates.templates.Codetemplates) UsedRulesFinder(org.eclipse.xtext.xtext.UsedRulesFinder) Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule)

Aggregations

Codetemplates (org.eclipse.xtext.ui.codetemplates.templates.Codetemplates)6 Codetemplate (org.eclipse.xtext.ui.codetemplates.templates.Codetemplate)5 Grammar (org.eclipse.xtext.Grammar)4 ParserRule (org.eclipse.xtext.ParserRule)4 Variable (org.eclipse.xtext.ui.codetemplates.templates.Variable)3 EPackage (org.eclipse.emf.ecore.EPackage)2 ContextTypeRegistry (org.eclipse.jface.text.templates.ContextTypeRegistry)2 TemplateContextType (org.eclipse.jface.text.templates.TemplateContextType)2 TemplateVariableResolver (org.eclipse.jface.text.templates.TemplateVariableResolver)2 AbstractRule (org.eclipse.xtext.AbstractRule)2 Action (org.eclipse.xtext.Action)2 Parameter (org.eclipse.xtext.Parameter)2 Dollar (org.eclipse.xtext.ui.codetemplates.templates.Dollar)2 Literal (org.eclipse.xtext.ui.codetemplates.templates.Literal)2 TemplateBody (org.eclipse.xtext.ui.codetemplates.templates.TemplateBody)2 ContextTypeIdHelper (org.eclipse.xtext.ui.editor.templates.ContextTypeIdHelper)2 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 StyledString (org.eclipse.jface.viewers.StyledString)1 Keyword (org.eclipse.xtext.Keyword)1 IHighlightedPositionAcceptor (org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor)1