New features: Type Info and Toggle Type Annotation
I am pleased to announce the availability of new useful yet hard-to-discover features.
Type Info hint:
Toggle Type Annotation intention:
Get the next nightly build to try them out.
请先登录再写评论。
I am pleased to announce the availability of new useful yet hard-to-discover features.
Type Info hint:
Toggle Type Annotation intention:
Get the next nightly build to try them out.
请先登录再写评论。
Outstanding!
Thanks to all involved for these features. I've heard several complaints about the (now former) lack of type inference for the formal parameters in function literals.
Randall Schulz
Nice work, these small features are really useful.
There is a similar feature I added some time ago which is also a bit hard to find: you can select an expression, and use the Surround Template (CTRL-ALT-T on Windows) '(expr: Type)'
List(1, 2, 3).map(_.toDouble).map(_.toInt)
((List(1, 2, 3).map(_.toDouble): List[Double])).map(_.toInt)
-jason
u rock
I've disabled "Toggle Type Annotation" by accident.
Now, for the life of me, I cannot figure out how to enable it again.
I would expect to find it in the regular "Intentions" tree, but it's not there.
take a look at the something.xml where the settings are stored, the setting should be there
the file is here:
blublublu\.IntelliJIdea90\config\inspection
I got it enabled again by deleting ~/.IntelliJIdea90/config/options/intentionSettings.xml
I've filed http://youtrack.jetbrains.net/issue/SCL-1906 for showing the setting in a more obvious place.
This feature is a lifesaver! Thanks so so much.
A question:
This feature is brilliant but I think I may have found some unexpected behaviour.
I have a composed type "Foo with Bar" FooBar which used to resolve correctly but now resolves as "Any with Bar".
So functions referencing values on Foo like (someFooBar.fooValue) can't be resolved or clicked through while functions referencing values on Bar like (someFooBar.barValue) do resolve properly.
Here's a thumbnail of the code:
Foo.scala
package object foo {
trait Foo {
// some foo stuff
val salutation = "Salve!"
}
}
Bar.scala
package object bar {
trait Bar {
// some bar stuff
val valediction = "Vale!"
}
type FooBar = Foo with Bar
}
Baz.scala
class Baz {
val fooBars = Seq(someFooBar1, someFooBar2)
val salutations = fooBars.map(_.salutation) // _.salutation does not click-through resolve
val valedictions = fooBars.map(_.valediction) // _.valediction does click-through resolve
}
I tried reversing the order of the FooBar type to be "Bar with Foo" but the same behaviour occurs. Maybe the Scala plugin doesn't like one package object trait referencing another?
Should I file a bug report? I am using build 1473, but I tested 1480 and it had the same issue.
Further note:
I was able to fix resolution on composed type FooBar by making the following change:
Foo.scala
package object foo {
// some package object foo stuff
}
package foo {
trait Foo {
// some foo stuff
val salutation = "Salve!"
}
}
The Scala compiler didn't complain about the original setup, so I don't think what I was doing was incorrect. Should I have expected type info to correctly resolve FooBar using the first example?
You may press "secret shortcut" Сtrl+Alt+Shift+E to turn on/off all available code highlighting and discover a root cause of the problem.
While the code you posted is rather complex, it is very likely that one or more references are simply unresolved.
Feel free to report any discovered bugs directly to YouTrack.
Hi Pavel,
That will be quite a useful feature while the plugin is in the "early stages" (compared to the IDEA Java editor).
Are you interested in all "red code", or is there a list of categories that you already know about?
-tt
What is needed is, actualy, not just "red code", but isolated problems (something like this report).
Red code may be caused by arbitrary code analysis bugs and usually it's not so easy to reproduce them in different environment.
The most simple, self-sufficient, code snippets that still exhibit a bug and a possible problem description are the artifacts that helps us to fix bugs and make Scala plugin better.
Once I see the type, is there an easy way to navigate to its decleration? If not, maybe the type in the tooltip can be a link to the type's decleration? or maybe hovering over a variable decleration with ctrl pressed can turn the variable name into a link?
cursor at type: ctrl+b or middle click or ctrl+left (or was ist alt+left?) click
cursor at variable: ctrl+shift+b
the first two don't work since there's no type (e.g. 'val foo = doSomething()')
ctrl-shift-b works.
thanks!