Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

/**
* Represents a Java class or interface.
* Represents a Java class, interface, enum or record.
*/
public class ClassType
extends BaseType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
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
Expand All @@ -38,6 +40,9 @@
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...
*
Expand Down Expand Up @@ -156,8 +161,7 @@ and packages that are imported with this (ex "test.*") will be

// 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 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,15 @@ public void testJXR_170_multiLineString() throws IOException
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() );
}

}
Original file line number Diff line number Diff line change
@@ -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) {
}