Did 2017.3 break resolveScopeEnlarger and/or indexedRootsProvider?

I've been using these two EPs to ensure that custom JavaScript libs are included properly for HTML-based markup files in my custom language plugin in Ultimate Edition. I noticed that I wasn't getting references or code completion for identifiers from those JS libs any longer the other day. It's possible that it happened prior to 2017.3, but that's when I noticed it.

Setting breakpoints in my implementations of those EPs, I'm seeing indexedRootsProvider being hit but not resolveScopeEnlarger. I noticed other EPs called resolveScopeProvider and JavaScript.elementScopeProvider and tried to implement those, but they're never being called for my markup files.

Something has definitely regressed in a recent IDE update, though I'm not 100% sure when it happened. Before I start backtracking and testing older versions to try to isolate the exact breaking update, I figured I'd post here to see if this was already known and/or on someone's radar to fix.

Any insights? Thanks!

0
8 comments
Official comment

No, unfortunately no relevant changes come to my mind. Could you please post stack traces of your extensions being called in an earlier IDE version? That might helps us figure out what's changed.

Thanks, Peter. I'll try to capture a stack showing how each was called previously vs. how it's called (or not called, as the case may be) now. Something has definitely changed because this was implemented based on a discussion with you guys and then worked perfectly for a long time, then just stopped working in a recent IDE release, but I'll see if I can provide more details shortly.

0

Here's a stack from a previous version of IntelliJ where it calls my implementation of resolveScopeEnlarger:

 at com.illuminatedcloud.intellij.completion.SimpleJavaScriptResolveScopeEnlarger.getAdditionalResolveScope(SourceFile:37)
at com.intellij.psi.impl.file.impl.ResolveScopeManagerImpl$1.create(ResolveScopeManagerImpl.java:54)
at com.intellij.psi.impl.file.impl.ResolveScopeManagerImpl$1.create(ResolveScopeManagerImpl.java:44)
at com.intellij.util.containers.FactoryMap.get(FactoryMap.java:56)
at com.intellij.psi.impl.file.impl.ResolveScopeManagerImpl.a(ResolveScopeManagerImpl.java:79)
at com.intellij.psi.impl.file.impl.ResolveScopeManagerImpl.getDefaultResolveScope(ResolveScopeManagerImpl.java:177)
at com.intellij.lang.javascript.psi.resolve.JavaScriptResolveScopeProvider.getElementResolveScope(JavaScriptResolveScopeProvider.java:60)
at com.intellij.lang.javascript.psi.resolve.JSResolveUtil.getResolveScope(JSResolveUtil.java:675)
at com.intellij.lang.javascript.index.JSTypeEvaluateManager.getTypedefValue(JSTypeEvaluateManager.java:300)
at com.intellij.lang.javascript.index.JSTypeEvaluateManager.expandTypedefs(JSTypeEvaluateManager.java:271)
at com.intellij.lang.javascript.psi.types.JSTypeImpl.getTypedef(JSTypeImpl.java:231)
at com.intellij.lang.javascript.psi.JSTypeUtils.processExpandedType(JSTypeUtils.java:830)
at com.intellij.lang.javascript.psi.resolve.QualifiedItemProcessor.process(QualifiedItemProcessor.java:63)
at com.intellij.lang.javascript.psi.resolve.JSTypeEvaluator.addType(JSTypeEvaluator.java:163)
at com.intellij.lang.javascript.psi.resolve.JSTypeEvaluator.addTypeFromDefExpr(JSTypeEvaluator.java:1286)
at com.intellij.lang.javascript.psi.resolve.JSTypeEvaluator.addTypeFromElementResolveResult(JSTypeEvaluator.java:939)
at com.intellij.lang.javascript.psi.resolve.JSTypeEvaluator.addTypeFromResolveResult(JSTypeEvaluator.java:797)
at com.intellij.lang.javascript.psi.resolve.JSTypeEvaluator.processRefExpr(JSTypeEvaluator.java:738)
at com.intellij.lang.javascript.psi.resolve.JSTypeEvaluator.evaluateTypes(JSTypeEvaluator.java:204)
at com.intellij.lang.javascript.psi.resolve.JSTypeEvaluator.evaluateTypes(JSTypeEvaluator.java:91)
at com.intellij.lang.javascript.psi.resolve.JSReferenceExpressionResolver.doResolve(JSReferenceExpressionResolver.java:112)
at com.intellij.lang.javascript.psi.resolve.JSResolveUtil.resolve(JSResolveUtil.java:2645)
at com.intellij.lang.javascript.psi.impl.JSReferenceExpressionImpl.multiResolve(JSReferenceExpressionImpl.java:413)
at com.intellij.lang.javascript.highlighting.JSSemanticHighlightingUtil.highlight(JSSemanticHighlightingUtil.java:97)
at com.intellij.lang.javascript.validation.JSAnnotatingVisitor.visitJSReferenceExpression(JSAnnotatingVisitor.java:626)
at com.intellij.lang.javascript.psi.impl.JSReferenceExpressionImpl.accept(JSReferenceExpressionImpl.java:403)
at com.intellij.lang.javascript.validation.JSAnnotatingVisitor.annotate(JSAnnotatingVisitor.java:119)
at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.a(DefaultHighlightVisitor.java:159)

