Skip to content

Conversation

@Strum355
Copy link
Contributor

@Strum355 Strum355 commented Apr 14, 2021

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 RangeFinder class, 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).

@Strum355 Strum355 force-pushed the nsc/constructor-range-fix branch from 339d4cb to 8fb4663 Compare April 14, 2021 14:14
Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 One non-blocking comment about the fix, feel free to merge.

Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new fix looks a lot cleaner, thank you for following up on that comment 🙏

@olafurpg
Copy link
Contributor

I'm not sure what's causing the CI failure. It looks like Gradle is failing sporadically 🤔 Might be worth trying to restart the jobs tomorrow.

@Strum355
Copy link
Contributor Author

sbt test passes locally for me, still failing in CI 🤔
Ill merge this PR and we can investigate CI at a later stage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants