Haehnchen/idea-php-annotation-plugin

Error with PHPStorm 2023.1 EAP

ker0x opened this issue · 9 comments

ker0x commented

The plugin throw an error when opening my IDE (PHPStorm 2023.1 EAP)

Here is the stacktrace:

java.lang.NoSuchMethodError
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:564)
	at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:591)
	at java.base/java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:672)
	at com.intellij.concurrency.JobLauncherImpl.processQueue(JobLauncherImpl.java:360)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.processInOrder(InspectionRunner.java:300)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.visitElements(InspectionRunner.java:275)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$inspect$4(InspectionRunner.java:129)
	at com.intellij.codeInspection.InspectionEngine.withSession(InspectionEngine.java:227)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.inspect(InspectionRunner.java:114)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.collectInformationWithProgress(LocalInspectionsPass.java:115)
	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:381)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1095)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:373)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:372)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:348)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:223)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:184)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:346)
	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.NoSuchMethodError: 'boolean com.jetbrains.php.lang.documentation.phpdoc.PhpDocUtil.processTagElementsByName(com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment, java.lang.String, com.intellij.util.Processor)'
	at de.espend.idea.php.annotation.inspection.visitor.PhpDocTagWithUsePsiElementVisitor.visitElement(PhpDocTagWithUsePsiElementVisitor.java:35)
	at com.intellij.psi.impl.PsiElementBase.accept(PsiElementBase.java:273)
	at com.jetbrains.php.lang.psi.elements.impl.PhpPsiElementImpl.accept(PhpPsiElementImpl.java:76)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$9(InspectionRunner.java:324)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1095)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$10(InspectionRunner.java:332)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:223)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:184)
	at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$processInOrder$11(InspectionRunner.java:338)
	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$12(InspectionRunner.java:301)
	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$13(InspectionRunner.java:301)
	at com.intellij.concurrency.JobLauncherImpl$1MyProcessQueueTask.lambda$call$0(JobLauncherImpl.java:299)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.concurrency.JobLauncherImpl$1MyProcessQueueTask.call(JobLauncherImpl.java:284)
	at com.intellij.concurrency.JobLauncherImpl$1MyProcessQueueTask.call(JobLauncherImpl.java:272)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1428)
	... 5 more
shyim commented

Looks like Jetbrains readded that method in newest EAP + plugin

Looks like Jetbrains readded that method in newest EAP + plugin

I'm having the issue in 2023.1 EAP build 231.6471.15 --- which is the latest available version.

#4 was released today - it's good too go!
Never mind, it's happening again in 231.6890.13

shyim commented

I hacked it for me local by just copying the deleted function and adding it to the plugin.

Here the build file

PHP Annotations-8.3.0.zip

Index: src/main/java/de/espend/idea/php/annotation/inspection/visitor/PhpDocTagWithUsePsiElementVisitor.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/de/espend/idea/php/annotation/inspection/visitor/PhpDocTagWithUsePsiElementVisitor.java b/src/main/java/de/espend/idea/php/annotation/inspection/visitor/PhpDocTagWithUsePsiElementVisitor.java
--- a/src/main/java/de/espend/idea/php/annotation/inspection/visitor/PhpDocTagWithUsePsiElementVisitor.java	(revision 9df371e20a1fe4454d77199d29e4ffeb1a7c8db8)
+++ b/src/main/java/de/espend/idea/php/annotation/inspection/visitor/PhpDocTagWithUsePsiElementVisitor.java	(date 1676895255234)
@@ -3,8 +3,13 @@
 import com.intellij.codeInspection.ProblemsHolder;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiElementVisitor;
-import com.jetbrains.php.lang.documentation.phpdoc.PhpDocUtil;
+import com.intellij.psi.stubs.StubElement;
+import com.intellij.util.Processor;
+import com.intellij.util.containers.ContainerUtil;
 import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment;
+import com.jetbrains.php.lang.documentation.phpdoc.psi.impl.PhpDocCommentImpl;
+import com.jetbrains.php.lang.documentation.phpdoc.psi.stubs.PhpDocCommentStub;
+import com.jetbrains.php.lang.documentation.phpdoc.psi.stubs.PhpDocTagStub;
 import com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocTag;
 import de.espend.idea.php.annotation.inspection.AnnotationInspectionUtil;
 import de.espend.idea.php.annotation.util.AnnotationUtil;
@@ -13,6 +18,7 @@
 
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Iterator;
 
 public class PhpDocTagWithUsePsiElementVisitor extends PsiElementVisitor {
     @NotNull
@@ -32,7 +38,7 @@
             Collection<PhpDocTag> phpDocTags = new HashSet<>();
 
             // there os no "getAllTags", we can only search by name; so use same internal logic but without name
-            PhpDocUtil.processTagElementsByName((PhpDocComment) element, null, phpDocTag -> {
+            processTagElementsByNames((PhpDocComment) element, phpDocTag -> {
                 String name = phpDocTag.getName();
                 if (StringUtils.isNotBlank(name) && !AnnotationUtil.isBlockedAnnotationTag(name)) {
                     phpDocTags.add(phpDocTag);
@@ -58,4 +64,36 @@
     public interface DocWithUsePsiPsiElementVisitor {
         void visitElement(@NotNull PhpDocTag phpDocTag, @NotNull ProblemsHolder holder, @NotNull AnnotationInspectionUtil.LazyNamespaceImportResolver lazyNamespaceImportResolver);
     }
+
+    public static void processTagElementsByNames(@NotNull PhpDocComment comment, @NotNull Processor<? super PhpDocTag> processor, String... tagNames) {
+        PhpDocCommentStub stub = comment instanceof PhpDocCommentImpl ? (PhpDocCommentStub)((PhpDocCommentImpl)comment).getGreenStub() : null;
+        if (stub != null) {
+            Iterator var4 = stub.getChildrenStubs().iterator();
+
+            while(var4.hasNext()) {
+                StubElement child = (StubElement)var4.next();
+                if (child instanceof PhpDocTagStub) {
+                    PhpDocTagStub tagStub = (PhpDocTagStub)child;
+                    String tagStubName = tagStub.getName();
+                    if (ContainerUtil.exists(tagNames, (tagName) -> {
+                        return tagName == null || tagName.equals(tagStubName);
+                    }) && !processor.process(tagStub.getPsi())) {
+                        return;
+                    }
+                }
+            }
+        } else {
+            for(PsiElement child = comment.getFirstChild(); child != null; child = child.getNextSibling()) {
+                if (child instanceof PhpDocTag) {
+                    String name = ((PhpDocTag)child).getName();
+                    if (ContainerUtil.exists(tagNames, (tagName) -> {
+                        return tagName == null || tagName.equals(name);
+                    }) && !processor.process((PhpDocTag)child)) {
+                        return;
+                    }
+                }
+            }
+        }
+
+    }
 }
\ No newline at end of file

@shyim Why not make a PR?

shyim commented

It's not a solution, it an hack. I just copied decompiled methods from old version back 🤣

I am working with that patch for some hours and it makes less errors now :) ty

EAP 5 might fixed this issue. I haven't seen it popup since I installed it yesterday afternoon. But makes me wonder if there should be a change made, since it seems like it that functionality could be phased out at a later time?

PhpStorm 2023.1 will work here. fyi: the method was added again with a deprecation hint. Cleaning the deprecation is a running task then and also depends when dropping old releases.

image