and here's a stack where it calls my implementation of indexedRootsProvider:

at com.illuminatedcloud.intellij.completion.SimpleJavaScriptIndexedRootsProvider.getAdditionalRootsToIndex(SourceFile:32)
at com.intellij.util.indexing.IndexableSetContributor.getRootsToIndex(IndexableSetContributor.java:58)
at com.intellij.util.indexing.FileBasedIndexImpl.iterateIndexableFiles(FileBasedIndexImpl.java:2596)
at com.intellij.util.indexing.FileBasedIndexImpl.projectIndexableFiles(FileBasedIndexImpl.java:1095)
at com.intellij.util.indexing.FileBasedIndexImpl$ChangedFilesCollector.a(FileBasedIndexImpl.java:2236)
at com.intellij.util.indexing.FileBasedIndexImpl$ChangedFilesCollector.access$1700(FileBasedIndexImpl.java:1875)
at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:818)
at com.intellij.util.indexing.FileBasedIndexImpl.ensureUpToDate(FileBasedIndexImpl.java:788)
at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:250)

Note that neither of these extensions are hit any longer in recent versions of the IDE. I have not been able to isolate the exact time when this change occurred, but I'm pretty sure it was recent (perhaps 2017.*?).

Please let me know if you need anything else to help with this.

0

Hi, Scott. Indeed, in 2017.3 resolve scope evaluation was changed for javascript code to better controlling of scope evaluation for files having several languages inside. I've fixed calling ResolveScopeEnlargers for javascript code in custom files, but the fix will be available only in 2018.1. Alternatively you may add com.intellij.lang.javascript.index.IndexedFileTypeProvider extension, in this case your files will be treated as JS files for scope evaluation, and ResolveScopeEnlargers will be called.

1

Thanks, Konstantin. I appreciate the quick turnaround on a permanent fix and the recommendation for a workaround until that's available. I'll look at implementing it in the next few days.

There was a second issue in the bug I logged for this where comments in multi-language blocks are using the wrong commenter because it now sees elements in that range as heterogeneous. This is another recent regression, and in the bug I logged I point to the exact code that's causing the errant behavior. Any ideas on whether that's also a known issue and/or slated to be fixed? And of course, is there anything I can do in the plugin SDK to work around it in the interim?

Thanks again!

0

The second issue investigation is still underway, and will be discussed in the issue itself.

0

Perfect. Thanks much, guys!

0

Konstantin, I implemented JavaScript.indexedFileTypeProvider as a workaround and it's working very well! Thanks so much for the pointer.

0

Please sign in to leave a comment.