Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tooltip message for 'var's #1005

Merged

Conversation

andrey-ilinykh
Copy link
Contributor

Distinguish var from def by checking if the owner has both a setter and
a getter with the same name

Fix #1001007

Distinguish var from def by checking if the owner has both a setter and
a getter with the same name

Fix #1001007
@ghprb-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://jenkins.scala-ide.org:8496/jenkins//job/ghprb-scala-ide-multi-conf/323/
Test PASSed.

@kiritsuku
Copy link
Member

The formatting is still not perfect (if it had changed at all), but I don't want to be too pedantic. Therefore, LGTM.

kiritsuku added a commit that referenced this pull request Sep 12, 2015
@kiritsuku kiritsuku merged commit 4dd5569 into scala-ide:master Sep 12, 2015
@kiritsuku
Copy link
Member

Thanks

@andrey-ilinykh andrey-ilinykh deleted the var-tooltip-1001007-squashed branch September 12, 2015 15:42
def hasGetterSetter(sym:Symbol)= gsym != NoSymbol && sym.setterIn(sym.owner) != NoSymbol

if(hasGetterSetter(sym)){
compose("", "var",sym.localName.toString.trim+": "+gsym.tpe.resultType)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is working very well, since modifiers are eluded and hardcoded to "". What about private/protected vars?. Also, the type should be printed using the same calls as in the original code. I think the proper way would be to use the getter symbol for all of these. For an example about the type:

trait Foo[T] {
  var x: T = _
}

class C extends Foo[Int] {
  prinntl(x) // x: Int or x: T?
}

@andrey-ilinykh
Copy link
Contributor Author

Yes, I agree. It is not perfect. I hardcoded modifiers to "" because they are wrong any way. In simple case
class Foo{
val x:Int = 100
}
tooltip is "private[this] val x: Int"

@dragos
Copy link
Member

dragos commented Sep 17, 2015

@andrey-ilinykh I think there is at least one symbol (not the field, but probably the getter) that has the correct flags. We should use those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants