Exception when creating annotations
I'm getting a weird exception when my annotator creates an annotation. Here's the stack trace:
+java.lang.ClassCastException: java.util.ArrayList cannot be cast to [Ljava.lang.Object;
at com.intellij.util.SmartList.add(SmartList.java:61)
at com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl.createAnnotation(AnnotationHolderImpl.java:20)
at com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl.createInfoAnnotation(AnnotationHolderImpl.java:17)
at com.logical.loomy.intellij.lang.annotator.TemplateTagAnnotator.visitXmlTag(TemplateTagAnnotator.java:76)
at com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:21)
at com.logical.loomy.intellij.lang.annotator.TemplateTagAnnotator.annotate(TemplateTagAnnotator.java:58)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitElement(HighlightVisitorImpl.java:447)
at com.intellij.psi.XmlElementVisitor.visitXmlElement(XmlElementVisitor.java:22)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitXmlElement(HighlightVisitorImpl.java:344)
at com.intellij.psi.XmlElementVisitor.visitXmlTag(XmlElementVisitor.java:54)
at com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:21)
at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visit(HighlightVisitorImpl.java:372)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:136)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.access$600(GeneralHighlightingPass.java:76)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$1.run(GeneralHighlightingPass.java:6)
at com.intellij.codeInsight.daemon.impl.RefCountHolder.analyzeAndStoreReferences(RefCountHolder.java:66)
at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:87)
at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:11)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:50)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:12)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:286)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:1)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:75)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:5)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)+
Any idea what might be causing this ?
请先登录再写评论。
Hello Hugo,
Make sure the AnnotationHolder instance passed to your annotator doesn't
leak elsewhere. Don't cache it between calls, and you may also need to mark
your annotate() method as synchronized.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Marking the annotate method as synchronized seems to have worked.
Thanks.