Package com.pogofish.jadt.parser

Examples of com.pogofish.jadt.parser.ParserImpl


               
    }
   
    @Test
    public void testInvalidCommentLocations() throws Exception {
        final ParserImpl p1 = parserImpl("/* */");
        p1.eof();
        checkVoidCommentError("<EOF>", p1);
       
        final ParserImpl p2 = parserImpl("/**/>");
        p2.rangle();
        checkVoidCommentError("'>'", p2);
       
        final ParserImpl p3 = parserImpl("/**/<");
        p3.langle();
        checkVoidCommentError("'<'", p3);
       
        final ParserImpl p4 = parserImpl("/**/[");
        p4.lbracket();
        checkVoidCommentError("'['", p4);
       
        final ParserImpl p5 = parserImpl("/**/]");
        p5.rbracket();
        checkVoidCommentError("']'", p5);
       
        final ParserImpl p6 = parserImpl("/**/(");
        p6.lparen();
        checkVoidCommentError("'('", p6);
       
        final ParserImpl p7 = parserImpl("/**/)");
        p7.rparen();
        checkVoidCommentError("')'", p7);
       
        final ParserImpl p8 = parserImpl("/**/,");
        p8.comma();
        checkVoidCommentError("','", p8);
       
        final ParserImpl p9 = parserImpl("/**/.");
        p9.dot();
        checkVoidCommentError("'.'", p9);       
       
        final ParserImpl p10 = parserImpl("/**/double");
        checkCommentError(_DoubleType(), p10.doubleType(), "'double'", p10);
       
        final ParserImpl p11 = parserImpl("/**/float");
        checkCommentError(_FloatType(), p11.floatType(), "'float'", p11);
       
        final ParserImpl p12 = parserImpl("/**/long");
        checkCommentError(_LongType(), p12.longType(), "'long'", p12);
       
        final ParserImpl p13 = parserImpl("/**/int");
        checkCommentError(_IntType(), p13.intType(), "'int'", p13);
       
        final ParserImpl p14 = parserImpl("/**/short");
        checkCommentError(_ShortType(), p14.shortType(), "'short'", p14);
       
        final ParserImpl p15 = parserImpl("/**/char");
        checkCommentError(_CharType(), p15.charType(), "'char'", p15);
       
        final ParserImpl p16 = parserImpl("/**/byte");
        checkCommentError(_ByteType(), p16.byteType(), "'byte'", p16);
       
        final ParserImpl p17 = parserImpl("/**/boolean");
        checkCommentError(_BooleanType(), p17.booleanType(), "'boolean'", p17);
       
        final ParserImpl p18 = parserImpl("/**/final");
        checkCommentError(_Final(), p18.finalKeyword(), "'final'", p18);
       
        final ParserImpl p20 = parserImpl("/**/identifier");
        checkCommentError("identifier", p20.identifier("an identifier"), "an identifier", p20);

        final ParserImpl p21 = parserImpl("/**/extends");
        p21.extendsKeyword();
        checkVoidCommentError("'extends'", p21);       
       
        final ParserImpl p22 = parserImpl("/**/implements");
        p22.implementsKeyword();
        checkVoidCommentError("'implements'", p22);       
       
        final ParserImpl p23 = parserImpl("/**/transient");
        checkCommentError(_Transient(), p23.transientKeyword(), "'transient'", p23);
       
        final ParserImpl p24 = parserImpl("/**/volatile");
        checkCommentError(_Volatile(), p24.volatileKeyword(), "'volatile'", p24);
       
        final ParserImpl p25 = parserImpl("/**/@");
        p25.at(false);
        checkVoidCommentError("'@'", p25)
       
        final ParserImpl p26 = parserImpl("/**/{");
        p26.lcurly();
        checkVoidCommentError("'{'", p26);
       
        final ParserImpl p27 = parserImpl("/**/}");
        p27.rcurly();
        checkVoidCommentError("'}'", p27);
       
        final ParserImpl p28 = parserImpl("/**/=");
        p28.equals(false);
        checkVoidCommentError("'='", p28);

        final ParserImpl p29 = parserImpl("/**/?");
        p29.question();
        checkVoidCommentError("'?'", p29);

        final ParserImpl p30 = parserImpl("/**/:");
        p30.colon();
        checkVoidCommentError("':'", p30);
    }
