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

Explicit typing feature #161

Open
JohnReedLOL opened this issue Jun 8, 2016 · 1 comment
Open

Explicit typing feature #161

JohnReedLOL opened this issue Jun 8, 2016 · 1 comment

Comments

@JohnReedLOL
Copy link

JohnReedLOL commented Jun 8, 2016

I'm currently working on implementing an explicit typing feature.

https://www.reddit.com/r/scala/comments/4mwp0o/scalatype_need_help/

Basically the idea is that it adds explicit types to variable declarations to make code easier to maintain after it has been written.

I was wondering if there was any way we could integrate functionality. Right now I'm getting my type information by telling my command line utility to compile with -print. This generates desugared source code with type information that can be extracted (using regular expression).

@kiritsuku
Copy link
Member

I worked on this years ago, there is still an open PR for it: #66

Unfortunately it isn't a reliable feature, therefore it was never merged. scalac removes too much syntactic information from the trees, which made it really difficult for scala-refactoring to just add types to the source code at the correct position.

scala-ide however still supports that feature: https://github.com/scala-ide/scala-ide/blob/2a16bde67fc120836180bf92f0ae2ab94501a728/org.scala-ide.sdt.core/src/org/scalaide/core/internal/quickassist/explicit/ExplicitReturnType.scala The code is quite easy to understand. We basically just ask the presentation compiler for the type (no need to print it back to text as you are doing it) and then add it to the source code directly. The current implementation doesn't work in all possible use cases but it is still good enough that I use it regularly.

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

No branches or pull requests

2 participants