Search in sources :

Example 1 with Production

use of org.whole.lang.grammars.reflect.GrammarsEntityDescriptorEnum.Production in project whole by wholeplatform.

the class GrammarsContentAssistVisitor method calculateAsNameValues.

public static Set<String> calculateAsNameValues(IEntity e) {
    Grammar grammar = Matcher.findAncestor(Grammar, e);
    if (grammar != null) {
        Production production = Matcher.findAncestor(Production, e);
        String entityName = production.getName().getValue();
        ILanguageKit languageKit = getLanguageKitIfExists(grammar);
        if (languageKit != null) {
            EntityDescriptor<?> ed = languageKit.getEntityDescriptorEnum().valueOf(entityName);
            if (ed != null) {
                Set<String> names = new HashSet<String>();
                for (FeatureDescriptor fd : ed.getEntityFeatureDescriptors()) names.add(fd.getName());
                return names;
            }
        }
    }
    return Collections.emptySet();
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) Production(org.whole.lang.grammars.reflect.GrammarsEntityDescriptorEnum.Production) Production(org.whole.lang.grammars.model.Production) Grammar(org.whole.lang.grammars.reflect.GrammarsEntityDescriptorEnum.Grammar) Grammar(org.whole.lang.grammars.model.Grammar) ILanguageKit(org.whole.lang.reflect.ILanguageKit) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Grammar (org.whole.lang.grammars.model.Grammar)1 Production (org.whole.lang.grammars.model.Production)1 Grammar (org.whole.lang.grammars.reflect.GrammarsEntityDescriptorEnum.Grammar)1 Production (org.whole.lang.grammars.reflect.GrammarsEntityDescriptorEnum.Production)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1 ILanguageKit (org.whole.lang.reflect.ILanguageKit)1