fix range building for all constructors #151
Merged
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.
Previously, only generated constructors were delegated to using text search to find the range encompassing the constructor name (aka the class name, which shares the same range as the generated default constructor).
For this reason, non-generated constructors were not hitting the code-path that checks if the
name == "<init>", aka it was a constructor, which followed with logic to build a range based on the owning class's name, causing the range to be built based on the synthetic<init>name.This PR fixes this bug by delegating all constructors to the aforementioned text search codepath. It does it slightly differently by using text search from point, as constructors' preferred/point position starts from the name, avoiding the problem outlined here.
This allows for a minor simplification in the
RangeFinderclass, as we no longer have to prepend the search name with a space. This was only required for constructors which may have the constructor name at the start of the line (after whitespace).