use of org.whole.lang.queries.model.Path in project whole by wholeplatform.
the class GrammarsContentAssistVisitor method calculateNonTerminalValues.
public static Set<String> calculateNonTerminalValues(IEntity e) {
Grammar grammar = Matcher.findAncestor(Grammar, e);
if (grammar != null) {
Set<String> names = new HashSet<String>();
IEntity parent = e.wGetParent();
ILanguageKit languageKit = getLanguageKitIfExists(grammar);
if (languageKit != null) {
if (!grammar.getLexicalStructure().equals(parent.wGetParent()))
names.addAll(languageKit.getEntityDescriptorEnum().names());
if (!parent.wGetFeatureDescriptor(e).equals(name)) {
QueriesEntityFactory qef = QueriesEntityFactory.instance;
Path allTokenNames = qef.createPath(qef.createSequence(qef.createFeatureStep("lexicalStructure"), qef.createFeatureStep("phraseStructure")), qef.createChildStep(), qef.createFilter(qef.createFeatureStep("name"), qef.createKindTest(KindTestEnum.IMPL)));
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(allTokenNames, grammar)) names.add(nt.getValue());
}
} else {
AbstractPatternFilterIterator<NonTerminal> i = IteratorFactory.<NonTerminal>descendantOrSelfMatcherIterator().withPattern(NonTerminal);
i.reset(grammar);
for (NonTerminal nt : i) if (EntityUtils.isNotResolver(nt))
names.add(nt.getValue());
}
return names;
}
return Collections.emptySet();
}
use of org.whole.lang.queries.model.Path in project whole by wholeplatform.
the class PojoNormalizerVisitor method createDefaultTypeInParameters.
public static void createDefaultTypeInParameters(Library entity, IBindingManager bindings) {
Path findAllParametersWithoutType = (Path) PojoTemplateManager.instance().create("findAllParametersWithoutType");
Path findParameterType = (Path) PojoTemplateManager.instance().create("findPropertyType");
bindings.wEnterScope();
for (Parameter parameter : BehaviorUtils.<Parameter>compileAndLazyEvaluate(findAllParametersWithoutType, entity, bindings)) {
PojoDeclaration pojo = (PojoDeclaration) bindings.wGet("pojo");
Type type = BehaviorUtils.<Type>evaluateFirstResult(findParameterType, pojo, bindings);
if (type != null)
parameter.setType(EntityUtils.clone(type));
else
throw new IllegalArgumentException("Missing " + bindings.wStringValue("name") + " property in " + pojo.getName().wStringValue() + " pojo declaration");
}
bindings.wExitScope();
}
use of org.whole.lang.queries.model.Path in project whole by wholeplatform.
the class PojoNormalizerVisitor method resolveTemplateNameCollisionsInDeclarations.
public static void resolveTemplateNameCollisionsInDeclarations(Library entity, IBindingManager bindings, FreshNameGenerator entityNameGenerator) {
Path findAllProductDeclarationsWithTemplateName = (Path) PojoTemplateManager.instance().create("findAllProductDeclarationsWithTemplateName");
bindings.wEnterScope();
for (ProductDeclaration declaration : BehaviorUtils.<ProductDeclaration>compileAndLazyEvaluate(findAllProductDeclarationsWithTemplateName, entity, bindings)) {
Template template = declaration.getTemplate();
template.wSetValue(entityNameGenerator.nextFreshName(StringUtils.toSimpleName(template.wStringValue())));
}
bindings.wExitScope();
}
use of org.whole.lang.queries.model.Path in project whole by wholeplatform.
the class PojoNormalizerVisitor method createDefaultTemplateInDeclarations.
public static void createDefaultTemplateInDeclarations(Library entity, IBindingManager bindings, FreshNameGenerator entityNameGenerator) {
PojoEntityFactory pef = PojoEntityFactory.instance;
Path findAllProductDeclarationsWithEmptyTemplate = (Path) PojoTemplateManager.instance().create("findAllProductDeclarationsWithEmptyTemplate");
bindings.wEnterScope();
for (ProductDeclaration declaration : BehaviorUtils.<ProductDeclaration>compileAndLazyEvaluate(findAllProductDeclarationsWithEmptyTemplate, entity, bindings)) {
String name = StringUtils.toSimpleName(bindings.wStringValue("name"));
declaration.setTemplate(pef.createName(entityNameGenerator.nextFreshName(name)));
}
bindings.wExitScope();
}
use of org.whole.lang.queries.model.Path in project whole by wholeplatform.
the class PojoNormalizerVisitor method addMappingDataTypes.
public static void addMappingDataTypes(Library entity, IBindingManager bindings, FreshNameGenerator entityNameGenerator) {
Path findNonPrimitiveTypes = (Path) PojoTemplateManager.instance().create("findAllPropertyTypes");
bindings.wEnterScope();
for (Type type : BehaviorUtils.<Type>compileAndLazyEvaluate(findNonPrimitiveTypes, entity, bindings)) addMappingDataType(type, entity, bindings, entityNameGenerator);
bindings.wExitScope();
}
Aggregations