type inference+auto-completion in trivial scenarios stopped working? Follow
-scala plugin - latest (0.2.24088)
-project is using maven+scala 2.7.4
- auto completion for java libs (while editing scala) seems to be working just fine
- i can build the project with maven so it seems my environment is setup correctly
Dear jetbrains team,
val map = Map(1->'2')
map.<ctrl+space> gives me "No suggestion"
val l = List(1,2,3)
l.<ctrl+space> gives me "No suggestion"
val regex = "(.*)/some".r
regex.<ctrl+space> gives me "No suggestion"
I thought that auto-completion was working in scenarios like these before (I might be wrong though).
Could you please tell whether support for this is going to be added?
also how could I make ctrl+J (quick doc loookup) work for scala standard lib? right now it does not give me scala doc even though i added sources/doc for my global scala lib.
Thank you in advance
Please sign in to leave a comment.
I believe that if you specify the types of those vals explicitly, it will work.
From a coding style perspective, I think that for local vals and vars explicit type declaration is optional and often better omitted. For class (or trait or object) fields, I think it's best to always specify the type explicitly.
Thanks for your replay.
>I believe that if you specify the types of those vals explicitly, it will work.
I would rather not pollute my code just to help my IDE to provide auto completion.
I think you should write code that says what you mean. I think you'll find that experienced Scala programmers make similar suggestions.
It is really just laziness to omit type declarations and forces readers (including the author at a later date) to mentally perform the type inference that the compiler implements. That in turn brings with it the attendent likelihood of human error.
Nonetheless, I believe JetBrains intends to match the compiler's type inference in the Scala plug-in.
>I think you should write code that says what you mean. I think you'll find that experienced Scala programmers make similar suggestions.
I think we are getting off-topic here. With all due respect, this thread was not meant to be a debate about scala programming style. If you prefer to use explicit type def for Maps or Lists that's your call but I do not and my question was just whether jetbeans are going to add support for stuff like this in the future and if so when.
Of course we plan to finish our type inference. I think that in summer it will be ended.
This bugs, which you wrote here, we'll fix soon (not sure that all three cases are trivial, but List(1,2,3) is really trivial, it must be new bug), possibly in next update.
Thanks for your feedback.
the first example is just an example of a general method type parameters type inference:
def apply [A](xs : A*) : List[A]
So if you implement a general case, then it should be picked automatically.
Thank you for your update.
Let me clarify some details.
This might be surprising but that code is the most untrivial of all examples you've mentioned. Here we have sequently the generic implicit conversion (Int 2 ArrowAssoc), the generic method application (->) and the generic apply() method invocation. Because of the incorrect assignment of type parameters the second step fails for now. Sorry. Will fix it soon.
A one more case of an implicit conversion (String 2 RichString). Implemented in the last plugin version, will be available on Friday, th 22th of May.
With best regards,
Thanks for getting back to me.
The fact that you are responding to customer requests is the main reason why I bought an Intellij license (and planning to upgrade it).
Keep up the good work!