[Git][java-team/qdox2][upstream] Import Upstream version 2.0~M9

Markus Koschany gitlab at salsa.debian.org
Tue Oct 2 17:40:22 BST 2018


Markus Koschany pushed to branch upstream at Debian Java Maintainers / qdox2


Commits:
a0a80f05 by Markus Koschany at 2018-10-02T11:59:43Z
Import Upstream version 2.0~M9
- - - - -


8 changed files:

- pom.xml
- src/grammar/lexer.flex
- src/grammar/parser.y
- src/main/java/com/thoughtworks/qdox/builder/impl/ModelBuilder.java
- src/main/java/com/thoughtworks/qdox/parser/impl/BinaryClassParser.java
- src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java
- src/test/java/com/thoughtworks/qdox/parser/LexerTest.java
- src/test/java/com/thoughtworks/qdox/parser/ParserTest.java


Changes:

=====================================
pom.xml
=====================================
@@ -10,7 +10,7 @@
   <name>QDox</name>
   <groupId>com.thoughtworks.qdox</groupId>
   <artifactId>qdox</artifactId>
-  <version>2.0-M8</version>
+  <version>2.0-M9</version>
 
   <url>https://github.com/paul-hammant/qdox</url>
   <description>
@@ -36,7 +36,7 @@
     <connection>scm:git:https://github.com/paul-hammant/qdox.git</connection>
     <developerConnection>scm:git:ssh://git@github.com/paul-hammant/qdox.git</developerConnection>
     <url>https://github.com/paul-hammant/qdox</url>
-    <tag>qdox-2.0-M8</tag>
+    <tag>qdox-2.0-M9</tag>
   </scm>
 
   <developers>
@@ -360,7 +360,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.8.2</version>
+      <version>4.12</version>
       <scope>test</scope>
     </dependency>
     <dependency>


=====================================
src/grammar/lexer.flex
=====================================
@@ -227,6 +227,7 @@ JavadocEnd                      = "*"+ "/"
 }
 <NAME_OR_MODIFIER> {
     {Id} / {WhiteSpace}* "."  { popState(); pushState(NAME); return Parser.IDENTIFIER; }
+    {Id} / {WhiteSpace}* ";"  { popState(); return Parser.IDENTIFIER; }
     "static"                  { return Parser.STATIC; }
     "transitive"              { return Parser.TRANSITIVE; }
 }


=====================================
src/grammar/parser.y
=====================================
@@ -907,6 +907,7 @@ Primary: PrimaryNoNewArray
 //     MethodInvocation 
 //     MethodReference
 PrimaryNoNewArray: Literal 
