This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jaxx. See http://git.nuiton.org/jaxx.git commit 67396a686b2d4859a20ee66fe867be94cd9e8de5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 12 13:58:25 2015 +0200 refs #3668 can now use diamond syntax in field declarations --- .../java/jaxx/compiler/java/parser/JavaParser.java | 58 +++++++++++++++++++++- .../jaxx/compiler/java/parser/JavaParserTest.java | 12 ++++- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java b/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java index 6368eb6..4800ccd 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParser.java @@ -2392,6 +2392,62 @@ public class JavaParser/*@bgen(jjtree)*/ implements JavaParserTreeConstants, Jav } } + final public void TypeArgumentsForAllocation() throws ParseException { + /*@bgen(jjtree) TypeArguments */ + SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENTS); + boolean jjtc000 = true; + jjtree.openNodeScope(jjtn000); + jjtreeOpenNodeScope(jjtn000); + try { + jj_consume_token(LT); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case GT: + // Diamond expression (jdk7) + jj_consume_token(GT); + return; + } + TypeArgument(); + label_21: + while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + break label_21; + } + jj_consume_token(COMMA); + TypeArgument(); + } + jj_consume_token(GT); + } catch (Throwable jjte000) { + if (jjtc000) { + jjtree.clearNodeScope(jjtn000); + jjtc000 = false; + } else { + jjtree.popNode(); + } + if (jjte000 instanceof RuntimeException) { + { + if (true) throw (RuntimeException) jjte000; + } + } + if (jjte000 instanceof ParseException) { + { + if (true) throw (ParseException) jjte000; + } + } + { + if (true) throw (Error) jjte000; + } + } finally { + if (jjtc000) { + jjtree.closeNodeScope(jjtn000, true); + jjtreeCloseNodeScope(jjtn000); + } + } + } + final public void TypeArgument() throws ParseException { /*@bgen(jjtree) TypeArgument */ SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENT); @@ -4390,7 +4446,7 @@ public class JavaParser/*@bgen(jjtree)*/ implements JavaParserTreeConstants, Jav ClassOrInterfaceType(); switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { case LT: - TypeArguments(); + TypeArgumentsForAllocation(); break; default: ; diff --git a/jaxx-compiler/src/test/java/jaxx/compiler/java/parser/JavaParserTest.java b/jaxx-compiler/src/test/java/jaxx/compiler/java/parser/JavaParserTest.java index 927e73f..b82a862 100644 --- a/jaxx-compiler/src/test/java/jaxx/compiler/java/parser/JavaParserTest.java +++ b/jaxx-compiler/src/test/java/jaxx/compiler/java/parser/JavaParserTest.java @@ -15,6 +15,7 @@ import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.List; /** * Created on 4/12/15. @@ -24,6 +25,9 @@ import java.util.ArrayList; */ public class JavaParserTest { + public static final List<String> DUMMY_LIST = new ArrayList<>(); + public static final List<String> DUMMY_LIST2 = new ArrayList<String>(); + @Test public void testParseClassButNotMethodBody() throws IOException, ClassNotFoundException, NoSuchMethodException { @@ -81,15 +85,19 @@ public class JavaParserTest { public void methodWithDiamondInside() { - new ArrayList<>(); + System.out.println(new ArrayList<>()); + System.out.println(DUMMY_LIST); + System.out.println(DUMMY_LIST2); } - public void methodWithTryResourceInside() throws IOException { + public void methodWithTryResourceInside() { try (BufferedReader reader = Files.newBufferedReader(new File("").toPath(), Charset.forName("UTF-8"))) { System.out.println(reader); + } catch (IOException | RuntimeException e ) { + e.printStackTrace(); } -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.