Fix for setting breakpoints in async code. #360
Closed
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.
this fixes long standing issues with stepping through and setting breakpoints in the scala/async async code.
bug happens because NamePattern.forElement(elem) returns nothing for async psi elements, and as a result method returns zero candidate classes for given SourcePosition.
nothing in NamePattern.forElement(elem) is returned because it doesn't know that async methods generate classes (in our case, classes generated are named Basename$statemachine$...). I think the logic that filters out our case in NamePattern.forElement(elem) should be improved but I don't know how.
but creating NamePattern directly helps. Although filter is more loose and may falsely accept more cases, hasLocations(refType: ReferenceType, position: SourcePosition) seems to be strict enough to filter out the only one correct class from generated statemachine. I wonder what could be the cases that are falsely accepted.
Environment for which it fixes bug:
scala-async_2.11 0.9.6-RC2
idea162.x branch as of today
scala 2.11.7
maybe fix for scala/scala-async#136
and for https://youtrack.jetbrains.com/issue/SCL-4935
best regards.