-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add a dotty-interfaces
package
#1125
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
Conversation
- Rename Diagnostic#msg to message, this is nicer for a public API - Rename SourceFile#lineContents and SourcePosition#lineContents to lineContent, the former is not grammatically correct. - Add some convenience methods to SourcePosition.
3363f00
to
1a57ca6
Compare
|
||
/** Set of callbacks called in response to events during the compilation process. | ||
* | ||
* You should implement this interface if you want to react to one or more of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc style is different than Scaladoc. See http://www.oracle.com/technetwork/articles/java/index-137868.html#format
It should therefore be:
/**
* Set of callbacks ...
*
* You should ...
* ...
*/
(same everywhere there are JavaDocs, obviously.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not against changing it, but isn't it nicer to keep the style consistent across Dotty? javadoc
seems to interpret this style correctly so I don't see any downside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any strong feelings either way. We can keep it like this.
What command tests |
That's all. |
@@ -0,0 +1,19 @@ | |||
package dotty.tools.dotc.interfaces; | |||
|
|||
import java.io.File; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import is unused.
It will be run by |
OK. |
I run dotty compiler from IDEA with this version of dotty interface. We can make a build of scala plugin with Dotty compiler as soon as you merge this PR and publish jars. |
@niktrop : Cool! Note that since this is very experimental we might have to break the ABI, I think that's okay until we have a real release of Dotty. |
@sjrd: what do you think of adding an public interface AbstractFile {
String name();
String path();
Optional<File> file();
} and we would change the public interface SourceFile extends AbstractFile {
/** The content of this file as seen by the compiler. */
char[] content();
} Then we could have: default void onClassGenerated(SourceFile source, AbstractFile generatedClass, String className) {}; |
Yes, good idea. |
Hmm, but I can't do that without changing the definition of def wrapAbstractFile(absfile: AbstractFile) = new interfaces.AbstractFile {
def name = absfile.name
def path = absfile.path
def file = if (absfile.file != null) Optional.of(absfile.file) else Optional.none
} What do you think? |
Yes, you'll probably have to wrap. You'll lose identity, though, which should be documented (like "Do not rely on the identity of |
We already use an AbstractFile abstraction, the one reflect.io. SourceFile
On Thu, Feb 25, 2016 at 6:42 PM, Guillaume Martres <[email protected]
Martin Odersky |
The |
Ah, yes, that is a good enough reason, I think. On Sat, Feb 27, 2016 at 2:24 PM, Sébastien Doeraene <
Martin Odersky |
@sjrd AbstractFile interfaces added, I find CompilerCallback clearer than CompilerListener so I'm not motivated to rename it :). |
LGTM
Fair enough. |
We introduce a new entry point for the compiler in `dotty.tools.dotc.Driver`: ``` def process(args: Array[String], simple: interfaces.SimpleReporter, callback: interfaces.CompilerCallback): interfaces.ReporterResult ``` Except for `args` which is just an array, the argument types and return type of this method are Java interfaces defined in a new package called `dotty-interfaces` which has a stable ABI. This means that you can programmatically run a compiler with a custom reporter and callbacks without having to recompile it against every version of dotty: you only need to have `dotty-interfaces` present at compile-time and call the `process` method using Java reflection. See `test/test/InterfaceEntryPointTest.scala` for a concrete example. This design is based on discussions with the IntelliJ IDEA Scala plugin team. Thanks to Nikolay Tropin for the discussions and his PR proposal (see scala#1011).
26f60b0
to
7e7ee82
Compare
Add a `dotty-interfaces` package
We introduce a new entry point for the compiler in
dotty.tools.dotc.Driver
:Except for
args
which is just an array, the argument types and returntype of this method are Java interfaces defined in a new package called
dotty-interfaces
which has a stable ABI. This means that you canprogrammatically run a compiler with a custom reporter and callbacks
without having to recompile it against every version of dotty: you only
need to have
dotty-interfaces
present at compile-time and call theprocess
method using Java reflection.See
test/test/InterfaceEntryPointTest.scala
for a concrete example.This design is based on discussions with the IntelliJ IDEA Scala plugin
team. Thanks to Nikolay Tropin for the discussions and his PR
proposal (see #1011).
Review by @sjrd
/cc @niktrop