maiqingqiang / go-orm-helper

🚀🚀 A GoLand plugin that automatically provides database field completion, tags, and generates Structs for writing ORM code. Supports: Gorm、Xorm、Beego、GoFrame, etc. ⭐️ Star to support our work!一个为了让你在 Goland 上写 ORM 能自动补全数据库字段、Tag、生成Struct 的插件。支持:Gorm、Xorm、Beego、GoFrame...)请给个 ⭐️Star 支持我们的工作吧!
GNU General Public License v3.0
161 stars 9 forks source link

[BUG] goframe - 安装插件后经常导致IDE索引失效 #12

Closed shuqingzai closed 1 year ago

shuqingzai commented 1 year ago

image

om.intellij.psi.stubs.ManyProjectsStubIndexMismatch: PSI and index do not match.
Please report the problem to JetBrains with the files attached
INDEXED VERSION IS THE CURRENT ONE file=GO_FILE, file.class=class com.goide.psi.GoFile, file.lang=Language: go, modStamp=3
 tree consistent
 stub debugInfo=created in calcStubTree; with backReference
 viewProvider=com.intellij.psi.SingleRootFileViewProvider{vFile=file:///test/goframe/internal/pkg/redis/impl/redis.go, vFileId=724513, content=VirtualFileContent{size=7572}, eventSystemEnabled=true}
 viewProvider stamp: 36830; file stamp: 36830; file modCount: 1691551437676; file length: 7572
 doc saved: true; doc stamp: 36830; doc size: 6754; committed: true
indexing info: indexing timestamp = 1691551437676, binary = false, byte size = 7572, char size = 6754
latestIndexedStub=StubTree{myDebugInfo='created from index; with backReference', myRoot=GoFileStub}509253842
   same size=false
   debugInfo=created from index; with backReference
    at com.intellij.psi.stubs.StubTreeLoader.handleManyProjectsMismatch(StubTreeLoader.java:215)
    at com.intellij.psi.stubs.StubTreeLoader.access$000(StubTreeLoader.java:28)
    at com.intellij.psi.stubs.StubTreeLoader$StubTreeAndIndexUnmatchCoarseException.doCreateCompleteException(StubTreeLoader.java:200)
    at com.intellij.psi.stubs.StubTreeLoader$StubTreeAndIndexUnmatchCoarseException.access$300(StubTreeLoader.java:144)
    at com.intellij.psi.stubs.StubTreeLoader.lambda$stubTreeAndIndexDoNotMatch$0(StubTreeLoader.java:68)
    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.lambda$computeInNonCancelableSection$4(CoreProgressManager.java:230)
    at com.intellij.openapi.progress.Cancellation.computeInNonCancelableSection(Cancellation.java:64)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeInNonCancelableSection(CoreProgressManager.java:230)
    at com.intellij.psi.stubs.StubTreeLoader.stubTreeAndIndexDoNotMatch(StubTreeLoader.java:67)
    at com.intellij.psi.stubs.StubProcessingHelperBase.inconsistencyDetected(StubProcessingHelperBase.java:151)
    at com.intellij.psi.stubs.StubProcessingHelperBase.checkType(StubProcessingHelperBase.java:93)
    at com.intellij.psi.stubs.StubProcessingHelperBase.processStubsInFile(StubProcessingHelperBase.java:72)
    at com.intellij.psi.stubs.StubIndexEx.lambda$processElements$4(StubIndexEx.java:150)
    at com.intellij.psi.stubs.StubIndexEx.processElements(StubIndexEx.java:214)
    at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:102)
    at com.goide.stubs.index.GoMethodIndex.find(GoMethodIndex.java:52)
    at com.goide.psi.impl.GoPsiImplUtil.calcMethods(GoPsiImplUtil.java:1624)
    at com.goide.psi.impl.GoPsiImplUtil.lambda$getMethods$29(GoPsiImplUtil.java:1485)
    at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:158)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:37)
    at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:240)
    at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:43)
    at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:240)
    at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:110)
    at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:27)
    at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:65)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:241)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:27)
    at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:69)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:155)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:121)
    at com.goide.psi.impl.GoPsiImplUtil.getMethods(GoPsiImplUtil.java:1484)
    at com.goide.psi.impl.GoTypeSpecImpl.getMethods(GoTypeSpecImpl.java:48)
    at com.goide.psi.impl.GoPsiImplUtil.calcAllMethodsWithSubstitutionSource(GoPsiImplUtil.java:1669)
    at com.goide.psi.impl.GoPsiImplUtil.calcAllMethodsWithSubstitutionSource(GoPsiImplUtil.java:1517)
    at com.goide.psi.impl.GoTypeUtil.findImplementedMethodsWithSubstitutionSource(GoTypeUtil.java:1699)
    at com.goide.psi.impl.GoTypeUtil.checkImplementsInterface(GoTypeUtil.java:1449)
    at com.goide.psi.impl.GoTypeUtil.checkImplementsInterface(GoTypeUtil.java:1422)
    at com.goide.psi.impl.GoTypeUtil.checkAssignable(GoTypeUtil.java:1110)
    at com.goide.psi.impl.GoTypeUtil.checkAssignable(GoTypeUtil.java:1075)
    at com.goide.psi.impl.expectedTypes.GoExpectedTypeImpl.checkCompatibleWith(GoExpectedTypeImpl.java:87)
    at com.goide.psi.impl.expectedTypes.GoExpectedTypes.checkCompatibleWith(GoExpectedTypes.java:147)
    at com.goide.psi.impl.expectedTypes.GoExpectedTypes.checkCompatibleWith(GoExpectedTypes.java:133)
    at com.goide.highlighting.legacyErrorInspections.GoTypesCompatibilityInspection.visitCallExpr(GoTypesCompatibilityInspection.java:87)
    at com.goide.psi.impl.GoCallExprImpl.accept(GoCallExprImpl.java:20)
    at com.goide.psi.impl.GoCallExprImpl.accept(GoCallExprImpl.java:25)
    at com.goide.highlighting.GoAnnotator.annotate(GoAnnotator.java:103)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.runAnnotators(DefaultHighlightVisitor.java:130)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.visit(DefaultHighlightVisitor.java:107)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.runVisitors(GeneralHighlightingPass.java:360)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$collectHighlights$7(GeneralHighlightingPass.java:291)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:320)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$8(GeneralHighlightingPass.java:323)
    at com.github.maiqingqiang.goormhelper.codeInsights.daemon.GoORMHelperHighlightVisitor.analyze(GoORMHelperHighlightVisitor.java:80)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:323)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$8(GeneralHighlightingPass.java:323)
    at ḅイ.analyze(Unknown Source)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:323)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$8(GeneralHighlightingPass.java:323)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:92)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:323)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:286)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:234)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:95)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:57)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:390)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.runWithSpanIgnoreThrows(trace.kt:77)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceUtil.runWithSpanThrows(TraceUtil.java:24)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:386)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1133)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$3(PassExecutorService.java:377)
    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:61)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:376)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:352)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:201)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:207)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:350)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:185)
    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)

