Examples of GlobalDescr


Examples of org.drools.lang.descr.GlobalDescr

                      impdescr.getEndCharacter() );

        assertEquals( 2,
                      pkg.getGlobals().size() );

        GlobalDescr global = pkg.getGlobals().get( 0 );
        assertEquals( "java.util.List<java.util.Map<String,Integer>>",
                      global.getType() );
        assertEquals( "aList",
                      global.getIdentifier() );
        assertEquals( source.indexOf( "global " + global.getType() ),
                      global.getStartCharacter() );
        assertEquals( source.indexOf( "global " + global.getType() + " " + global.getIdentifier() ) +
                              ("global " + global.getType() + " " + global.getIdentifier()).length() + 1,
                      global.getEndCharacter() );

        global = pkg.getGlobals().get( 1 );
        assertEquals( "Integer",
                      global.getType() );
        assertEquals( "aNumber",
                      global.getIdentifier() );
        assertEquals( source.indexOf( "global " + global.getType() ),
                      global.getStartCharacter() );
        assertEquals( source.indexOf( "global " + global.getType() + " " + global.getIdentifier() ) +
                              ("global " + global.getType() + " " + global.getIdentifier()).length(),
                      global.getEndCharacter() );
    }
View Full Code Here

Examples of org.drools.lang.descr.GlobalDescr

        assertEquals( 1,
                      pack.getImports().size() );
        assertEquals( 2,
                      pack.getGlobals().size() );

        final GlobalDescr foo = (GlobalDescr) pack.getGlobals().get( 0 );
        assertEquals( "java.lang.String",
                      foo.getType() );
        assertEquals( "foo",
                      foo.getIdentifier() );
        final GlobalDescr bar = (GlobalDescr) pack.getGlobals().get( 1 );
        assertEquals( "java.lang.Integer",
                      bar.getType() );
        assertEquals( "bar",
                      bar.getIdentifier() );
    }
View Full Code Here

