The Unified and Autonomous Development Platform
midwork
robin shine9c64b81eed56
diff --git a/commons.all/pom.xml b/commons.all/pom.xmlindex 773587f123..24f451e50a 100644--- a/commons.all/pom.xml+++ b/commons.all/pom.xml@@ -33,6 +33,7 @@<module>../commons.markdown</module><module>../gitplex.search</module>+ <module>../commons.antlr</module></modules><repositories><repository>diff --git a/commons.antlr/pom.xml b/commons.antlr/pom.xmlnew file mode 100644index 0000000000..2fe081fe71--- /dev/null+++ b/commons.antlr/pom.xml@@ -0,0 +1,80 @@+<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/maven-v4_0_0.xsd">+ <modelVersion>4.0.0</modelVersion>+ <artifactId>commons.antlr</artifactId>+ <version>1.0.0</version>+ <parent>+ <groupId>com.pmease</groupId>+ <artifactId>parent.general</artifactId>+ <version>1.0.31</version>+ </parent>++ <build>+ <plugins>+ <plugin>+ <groupId>com.pmease</groupId>+ <artifactId>plugin.maven</artifactId>+ </plugin>+ <plugin>+ <artifactId>maven-source-plugin</artifactId>+ </plugin>+ <plugin>+ <artifactId>maven-javadoc-plugin</artifactId>+ </plugin>+ <plugin>+ <groupId>org.antlr</groupId>+ <artifactId>antlr4-maven-plugin</artifactId>+ <configuration>+ <grammars>ANTLRv4Parser.g4</grammars>+ <includes>+ <include>ANTLRv4Lexer.g4</include>+ <include>ANTLRv4Parser.g4</include>+ </includes>+ <libDirectory>${basedir}/src/main/java/com/pmease/commons/antlr</libDirectory>+ </configuration>+ </plugin>+ </plugins>+ </build>++ <dependencies>+ <dependency>+ <groupId>com.pmease</groupId>+ <artifactId>commons.loader</artifactId>+ <version>1.0.31</version>+ </dependency>+ <dependency>+ <groupId>org.antlr</groupId>+ <artifactId>antlr4-runtime</artifactId>+ </dependency>+ <dependency>+ <groupId>com.pmease</groupId>+ <artifactId>commons.loader</artifactId>+ <version>1.0.31</version>+ <type>test-jar</type>+ <scope>test</scope>+ </dependency>+ </dependencies>++ <repositories>+ <repository>+ <id>pmeaseRepo</id>+ <name>PMEase Repository</name>+ <releases>+ <enabled>true</enabled>+ <updatePolicy>never</updatePolicy>+ <checksumPolicy>fail</checksumPolicy>+ </releases>+ <snapshots>+ <enabled>true</enabled>+ <updatePolicy>always</updatePolicy>+ <checksumPolicy>fail</checksumPolicy>+ </snapshots>+ <url>http://artifact.pmease.com/</url>+ </repository>+ </repositories>++ <properties>+ <moduleClass>com.pmease.commons.antlr.PluginModule</moduleClass>+ </properties>++</project>diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Lexer.g4 b/commons.antlr/src/main/java/com/pmease/commons/antlr/ANTLRv4Lexer.g4similarity index 100%rename from commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Lexer.g4rename to commons.antlr/src/main/java/com/pmease/commons/antlr/ANTLRv4Lexer.g4diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Parser.g4 b/commons.antlr/src/main/java/com/pmease/commons/antlr/ANTLRv4Parser.g4similarity index 100%rename from commons.wicket/src/main/java/com/pmease/commons/wicket/behavior/inputassist/antlr/ANTLRv4Parser.g4rename to commons.antlr/src/main/java/com/pmease/commons/antlr/ANTLRv4Parser.g4diff --git a/commons.wicket/src/main/java/LexBasic.g4 b/commons.antlr/src/main/java/com/pmease/commons/antlr/LexBasic.g4similarity index 97%rename from commons.wicket/src/main/java/LexBasic.g4rename to commons.antlr/src/main/java/com/pmease/commons/antlr/LexBasic.g4index 241ce5c494..1422d120cf 100644--- a/commons.wicket/src/main/java/LexBasic.g4+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/LexBasic.g4@@ -133,8 +133,8 @@ fragment DQuoteLiteral : DQuote ( EscSeq | ~["\r\n\\] )* DQuote ;fragment USQuoteLiteral : SQuote ( EscSeq | ~['\r\n\\] )* ;fragment DecimalFloatingPointLiteral- : DecDigits Dot DecDigits? ExponentPart? FloatTypeSuffix?- | Dot DecDigits ExponentPart? FloatTypeSuffix?+ : DecDigits DOT DecDigits? ExponentPart? FloatTypeSuffix?+ | DOT DecDigits ExponentPart? FloatTypeSuffix?| DecDigits ExponentPart FloatTypeSuffix?| DecDigits FloatTypeSuffix;@@ -152,8 +152,8 @@ fragment HexadecimalFloatingPointLiteral;fragment HexSignificand- : HexNumeral Dot?- | '0' [xX] HexDigits? Dot HexDigits+ : HexNumeral DOT?+ | '0' [xX] HexDigits? DOT HexDigits;fragment BinaryExponentdiff --git a/commons.wicket/src/main/java/LexUnicode.g4 b/commons.antlr/src/main/java/com/pmease/commons/antlr/LexUnicode.g4similarity index 100%rename from commons.wicket/src/main/java/LexUnicode.g4rename to commons.antlr/src/main/java/com/pmease/commons/antlr/LexUnicode.g4diff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/LexerAdaptor.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/LexerAdaptor.javanew file mode 100644index 0000000000..3263bc8554--- /dev/null+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/LexerAdaptor.java@@ -0,0 +1,87 @@+package com.pmease.commons.antlr;++import org.antlr.v4.runtime.CharStream;+import org.antlr.v4.runtime.Lexer;+import org.antlr.v4.runtime.Token;+import org.antlr.v4.runtime.misc.Interval;++public abstract class LexerAdaptor extends Lexer {++ public LexerAdaptor(CharStream input) {+ super(input);+ }++ /**+ * Track whether we are inside of a rule and whether it is lexical parser. _currentRuleType==Token.INVALID_TYPE+ * means that we are outside of a rule. At the first sign of a rule name reference and _currentRuleType==invalid, we+ * can assume that we are starting a parser rule. Similarly, seeing a token reference when not already in rule means+ * starting a token rule. The terminating ';' of a rule, flips this back to invalid type.+ *+ * This is not perfect logic but works. For example, "grammar T;" means that we start and stop a lexical rule for+ * the "T;". Dangerous but works.+ *+ * The whole point of this state information is to distinguish between [..arg actions..] and [charsets]. Char sets+ * can only occur in lexical rules and arg actions cannot occur.+ */+ private int _currentRuleType = Token.INVALID_TYPE;++ public int getCurrentRuleType() {+ return _currentRuleType;+ }++ public void setCurrentRuleType(int ruleType) {+ this._currentRuleType = ruleType;+ }++ protected void handleBeginArgument() {+ if (inLexerRule()) {+ pushMode(ANTLRv4Lexer.LexerCharSet);+ more();+ } else {+ pushMode(ANTLRv4Lexer.Argument);+ }+ }++ protected void handleEndArgument() {+ popMode();+ if (_modeStack.size() > 0) {+ setType(ANTLRv4Lexer.ARGUMENT_CONTENT);+ }+ }++ protected void handleEndAction() {+ popMode();+ if (_modeStack.size() > 0) {+ setType(ANTLRv4Lexer.ACTION_CONTENT);+ }+ }++ @Override+ public Token emit() {+ if (_type == ANTLRv4Lexer.ID) {+ String firstChar = _input.getText(Interval.of(_tokenStartCharIndex, _tokenStartCharIndex));+ if (Character.isUpperCase(firstChar.charAt(0))) {+ _type = ANTLRv4Lexer.TOKEN_REF;+ } else {+ _type = ANTLRv4Lexer.RULE_REF;+ }++ if (_currentRuleType == Token.INVALID_TYPE) { // if outside of rule def+ _currentRuleType = _type; // set to inside lexer or parser rule+ }+ } else if (_type == ANTLRv4Lexer.SEMI) { // exit rule def+ _currentRuleType = Token.INVALID_TYPE;+ }++ return super.emit();+ }++ private boolean inLexerRule() {+ return _currentRuleType == ANTLRv4Lexer.TOKEN_REF;+ }++ @SuppressWarnings("unused")+ private boolean inParserRule() { // not used, but added for clarity+ return _currentRuleType == ANTLRv4Lexer.RULE_REF;+ }+}\ No newline at end of filediff --git a/commons.antlr/src/main/java/com/pmease/commons/antlr/PluginModule.java b/commons.antlr/src/main/java/com/pmease/commons/antlr/PluginModule.javanew file mode 100644index 0000000000..190e03189a--- /dev/null+++ b/commons.antlr/src/main/java/com/pmease/commons/antlr/PluginModule.java@@ -0,0 +1,18 @@+package com.pmease.commons.antlr;++import com.pmease.commons.loader.AbstractPluginModule;++/**+ * NOTE: Do not forget to rename moduleClass property defined in the pom if you've renamed this class.+ *+ */+public class PluginModule extends AbstractPluginModule {++ @Override+ protected void configure() {+ super.configure();++ // put your guice bindings here+ }++}diff --git a/commons.antlr/src/main/resources/META-INF/maven/archetype-metadata.xml b/commons.antlr/src/main/resources/META-INF/maven/archetype-metadata.xmlnew file mode 100644index 0000000000..904fb7a4bb--- /dev/null+++ b/commons.antlr/src/main/resources/META-INF/maven/archetype-metadata.xml@@ -0,0 +1,17 @@+<?xml version="1.0" encoding="UTF-8"?>+<archetype-descriptor name="archetype.plugin">+ <fileSets>+ <fileSet filtered="true" packaged="true">+ <directory>src/main/java</directory>+ </fileSet>+ <fileSet filtered="false" packaged="false">+ <directory>src/main/resources</directory>+ </fileSet>+ <fileSet filtered="false" packaged="false">+ <directory>src/test/java</directory>+ </fileSet>+ <fileSet filtered="false" packaged="false">+ <directory>src/test/resources</directory>+ </fileSet>+ </fileSets>+</archetype-descriptor>\ No newline at end of filediff --git a/commons.antlr/src/main/resources/archetype-resource/pom.xml b/commons.antlr/src/main/resources/archetype-resource/pom.xmlnew file mode 100644index 0000000000..b4f8a999c6--- /dev/null+++ b/commons.antlr/src/main/resources/archetype-resource/pom.xml@@ -0,0 +1,60 @@+<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/maven-v4_0_0.xsd">+ <modelVersion>4.0.0</modelVersion>+#if (\${groupId} != "com.pmease")+ <groupId>\${groupId}</groupId>+#end+ <artifactId>\${artifactId}</artifactId>+ <version>\${version}</version>+ <parent>+ <groupId>com.pmease</groupId>+ <artifactId>parent.general</artifactId>+ <version>1.0.31</version>+ </parent>++ <build>+ <plugins>+ <plugin>+ <groupId>com.pmease</groupId>+ <artifactId>plugin.maven</artifactId>+ </plugin>+ <plugin>+ <artifactId>maven-source-plugin</artifactId>+ </plugin>+ <plugin>+ <artifactId>maven-javadoc-plugin</artifactId>+ </plugin>+ </plugins>+ </build>++ <dependencies>+ <dependency>+ <groupId>${project.groupId}</groupId>+ <artifactId>${project.artifactId}</artifactId>+ <version>${project.version}</version>+ </dependency>+ </dependencies>++ <repositories>+ <repository>+ <id>pmeaseRepo</id>+ <name>PMEase Repository</name>+ <releases>+ <enabled>true</enabled>+ <updatePolicy>never</updatePolicy>+ <checksumPolicy>fail</checksumPolicy>+ </releases>+ <snapshots>+ <enabled>true</enabled>+ <updatePolicy>always</updatePolicy>+ <checksumPolicy>fail</checksumPolicy>+ </snapshots>+ <url>http://artifact.pmease.com/</url>+ </repository>+ </repositories>++ <properties>+ <moduleClass>\${package}.PluginModule</moduleClass>+ </properties>++</project>diff --git a/commons.antlr/src/main/resources/archetype-resource/src/main/java/PluginModule.java b/commons.antlr/src/main/resources/archetype-resource/src/main/java/PluginModule.javanew file mode 100644index 0000000000..2e302e6bcc--- /dev/null+++ b/commons.antlr/src/main/resources/archetype-resource/src/main/java/PluginModule.java@@ -0,0 +1,19 @@+package ${package};++import com.pmease.commons.loader.AbstractPlugin;+import com.pmease.commons.loader.AbstractPluginModule;++/**+ * NOTE: Do not forget to rename moduleClass property defined in the pom if you've renamed this class.+ *+ */+public class PluginModule extends AbstractPluginModule {++ @Override+ protected void configure() {+ super.configure();++ // put your guice bindings here+ }++}diff --git a/commons.lang/pom.xml b/commons.lang/pom.xmlindex 4dbcaa0d76..3750b4936e 100644--- a/commons.lang/pom.xml+++ b/commons.lang/pom.xml@@ -37,10 +37,6 @@<artifactId>commons.loader</artifactId><version>1.0.31</version></dependency>- <dependency>- <groupId>org.antlr</groupId>- <artifactId>antlr4-runtime</artifactId>- </dependency><dependency><groupId>org.webjars</groupId><artifactId>codemirror</artifactId>@@ -63,6 +59,11 @@<artifactId>commons.wicket</artifactId><version>1.0.29</version></dependency>+ <dependency>+ <groupId>com.pmease</groupId>+ <artifactId>commons.antlr</artifactId>+ <version>1.0.0</version>+ </dependency></dependencies><repositories>diff --git a/commons.wicket/pom.xml b/commons.wicket/pom.xmlindex 36ce0aff73..4dc665d9cb 100644--- a/commons.wicket/pom.xml+++ b/commons.wicket/pom.xml@@ -21,14 +21,6 @@<plugin><artifactId>maven-javadoc-plugin</artifactId></plugin>- <plugin>- <groupId>org.antlr</groupId>- <artifactId>antlr4-maven-plugin</artifactId>- <configuration>- <libDirectory></libDirectory>- <visitor>true</visitor>- </configuration>- </plugin></plugins></build><dependencies>@@ -130,8 +122,9 @@<version>1.0.0</version></dependency><dependency>- <groupId>org.antlr</groupId>- <artifactId>antlr4-runtime</artifactId>+ <groupId>com.pmease</groupId>+ <artifactId>commons.antlr</artifactId>+ <version>1.0.0</version></dependency></dependencies><properties>diff --git a/parent.general/pom.xml b/parent.general/pom.xmlindex bcf2c345bc..4a17fd592f 100644--- a/parent.general/pom.xml+++ b/parent.general/pom.xml@@ -241,7 +241,6 @@</executions><configuration><sourceDirectory>${basedir}/src/main/java</sourceDirectory>- <libDirectory>${basedir}/src/main/java</libDirectory></configuration></plugin><plugin>