很多文件都这样

image

maiqingqiang commented 1 year ago

有复现流程吗? 我看看我能不能复现

shuqingzai commented 1 year ago

有复现流程吗? 我看看我能不能复现

就是项目安装后建立文件索引失败,导致索引失效,你也可以试试重新索引项目

可能也很电脑或系统有关?

系统:MacOS 12.6.7
电脑 :Mac mini (2018)

我觉得应该建立索引时,初始化项目与插件,CPU跑满了,导致没有完全索引文件,考虑一下延迟初始化插件?

maiqingqiang commented 1 year ago

有复现流程吗? 我看看我能不能复现

就是项目安装后建立文件索引失败,导致索引失效,你也可以试试重新索引项目

可能也很电脑或系统有关?

系统:MacOS 12.6.7
电脑 :Mac mini (2018)

我觉得应该建立索引时,初始化项目与插件,CPU跑满了,导致没有完全索引文件,考虑一下延迟初始化插件?

👌🏻 我排查一下

maiqingqiang commented 1 year ago

有复现流程吗? 我看看我能不能复现

就是项目安装后建立文件索引失败,导致索引失效,你也可以试试重新索引项目

可能也很电脑或系统有关?

系统:MacOS 12.6.7
电脑 :Mac mini (2018)

我觉得应该建立索引时,初始化项目与插件,CPU跑满了,导致没有完全索引文件,考虑一下延迟初始化插件?

性能问题可以关闭全局扫描,设置扫描范围,直接指定model的目录,减少不必要的扫描 image

maiqingqiang commented 1 year ago

初步分析应该是插件扫描目录的时候,项目索引还没完成,而且扫描的时候有依赖到PSI索引。打算使用runWhenProjectIsInitialized等项目初始化完成再扫描