Package com.pogofish.jadt.ast

Examples of com.pogofish.jadt.ast.DataType


        assertEquals(
                new ParseResult(new Doc(
                        "ParserTest",
                        Pkg._Pkg(list(_JavaEOLComment("//a pre-start comment"), _JavaEOLComment("//a start comment")), "hello.world"), list(Imprt._Imprt(list(IMPORTS_COMMENT), "wow.man"), Imprt._Imprt(NO_COMMENTS, "flim.flam")),
                        list(new DataType(list(_JavaEOLComment("//an annotation comment"), _JavaEOLComment("//datatype comment")), list(_Annotation("foo", Optional.<AnnotationElement>_None()), _Annotation("foo", _Some(_ElementValue(_AnnotationValueAnnotation(_Annotation("bar", Optional.<AnnotationElement>_None())))))),
                                "FooBar",
                                NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS,
                                list(
                                        new Constructor(list(_JavaEOLComment("//equal comment"), _JavaEOLComment("//constructor comment")), "foo", Util
                                                .<Arg> list()),
                                        new Constructor(list(_JavaEOLComment("//bar comment"), _JavaEOLComment("//really a bar comment")),
                                                "bar",
                                                list(new Arg(Util
                                                        .<ArgModifier> list(),
                                                        _Primitive(_IntType()),
                                                        "hey"),
                                                        new Arg(
                                                                list(_Final()),
                                                                _Ref(_ArrayType(_Ref(_ClassType(
                                                                        "String",
                                                                        NO_ACTUAL_TYPE_ARGUMENTS)))),
                                                                "yeah"))))),
                                new DataType(NO_COMMENTS, NO_ANNOTATIONS, "whatever", NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS,
                                        list(new Constructor(NO_COMMENTS, "whatever", Util
                                                .<Arg> list()))))), Util.<SyntaxError>list()).toString(), result.toString());
    }
View Full Code Here


        assertEquals(
                new ParseResult(new Doc(
                        "ParserTest",
                        Pkg._Pkg(list(_JavaEOLComment("//a start comment")), "hello.world"), list(Imprt._Imprt(list(IMPORTS_COMMENT), "wow.man"), Imprt._Imprt(NO_COMMENTS, "flim.flam")),
                        list(new DataType(NO_COMMENTS, NO_ANNOTATIONS,
                                "FooBar",
                                NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS,
                                list(
                                        new Constructor(NO_COMMENTS, "foo", Util
                                                .<Arg> list()),
                                        new Constructor(NO_COMMENTS,
                                                "bar",
                                                list(new Arg(Util
                                                        .<ArgModifier> list(),
                                                        _Primitive(_IntType()),
                                                        "hey"),
                                                        new Arg(
                                                                list(_Final()),
                                                                _Ref(_ArrayType(_Ref(_ClassType(
                                                                        "String",
                                                                        NO_ACTUAL_TYPE_ARGUMENTS)))),
                                                                "yeah"))))),
                                new DataType(NO_COMMENTS, NO_ANNOTATIONS, "whatever", NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS,
                                        list(new Constructor(NO_COMMENTS, "BAD_IDENTIFIER_int@1", Util
                                                .<Arg> list()))))), list(SyntaxError._UnexpectedToken("a constructor name", "'int'", 2))).toString(), result.toString());
               
    }
View Full Code Here

     */
    @Test
    public void testFull() {
        @SuppressWarnings("unchecked")
        final Doc doc = new Doc("EmitterTest", Pkg._Pkg(Util.list(_JavaDocComment("/**", list(_JDWhiteSpace(" "), _JDWord("hello"), _JDWhiteSpace(" ")), Util.<JDTagSection>list(), "*/")), "some.package"), list(Imprt._Imprt(Util.list(_JavaBlockComment(list(list(_BlockWord("/* hello */"))))), "wow.man"), Imprt._Imprt(Util.list(_JavaEOLComment("// hello")), "flim.flam")), list(
                new DataType(NO_COMMENTS, NO_ANNOTATIONS, "FooBar", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(
                        new Constructor(NO_COMMENTS, "Foo", list(
                                new Arg(Util.<ArgModifier>list(), _Primitive(_IntType()), "yeah"),
                                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType>list())), "hmmm")
                        )),
                        new Constructor(NO_COMMENTS, "Bar", Util.<Arg>list())
                )),
                new DataType(NO_COMMENTS, NO_ANNOTATIONS, "Whatever", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(
                        new Constructor(NO_COMMENTS, "Whatever", Util.<Arg>list())
                ))
               
        ));
        final StringSinkFactory factory = new StringSinkFactory("whatever");
View Full Code Here

     * Test a doc with no imports
     */
    @Test
    public void testNoImports() {
        final Doc doc = new Doc("EmitterTest", Pkg._Pkg(NO_COMMENTS, "some.package"), NO_IMPORTS, list(
                new DataType(NO_COMMENTS, NO_ANNOTATIONS, "FooBar", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(
                        new Constructor(NO_COMMENTS, "Foo", list(
                                new Arg(Util.<ArgModifier>list(), _Primitive(_IntType()), "yeah"),
                                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType>list())), "hmmm")
                        )),
                        new Constructor(NO_COMMENTS, "Bar", Util.<Arg>list())
                )),
                new DataType(NO_COMMENTS, NO_ANNOTATIONS, "Whatever", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(
                        new Constructor(NO_COMMENTS, "Whatever", Util.<Arg>list())
                ))
               
        ));
        final StringSinkFactory factory = new StringSinkFactory("whatever");
