sourish-rygbee / javaparser

Automatically exported from code.google.com/p/javaparser
0 stars 0 forks source link

all comments are lost after occurrence of \" #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. parse the attached source file with JavaParser.parse(File)
2. print the returned CompilationUnit

What is the expected output? What do you see instead?

The parsing of the test file CommentsParserTest.java should preserve all 
comments.
There are two comments in CommentsParserTest.java, only the first, that is 
preceding the occurrence of \" at the end of line 3 is preserved. The class 
comment, which follows the occurrence of \" is lost.

What version of the product are you using? On what operating system?

    <groupId>com.github.javaparser</groupId>
    <artifactId>javaparser-parent</artifactId>
    <packaging>pom</packaging>
    <version>3.0.0-SNAPSHOT</version>

OS is Linux

Please provide any additional information below.

The problem is in com.github.javaparser.ast.comments.CommentsParser, line 129:

                case IN_STRING:
                    if (!prevTwoChars.peekLast().equals('\\') && c == '"') {
                        state = State.CODE;
                    }

This code fails to detect the end of certain string literals like "\\" or 
"test\\".

Original issue reported on code.google.com by franzb...@gmail.com on 9 Jun 2015 at 8:19

Attachments: