This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jxr.git


The following commit(s) were added to refs/heads/master by this push:
     new 3a2e4bf  [JXR-175] Support Java 14 record as class type in cross 
reference
3a2e4bf is described below

commit 3a2e4bf5b6e5242981b1be000a052103dcffc475
Author: Markus Spann <[email protected]>
AuthorDate: Tue Aug 30 13:54:33 2022 +0200

    [JXR-175] Support Java 14 record as class type in cross reference
---
 .../org/apache/maven/jxr/pacman/ClassType.java     |  2 +-
 .../org/apache/maven/jxr/pacman/JavaFileImpl.java  |  8 ++++--
 .../apache/maven/jxr/pacman/JavaFileImplTest.java  | 11 ++++++++
 .../org/apache/maven/jxr/pacman/Java14Record.java  | 30 ++++++++++++++++++++++
 4 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ClassType.java 
b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ClassType.java
index 023332e..f0c1404 100644
--- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ClassType.java
+++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/ClassType.java
@@ -20,7 +20,7 @@ package org.apache.maven.jxr.pacman;
  */
 
 /**
- * Represents a Java class or interface.
+ * Represents a Java class, interface, enum or record.
  */
 public class ClassType
     extends BaseType
diff --git 
a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFileImpl.java 
b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFileImpl.java
index 74f2470..bd0840b 100644
--- a/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFileImpl.java
+++ b/maven-jxr/src/main/java/org/apache/maven/jxr/pacman/JavaFileImpl.java
@@ -27,6 +27,8 @@ import java.io.Reader;
 import java.io.StreamTokenizer;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * PacMan implementation of a JavaFile. This will parse out the file and
@@ -38,6 +40,9 @@ import java.nio.file.Path;
 public class JavaFileImpl
     extends JavaFile
 {
+
+    private final List<String> classTypes = Arrays.asList( "class", 
"interface", "enum", "record" );
+
     /**
      * Create a new JavaFileImpl that points to a given file...
      *
@@ -156,8 +161,7 @@ public class JavaFileImpl
 
             // Add the class or classes. There can be several classes in one 
file so
             // continue with the while loop to get them all.
-            if ( ( "class".equals( stok.sval ) || "interface".equals( 
stok.sval ) || "enum".equals( stok.sval ) )
-                    &&  stok.ttype != '"' )
+            if ( classTypes.contains( stok.sval ) &&  stok.ttype != '"' )
             {
                 stok.nextToken();
                 if ( stok.sval != null )
diff --git 
a/maven-jxr/src/test/java/org/apache/maven/jxr/pacman/JavaFileImplTest.java 
b/maven-jxr/src/test/java/org/apache/maven/jxr/pacman/JavaFileImplTest.java
index ca3f1eb..1764bda 100644
--- a/maven-jxr/src/test/java/org/apache/maven/jxr/pacman/JavaFileImplTest.java
+++ b/maven-jxr/src/test/java/org/apache/maven/jxr/pacman/JavaFileImplTest.java
@@ -56,4 +56,15 @@ public class JavaFileImplTest {
         assertEquals( "ClassWithMultiLineString", 
javaFile.getClassTypes().get(0).getName() );
         assertEquals( "[ImportType[name=java.lang.*]]", 
javaFile.getImportTypes().toString() );
     }
+
+    @Test
+    public void testJXR_175_java14Record() throws IOException
+    {
+        JavaFileImpl javaFile = new JavaFileImpl( Paths.get(
+                
"src/test/resources/jxr175/org/apache/maven/jxr/pacman/Java14Record.java" ),
+                "UTF-8" );
+        assertEquals( 1, javaFile.getClassTypes().size() );
+        assertEquals( "Java14Record", 
javaFile.getClassTypes().get(0).getName() );
+    }
+
 }
diff --git 
a/maven-jxr/src/test/resources/jxr175/org/apache/maven/jxr/pacman/Java14Record.java
 
b/maven-jxr/src/test/resources/jxr175/org/apache/maven/jxr/pacman/Java14Record.java
new file mode 100644
index 0000000..3c64d4a
--- /dev/null
+++ 
b/maven-jxr/src/test/resources/jxr175/org/apache/maven/jxr/pacman/Java14Record.java
@@ -0,0 +1,30 @@
+package org.apache.maven.jxr;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Test Java source of the test for JXR-175.
+ *
+ * @author Markus Spann
+ */
+public record Java14Record(
+    String aString,
+    int anInt) {
+}

Reply via email to