View Full Code Here


    public void testCommentAllowedTokens() throws Exception {
        final String commentString = "/*block*//**javadoc*///eol\n";
        @SuppressWarnings("unchecked")
        final List<JavaComment> comments = list(_JavaBlockComment(list(list(_BlockWord("/*block*/")))), _JavaDocComment("/**", list(_JDWord("javadoc")), Util.<JDTagSection>list(), "*/"), _JavaEOLComment("//eol"));
       
        final ParserImpl p1 = parserImpl(commentString + "|");
        checkParseResult(comments, p1.bar(), p1);

        final ParserImpl p2 = parserImpl(commentString + "=");
        checkParseResult(comments, p2.equals(true), p2);

        final ParserImpl p3 = parserImpl(commentString + "package");
        checkParseResult(comments, p3.packageKeyword(), p3);

        final ParserImpl p4 = parserImpl(commentString + "import");
        checkParseResult(comments, p4.importKeyword(), p4);

        final ParserImpl p5 = parserImpl(commentString + "hello");
        checkParseResult(_Tuple(comments, "hello"), p5.commentedIdentifier("an identifier"), p5);

        final ParserImpl p6 = parserImpl(commentString + "@");
        checkParseResult(comments, p6.at(true), p6);

    }
View Full Code Here

        testLiteral(_StringLiteral("\"hello\""), "\"hello\"");
        testLiteral(_CharLiteral("'c'"), "'c'");
    }

    private void testLiteral(Literal expected, String input) throws Exception {
        final ParserImpl p = parserImpl(input);
        final Literal lit = p.literal();
        assertEquals(Util.<SyntaxError>list().toString(), p.errors().toString());
        assertEquals(expected, lit);
       
    }
View Full Code Here

        testExpression(_VariableExpression(_Some(_VariableExpression(Optional.<Expression>_None(), "foo")), "bar"), "foo.bar");
        testExpression(_ClassReference(_Ref(_ClassType("foo.bar", NO_ACTUAL_TYPE_ARGUMENTS))), "foo.bar.class");
    }
   
    private void testExpression(Expression expected, String input) throws Exception {
        final ParserImpl p = parserImpl(input);
        final Expression expression = p.expression();
        assertEquals("[]", p.errors().toString());
        assertEquals(expected.toString(), expression.toString());
    }
View Full Code Here

        testAnnotation(_Tuple(NO_COMMENTS, _Annotation("foo", _Some(_ElementValuePairs(list(_AnnotationKeyValue("x", _AnnotationValueExpression(_LiteralExpression(_NullLiteral())))))))), "@foo( x = null )");
        testAnnotation(_Tuple(NO_COMMENTS, _Annotation("foo", _Some(_ElementValuePairs(list(_AnnotationKeyValue("x", _AnnotationValueExpression(_LiteralExpression(_NullLiteral()))), _AnnotationKeyValue("y", _AnnotationValueAnnotation(_Annotation("bar", Optional.<AnnotationElement>_None())))))))), "@foo( x = null, y = @bar )");       
    }
   
    private void testAnnotation(Tuple<List<JavaComment>, Annotation> expected, String input) throws Exception {
        final ParserImpl p = parserImpl(input);
        final Tuple<List<JavaComment>, Annotation> ca = p.annotation(true);
        assertEquals("[]", p.errors().toString());
        assertEquals(expected.toString(), ca.toString());
    }
View Full Code Here

TOP

Related Classes of com.pogofish.jadt.parser.ParserImpl

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.