Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

Fix rename in for comprehensions #156

Merged

Conversation

mlangc
Copy link
Collaborator

@mlangc mlangc commented Apr 7, 2016

Note that this PR actually makes the implementation simpler, and removes more code than it adds.

Fix #1002650

@misto
Copy link
Member

misto commented Apr 8, 2016

Nice! A very clever solution, and it's even shorter and easier to understand than the original.

@misto misto merged commit 28ac974 into scala-ide:master Apr 8, 2016
private def termsWithSamePointButRange(s: Symbol): List[Symbol] = {
val lookAtSymbol = {
s != NoSymbol && !s.isSynthetic && s.isInstanceOf[TermSymbol] &&
s.pos.isInstanceOf[OffsetPosition] && !s.pos.isInstanceOf[RangePosition]
Copy link
Member

Choose a reason for hiding this comment

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

just a question why s.pos.isRange and s.isTerm are too weak for this check. Or maybe it is not this position and symbol?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing that out! See #157.

Copy link
Member

Choose a reason for hiding this comment

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

just asking, maybe 2.10 api is too weak so you decided to use
isInstanceOf?

2016-04-08 9:46 GMT+02:00 Matthias Langer notifications@github.com:

In src/main/scala/scala/tools/refactoring/analysis/SymbolExpanders.scala
#156 (comment)
:

  • * The reason that we need this is that in some cases, the PC generates multiple
  • * symbols for one and the same symbol in user source code, one of them with a
  • * proper range position, and others just with offset positions. One place where
  • * this happens is in desugared for comprehensions with filter clauses.
  • * See Assembler Ticket #1002650.
  • */
  • trait TermsWithMissingRanges extends SymbolExpander { this: IndexLookup =>
  • protected abstract override def doExpand(s: Symbol): List[Symbol] = {
  •  termsWithSamePointButRange(s) ::: super.doExpand(s)
    
  • }
  • private def termsWithSamePointButRange(s: Symbol): List[Symbol] = {
  •  val lookAtSymbol = {
    
  •    s != NoSymbol && !s.isSynthetic && s.isInstanceOf[TermSymbol] &&
    
  •      s.pos.isInstanceOf[OffsetPosition] && !s.pos.isInstanceOf[RangePosition]
    

Thanks for pointing that out! See #157
#157.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/scala-ide/scala-refactoring/pull/156/files/44270070343f8811cc3e9524e9fe35921b3b1f1c#r58990634

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I was indeed thinking about 2.10 compatibility when writing these isInstanceOf tests, but I was wrong. The only thing missing in 2.10 is isOffset.

@mlangc mlangc mentioned this pull request Apr 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants