lte2000 / intellibot

IntelliJ/PyCharm plugin for Robot Automation Framework
https://github.com/lte2000/intellibot
MIT License
91 stars 26 forks source link

Intellibot 0.14.191.8026 ArrayIndexOutOfBoundsException #54

Open orthur opened 1 year ago

orthur commented 1 year ago

Project has many python keywords. I am not able to find exact reason for that exception yet.

java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at com.millennialmedia.intellibot.psi.util.PythonParser.keywordNameFromDecorator(PythonParser.java:64)
    at com.millennialmedia.intellibot.psi.util.PythonParser.keywordName(PythonParser.java:36)
    at com.millennialmedia.intellibot.psi.ref.RobotPythonWrapper$2.process(RobotPythonWrapper.java:46)
    at com.millennialmedia.intellibot.psi.ref.RobotPythonWrapper$2.process(RobotPythonWrapper.java:42)
    at com.intellij.util.containers.ContainerUtil.process(ContainerUtil.java:722)
    at com.jetbrains.python.psi.impl.PyClassImpl.visitMethods(PyClassImpl.java:985)
    at com.millennialmedia.intellibot.psi.ref.RobotPythonWrapper.addDefinedKeywords(RobotPythonWrapper.java:41)
    at com.millennialmedia.intellibot.psi.ref.RobotPythonClass.getDefinedKeywords(RobotPythonClass.java:39)
    at com.millennialmedia.intellibot.psi.ref.ResolverUtils.resolveKeywordFromFile(ResolverUtils.java:67)
    at com.millennialmedia.intellibot.psi.ref.RobotArgumentReference.resolveKeyword(RobotArgumentReference.java:59)
    at com.millennialmedia.intellibot.psi.ref.RobotArgumentReference.resolve(RobotArgumentReference.java:41)
    at com.millennialmedia.intellibot.psi.element.HeadingImpl.addReferencedArguments(HeadingImpl.java:253)
    at com.millennialmedia.intellibot.psi.element.HeadingImpl.collectReferencedFiles(HeadingImpl.java:235)
    at com.millennialmedia.intellibot.psi.element.HeadingImpl.getFilesFromInvokedKeywordsAndVariables(HeadingImpl.java:217)
    at com.millennialmedia.intellibot.psi.element.RobotFileImpl.getFilesFromInvokedKeywordsAndVariables(RobotFileImpl.java:121)
    at com.millennialmedia.intellibot.ide.inspections.cleanup.RobotImportNotUsed.skip(RobotImportNotUsed.java:63)
    at com.millennialmedia.intellibot.ide.inspections.SimpleInspectionVisitor.visitElement(SimpleInspectionVisitor.java:23)
    at com.intellij.psi.impl.PsiElementBase.accept(PsiElementBase.java:273)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$10(InspectionRunner.java:317)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1154)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$11(InspectionRunner.java:325)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:174)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:215)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$12(InspectionRunner.java:331)
    at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:159)
    at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:151)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$13(InspectionRunner.java:294)
    at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:130)
    at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:119)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$14(InspectionRunner.java:294)
    at com.intellij.concurrency.JobLauncherImpl$1MyProcessQueueTask.lambda$call$0(JobLauncherImpl.java:297)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:608)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:683)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:639)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:607)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
    at com.intellij.concurrency.JobLauncherImpl$1MyProcessQueueTask.call(JobLauncherImpl.java:282)
    at com.intellij.concurrency.JobLauncherImpl$1MyProcessQueueTask.call(JobLauncherImpl.java:270)
    at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1428)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
    at java.base/java.util.concurrent.ForkJoinPool.helpJoin(ForkJoinPool.java:1883)
    at java.base/java.util.concurrent.ForkJoinTask.awaitDone(ForkJoinTask.java:440)
    at java.base/java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:670)
    at com.intellij.concurrency.JobLauncherImpl.processQueue(JobLauncherImpl.java:357)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.processInOrder(InspectionRunner.java:293)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.visitElements(InspectionRunner.java:268)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$inspect$5(InspectionRunner.java:130)
    at com.intellij.codeInspection.InspectionEngine.withSession(InspectionEngine.java:226)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.inspect(InspectionRunner.java:109)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.collectInformationWithProgress(LocalInspectionsPass.java:131)
    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:400)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1154)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:393)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:608)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:683)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:639)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:607)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:392)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:368)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:174)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:215)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:366)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:184)
    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)
lte2000 commented 1 year ago

Do your python keywords has decorator @keyword, and the code like below:

class test_class:
    @keyword()
    def test_keyword():

if so, can you change the code to:

class test_class:
    @keyword
    def test_keyword():

or something like:

class test_class:
    @keyword("custom keyword name")
    def test_keyword():

I find the decorator has parentheses but without actual argument, i.e., "@keyword()" may cause above exception. If you confirm after you adjust your code there is no such exception, I can build a patch for you.

lte2000 commented 1 year ago

@orthur please try the attached patch v0.14.191.8026.1: intellibot.zip

orthur commented 1 year ago

Do your python keywords has decorator @Keyword, and the code like below:

class test_class:
    @keyword()
    def test_keyword():

if so, can you change the code to:

class test_class:
    @keyword
    def test_keyword():

or something like:

class test_class:
    @keyword("custom keyword name")
    def test_keyword():

I find the decorator has parentheses but without actual argument, i.e., "@Keyword()" may cause above exception. If you confirm after you adjust your code there is no such exception, I can build a patch for you.

I have hundreds of keywords, I cant change them all, but I try to reproduce in new small project

orthur commented 1 year ago

@orthur please try the attached patch v0.14.191.8026.1: intellibot.zip

can't install it, error

Screenshot 2022-09-19 at 11 26 23
lte2000 commented 1 year ago

@orthur please try the attached patch v0.14.191.8026.1: intellibot.zip

can't install it, error

Screenshot 2022-09-19 at 11 26 23

Do you extract the zip file, and use pycharm "Install Plugin from Disk..." ?

orthur commented 1 year ago

Do you extract the zip file, and use pycharm "Install Plugin from Disk..." ?

my bad, I did not extract the zip file. now installed fine. I will update you here if encounter exceptions

orthur commented 1 year ago

I have not encountered that exception anymore

lte2000 commented 1 year ago

I have not encountered that exception anymore

Thanks for the feedback. I will merge the fix to main branch later.