Reputation: 96461
Lets take a
val m = "Scala is fun"
IntelliJ
helps figure out a lot of things that can be done with this
Is there a way for me to know which of these functions come from Scala and which ones come from Java?
Upvotes: 4
Views: 168
Reputation: 7963
If you have IDEA 12 you can hit Ctrl-Q on any selected method in the pop-up to view "Quick documentation" for that method, not only that, you can traverse the list of methods and the quick doc will change to suit the new selections.
If you find any entries with no quick help, it's a good bet it will be a Scala method ;@)
I'll check for IDEA 11 too.
EDIT: It works for IDEA 11 CE and Ultimate too.
Upvotes: 2
Reputation: 6488
In IDEA's autocompletion, bold entries are methods defined on the type of the object itself, while underlined functions are added by implicit conversions and pimp-my-library (for explanation, see for instance here or search on StackOverflow or Google).
However, for the special case of types which are defined in Java (like String
, the type of m
), you happen to be right on the Java-vs-Scala distinction: there bold methods are real methods, which must be defined within the type of m
(here String
) and thus in Java. While pimp-my-library is a Scala pattern, so typically underlined functions will be written in Scala (this is just a rule of thumb, but I've never yet seen an exception).
Non-bold functions are simply inherited.
For the amount of documentation, as a rule of thumb the Java standard library has quite comprehensive documentation (it's supposed to be a specification for the method) while Scala varies typically between less and much less documentation.
I've searched for how to change the fonts used for this highlighting in IntelliJ 11, but I've not found much - you can change fonts used to highlight the code, but I suspect that doesn't make a difference here.
Upvotes: 4