branch feature/3980_lmbda_in_handlers-constructor created (now 4d0bc71)
This is an automated email from the git hooks/post-receive script. New change to branch feature/3980_lmbda_in_handlers-constructor in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git at 4d0bc71 fixes #3980 Be able to use java 8 lambda syntax at least in construtor's bodies This branch includes the following new commits: new 4d0bc71 fixes #3980 Be able to use java 8 lambda syntax at least in construtor's bodies The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 4d0bc71b76c705dd9a4f62acbe68b6902c7105cc Author: Kevin Morin <morin@codelutin.com> Date: Fri Jul 29 16:37:30 2016 +0200 fixes #3980 Be able to use java 8 lambda syntax at least in construtor's bodies -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/3980_lmbda_in_handlers-constructor in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit 4d0bc71b76c705dd9a4f62acbe68b6902c7105cc Author: Kevin Morin <morin@codelutin.com> Date: Fri Jul 29 16:37:30 2016 +0200 fixes #3980 Be able to use java 8 lambda syntax at least in construtor's bodies --- .../java/jaxx/compiler/java/parser/JavaParser.java | 67 ++++------------------ .../compiler/java/parser/JavaParserConstants.java | 2 +- .../java/org/nuiton/jaxx/plugin/LambdaTest.java | 17 ++++++ .../org/nuiton/jaxx/plugin/lambdaTest/Lambda.jaxx | 22 +++++++ .../org/nuiton/jaxx/plugin/lambdaTest/Lambda.xml | 50 ++++++++++++++++ .../jaxx/plugin/lambdaTest/LambdaHandler.java | 44 ++++++++++++++ 6 files changed, 145 insertions(+), 57 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 4800ccd..fc2d9b5 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 @@ -1951,67 +1951,22 @@ public class JavaParser/*@bgen(jjtree)*/ implements JavaParserTreeConstants, Jav } else { ; } - label_16: - while (true) { + // We do not care about what is inside the constructor, let's allow java 8 lambdas! + int lbraceNb = 1;// 1 left brace consumed + // while all the left braces have not been closed + while (lbraceNb > 0) { switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ABSTRACT: - case ASSERT: - case BOOLEAN: - case BREAK: - case BYTE: - case CHAR: - case CLASS: - case CONTINUE: - case DO: - case DOUBLE: - case FALSE: - case FINAL: - case FLOAT: - case FOR: - case IF: - case INT: - case INTERFACE: - case LONG: - case NATIVE: - case NEW: - case NULL: - case PRIVATE: - case PROTECTED: - case PUBLIC: - case RETURN: - case SHORT: - case STATIC: - case STRICTFP: - case SUPER: - case SWITCH: - case SYNCHRONIZED: - case THIS: - case THROW: - case TRANSIENT: - case TRUE: - case TRY: - case VOID: - case VOLATILE: - case WHILE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case CHARACTER_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case LBRACE: - case SEMICOLON: - case AT: - case INCR: - case DECR: - ; + case LBRACE: // new left brace opened + lbraceNb++; + break; + case RBRACE: // left brace closed + lbraceNb--; break; default: - break label_16; + break; } - BlockStatement(); + jj_consume_token(jj_ntk); } - jj_consume_token(RBRACE); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java b/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java index b0e1bb6..d7c2d2c 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/java/parser/JavaParserConstants.java @@ -398,7 +398,7 @@ public interface JavaParserConstants { "\">>\"", "\">\"", "\"\\u001a\"", - "<STUFF_TO_IGNORE>", + "<STUFF_TO_IGNORE>" }; } diff --git a/jaxx-maven-plugin/src/test/java/org/nuiton/jaxx/plugin/LambdaTest.java b/jaxx-maven-plugin/src/test/java/org/nuiton/jaxx/plugin/LambdaTest.java new file mode 100644 index 0000000..0a609a9 --- /dev/null +++ b/jaxx-maven-plugin/src/test/java/org/nuiton/jaxx/plugin/LambdaTest.java @@ -0,0 +1,17 @@ +package org.nuiton.jaxx.plugin; + +import org.junit.Test; + +/** + * @author Kevin Morin (Code Lutin) + * @since 2.30 + */ +public class LambdaTest extends JaxxBaseTest { + + @Test + public void Lambda() throws Exception { + getMojo().execute(); + assertNumberJaxxFiles(1); + } + +} diff --git a/jaxx-maven-plugin/src/test/resources/org/nuiton/jaxx/plugin/lambdaTest/Lambda.jaxx b/jaxx-maven-plugin/src/test/resources/org/nuiton/jaxx/plugin/lambdaTest/Lambda.jaxx new file mode 100644 index 0000000..ff8cc9b --- /dev/null +++ b/jaxx-maven-plugin/src/test/resources/org/nuiton/jaxx/plugin/lambdaTest/Lambda.jaxx @@ -0,0 +1,22 @@ +<!-- + #%L + JAXX :: Maven plugin + %% + Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<JLabel/> diff --git a/jaxx-maven-plugin/src/test/resources/org/nuiton/jaxx/plugin/lambdaTest/Lambda.xml b/jaxx-maven-plugin/src/test/resources/org/nuiton/jaxx/plugin/lambdaTest/Lambda.xml new file mode 100644 index 0000000..e25230e --- /dev/null +++ b/jaxx-maven-plugin/src/test/resources/org/nuiton/jaxx/plugin/lambdaTest/Lambda.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + JAXX :: Maven plugin + %% + Copyright (C) 2008 - 2014 Code Lutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>jaxx-maven-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <force>true</force> + <resetAfterCompile>false</resetAfterCompile> + <addAutoHandlerUI>true</addAutoHandlerUI> + <includes> + <value>**/lambdaTest/*.jaxx</value> + <value>**/lambdaTest/*.java</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/jaxx-maven-plugin/src/test/resources/org/nuiton/jaxx/plugin/lambdaTest/LambdaHandler.java b/jaxx-maven-plugin/src/test/resources/org/nuiton/jaxx/plugin/lambdaTest/LambdaHandler.java new file mode 100644 index 0000000..8d97094 --- /dev/null +++ b/jaxx-maven-plugin/src/test/resources/org/nuiton/jaxx/plugin/lambdaTest/LambdaHandler.java @@ -0,0 +1,44 @@ +package org.nuiton.jaxx.plugin.lambdaTest; + +import jaxx.runtime.JAXXObject; +import jaxx.runtime.spi.UIHandler; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.beans.PropertyChangeListener; + +/** + * @author Kevin Morin (Code Lutin) + * @since x.x + */ +public class LambdaHandler implements UIHandler { + + /** Logger. */ + private static final Log log = LogFactory.getLog(LambdaHandler.class); + + private PropertyChangeListener propertyChangeListener; + + public LambdaHandler() { + propertyChangeListener = evt -> { + if (evt.getNewValue() != null) { + if (log.isInfoEnabled()) { + log.info("property changed !"); + } + } + }; + } + + @Override + public void beforeInit(JAXXObject jaxxObject) { + if (log.isInfoEnabled()) { + log.info("before init"); + } + } + + @Override + public void afterInit(JAXXObject jaxxObject) { + if (log.isInfoEnabled()) { + log.info("after init"); + } + } +} -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm