izhangzhihao / intellij-rainbow-brackets

🌈Rainbow Brackets for IntelliJ based IDEs/Android Studio/HUAWEI DevEco Studio/Fleet
https://plugins.jetbrains.com/plugin/10080-rainbow-brackets
GNU General Public License v3.0
4.46k stars 214 forks source link

Class initialization must not depend on services(2024.2 Beta) #2756

Closed fburleigh closed 3 months ago

fburleigh commented 3 months ago

Have you checked the issues and discussions to ensure there are no duplicates?

Yes

Your programming languages

N/A

Free or paid?

Paid users

Expected Behavior

No exception. Thank you!

Current Behavior

On startup, the IDE shows an exception in the Rainbow plugin (free or paid):

`java.lang.Throwable: ոଙ <clinit> requests com.github.izhangzhihao.rainbow.brackets.settings.RainbowSettings instance. Class initialization must not depend on services. Consider using instance of the service on-demand instead.
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
at com.intellij.serviceContainer.ComponentManagerImplKt.checkOutsideClassInitializer(ComponentManagerImpl.kt:1577)

`

Code snippet for reproduce

N/A

Your Environment

IntelliJ IDEA 2024.2 Beta (Ultimate Edition) Build #IU-242.20224.91, built on July 18, 2024 Licensed to IntelliJ IDEA EAP user: Frank Burleigh Expiration date: August 17, 2024 Runtime version: 21.0.3+13-b509.4 aarch64 (JCEF 122.1.9) VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Toolkit: sun.lwawt.macosx.LWCToolkit macOS 14.5 Kotlin plugin: K2 mode (Beta) GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation Memory: 4096M Cores: 10 Metal Rendering is ON Registry: ide.balloon.shadow.size=0 debugger.new.tool.window.layout=true ide.new.editor.tabs.vertical.borders=true ide.animate.toolwindows=true ide.experimental.ui=true ide.editor.tab.selection.animation=true Non-Bundled Plugins: com.jetbrains.space (242.20224.22) com.intellij.ml.llm (242.20224.99) net.seesharpsoft.intellij.plugins.csv (2.21.0) org.jetbrains.plugins.gitlab (242.20224.99) org.jetbrains.plugins.github (242.20224.99) com.intellij.bigdatatools.core (242.20224.91) com.intellij.bigdatatools.binary.files (242.20224.23) com.intellij.bigdatatools.rfs (242.20224.91) com.dmarcotte.handlebars (242.20224.22) com.jetbrains.php (242.20224.112) izhangzhihao.rainbow.brackets (2024.2.5-241) com.chrisrm.idea.MaterialThemeUI (9.4.1) com.mallowigi (97.0.0) Kotlin: 242.20224.91-IJ

ilanKeshet commented 3 months ago

@izhangzhihao Same issue reproduces with Rainbow brackets lite 1.1.0 - IntelliJ IDEA 2024.2 (Ultimate Edition) image

