Search in sources :

Example 1 with EntityType

use of org.whole.lang.queries.reflect.QueriesEntityDescriptorEnum.EntityType in project whole by wholeplatform.

the class QueriesContentAssistVisitor method visit.

@Override
public void visit(Name entity) {
    IEntity bindEntity = entity.wGetParent();
    if (!Matcher.match(Bind, bindEntity))
        return;
    IEntity bindingsEntity = bindEntity.wGetParent();
    if (!Matcher.match(Bindings, bindingsEntity))
        return;
    EntityType entityType;
    boolean allLanguageFeatures;
    IEntity entityCallOrTemplateEntity = bindingsEntity.wGetParent();
    switch(entityCallOrTemplateEntity.wGetEntityDescriptor().getOrdinal()) {
        case EntityCall_ord:
            entityType = ((EntityCall) entityCallOrTemplateEntity).getName();
            allLanguageFeatures = true;
            break;
        case EntityTemplate_ord:
            entityType = ((EntityTemplate) entityCallOrTemplateEntity).getName();
            allLanguageFeatures = false;
            break;
        default:
            return;
    }
    if (!DataTypeUtils.getDataKind(entityType).isString())
        return;
    String edUri = entityType.wStringValue();
    TreeSet<String> sortedNames = new TreeSet<String>();
    EntityDescriptor<?> ed = CommonsDataTypePersistenceParser.getEntityDescriptor(edUri, false, null);
    if (allLanguageFeatures || ed == null) {
        ILanguageKit lk = CommonsDataTypePersistenceParser.getLanguageKitPart(edUri);
        if (lk == null)
            return;
        Set<String> fNames = lk.getFeatureDescriptorEnum().names();
        sortedNames.addAll(fNames);
    } else
        for (FeatureDescriptor fd : ed.getEntityFeatureDescriptors()) sortedNames.add(fd.getName());
    allFeatureNames(sortedNames, entity.getValue());
}
Also used : EntityType(org.whole.lang.queries.model.EntityType) EntityType(org.whole.lang.queries.reflect.QueriesEntityDescriptorEnum.EntityType) IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) TreeSet(java.util.TreeSet) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Aggregations

TreeSet (java.util.TreeSet)1 IEntity (org.whole.lang.model.IEntity)1 EntityType (org.whole.lang.queries.model.EntityType)1 EntityType (org.whole.lang.queries.reflect.QueriesEntityDescriptorEnum.EntityType)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1 ILanguageKit (org.whole.lang.reflect.ILanguageKit)1