Package org.rythmengine.extension

Examples of org.rythmengine.extension.ISourceCodeEnhancer


    }

    protected void implicitConfig(final Map<String, Object> map) {
        if (this.implicitVariables != null || this.implicitPackages != null) {
            map.put("codegen.source_code_enhancer.impl",
                    new ISourceCodeEnhancer() {

                        @Override
                        public List<String> imports() {
                            final List<String> packages = new ArrayList<String>();
                            if (implicitPackages != null) {
View Full Code Here


//        for (String argName : renderArgs.keySet()) {
//            p2t("System.err.println(\"").p(argName).p("=\" + this.").p(argName).pn(");");
//        }
        ptn("}");

        ISourceCodeEnhancer ce = engine.conf().get(RythmConfigurationKey.CODEGEN_SOURCE_CODE_ENHANCER);
        int userDefinedArgNumber = basicTemplate() ? renderArgs.size() : (renderArgs.size() - ((null == ce) ? 0 : ce.getRenderArgDescriptions().size()));
        if (0 < userDefinedArgNumber) {
            // -- output __setRenderArgs method with args passed in positioned order
            pn();
            ptn("@SuppressWarnings(\"unchecked\") public TemplateBase __setRenderArgs(java.lang.Object... __args) {");
            {
View Full Code Here

            }
        });
        m.put(RythmEvents.ON_BUILD_JAVA_SOURCE, new IEventHandler<Void, CodeBuilder>() {
            @Override
            public Void handleEvent(RythmEngine engine, CodeBuilder cb) {
                ISourceCodeEnhancer ce = sourceCodeEnhancer;
                if (null == ce) return null;
                if (cb.basicTemplate()) {
                    // basic template do not have common codes
                    return null;
                }
                // add common render args
                Map<String, ?> defArgs = ce.getRenderArgDescriptions();
                for (String name : defArgs.keySet()) {
                    Object o = defArgs.get(name);
                    String type = (o instanceof Class<?>) ? ((Class<?>) o).getName() : o.toString();
                    cb.addRenderArgs(-1, type, name);
                }
                // add common imports
                for (String s : ce.imports()) {
                    cb.addImport(s, -1);
                }
                return null;
            }
        });
        m.put(RythmEvents.COMPILED, new IEventHandler<byte[], byte[]>() {
            @Override
            public byte[] handleEvent(RythmEngine engine, byte[] bytes) {
                TemplateResourceManager.commitTmpBlackList();
                return bytes;
            }
        });
        m.put(RythmEvents.COMPILE_FAILED, new IEventHandler<Void, TemplateClass>() {
            @Override
            public Void handleEvent(RythmEngine engine, TemplateClass tc) {
                TemplateResourceManager.rollbackTmpBlackList();
                return null;
            }
        });
        m.put(RythmEvents.ON_CLOSING_JAVA_CLASS, new IEventHandler<Void, CodeBuilder>() {
            @Override
            public Void handleEvent(RythmEngine engine, CodeBuilder cb) {
                // add common source code
                ISourceCodeEnhancer ce = sourceCodeEnhancer;
                if (null == ce) {
                    return null;
                }
                if (cb.basicTemplate()) {
                    // basic template do not have common codes
                    return null;
                }
                cb.np(ce.sourceCode());
                cb.pn();
                return null;
            }
        });
        m.put(RythmEvents.ON_RENDER, new IEventHandler<Void, ITemplate>() {
            @Override
            public Void handleEvent(RythmEngine engine, ITemplate template) {
                ISourceCodeEnhancer ce = engine.conf().sourceEnhancer();
                if (null != ce) {
                    ce.setRenderArgs(template);
                }
                renderListener.onRender(template);
                return null;
            }
        });
View Full Code Here

    }

    protected void implicitConfig(final Map<String, Object> map) {
        if (this.implicitVariables != null || this.implicitPackages != null) {
            map.put("codegen.source_code_enhancer.impl",
                    new ISourceCodeEnhancer() {

                        @Override
                        public List<String> imports() {
                            final List<String> packages = new ArrayList<String>();
                            if (implicitPackages != null) {
View Full Code Here

TOP

Related Classes of org.rythmengine.extension.ISourceCodeEnhancer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.