Examples of org.drools.lang.descr.GlobalDescr

                            }
                        }
                        // add globals
                        List globals = drlInfo.getPackageDescr().getGlobals();
                        for (Iterator iterator = globals.iterator(); iterator.hasNext();) {
                            GlobalDescr globalDescr = (GlobalDescr) iterator.next();
                            Global global = DroolsModelBuilder.addGlobal(
                                pkg, globalDescr.getIdentifier(), file, globalDescr.getStartCharacter(),
                                globalDescr.getEndCharacter() - globalDescr.getStartCharacter() + 1);
                            // create link between resource and created rule nodes
                            List droolsElements = (List) resourcesMap.get(file);
                            if (droolsElements == null) {
                                droolsElements = new ArrayList();
                                resourcesMap.put(file, droolsElements);
View Full Code Here

Examples of org.drools.lang.descr.GlobalDescr

    private void populateGlobalInfo(final List jars) {

        // populating information for the globals
        for ( final Iterator it = pkgDescr.getGlobals().iterator(); it.hasNext(); ) {
            final GlobalDescr global = (GlobalDescr) it.next();
            try {
                final String shortTypeName = getShortNameOfClass( global.getType() );
                final Class< ? > clazz = loadClass( global.getType(),
                                                    jars );
                if ( !this.builder.hasFieldsForType( shortTypeName ) ) {

                    loadClassFields( clazz,
                                     shortTypeName );

                    this.builder.addGlobalType( global.getIdentifier(),
                                                shortTypeName );

                }
                if ( implementsCollection( clazz ) ) {
                    this.builder.addGlobalCollection( global.getIdentifier() );
                }
                this.builder.addGlobalType( global.getIdentifier(),
                                            shortTypeName );
            } catch ( final IOException e ) {
                this.errors.add( "Error while inspecting class for global: " + global.getType() + " error message: " + e.getMessage() );
            }

        }
    }
View Full Code Here

Examples of org.drools.lang.descr.GlobalDescr

                    }
                }
            }
            // globals
            for (Iterator iterator = packageDescr.getGlobals().iterator(); iterator.hasNext(); ) {
                GlobalDescr globalDescr = (GlobalDescr) iterator.next();
                if (globalDescr != null) {
                    BaseDescr result = getDescr(globalDescr, offset);
                    if (result != null) {
                        return result;
                    }
View Full Code Here

Examples of org.drools.lang.descr.GlobalDescr

        Map result = new HashMap();
        // add globals
        List globals = getGlobals();
        if ( globals != null ) {
            for ( Iterator iterator = globals.iterator(); iterator.hasNext(); ) {
                GlobalDescr global = (GlobalDescr) iterator.next();
                result.put( global.getIdentifier(),
                            global.getType() );
            }
        }

        if ( context == null ) {
            context = new CompletionContext( backText );
View Full Code Here

Examples of org.drools.lang.descr.GlobalDescr

            pkgRegistry.getPackage().addStaticImport( importEntry );
        }

        final List globals = packageDescr.getGlobals();
        for ( final Iterator it = globals.iterator(); it.hasNext(); ) {
            final GlobalDescr global = (GlobalDescr) it.next();
            final String identifier = global.getIdentifier();
            final String className = global.getType();

            Class clazz;
            try {
                clazz = pkgRegistry.getTypeResolver().resolveType( className );
                pkgRegistry.getPackage().addGlobal( identifier,
                                                    clazz );
                this.globals.put( identifier,
                                  clazz );
            } catch ( final ClassNotFoundException e ) {
                this.results.add( new GlobalError( identifier,
                                                   global.getLine() ) );
                e.printStackTrace();
            }
        }

    }
View Full Code Here

Examples of org.drools.lang.descr.GlobalDescr

    private String processGlobalsList(final List globals) {
        String globalList = "";

        for ( final Iterator it = globals.iterator(); it.hasNext(); ) {
            final GlobalDescr global = (GlobalDescr) it.next();
            final String identifier = global.getIdentifier();
            final String type = global.getType();
            final String globalTemplate = "global " + type + " " + identifier + ";" + DrlDumper.eol;
            globalList += globalTemplate;
        }

        return globalList + DrlDumper.eol;
View Full Code Here

Examples of org.drools.lang.descr.GlobalDescr

    }

    private String processGlobalsList(final List globals) {
        String globalList = "";
        for ( final Iterator iterator = globals.iterator(); iterator.hasNext(); ) {
            final GlobalDescr global = (GlobalDescr) iterator.next();
            final String identifier = global.getIdentifier();
            final String type = global.getType();
            final String globalTemplate = "<global identifier=\"" + identifier + "\" type=\"" + type + "\" />" + XmlDumper.eol;
            globalList += globalTemplate;
        }

        return globalList + XmlDumper.eol;
View Full Code Here

Examples of org.drools.lang.descr.GlobalDescr

                      impdescr.getEndCharacter() );

        assertEquals( 2,
                      pkg.getGlobals().size() );

        GlobalDescr global = pkg.getGlobals().get( 0 );
        assertEquals( "java.util.List<java.util.Map<String,Integer>>",
                      global.getType() );
        assertEquals( "aList",
                      global.getIdentifier() );
        assertEquals( source.indexOf( "global " + global.getType() ),
                      global.getStartCharacter() );
        assertEquals( source.indexOf( "global " + global.getType() + " " + global.getIdentifier() ) +
                              ("global " + global.getType() + " " + global.getIdentifier()).length(),
                      global.getEndCharacter() );

        global = pkg.getGlobals().get( 1 );
        assertEquals( "Integer",
                      global.getType() );
        assertEquals( "aNumber",
                      global.getIdentifier() );
        assertEquals( source.indexOf( "global " + global.getType() ),
                      global.getStartCharacter() );
        assertEquals( source.indexOf( "global " + global.getType() + " " + global.getIdentifier() ) +
                              ("global " + global.getType() + " " + global.getIdentifier()).length(),
                      global.getEndCharacter() );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.