entities: function()

in parsers/LU/JS/packages/lu/src/parser/converters/luistocsconverter.js [82:174]


    entities: function(app, writer) {
        writer.writeLine();
        writer.writeLineIndented([
            'public class _Entities',
            '{'
        ]);
        writer.increaseIndentation();
        this.writeEntityBlock(app.entities, 'Simple entities', (entity) => {
            writer.writeLineIndented(this.getEntityWithType(entity));
        }, writer);
        this.writeEntityBlock(app.prebuiltEntities, 'Built-in entities', (entities) => {
            const entityType = entities[0];
            entities.forEach(entity => {
                writer.writeLineIndented(this.getEntityWithType(entity, entityType));
            });
        }, writer);
        this.writeEntityBlock(app.closedLists, 'Lists', (entity) => {
            writer.writeLineIndented(this.getEntityWithType(entity, 'list'));
        }, writer);
        this.writeEntityBlock(app.regex_entities, 'Regex entities', (entity) => {
            writer.writeLineIndented(this.getEntityWithType(entity));
        }, writer);
        this.writeEntityBlock(app.patternAnyEntities, 'Pattern.any', (entity) => {
            writer.writeLineIndented(this.getEntityWithType(entity));
        }, writer);
        // Composites
        if (app.composites.length > 0) {
            writer.writeLine();
            writer.writeLineIndented('// Composites');
            let first = true;
            app.composites.forEach(composite => {
                if (first) {
                    first = false;
                }
                else {
                    writer.writeLine();
                }
                writer.writeLineIndented([
                    `public class _Instance${lodash.upperFirst(composite.compositeName)}`,
                    '{'
                ]);
                writer.increaseIndentation();
                composite.attributes.forEach(attr => {
                    writer.writeLineIndented([
                        `public InstanceData[] ${parse_multi_platform_luis_1.jsonPropertyName(attr)};`
                    ]);
                });
                writer.decreaseIndentation();
                writer.writeLineIndented([
                    '}',
                    `public class ${lodash.upperFirst(composite.compositeName)}Class`,
                    '{'
                ]);
                writer.increaseIndentation();
                composite.attributes.forEach(attr => {
                    writer.writeLineIndented(this.getEntityWithType(attr, app.closedLists.includes(attr) ? 'list' : attr));

                });
                writer.writeLineIndented([
                    '[JsonProperty("$instance")]',
                    `public _Instance${lodash.upperFirst(composite.compositeName)} _instance;`
                ]);
                writer.decreaseIndentation();
                writer.writeLineIndented([
                    '}',
                    `public ${lodash.upperFirst(composite.compositeName)}Class[] ${composite.compositeName};`
                ]);
            });
        }
        // Instance
        writer.writeLine();
        writer.writeLineIndented([
            '// Instance',
            'public class _Instance',
            '{'
        ]);
        writer.increaseIndentation();
        app.getInstancesList().forEach(instanceData => {
            writer.writeLineIndented(`public InstanceData[] ${parse_multi_platform_luis_1.jsonPropertyName(instanceData)};`);
        });
        writer.decreaseIndentation();
        writer.writeLineIndented([
            '}',
            '[JsonProperty("$instance")]',
            'public _Instance _instance;'
        ]);
        writer.decreaseIndentation();
        writer.writeLineIndented([
            '}',
            '[JsonProperty("entities")]',
            'public _Entities Entities;'
        ]);
    },