+                 | MethodInvocation
                  | PrimitiveType Dims_opt DOT CLASS 
                    { 
                      $$ = new TypeRefDef(new TypeDef($1.getName(), $2));
@@ -924,7 +925,6 @@ PrimaryNoNewArray: Literal
                    {
                      $$ = new TypeRefDef(new TypeDef($1, $2));
                    } 
-                 | MethodInvocation
                  | MethodReference 
                  | QualifiedIdentifier 
                    { 
@@ -980,7 +980,11 @@ TypeArgumentsOrDiamond_opt:
 //     Primary . [TypeArguments] Identifier ( [ArgumentList] ) 
 //     super . [TypeArguments] Identifier ( [ArgumentList] ) 
 //     TypeName . super . [TypeArguments] Identifier ( [ArgumentList] )
-MethodInvocation: IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
+MethodInvocation: Primary DOT TypeParameters_opt IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
+                  {
+                    $$ = new MethodInvocationDef( $1 + "." + $4, null);
+                  }                
+                | IDENTIFIER PARENOPEN ArgumentList_opt PARENCLOSE
                   {
                     $$ = new MethodInvocationDef($1, null);
                   }


=====================================
src/main/java/com/thoughtworks/qdox/builder/impl/ModelBuilder.java
=====================================
@@ -499,7 +499,15 @@ public class ModelBuilder implements Builder {
         {
             return null;
         }
+        
         JavaClass declaringClass = getContext( genericDeclaration );
+        // can't select a declaring class based on the genericDeclaration
+        // likely method specifies its own genericDecleration
+        if ( declaringClass == null )
+        {
+            return null;
+        }
+        
         TypeResolver typeResolver = TypeResolver.byClassName( declaringClass.getBinaryName(), classLibrary, source.getImports() );
         
         DefaultJavaTypeVariable<G> result = new DefaultJavaTypeVariable<G>( typeVariableDef.getName(), typeResolver );


=====================================
src/main/java/com/thoughtworks/qdox/parser/impl/BinaryClassParser.java
=====================================
@@ -50,7 +50,10 @@ public class BinaryClassParser
     {
         try
         {
-            if(declaringClazz.getPackage() != null)
+            // Spec change in Java 9:
+            // "If this class represents an array type, a primitive type or void, this method returns null."
+            // This means that classes without package will get a package with empty name
+            if ( declaringClazz.getPackage() != null && !"".equals( declaringClazz.getPackage().getName() ) )
             {
                 binaryBuilder.addPackage( new PackageDef( declaringClazz.getPackage().getName() ) );
             }


=====================================
src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java
=====================================
@@ -1645,6 +1645,21 @@ public class JavaProjectBuilderTest extends TestCase
         assertTrue( classA.getImplements().equals( Arrays.asList( builder.getClassByName( "Itf2" ) ) ) );
     }
     
+    public void testGenericEnumMethod() throws Exception {
+        String source = "package java.time.temporal;\r\n" + 
+            "public final class IsoFields {\r\n" + 
+            "    private static enum Field implements TemporalField {\r\n" + 
+            "        DAY_OF_QUARTER {\r\n" + 
+            "            public <R extends Temporal> R adjustInto(R temporal, long newValue) {\r\n" + 
+            "                return null;\r\n" + 
+            "            }\r\n" + 
+            "        }\r\n" + 
+            "    }\r\n" + 
+            "}";
+        
+        builder.addSource( new StringReader( source ) );
+    }
+    
     public void testDeclarationSignatureWithGenerics() {
         String source = "import java.util.List;"
             + "public interface Test {"
@@ -1708,6 +1723,16 @@ public class JavaProjectBuilderTest extends TestCase
         builder.addSource( new StringReader( source ) );
     }
     
+    public void testSimpleModule()
+    {
+        String source = "module bar {\r\n" + 
+            "  requires foo.foo;\r\n" + 
+            "}";
+
+        builder.addSource( new StringReader( source ) );
+
+    }
+    
     public void testLineNumbers() {
         String source = "package foo.bar;\n" + 
                         "/** some javadoc */\n" + 


=====================================
src/test/java/com/thoughtworks/qdox/parser/LexerTest.java
=====================================
@@ -902,14 +902,18 @@ public class LexerTest extends TestCase {
                     throws Exception
     {
         String in = "open module module.module {\n" + 
+            "  requires requires;\n" + 
             "  requires requires.requires;\n" + 
             "  requires transitive transitive.transitive;\n" + 
             "  requires static requires.transitive;\n" + 
             "  requires transitive static requires.transitive;\n" + 
+            "  exports exports;\n" + 
             "  exports exports.exports;\n" + 
             "  exports to.to to to.to, to.to;\n" + 
+            "  opens opens;\n" + 
             "  opens opens.opens;\n" + 
             "  opens to.to to to.to, to.to;\n" + 
+            "  uses uses;\n" + 
             "  uses uses.uses;\n" + 
             "  provides with.with with with.with, with.with;\n" + 
             "}";
@@ -921,7 +925,11 @@ public class LexerTest extends TestCase {
         assertLex( Parser.DOT, lexer );
         assertLex( Parser.IDENTIFIER, "module", lexer );
         assertLex( Parser.BRACEOPEN, lexer );
-        
+
+        assertLex( Parser.REQUIRES, lexer );
+        assertLex( Parser.IDENTIFIER, "requires", lexer );
+        assertLex( Parser.SEMI, lexer );
+
         assertLex( Parser.REQUIRES, lexer );
         assertLex( Parser.IDENTIFIER, "requires", lexer );
         assertLex( Parser.DOT, lexer );
@@ -950,6 +958,10 @@ public class LexerTest extends TestCase {
         assertLex( Parser.IDENTIFIER, "transitive", lexer );
         assertLex( Parser.SEMI, lexer );
 
+        assertLex( Parser.EXPORTS, lexer );
+        assertLex( Parser.IDENTIFIER, "exports", lexer );
+        assertLex( Parser.SEMI, lexer );
+
         assertLex( Parser.EXPORTS, lexer );
         assertLex( Parser.IDENTIFIER, "exports", lexer );
         assertLex( Parser.DOT, lexer );
@@ -970,6 +982,10 @@ public class LexerTest extends TestCase {
         assertLex( Parser.IDENTIFIER, "to", lexer );
         assertLex( Parser.SEMI, lexer );
 
+        assertLex( Parser.OPENS, lexer );
+        assertLex( Parser.IDENTIFIER, "opens", lexer );
+        assertLex( Parser.SEMI, lexer );
+
         assertLex( Parser.OPENS, lexer );
         assertLex( Parser.IDENTIFIER, "opens", lexer );
         assertLex( Parser.DOT, lexer );
@@ -990,6 +1006,10 @@ public class LexerTest extends TestCase {
         assertLex( Parser.IDENTIFIER, "to", lexer );
         assertLex( Parser.SEMI, lexer );
 
+        assertLex( Parser.USES, lexer );
+        assertLex( Parser.IDENTIFIER, "uses", lexer );
+        assertLex( Parser.SEMI, lexer );
+
         assertLex( Parser.USES, lexer );
         assertLex( Parser.IDENTIFIER, "uses", lexer );
         assertLex( Parser.DOT, lexer );


=====================================
src/test/java/com/thoughtworks/qdox/parser/ParserTest.java
=====================================
@@ -3022,6 +3022,56 @@ public class ParserTest extends TestCase {
         verify( builder ).endField();
         verify( builder ).endClass();
     }
+    
+    public void testStringBasedEnum()
+        throws Exception
+    {
+        setupLex( Parser.PUBLIC );
+        setupLex( Parser.ENUM );
+        setupLex( Parser.IDENTIFIER, "StringBasedEnum" );
+
+        setupLex( Parser.BRACEOPEN );
+
+        setupLex( Parser.IDENTIFIER, "LIST" );
+        setupLex( Parser.PARENOPEN );
+        setupLex( Parser.IDENTIFIER, "List" );
+        setupLex( Parser.DOT );
+        setupLex( Parser.CLASS );
+        setupLex( Parser.DOT );
+        setupLex( Parser.IDENTIFIER, "getName" );
+        setupLex( Parser.PARENOPEN );
+        setupLex( Parser.PARENCLOSE );
+        setupLex( Parser.PARENCLOSE );
+        setupLex( Parser.SEMI );
+
+        setupLex( Parser.IDENTIFIER, "StringBasedEnum" );
+        setupLex( Parser.PARENOPEN );
+        setupLex( Parser.IDENTIFIER, "String" );
+        setupLex( Parser.IDENTIFIER, "className" );
+        setupLex( Parser.PARENCLOSE );
+        setupLex( Parser.CODEBLOCK, "}" );
+
+        setupLex( Parser.BRACECLOSE );
+        setupLex( 0 );
+
+        Parser parser = new Parser( lexer, builder );
+        parser.setDebugParser( true );
+        parser.parse();
+
+        ArgumentCaptor<ClassDef> classCaptor = ArgumentCaptor.forClass( ClassDef.class );
+        ArgumentCaptor<FieldDef> fieldCaptor = ArgumentCaptor.forClass( FieldDef.class );
+        ArgumentCaptor<ExpressionDef> argumentCaptor = ArgumentCaptor.forClass( ExpressionDef.class );
+        ArgumentCaptor<MethodDef> methodCaptor = ArgumentCaptor.forClass( MethodDef.class );
+
+        verify( builder ).beginClass( classCaptor.capture() );
+        verify( builder ).beginField( fieldCaptor.capture() );
+        verify( builder ).addArgument( argumentCaptor.capture() );
+        verify( builder ).endField();
+        verify( builder ).beginConstructor();
+        verify( builder ).addParameter( fieldCaptor.capture() );
+        verify( builder ).endConstructor( methodCaptor.capture() );
+        verify( builder ).endClass();
+    }
 
     private void setupLex(int token, String value) {
         lexValues.add( token );



View it on GitLab: https://salsa.debian.org/java-team/qdox2/commit/a0a80f05abd83bf4f420603690577a075633b607

-- 
View it on GitLab: https://salsa.debian.org/java-team/qdox2/commit/a0a80f05abd83bf4f420603690577a075633b607
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20181002/1093efdd/attachment.html>


More information about the pkg-java-commits mailing list