Why do I get an internal error and syntax highlighting turned off when I import javafx.scene.paint.Color to IntelliJ Idea? - kotlin

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.

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

"inferred type is FragmentManager? but FragmentManager was expected" error after moving to androidX

I just moved my project to androidX. I used android studio refactor->upgrade to androidX. TargetSDK was already 28 and was working fine. So was not expecting many errors. But I was wrong and getting many errors, most of them are about fragmentManager
inferred type is FragmentManager? but FragmentManager was expected
This is when I am calling show method of a custom bottomSheetDialogue in a fragment.
bottomDialog.newInstance(//options here
).show(fragmentManager, bottomDialog.TAG)
The method is annotated as Nullable. Change like this
fragmentManager?.let { manager ->
bottomDialog.newInstance(//options here
).show(manager, bottomDialog.TAG)
}
Make sure you import androidx.fragment.app.FragmentManager instead of a android.app.FragmentManager
I ended up using parentFrgamentManager and it solved the issue. I tried with supportFragmentManager but it wasn't recognised, so used parentFragmentManager. This is the code I used.
bottomDialog.newInstance(//options here
).show(parentFragmentManager, bottomDialog.TAG)

XAML UWP Windows Store : error CS0266/warning CS1697 when deploying solution

I've some warning/error when trying to "create App Packages" from a XAML UWP project.
Firstly a warning :
2017\Projects\MyProjectName\MyProjectName\obj\x86\Release\MyPageName.g.cs(1,1,1,194): warning CS1697: Different checksum values given for C:\Users\administrateur\Documents\Visual Studio 2017\Projects\MyProjectName\MyProjectName\MyPageName.xaml
It seem there is a problem with space (the second path is beginning after the last space -before "2017"-). I'm on Win 10.
Ive an cast error too :
1>C:\Users\administrateur\Documents\Visual Studio 2017\Projects\MyProjectName\MyProjectName\obj\x86\Release\MyPageName.g.cs(39,36,39,85): error CS0266: Cannot implicitly convert type 'Windows.UI.Xaml.Controls.Button' to 'MyProjectName.MyButtonReturn'. An explicit conversion exists (are you missing a cast?)
MyButtonReturn is a button coded in a class extending Button, the definition of "MyButtonReturn" is :
public sealed class MyButtonReturn : Button
{...
Any help ?
Thanks
Found the solution, cleaning the solution + building the project on release worked.

What is the right way to use ScalaTest's BeforeAndAfterAll trait with sbt and IntelliJ IDEA?

I'm attempting to set up a testing framework for Spark jobs. I'd like to use spark-testing-base's SharedSparkContext trait which relies on ScalaTest's BeforeAndAfterAll trait to manage setup and tear-down. Something about my current environment is causing the beforeAll and afterAll methods to be called around each test case.
(Even if I wanted to permit this redundant behavior, I couldn't: I don't know how to tear down my HiveContext object properly, so the second call to beforeAll throws an exception that bottoms out at "ERROR XSDB6: Another instance of Derby may have already booted the database /Users/applemacbookpro/git/my-project/metastore_db.")
I'm using IntelliJ IDEA with an SBT-managed build.
MacOS 10.11.4
IntelliJ IDEA 2016.1.3
not sure about SBT version, should be recent
ScalaTest 2.2.6
Per the README of spark-testing-base and this question, I've put
parallelExecution in Test := false
in build.sbt.
Here's my example:
import org.scalatest.{BeforeAndAfterAll, FlatSpec}
class ExampleSpec extends FlatSpec with BeforeAndAfterAll {
override def beforeAll(): Unit = {
println("in beforeAll")
super.beforeAll()
}
override def afterAll() {
println("in afterAll")
super.afterAll()
}
behavior of "example"
it should "succeed" in {
println("test 1")
}
it should "succeed again" in {
println("test2")
}
}
I trigger it by right-clicking in the editor window and running from the context menu; the output is:
/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java...
Testing started at 2:50 PM ...
in beforeAll
test 1
in afterAll
in beforeAll
test2
in afterAll
Process finished with exit code 0
I think it's and Intellij/Scalatest bug.
I can reproduce your case, when right-clicking in the "Editor" window.
But if you right click on your class in the "Project" window and then run from the context menu, it works as expected :
in beforeAll
test 1
test2
in afterAll
When right-clicking in the editor window, Intellij seems to instantiate 2 runners, one for each test method.
You can see in the "Run/Debug" window that ExampleSpec class appears several times instead of once.

Mockolate Verify Error: Illegal override.. after Flex SDK 4.10 update

Since we upgraded the flex sdk in our application to 4.10 we've been running into Verify Errors while running unit tests that use mockolate.
They seem to occur when mocking an interface where a ByteArray is used in a method signature.
Example interface:
public interface IFileSystemHelper {
function loadFileContents(path:String):ByteArray;
}
Example test class:
public class SomeTest {
[Rule]
public var mockolateRule:MockolateRule = new MockolateRule();
[Mock]
public var fileHelper:IFileSystemHelper;
public function SomeTest() {
}
[Test]
public function testMethod():void {
// ...
}
}
When compiling and running the test with flexmojos 6.0.1 the following error is thrown:
VerifyError: Error #1053: Illegal override of
IFileSystemHelper8F2B5D281827800A824B85B588C6F2A08AE814ED in
mockolate.generated.IFileSystemHelper8F2B5D281827800A824B85B588C6F2A08AE814ED
My initial suspicion was an sdk version problem with playerglobal (or airglobal in our case) so i recompiled mockolate (and flexunit) with sdk 4.10, without any result.
The only thing that seems to work is to remove the ByteArray type from the method signature... but that's not really an option :-) (and this has never been a problem before)
Is there anyone who has had a similar issue?
Thanks
This problem usually occurs when compiling different parts of your application with different versions of the sdk.
I would recommend to have a look at the output of "mvn dependency:tree" as this should output all dependencies (direct and transitive ones). Perhaps this will help you find where the wrong version is comming from.

How to grab a dependency and make it work with IntelliJ project?

I am trying to start a GroovyFX project within IntelliJ 12.
However, I have not been able to get IntelliJ to compile and run the following simple script (for reproducing the problem in the simplest manner possible):
#Grab(group='org.codehaus.groovyfx', module='groovyfx', version='0.3.1')
import groovyx.javafx.GroovyFX
println GroovyFX.class.name
I used IntelliJ's support for Grape's Grab to add groovyfx as a dependency of my module (the jar is shown under "External Libraries" and the editor does not complain that the class is missing after that!) but still, when I run the script, it throws an error:
Groovyc: unable to resolve class groovyx.javafx.GroovyFX
I was able to get this script working in the GroovyConsole without much problem and as expected....
I tried grabbing another randomly chosen dependency (turned out to be a Spring library) and it worked straight out:
#Grab(group='org.springframework', module='spring', version='2.5.6')
import org.springframework.jdbc.core.JdbcTemplate
println JdbcTemplate.class.name
I can see no good reason why the Spring library should work, but not the GroovyFX library!!!!
I even double checked that the GroovyFx library had been actually downloaded, and it is there where it should be (under {user.home}/.groovy/grapes/{group}/{module}/jars/)
What can cause this weird and extremely frustrating problem??
I tested your problem both with groovyConsole (from groovy-sdk-2.1.0) and with IntelliJ IDEA 12.0.3. The only exception I got was:
Caught: java.lang.NoClassDefFoundError: javafx/application/Application
java.lang.NoClassDefFoundError: javafx/application/Application
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
... 1 more
This was because the JavaFX runtime (jfxrt.jar) was not in the classpath. This can be fixed with
mvn com.zenjava:javafx-maven-plugin:1.3:fix-classpath
The command above is taken from the JavaFX Maven Plugin Wiki. You have to execute it only once. After that change both groovyConsole and IntelliJ are working. I had to restart the groovyConsole, this was not necessary for IntelliJ.
What is interesting is that I don't see the GroovyFx-jar under "External Libraries". I am using plain IDEA community edition without any plugins.
The Hello World from the GroovyFX homepage works out of the box in IDEA but not in the groovyConsole - I also get the "java.lang.ClassNotFoundException: groovyx.javafx.GroovyFX". I managed to let it run with the following code, but it is not a good solution, since it works only on the first run, then you have to restart the groovyConsole:
#GrabConfig(systemClassLoader=true, initContextClassLoader=true)
#Grab(group='org.codehaus.groovyfx', module='groovyfx', version='0.3.1')
import static groovyx.javafx.GroovyFX.start
start {
stage(title: 'GroovyFX Hello World', visible: true) {
scene(fill: BLACK, width: 500, height: 250) {
hbox(padding: 60) {
text(text: 'Groovy', font: '80pt sanserif') {
fill linearGradient(endX: 0, stops: [PALEGREEN, SEAGREEN])
}
text(text: 'FX', font: '80pt sanserif') {
fill linearGradient(endX: 0, stops: [CYAN, DODGERBLUE])
effect dropShadow(color: DODGERBLUE, radius: 25, spread: 0.25)
}
}
}
}
}
I am not sure but I think the reason is this bug here. Should be fixed in Groovy 2.2, we will see.