Fix decompilation of Kernel that causes syntax highlighting crashes #1877
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1868
Changelog
Bug Fixes
Fix syntax highlighting stopping due to decompiling of
Kernel
failing caused by bugs introduced in Documentation Provider improvements #1834.Syntax highlighting could fail part way through a file when
Kernel
needed to be decompiled to resolve parts of the syntax. This would lead to the file to be colored above a certain point, but then the default gray after that point.Previously, when the decompiler didn't use the
Docs
, it was guaranteed that thePsiCompiled
stubs would correlate, in-order, with the decompiled source call definitions, and so mirrors could be set by matching up the list of them in order. Since theDocs
doesn't have to correspond to and doesn't correspond to the binary precisely for some BEAMs, most importantly,Elixir.Kernel.beam
, the PsiCompiled stub and decompiled source is now matched by name and arity. This means some mirrors are missed, but no errors are produced.Since the decompile source from
Docs
can have default arguments the call definition clauses can have an arity range and not just a fixed arity, so all arities in the range need to be mappable toPsiCompiled
functions.Docs
.Ensures that defmacro is used for macros instead of hard-coding
def
as in Documentation Provider improvements #1834.~S"""
for docs fromDocs
chunk.The docs from the
Docs
chunk may contain interpolation in the code samples or#{
in regex examples, but these should not be treated as an interpolation start as theDocs
format does not support interpolation. Anything that looks like interpolation in the docs text was actually escaped in the original docs, so also escape it here by usingS"""
, which turns off interpolation.Code
function can't be matched to decompiled source.Unlike the old
InvalidMirrorException
, this won't be an exception and the binary <-> decompile will still work for the other functions/macros in the file, so it will be a more graceful degradation.