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
}
}
}
Please sign in to leave a comment.
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
Hi Karol, here is the result of the task :
I don't see any big error :/
I made it work by catching MissingMethodException. Thanks anyway.
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:
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:
or:
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.
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).