View Full Code Here

     * Test a doc with no package declaration
     */
    @Test
    public void testNoPackage() {
        final Doc doc = new Doc("EmitterTest", EMPTY_PKG, list(Imprt._Imprt(NO_COMMENTS, "wow.man"), Imprt._Imprt(NO_COMMENTS, "flim.flam")), list(
                new DataType(NO_COMMENTS, NO_ANNOTATIONS, "FooBar", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(
                        new Constructor(NO_COMMENTS, "Foo", list(
                                new Arg(Util.<ArgModifier>list(), _Primitive(_IntType()), "yeah"),
                                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType>list())), "hmmm")
                        )),
                        new Constructor(NO_COMMENTS, "Bar", Util.<Arg>list())
                )),
                new DataType(NO_COMMENTS, NO_ANNOTATIONS, "Whatever", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(
                        new Constructor(NO_COMMENTS, "Whatever", Util.<Arg>list())
                ))
               
        ));
        final StringSinkFactory factory = new StringSinkFactory("whatever");
View Full Code Here

    /**
     * Test that multiple constructors with no base does its thing correctly
     */
    @Test
    public void testMultipleConstructorsNoBase() {
        final DataType fooBar = new DataType(Util.list(_JavaDocComment("/**", list(_JDWhiteSpace(" "), _JDWord("hello"), _JDWhiteSpace(" ")), Util.<JDTagSection>list(), "*/")), ANNOTATIONS, "FooBar", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(
                new Constructor(NO_COMMENTS, "Foo", list(new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("Integer", Util.<RefType> list())), "yeah"),
                        new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType> list())), "hmmm"))), new Constructor(NO_COMMENTS, "Bar",
                        Util.<Arg> list())));

        final StringSink sink = new StringSink("test");
View Full Code Here

    /**
     * Test that multiple constructors with base types does its thing correctly
     */
    @Test
    public void testMultipleConstructorsWithBase() {
        final DataType fooBar = new DataType(Util.list(_JavaDocComment("/**", list(_JDWhiteSpace(" "), _JDWord("hello"), _JDWhiteSpace(" ")), Util.<JDTagSection>list(), "*/")), ANNOTATIONS, "FooBar", Util.<String>list(), _Some(_ClassType("FooA", NO_TYPE_ARGS)), list(_ClassType("FooB", NO_TYPE_ARGS), _ClassType("FooC", NO_TYPE_ARGS)), list(
                new Constructor(NO_COMMENTS, "Foo", list(new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("Integer", Util.<RefType> list())), "yeah"),
                        new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType> list())), "hmmm"))), new Constructor(NO_COMMENTS, "Bar",
                        Util.<Arg> list())));

        final StringSink sink = new StringSink("test");
View Full Code Here

    /**
     * Test that single constructor with no base does its thing properly
     */
    @Test
    public void testSingleConstructorNoBase() {
        final DataType fooBar = new DataType(Util.list(_JavaDocComment("/**", list(_JDWhiteSpace(" "), _JDWord("hello"), _JDWhiteSpace(" ")), Util.<JDTagSection>list(), "*/")), ANNOTATIONS, "FooBar", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(new Constructor(NO_COMMENTS, "Foo", list(
                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("Integer", Util.<RefType> list())), "yeah"),
                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType> list())), "hmmm")))));

        final StringSink sink = new StringSink("test");
        try {
View Full Code Here

    /**
     * Test that single constructor with base does its thing properly
     */
    @Test
    public void testSingleConstructorWithBase() {
        final DataType fooBar = new DataType(Util.list(_JavaDocComment("/**", list(_JDWhiteSpace(" "), _JDWord("hello"), _JDWhiteSpace(" ")), Util.<JDTagSection>list(), "*/")), ANNOTATIONS, "FooBar", Util.<String>list(), _Some(_ClassType("FooA", NO_TYPE_ARGS)), list(_ClassType("FooB", NO_TYPE_ARGS), _ClassType("FooC", NO_TYPE_ARGS)), list(new Constructor(NO_COMMENTS, "Foo", list(
                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("Integer", Util.<RefType> list())), "yeah"),
                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType> list())), "hmmm")))));

        final StringSink sink = new StringSink("test");
        try {
View Full Code Here

    /**
     * Test that datatypes print properly
     */
    @Test
    public void testDataTypes() {
        assertEquals("Foo =\n" + "    Bar\n" + "  | Baz", print(new DataType(NO_COMMENTS, NO_ANNOTATIONS, "Foo", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(new Constructor(NO_COMMENTS, "Bar",
                Util.<Arg> list()), new Constructor(NO_COMMENTS, "Baz", Util.<Arg> list())))));
        assertEquals("Foo extends FooA implements FooB, FooC =\n" + "    Bar\n" + "  | Baz", print(new DataType(NO_COMMENTS, NO_ANNOTATIONS, "Foo", Util.<String>list(), _Some(_ClassType("FooA", NO_TYPE_ARGS)), list(_ClassType("FooB", NO_TYPE_ARGS), _ClassType("FooC", NO_TYPE_ARGS)), list(new Constructor(NO_COMMENTS, "Bar",
                Util.<Arg> list()), new Constructor(NO_COMMENTS, "Baz", Util.<Arg> list())))));
        assertEquals("@foo\n@foo( @bar )\nFoo =\n" + "    Bar\n" + "  | Baz", print(new DataType(NO_COMMENTS, list(_Annotation("foo", Optional.<AnnotationElement>_None()), _Annotation("foo", _Some(_ElementValue(_AnnotationValueAnnotation(_Annotation("bar", Optional.<AnnotationElement>_None())))))), "Foo", Util.<String>list(), NO_EXTENDS, NO_IMPLEMENTS, list(new Constructor(NO_COMMENTS, "Bar",
                Util.<Arg> list()), new Constructor(NO_COMMENTS, "Baz", Util.<Arg> list())))));
    }
View Full Code Here

TOP

Related Classes of com.pogofish.jadt.ast.DataType

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.