For BashSupport Pro, I received this exception:
java.lang.Throwable: Range for element: 'FUNCTION_DEFINITION' = (5246,8273) is out of file 'ShFile: file.sh)' range: (0,7855); file contents length: 7855
file provider: com.intellij.psi.SingleRootFileViewProvider{vFile=file://path/file.sh, vFileId=1428361, content=VirtualFileContent{size=8309}, eventSystemEnabled=true}
The code, which is throwing it is in an inspection, which detects if a variable could be made local (i.e. it does not have any global uses outside the current scope). It’s running a ReferenceSearch for the inspection. This is probably not the best, but I can’t think of a better solution right now.
The code usually works, but appears to be causing the exception on some setups.
What’s causing these range is out of range … errors?
Code:
ReferencesSearch.search(referenceTarget, effectiveUseScope).anyMatch {
// ...
}
Stacktrace starting from the reference search:
java.lang.Throwable: Range for element: 'FUNCTION_DEFINITION' = (5246,8273) is out of file 'ShFile: file.sh)' range: (0,7855); file contents length: 7855
file provider: com.intellij.psi.SingleRootFileViewProvider{vFile=file:///path/file.sh, vFileId=1428361, content=VirtualFileContent{size=8309}, eventSystemEnabled=true}
committed=true
sharedSourceSupport:true, cachedViewProviders:1
root Language: BashSupport Pro Shell Script length=7855; contentsLoaded=true
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:375)
at com.intellij.psi.impl.search.LowLevelSearchUtil.diagnoseInvalidRange(LowLevelSearchUtil.java:253)
at com.intellij.psi.impl.search.LowLevelSearchUtil.getTextOccurrencesInScope(LowLevelSearchUtil.java:159)
at com.intellij.psi.impl.search.PsiSearchHelperImpl$1.processInReadAction(PsiSearchHelperImpl.java:315)
at com.intellij.psi.impl.search.PsiSearchHelperImpl$1.processInReadAction(PsiSearchHelperImpl.java:299)
at com.intellij.openapi.application.ReadActionProcessor.lambda$process$0(ReadActionProcessor.java:11)
at com.intellij.openapi.application.impl.AppImplKt$rethrowCheckedExceptions$2.invoke(appImpl.kt:126)
at com.intellij.platform.locking.impl.NestedLocksThreadingSupport.runReadAction(NestedLocksThreadingSupport.kt:854)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:1109)
at com.intellij.openapi.application.ReadAction.computeBlocking(ReadAction.java:88)
at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:70)
at com.intellij.openapi.application.ReadActionProcessor.process(ReadActionProcessor.java:11)
at com.intellij.concurrency.JobLauncherImpl.lambda$processImmediatelyIfTooFew$8(JobLauncherImpl.java:245)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$14(CoreProgressManager.java:744)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:819)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:775)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:743)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
at com.intellij.concurrency.JobLauncherImpl.lambda$processImmediatelyIfTooFew$9(JobLauncherImpl.java:242)
at com.intellij.openapi.application.impl.AppImplKt$runnableUnitFunction$1.invoke(appImpl.kt:124)
at com.intellij.openapi.application.impl.AppImplKt$runnableUnitFunction$1.invoke(appImpl.kt:124)
at com.intellij.platform.locking.impl.NestedLocksThreadingSupport.runReadAction(NestedLocksThreadingSupport.kt:854)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:1099)
at com.intellij.concurrency.JobLauncherImpl.processImmediatelyIfTooFew(JobLauncherImpl.java:252)
at com.intellij.concurrency.JobLauncherImpl.invokeConcurrentlyUnderProgressAsync(JobLauncherImpl.java:78)
at com.intellij.concurrency.JobLauncherImpl.invokeConcurrentlyUnderProgress(JobLauncherImpl.java:65)
at com.intellij.concurrency.JobLauncher.lambda$invokeConcurrentlyUnderContextProgress$0(JobLauncher.java:65)
at com.intellij.concurrency.ConcurrencyUtils.runWithIndicatorOrContextCancellation(ConcurrencyUtils.java:38)
at com.intellij.concurrency.ConcurrencyUtils.runWithIndicatorOrContextCancellation(ConcurrencyUtils.java:20)
at com.intellij.concurrency.JobLauncher.invokeConcurrentlyUnderContextProgress(JobLauncher.java:63)
at com.intellij.psi.impl.search.PsiSearchHelperImpl.bulkProcessElementsWithWord(PsiSearchHelperImpl.java:323)
at com.intellij.psi.impl.search.PsiSearchHelperImpl.processSingleRequest(PsiSearchHelperImpl.java:1344)
at com.intellij.psi.impl.search.PsiSearchHelperImpl.lambda$processRequests$22(PsiSearchHelperImpl.java:903)
at com.intellij.concurrency.ConcurrencyUtils.runWithIndicatorOrContextCancellation(ConcurrencyUtils.java:38)
at com.intellij.concurrency.ConcurrencyUtils.runWithIndicatorOrContextCancellation(ConcurrencyUtils.java:20)
at com.intellij.psi.impl.search.PsiSearchHelperImpl.processRequests(PsiSearchHelperImpl.java:887)
at com.intellij.psi.search.SearchRequestQuery.processResults(SearchRequestQuery.java:21)
at com.intellij.util.AbstractQuery.doProcessResults(AbstractQuery.java:88)
at com.intellij.util.AbstractQuery.delegateProcessResults(AbstractQuery.java:105)
at com.intellij.util.MergeQuery.processResults(MergeQuery.java:22)
at com.intellij.util.AbstractQuery.doProcessResults(AbstractQuery.java:88)
at com.intellij.util.AbstractQuery.delegateProcessResults(AbstractQuery.java:105)
at com.intellij.util.UniqueResultsQuery.processResults(UniqueResultsQuery.java:37)
at com.intellij.util.AbstractQuery.doProcessResults(AbstractQuery.java:88)
at com.intellij.util.AbstractQuery.forEach(AbstractQuery.java:80)
at com.intellij.util.Query.anyMatch(Query.kt:80)
at pro.bashsupport.editor.inspections.ShOnlyLocallyUsedGlobalVariableInspection.M(ShOnlyLocallyUsedGlobalVariableInspection.kt:111)