Federico Tomassetti | 3cf311c | 2015-02-19 12:15:06 +0000 | [diff] [blame] | 1 | import com.github.javaparser.JavaParser; |
| 2 | import com.github.javaparser.ParseException; |
| 3 | import com.github.javaparser.ast.CompilationUnit; |
| 4 | import com.github.javaparser.ast.Node; |
| 5 | |
| 6 | import java.io.ByteArrayInputStream; |
| 7 | import java.io.InputStream; |
| 8 | import java.nio.charset.StandardCharsets; |
| 9 | |
| 10 | /** |
| 11 | * Created by federico on 03/09/15. |
| 12 | */ |
| 13 | public class Issue192 { |
| 14 | |
| 15 | public static void main(String[] args) throws ParseException { |
| 16 | String code = "public class StepImplementation {\n" + |
| 17 | " public void contextStep() {\n" + |
| 18 | " for (int i = 0; i < 5; i++) {\n" + |
| 19 | " // foo bar\n" + |
| 20 | " System.out.println();\n" + |
| 21 | " // another foo bar\n" + |
| 22 | " }\n" + |
| 23 | " }\n" + |
| 24 | "}"; |
| 25 | InputStream stream = new ByteArrayInputStream(code.getBytes(StandardCharsets.UTF_8)); |
| 26 | CompilationUnit cu = JavaParser.parse(stream); |
| 27 | lookInto(cu); |
| 28 | } |
| 29 | |
| 30 | private static void lookInto(Node node) { |
| 31 | if (node.getOrphanComments() != null && node.getOrphanComments().size() > 0) { |
| 32 | System.out.println("GOTCHA in " + node.getClass().getCanonicalName()); |
| 33 | } |
| 34 | for (Node child : node.getChildrenNodes()) { |
| 35 | lookInto(child); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | } |