[BUG] Code assist broken for userutil sources using Java 14+ syntax
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- java
- Bereich
- developer-experience
Rechercherichtung
Start with com.mirth.connect.client.ui.reference.ReferenceListFactory#addUserutilReferences(String, InputStream) and identify the bundled JavaParser dependency and configured source level. Migrate its parsing and AST/visitor usage to the current com.github.javaparser API. Done means Java 17 syntax in a CLIENT userutil source is parsed and its class offers CTRL+space completions.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
The Java baseline for OIE is now Java 17, but the JavaParser library used to build code-assist references for the JavaScript editor is japa.parser JavaParser 1.0.8 (javaparser-1.0.8.jar), the legacy version that only understands an old Java grammar (no enhanced switch expressions, records, text blocks, etc.). When a CLIENT source library contains any class written with Java 14+ syntax, JavaParser fails to parse it at Administrator startup, the exception is caught and logged, and that class is dropped from the completion cache — so CTRL+space code assist is unavailable for it. Consistently reproducible.
To Reproduce
Setup: a custom extension/plugin that ships a *-userutil-sources.jar referenced in its metadata as a CLIENT library.
- In a userutil class, use any Java 14+ syntax (e.g. a switch expression):
/**
* Returns a human-readable label for the given priority code.
*
* @param code the single-character priority code
* @return the corresponding label
*/
public static String priorityLabel(final char code) {
// Java 14+ switch expression — not parseable by JavaParser 1.0.8.
return switch (code) {
case 'H' -> "High";
case 'M' -> "Medium";
case 'L' -> "Low";
default -> "Unknown";
};
}
- Package the sources into
myext-userutil-sources.jar. - Register it as a
CLIENTsource library in the extension metadata:
<library type="CLIENT" path="src/myext-userutil-sources.jar" />
- Start the Administrator (this is when userutil sources are parsed and the reference/completion cache is built).
- Open a transformer in the JavaScript editor and trigger code assist (CTRL+space) against the class.
Expected behavior
Since the project baseline is Java 17, the JavaParser used to build code-assist references should be able to parse Java 17 source, so the userutil class loads normally and CTRL+space offers completions for it.
Actual behavior
At Administrator startup, JavaParser.parse(is) in com.mirth.connect.client.ui.reference.ReferenceListFactory#addUserutilReferences(String, InputStream) throws a parse exception on the Java 14+ syntax. The catch (Exception e) swallows it and logs:
ERROR ... ReferenceListFactory - Unable to load references from userutil entry <package>/<Class>.java
japa.parser.ParseException: ...
The class is skipped, so no references are built and CTRL+space offers no completions for it — even though the same code compiles and runs fine under the Java 17 baseline.
Screenshots
N/A
Environment (please complete the following information):
- OS: Windows 11
- Java Distribution/Version: OpenJDK 17
- Connect Version: 4.5.2
Workaround(s)
Avoid Java 14+ syntax in any source that ends up in a CLIENT sources jar. For switch expressions, fall back to a classic switch statement:
public static String priorityLabel(final char code) {
switch (code) {
case 'H': return "High";
case 'M': return "Medium";
case 'L': return "Low";
default: return "Unknown";
}
}
The class still compiles and runs under Java 17; only the syntax exposed to JavaParser is downgraded. Note this is per-class: one offending class only drops its own references, not the whole jar.
Additional context
Root cause is a mismatch between the Java baseline (17) and the bundled JavaParser (japa.parser 1.0.8), which predates modern Java grammar by many language versions. The legacy japa.parser line is no longer maintained; the project moved to com.github.javaparser (3.x), which tracks current Java language levels. A fix would be to migrate ReferenceListFactory from japa.parser.* to a current com.github.javaparser:javaparser-core and keep it aligned with the configured source level. The API differs between the two (e.g. JavaParser.parse(InputStream) and the AST/visitor packages changed), so this is a small migration rather than a drop-in version bump.
I would be happy to work on this one if it has potential to me merged...
- Vorherrschende Sprache
- Java
- Sterne
- 227
- Forks
- 81
- Ø Merge
- 3 T. 6 Std.
- Gemergte PRs (30 T.)
- 15
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus OpenIntegrationEngine/engine
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
OpenIntegrationEngine/engine#485 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
OpenIntegrationEngine/engine#478 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
OpenIntegrationEngine/engine#355 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
OpenIntegrationEngine/engine#347 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
OpenIntegrationEngine/engine#313 ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in OpenIntegrationEngine/engine
Ähnliche Issues
-
[Bug] dubbo.protocol.triple.max-message-size is only read from OS environment variablesEvtl. vergeben @CCCLL hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
hierynomus/sshj#1070 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
intellij-elixir/intellij-elixir#4492 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
quarkiverse/quarkus-openapi-generator#1796 · 1 Kommentar ·