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
22 changes: 7 additions & 15 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -52,15 +43,16 @@ jobs:
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Setup Java JDK
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v3
with:
java-version: '17.0.1+12'
java-version: '17'
distribution: 'temurin'
cache: maven

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -74,4 +66,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
24 changes: 16 additions & 8 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 17
uses: actions/setup-java@v2.3.1
with:
java-version: '17.0.1+12'
distribution: 'temurin'
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Checkout repository
uses: actions/checkout@v3

- name: Check w/o SNAPSHOT when "bump version"
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build with Maven
run: mvn -B package --file pom.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib/
tmp/
codavaj-*.jar
java8.properties
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ codavaj.cmd codavaj http://jumpi.sourceforge.net/javadoc/j2se tmp/jumpi/src

## Cooperate with Java Parser

| **parser** | **set javadoc to decompiled source** | **rename argument names as javadoc documented** | **code** |
|:-----------|:------------------------------------:|:-----------------------------------------------:|----------|
| [JavaParser](https://github.com/javaparser/javaparser) | | 🚫 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/Test02.java) |
| [rewrite](https://github.com/Netflix-Skunkworks/rewrite) | | 🚧 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/Test03.java) |
| [JDT](https://www.eclipse.org/jdt/) | | 🚫 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/Test04.java) |
| [spoon](https://github.com/INRIA/spoon) | | 🚫 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/Test05.java) |
| **parser** | **set javadoc to (decompiled) source** | **rename argument names as javadoc documented** | **code** | **output** |
|:-----------|:--------------------------------------:|:-----------------------------------------------:|------------------------------------------------------------------------------------------------------------|:--------------------------------:|
| [JavaParser](https://github.com/javaparser/javaparser) | | 🚫 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/commentator/JavaParserCommentator.java) | 👑 |
| [rewrite](https://github.com/Netflix-Skunkworks/rewrite) | jdk version problem? | 🚧 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/commentator/RewriteCommentator.java) | |
| [JDT](https://www.eclipse.org/jdt/) | | 🚫 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/commentator/JgtCommentator.java) | little bit worse than JavaParser |
| [spoon](https://github.com/INRIA/spoon) | | 🚫 | [📄](https://github.com/umjammer/codavaj/blob/master/src/test/java/commentator/SpoonCommentator.java) | formats are gone |

## known issues

* codavaj does not introduce default constructor's if they weren't found
in the javadoc. This leads to compile problems if there are subclasses
which use the class's default constructor through the implicit super().

* hekohtml ~1.19.22
* nekohtml ~1.19.22
* https://mvnrepository.com/artifact/net.sourceforge.nekohtml/nekohtml/1.9.22
* https://mvnrepository.com/artifact/xerces/xercesImpl/2.11.0
* but 1.19.22 doesn't work with this project currently
Expand Down
5 changes: 5 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
jdk:
- openjdk17
before_install:
- sdk install java 17.0.1-open
- sdk use java 17.0.1-open
82 changes: 75 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.codavaj</groupId>
<artifactId>codavaj</artifactId>
<version>1.4.5-SNAPSHOT</version>
<version>1.4.6</version>

<description>
TODO
Expand All @@ -23,11 +23,10 @@ TODO

<properties>
<!-- for netflix rewrite (default) -->
<java8.home>/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home</java8.home>
<java8.home>/Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home</java8.home>
</properties>

<profiles>

<profile>
<id>codavaj</id>
<activation>
Expand Down Expand Up @@ -159,6 +158,71 @@ TODO
</dependency>
</dependencies>
</profile>

<profile>
<id>comment</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>spoon</id>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<java classname="commentator.SpoonCommentator" fork="true">
<classpath>
<path refid="maven.compile.classpath"/>
<path refid="maven.test.classpath"/>
</classpath>
<jvmarg value="-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties" />
<jvmarg line="--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
<jvmarg line="--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED" />
<jvmarg line="--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED" />
<jvmarg line="--add-exports jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED" />
<jvmarg line="--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED" />
<arg value="${user.home}/src/java/jsapi/tmp/javadoc" /> <!-- javadocDir -->
<arg value="https://docs.oracle.com/javase/jp/8/docs/api/" /> <!-- externalLink -->
<arg value="${user.home}/src/java/jsapi/src/main/java" /> <!-- sourceDir -->
<arg value="${user.home}/src/java/jsapi/tmp/src" /> <!-- outputDir -->
<arg value="javax\.speech" /> <!-- packageFilter -->
</java>
</target>
</configuration>
</execution>
<execution>
<id>javaParser</id>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<java classname="commentator.JavaParserCommentator" fork="true">
<classpath>
<path refid="maven.compile.classpath"/>
<path refid="maven.test.classpath"/>
</classpath>
<jvmarg value="-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties" />
<arg value="${user.home}/src/java/jsapi/tmp/javadoc" /> <!-- javadocDir -->
<arg value="https://docs.oracle.com/javase/jp/8/docs/api/" /> <!-- externalLink -->
<arg value="${user.home}/src/java/jsapi/src/main/java" /> <!-- sourceDir -->
<arg value="${user.home}/src/java/jsapi/tmp/src" /> <!-- outputDir -->
<arg value="javax\.speech" /> <!-- packageFilter -->
</java>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

</profiles>

<build>
Expand Down Expand Up @@ -232,7 +296,7 @@ TODO
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.8.2</version>
<version>5.9.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -298,7 +362,7 @@ TODO
<dependency>
<groupId>com.github.umjammer</groupId>
<artifactId>vavi-commons</artifactId>
<version>1.1.6</version>
<version>1.1.8</version>
</dependency>

<dependency>
Expand All @@ -320,7 +384,7 @@ TODO
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-symbol-solver-core</artifactId>
<version>3.24.4</version>
<version>3.24.7</version>
<scope>test</scope>
</dependency>

Expand All @@ -334,6 +398,10 @@ TODO
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -353,7 +421,7 @@ TODO
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>10.1.1</version>
<version>10.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
9 changes: 9 additions & 0 deletions retrieve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
mv pom.xml pom.xml.orig
sed -e 's@java8.home.*java8.home@java8.home>'$JAVA_HOME'</java8.home@' pom.xml.orig > pom.xml || mv pom.xml.orig pom.xml
diff pom.xml.orig pom.xml
if [ $? -eq 0 ]; then # no diff
rm pom.xml.orig
fi
echo "java8.home=$JAVA_HOME" > java8.properties
25 changes: 10 additions & 15 deletions src/main/java/org/codavaj/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.codavaj;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;

Expand All @@ -25,6 +26,7 @@
import org.codavaj.process.wget.Wget;
import org.codavaj.type.TypeFactory;


/**
* The program entry point.
* <p>
Expand All @@ -46,13 +48,12 @@ public class Main {
* to external javadoc links. External links to Sun's JDK javadoc apis are
* automatically resolved ( i.e. http://java.sun.com/j2se/X/docs/api/ )
*
* @param javadocdir the javadoc tree root
* @param javadocdir the javadoc tree root
* @param externalLinks a list of 'http://..' strings representing external javadoc refs.
*
* @return a TypeFactory handle on the resulting api
* @throws ProcessException any problem.
*/
public static TypeFactory analyze( String javadocdir, List<String> externalLinks ) throws ProcessException {
public static TypeFactory analyze(String javadocdir, List<String> externalLinks) throws ProcessException {

DocParser dp = new DocParser();
dp.setJavadocDirName(javadocdir);
Expand All @@ -67,12 +68,12 @@ public static TypeFactory analyze( String javadocdir, List<String> externalLinks
* <p>
* command is "wget" or "codavaj".
* </p>
*
* @param args 0: command, 1: source url, 2: output dir, [3: encoding], [4: language]
*/
public static void main(String[] args) throws Exception {
if (args.length < 3) {
System.err.println("usage alternatives: \n\t" + usage_wget + "\n\t"
+ usage_parse);
System.err.println("usage alternatives: \n\t" + usage_wget + "\n\t" + usage_parse);

return;
}
Expand All @@ -85,21 +86,18 @@ public static void main(String[] args) throws Exception {
// "exec-maven-plugin" doesn't have "fork" option.
// usually, use a jvmarg like "-Dcodavaj.file.encoding=MS932"
System.setProperty("codavaj.file.encoding", args[3]);
logger.info("encoding: " + System.getProperty("codavaj.file.encoding"));
logger.info("encoding: " + System.getProperty("codavaj.file.encoding"));
}
if (args.length > 4) {
// reluctantly, cause "exec-maven-plugin" cannot pass system properties as jvm arguments.
// "exec-maven-plugin" doesn't have "fork" option.
// usually, use a jvmarg like "-Dcodavaj.language=JAPANESE"
System.setProperty("codavaj.language", args[4]);
logger.info("language: " + System.getProperty("codavaj.language"));
logger.info("language: " + System.getProperty("codavaj.language"));
}

// all subsequent arguments become external javadoc URL references
List<String> externalLinks = new ArrayList<>();
for( int i = 3; i < args.length; i++) {
externalLinks.add(args[i]);
}
List<String> externalLinks = new ArrayList<>(Arrays.asList(args).subList(3, args.length));

if ("wget".equals(cmd)) {
Wget wget = new Wget();
Expand All @@ -121,10 +119,7 @@ public static void main(String[] args) throws Exception {
sw.addProgressListener(System.err::println);
sw.process();
} else {
System.err.println("usage alternatives: \n\t" + usage_wget + "\n\t"
+ usage_parse);

return;
System.err.println("usage alternatives: \n\t" + usage_wget + "\n\t" + usage_parse);
}
}
}
4 changes: 4 additions & 0 deletions src/main/java/org/codavaj/MissingParameterException.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@

package org.codavaj;

import java.io.Serial;


/**
* DOCUMENT ME!
*/
public class MissingParameterException extends ProcessException {
@Serial
private static final long serialVersionUID = -7654967901729855056L;

/**
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/codavaj/ProcessException.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@

package org.codavaj;

import java.io.Serial;


/**
* DOCUMENT ME!
*/
public class ProcessException extends Exception {
@Serial
private static final long serialVersionUID = 2949538686794102085L;

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/codavaj/process/ProgressEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* DOCUMENT ME!
*/
public class ProgressEvent {

private int done;
private int todo;
private String message;
Expand Down
Loading