Different behavior between runIde instance and vanilla instance of IDE

Answered

Hello everyone,
I have a different behavior between two instances of the IDE.
With the instances lauched by the runIde gradle task, i don't have any error, but when i lauch the IDE from the jet brain toolbox i have an error on a specific action.
I compared everything i though about, the ide build is the same, but i still get an error.
I'm confused. Do you guys have an idea or a lead to follow ?

And here is the error thrown by my plugin :

Unhandled exception in [StandaloneCoroutine{Cancelling}@5592aa57, EDT]

groovy.lang.MissingMethodException: No signature of method: com.intellij.psi.impl.source.PsiPlainTextFileImpl.getLocalName() is applicable for argument types: () values: []
Possible solutions: getName()
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)
    at com.intellij.psi.xml.XmlTag$getLocalName$8.call(Unknown Source)
    at fr.nereide.documentation.OfbizCommonDocumentationProvider.getQuickNavigateDocForElement(OfbizCommonDocumentationProvider.groovy:68)
    at fr.nereide.documentation.OfbizCommonDocumentationProvider$getQuickNavigateDocForElement$1.callStatic(Unknown Source)
    at fr.nereide.documentation.OfbizCommonDocumentationProvider.getQuickNavigateInfo(OfbizCommonDocumentationProvider.groovy:42)
    at fr.nereide.documentation.OfbizCommonDocumentationProvider$getQuickNavigateInfo.callCurrent(Unknown Source)
    at fr.nereide.documentation.OfbizXmlDocumentationProvider.getQuickNavigateInfo(OfbizXmlDocumentationProvider.groovy:35)
    at com.intellij.lang.documentation.CompositeDocumentationProvider.getQuickNavigateInfo(CompositeDocumentationProvider.java:111)
    at com.intellij.codeInsight.navigation.SingleTargetElementInfo.generateInfo(SingleTargetElementInfo.java:66)
    at com.intellij.lang.documentation.psi.PsiElementDocumentationTarget.computeDocumentationHint(PsiElementDocumentationTarget.kt:70)
    at com.intellij.codeInsight.navigation.CtrlMouseDataKt.targetCtrlMouseData(CtrlMouseData.kt:87)
    at com.intellij.codeInsight.navigation.CtrlMouseDataKt.symbolCtrlMouseData(CtrlMouseData.kt:56)
    at com.intellij.codeInsight.navigation.impl.CtrlMouseKt.ctrlMouseData(ctrlMouse.kt:40)
    at com.intellij.codeInsight.navigation.impl.TargetGTDActionData.ctrlMouseData(gtd.kt:62)
    at com.intellij.codeInsight.navigation.impl.GtduKt$toGTDUActionData$1.ctrlMouseData(gtdu.kt:75)
    at com.intellij.codeInsight.navigation.actions.GotoDeclarationOrUsageHandler2.getCtrlMouseData(GotoDeclarationOrUsageHandler2.kt:43)
    at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.getCtrlMouseData(GotoDeclarationAction.java:96)
    at com.intellij.codeInsight.navigation.CtrlMouseHandler2$computeInReadAction$1.invoke(CtrlMouseHandler.kt:235)
    at com.intellij.codeInsight.navigation.CtrlMouseHandler2$computeInReadAction$1.invoke(CtrlMouseHandler.kt:77)
    at com.intellij.lang.documentation.ide.impl.DocumentationTargetHoverInfoKt.injectedThenHost(DocumentationTargetHoverInfo.kt:76)
    at com.intellij.codeInsight.navigation.CtrlMouseHandler2.computeInReadAction(CtrlMouseHandler.kt:234)
    at com.intellij.codeInsight.navigation.CtrlMouseHandler2.access$computeInReadAction(CtrlMouseHandler.kt:77)
    at com.intellij.codeInsight.navigation.CtrlMouseHandler2$compute$2$1.invoke(CtrlMouseHandler.kt:222)
    at com.intellij.codeInsight.navigation.CtrlMouseHandler2$compute$2$1.invoke(CtrlMouseHandler.kt:77)
    at com.intellij.openapi.application.rw.InternalReadAction.insideReadAction(InternalReadAction.kt:96)
    at com.intellij.openapi.application.rw.InternalReadAction.access$insideReadAction(InternalReadAction.kt:13)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$1.invoke(InternalReadAction.kt:81)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$1.invoke(InternalReadAction.kt:13)
    at com.intellij.openapi.progress.CancellationKt$sam$com_intellij_openapi_util_ThrowableComputable$0.compute(cancellation.kt)
    at com.intellij.openapi.progress.Cancellation.withJob(Cancellation.java:60)
    at com.intellij.openapi.progress.CancellationKt.withJob(cancellation.kt:14)
    at com.intellij.openapi.progress.CancellationKt.executeWithJobAndCompleteIt(cancellation.kt:111)
    at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$2$1.run(cancellableReadAction.kt:33)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1154)
    at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$2.run(cancellableReadAction.kt:31)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:158)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal(cancellableReadAction.kt:29)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadCancellable(InternalReadAction.kt:80)
    at com.intellij.openapi.application.rw.InternalReadAction.access$tryReadCancellable(InternalReadAction.kt:13)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadAction$2.invoke(InternalReadAction.kt:66)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadAction$2.invoke(InternalReadAction.kt:13)
    at com.intellij.openapi.progress.CancellationKt$sam$com_intellij_openapi_util_ThrowableComputable$0.compute(cancellation.kt)
    at com.intellij.openapi.progress.Cancellation.withJob(Cancellation.java:60)
    at com.intellij.openapi.progress.CancellationKt.withJob(cancellation.kt:14)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:138)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadAction(InternalReadAction.kt:61)
    at com.intellij.openapi.application.rw.InternalReadAction.readLoop(InternalReadAction.kt:53)
    at com.intellij.openapi.application.rw.InternalReadAction.access$readLoop(InternalReadAction.kt:13)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$4.invokeSuspend(InternalReadAction.kt:33)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$4.invoke(InternalReadAction.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
    at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
    at com.intellij.openapi.application.rw.InternalReadAction.runReadAction(InternalReadAction.kt:32)
    at com.intellij.openapi.application.rw.PlatformReadActionSupport.executeReadAction(PlatformReadActionSupport.kt:24)
    at com.intellij.openapi.application.CoroutinesKt.constrainedReadAction(coroutines.kt:47)
    at com.intellij.codeInsight.navigation.CtrlMouseHandler2$compute$2.invokeSuspend(CtrlMouseHandler.kt:221)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

It happens on navigation.

And the code where it is thrown : 

class OfbizCommonDocumentationProvider extends AbstractDocumentationProvider {

    static String getQuickNavigateInfo(PsiElement element, String elementName) {
        if (!element || !element instanceof XmlTag) return null
        ProjectServiceInterface structureService = element.getProject().getService(ProjectServiceInterface.class)
        return getTag(element) ? getQuickNavigateDocForElement(getTag(element), structureService, elementName) : null
    }

    static String generateDoc(PsiElement element, String elementName) {
        if (!element instanceof XmlTag) return null
        ProjectServiceInterface structureService = element.getProject().getService(ProjectServiceInterface.class)
        XmlTag tag = getTag(element)
        if (!elementName || !tag) return null
        switch (tag.getLocalName()) {
            case 'service':
                String serviceName = structureService.getService(elementName).getName().getValue()
                return serviceName ? generateServiceDoc(serviceName, structureService) : 'Service not found'
            case 'entity':
                String entityName = structureService.getEntity(elementName).getEntityName().getValue()
                return entityName ? generateEntityDoc(entityName, structureService) : 'Entity not found'
            case 'view-entity':
                String viewName = structureService.getViewEntity(elementName).getEntityName().getValue()
                return viewName ? generateViewDoc(viewName, structureService) : 'View not found'
            case 'property':
                String propertyName = structureService.getProperty(MiscUtils.getUiLabelSafeValue(elementName)).getKey().getValue()
                return propertyName ? generateUiLabelDoc(propertyName, structureService) : 'UiLabel not found'
            default: return null
        }
    }

    static String getQuickNavigateDocForElement(XmlTag tag, ProjectServiceInterface structureService, String elementName) {
        switch (tag.getLocalName()) {
            case 'entity':
                return generateEntityQuickNavigateDoc(structureService, elementName)
            case 'view-entity':
                return generateViewQuickNavigateDoc(structureService, elementName)
            case 'service':
                return generateServiceQuickNavigateDoc(structureService, elementName)
            case 'property':
                return generatePropertyQuickNavigateDoc(MiscUtils.getUiLabelSafeValue(elementName), structureService)
            default: return null
        }
    }

}

 

0
5 comments

Hi Gaëtan,

It sounds like you have different plugins set in IDE run by runIde and installed from the Toolbox app. I suggest running the Plugin Verifier to check for compatibility issues:
https://plugins.jetbrains.com/docs/intellij/verifying-plugin-compatibility.html#plugin-verifier

0

Hi Karol, here is the result of the task :

17:24:01: Executing 'runPluginVerifier'...

> Task :setupDependencies
> Task :patchPluginXml
> Task :generateUpdatePluginXml UP-TO-DATE

> Task :verifyPluginConfiguration
[gradle-intellij-plugin :OfbizIdeaPlugin:verifyPluginConfiguration] The following plugin configuration issues were found:
- The 'since-build' property is lower than the target IntelliJ Platform major version: 220.* < 222.
- The Java configuration specifies sourceCompatibility=11 but IntelliJ Platform 2022.2.3 requires sourceCompatibility=17.
See: https://jb.gg/intellij-platform-versions

> Task :compileJava NO-SOURCE
> Task :compileGroovy
> Task :processResources
> Task :classes
> Task :setupInstrumentCode
> Task :instrumentCode
> Task :postInstrumentCode
> Task :jar
> Task :prepareSandbox
> Task :jarSearchableOptions SKIPPED
> Task :compileTestJava NO-SOURCE
> Task :compileTestGroovy
> Task :processTestResources
> Task :testClasses
> Task :instrumentTestCode
> Task :postInstrumentTestCode
> Task :prepareTestingSandbox

> Task :test
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.ref.DebugReflectionUtil (file:/home/gaetan/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2022.2.3/2af6809be127f13b2a50a13e1987a8051feeed1a/ideaIC-2022.2.3/lib/app.jar) to field java.lang.ref.ReferenceQueue.NULL
WARNING: Please consider reporting this to the maintainers of com.intellij.util.ref.DebugReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

> Task :classpathIndexCleanup
> Task :buildPlugin

> Task :listProductsReleases
IC-2022.2.4
IC-2022.1.4
> Task :verifyPlugin
[gradle-intellij-plugin :OfbizIdeaPlugin:verifyPlugin] Plugin name specified in plugin.xml should not contain the word 'IDEA'

> Task :runPluginVerifier
Starting the IntelliJ Plugin Verifier 1.288
Verification reports directory: /home/gaetan/Workspace/Plugin/intellij-plugin-v2/build/reports/pluginVerifier
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by retrofit2.Platform (file:/home/gaetan/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.plugins/verifier-cli/1.288/6817edd5260be2ae5fd6c8933c72eaab2bd90fbc/verifier-cli-1.288-all.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of retrofit2.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2022-11-07T17:25:12 [main] INFO  verification - Reading IDE /home/gaetan/.pluginVerifier/ides/IC-2022.2.4
2022-11-07T17:25:12 [main] INFO  c.j.p.options.OptionsParser - Reading IDE from /home/gaetan/.pluginVerifier/ides/IC-2022.2.4
2022-11-07T17:25:18 [main] INFO  verification - Reading IDE /home/gaetan/.pluginVerifier/ides/IC-2022.1.4
2022-11-07T17:25:18 [main] INFO  c.j.p.options.OptionsParser - Reading IDE from /home/gaetan/.pluginVerifier/ides/IC-2022.1.4
2022-11-07T17:25:24 [main] INFO  verification - Reading plugin to check from /home/gaetan/Workspace/Plugin/intellij-plugin-v2/build/distributions/OfbizIdeaPlugin-1.4.0.zip
2022-11-07T17:25:27 [main] INFO  verification - Task check-plugin parameters:
Scheduled verifications (2):
org.apache.ofbiz.OFBizIDEAInteg:1.4.0 against IC-222.4459.4, org.apache.ofbiz.OFBizIDEAInteg:1.4.0 against IC-221.6008.13

2022-11-07T17:25:30 [main] INFO  verification - Finished 1 of 2 verifications (in 2,7 s): IC-222.4459.4 against org.apache.ofbiz.OFBizIDEAInteg:1.4.0: Compatible
2022-11-07T17:25:30 [main] INFO  verification - Finished 2 of 2 verifications (in 2,7 s): IC-221.6008.13 against org.apache.ofbiz.OFBizIDEAInteg:1.4.0: Compatible
Plugin org.apache.ofbiz.OFBizIDEAInteg:1.4.0 against IC-222.4459.4: Compatible
    Plugin can probably be enabled or disabled without IDE restart

Plugin org.apache.ofbiz.OFBizIDEAInteg:1.4.0 against IC-221.6008.13: Compatible
    Plugin can probably be enabled or disabled without IDE restart

2022-11-07T17:25:30 [main] INFO  verification - Total time spent downloading plugins and their dependencies: 0 ms
2022-11-07T17:25:30 [main] INFO  verification - Total amount of plugins and dependencies downloaded: 0 B
2022-11-07T17:25:30 [main] INFO  verification - Total amount of space used for plugins and dependencies: 0 B

BUILD SUCCESSFUL in 1m 28s
21 actionable tasks: 21 executed
17:25:30: Execution finished 'runPluginVerifier'.

I don't see any big error :/

0

I made it work by catching MissingMethodException. Thanks anyway.

0

Hi,

Sorry for the delay. You should never catch exceptions like MissingMethodException, so it is not a proper solution.

Looking again at the exception, it suggests that getLocalName() was invoked on PsiPlainTextFileImpl.

I don't know Groovy, but your checking if the element is an instance of XmlTag seems suspicious:

!element instanceof XmlTag

Doesn't it convert the element to a boolean value and check if it is XmlTag (e.g. true instanceof XmlTag)? If yes, then it will never be evaluated as true and should rather go like this:

!(element instanceof XmlTag)

or:

element !instanceof XmlTag

If this is the case, personally, I would consider switching to a more type-safe language instead of Groovy (e.g., Kotlin) to avoid such issues in the future.

1

Hi Karol, no problem at all for the delay. 
Thanks for pointing the syntax, i think you are right, i don't need the try / catch anymore.

And thanks for the advice regarding language, but the whole plugin is built in Groovy, more by an ideologic choice (Groovy is completely libre and free, and developped by the Apache Software fundation, for an ERP of the Apache fundation).

0

Please sign in to leave a comment.