Home > Enterprise >  Why do I get an internal error and syntax highlighting turned off when I import javafx.scene.paint.C
Why do I get an internal error and syntax highlighting turned off when I import javafx.scene.paint.C

Time:01-22

Created a new TornadoFX project, changed the boilerplate in MainView.kt to this:

package com.example.demo.view

import javafx.scene.paint.Color
import tornadofx.*

class MainView : View("Hello TornadoFX") {
    override val root = hbox {
        label(title) {
            style {
                textFill = Color.BLUE
            }
        }
    }
}

I then immediately get this error that states that syntax highlighting is turned off due to an internal error. Clicking it reveals the following detail:

    java.lang.NoClassDefFoundError: javafx/scene/paint/Color
    at no.tornado.tornadofx.idea.annotator.ColorsKt.<clinit>(Colors.kt:157)
    at no.tornado.tornadofx.idea.annotator.CSSColorAnnotator.annotateFXColor(CSSColorAnnotator.kt:82)
    at no.tornado.tornadofx.idea.annotator.CSSColorAnnotator.handelProperty(CSSColorAnnotator.kt:72)
    at no.tornado.tornadofx.idea.annotator.CSSColorAnnotator.handelProperty$default(CSSColorAnnotator.kt:66)
    at no.tornado.tornadofx.idea.annotator.CSSColorAnnotator.annotate(CSSColorAnnotator.kt:55)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.runAnnotators(DefaultHighlightVisitor.java:131)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.visit(DefaultHighlightVisitor.java:108)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.runVisitors(GeneralHighlightingPass.java:344)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$collectHighlights$7(GeneralHighlightingPass.java:277)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:304)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$8(GeneralHighlightingPass.java:307)
    at org.jetbrains.kotlin.idea.highlighter.AbstractKotlinHighlightVisitor.analyze(AbstractKotlinHighlightVisitor.kt:51)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:307)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$8(GeneralHighlightingPass.java:307)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:93)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:307)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:274)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:222)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:97)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:57)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:379)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1086)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:371)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:589)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:664)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:620)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:588)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:370)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:346)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:173)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:182)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:344)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:181)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.ClassNotFoundException: javafx.scene.paint.Color PluginClassLoader(plugin=PluginDescriptor(name=TornadoFX, id=no.tornado.tornadofx.idea, descriptorPath=plugin.xml, path=~\AppData\Roaming\JetBrains\IdeaIC2022.3\plugins\tornadofx-idea-plugin, version=1.7.20.1, package=null, isBundled=false), packagePrefix=null, instanceId=152, state=active)
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:215)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 39 more

Commenting out the Color class import and the line of code that requires it immediately makes the error go away and syntax highlighting return.

Why is this error happening? How do I work with color in TornadoFX without it happening?

System info: Have the exact same issue on both Mac OS Ventura 13.1 M1 processor and Windows 11 AMD processor, both with 8 gigs of ram. Both computers run IntelliJ Idea Community Edition version 2022.3.1 with TornadoFX Plugin installed via IDE, and Azul JDK-FX 8.

CodePudding user response:

Someone rebuilt the TornadoFX plugin but admitted that they're not sure if the changes they made breaks something else, so I wasn't keen on that route. However, I discovered through experiments that syntax highlighting does NOT get turned off if the colors in the TornadoFX view are added indirectly through a custom class that imports JavaFX.scene.paint.color. IE: A non-TornadoFX class imports Color, and then that custom class is imported into the TornadoFX view.

I made an interface and uploaded it to Git Hub to make creating your own color class easier. Also seems to work if you just make your TornadoFX view use the interface I made.

So instead of

class CenterView : View("Center Pane")

I use

class CenterView : View("Center Pane"), ColorInterface 

And I have all the functionality of the JavaFX color, including color constants and their extensions like .darker(), .brighter() etc, without the internal error.

  • Related