java.lang.Throwable: com.github.izhangzhihao.rainbow.brackets.lite.BracePairs <clinit> requests com.intellij.codeInsight.highlighting.FileTypeBraceMatcher instance. Class initialization must not depend on services. Consider using instance of the service on-demand instead.
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
    at com.intellij.serviceContainer.ComponentManagerImplKt.checkOutsideClassInitializer(ComponentManagerImpl.kt:1588)
    at com.intellij.serviceContainer.ComponentManagerImplKt.getOrCreateInstanceBlocking(ComponentManagerImpl.kt:1557)
    at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:746)
    at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:690)
    at com.intellij.codeInsight.highlighting.FileTypeBraceMatcher.getInstance(FileTypeBraceMatcher.java:11)
    at com.intellij.codeInsight.highlighting.BraceMatchingUtil.getBraceMatcherByFileType(BraceMatchingUtil.java:470)
    at com.intellij.codeInsight.highlighting.BraceMatchingUtil.getBraceMatcher(BraceMatchingUtil.java:444)
    at com.github.izhangzhihao.rainbow.brackets.lite.BracePairs.<clinit>(BracePairs.kt:24)
    at com.github.izhangzhihao.rainbow.brackets.lite.visitor.DefaultRainbowVisitor$Companion.filterPairs(DefaultRainbowVisitor.kt:179)
    at com.github.izhangzhihao.rainbow.brackets.lite.visitor.DefaultRainbowVisitor$Companion.access$filterPairs(DefaultRainbowVisitor.kt:41)
    at com.github.izhangzhihao.rainbow.brackets.lite.visitor.DefaultRainbowVisitor.visit(DefaultRainbowVisitor.kt:20)
    at com.intellij.codeInsight.daemon.impl.HighlightVisitorRunner.runVisitor(HighlightVisitorRunner.java:194)
    at com.intellij.codeInsight.daemon.impl.HighlightVisitorRunner.lambda$runVisitors$3(HighlightVisitorRunner.java:122)
    at com.github.izhangzhihao.rainbow.brackets.lite.visitor.RainbowHighlightVisitor.analyze(RainbowHighlightVisitor.kt:34)
    at com.intellij.codeInsight.daemon.impl.HighlightVisitorRunner.lambda$runVisitors$4(HighlightVisitorRunner.java:120)
    at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:139)
    at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:152)
    at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:152)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.tryRunReadAction(AnyThreadWriteThreadingSupport.kt:279)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:965)
    at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$1(ApplierCompleter.java:96)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
    at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:108)
    at com.intellij.concurrency.ApplierCompleter.lambda$compute$0(ApplierCompleter.java:86)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.executeByImpatientReader(AnyThreadWriteThreadingSupport.kt:486)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:179)
    at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:86)
    at com.intellij.concurrency.JobLauncherImpl.invokeConcurrentlyUnderProgress(JobLauncherImpl.java:66)
    at com.intellij.concurrency.JobLauncher.invokeConcurrentlyUnderProgress(JobLauncher.java:52)
    at com.intellij.codeInsight.daemon.impl.HighlightVisitorRunner.runVisitors(HighlightVisitorRunner.java:112)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$collectHighlights$12(GeneralHighlightingPass.java:225)
    at com.intellij.codeInsight.daemon.impl.AnnotatorRunner.lambda$runAnnotatorsAsync$2(AnnotatorRunner.java:76)
    at com.intellij.concurrency.JobLauncherImpl.procInOrderAsync(JobLauncherImpl.java:539)
    at com.intellij.codeInsight.daemon.impl.AnnotatorRunner.runAnnotatorsAsync(AnnotatorRunner.java:67)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:231)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$collectInformationWithProgress$10(GeneralHighlightingPass.java:176)
    at com.intellij.codeInsight.daemon.impl.HighlightVisitorRunner.createHighlightVisitorsFor(HighlightVisitorRunner.java:84)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:109)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:84)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:57)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:418)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.runWithSpanIgnoreThrows(trace.kt:118)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceUtil.runWithSpanThrows(TraceUtil.java:36)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$3(PassExecutorService.java:413)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.tryRunReadAction(AnyThreadWriteThreadingSupport.kt:291)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:965)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$4(PassExecutorService.java:404)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:403)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:379)
    at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.cacheFileTypesInside(FileTypeManagerImpl.java:802)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$1(PassExecutorService.java:379)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.executeByImpatientReader(AnyThreadWriteThreadingSupport.kt:486)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:179)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:377)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:190)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
IntelliJ IDEA 2024.2 (Ultimate Edition)
Build #IU-242.20224.300, built on August 6, 2024
Licensed to <Reducted>
Subscription is active until April 24, 2025.
Runtime version: 21.0.3+13-b509.4 aarch64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 14.5
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 6096M
Cores: 16
Metal Rendering is ON
Registry:
  ide.experimental.ui=true
Non-Bundled Plugins:
  com.jetbrains.plugins.ini4idea (242.20224.361)
  com.ultrahob.zerolength.plugin (0.95)
  artsiomch.meson.syntax (203.1.0)
  org.jetbrains.plugins.go (242.20224.300)
  com.tabnine.TabNine (1.116.0)
  com.intellij.grazie.pro (0.3.326)
  info.fluffos.idea_bison (20230902.02)
  ir.msdehghan.plugins.ansible (0.92)
  name.kropp.intellij.makefile (242.20224.155)
  org.ermadan.kafkalytic (0.10.5)
  org.intellij.plugins.hcl (242.20224.159)
  PythonCore (242.20224.300)
  aws.toolkit.core (3.22-242)
  com.jetbrains.space (242.20224.155)
  org.jetbrains.plugins.ruby (242.20224.300)
  org.jetbrains.plugins.go-template (242.20224.155)
  idea.goyacc (0.1.0)
  Pythonid (242.20224.300)
  com.koxudaxi.pydantic (0.4.14)
  com.intellij.ml.llm (242.20224.331)
  net.seesharpsoft.intellij.plugins.csv (3.4.0-242)
  uk.co.ben-gibson.remote.repository.mapper (4.4.0)
  mobi.hsz.idea.gitignore (4.5.3)
  com.intellij.bigdatatools.core (242.20224.300)
  izhangzhihao.rainbow.brackets.lite (1.1.0)
  org.intellij.scala (2024.2.20)
  com.google.idea.bazel.ijwb (2024.07.16.0.1-api-version-242)
  amazon.q (3.22-242)
  com.github.copilot (1.5.17.6356)
  aws.toolkit (3.22-242)
Kotlin: 242.20224.300-IJ