-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add documentation for compiler plugin #4658
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
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.
Thanks @liufengyun
normal type checking. This is a nice feature for doing research, but for | ||
production usage, a predictable and consistent type checker is more important. | ||
|
||
For experiments and researches that depend on analyzer plugins in Scalac, |
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.
s/depend/rely
your domain-specific language. Research plugins are only enabled for nightly or | ||
snaphot releases of Dotty. | ||
|
||
The common plugins that add a new phase to the compiler pipeline are called |
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.
Only one phase?
The common plugins that add new phases ...
``` | ||
|
||
The above is a change from Scalac, which depends on an XML file | ||
`scalac-plugin.xml`. Since SBT 1.1.5, SBT also supports Dotty compiler plugins: |
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.
Starting with 1.1.5, sbt also...
@@ -10,13 +10,13 @@ import Symbols.Symbol | |||
import Constants.Constant | |||
import StdNames._ | |||
|
|||
class DivideZero extends MiniPhase with ResearchPlugin { | |||
class DivideZero extends PluginPhase with ResearchPlugin { |
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.
Since the CI only run the sbt scripted tests on nightlies, can you confirm that you ran this test locally
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 test is a neg test, not a scripted test. I just checked it works locally. I confused my self, for research plugins, we don't need the phases to be PluginPhase
.
|
||
For experiments and researches that rely on analyzer plugins in Scalac, | ||
_research plugin_ can be used for the same purpose in Dotty. Research plugins | ||
are more powerful than Scalac analyzers as it enables plugin authors to |
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.
"Than Scalac analyzer plugins"
|
||
For experiments and researches that rely on analyzer plugins in Scalac, | ||
_research plugin_ can be used for the same purpose in Dotty. Research plugins | ||
are more powerful than Scalac analyzers as it enables plugin authors to |
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.
as they enable
your domain-specific language. Research plugins are only enabled for nightly or | ||
snaphot releases of Dotty. | ||
|
||
The common plugins that add new phases to the compiler pipeline are called |
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'd switch the order of these 2 paragraphs, let's describe first the common case?
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 agree, but it seems the 2nd paragraph follows more naturally after the 1st paragraph. If we switch the 3rd and the 2nd, we have a problem between 1st and 3rd.
_standard plugins_ in Dotty. In terms of features, they are similar to | ||
Scalac plugins, despite minor changes in the API. | ||
|
||
## Physical Interface |
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.
Physical interface reads like a USB port, I'd call this section "Using compiler plugins" and have a separate subsection for the command line and for sbt.
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.
Maybe we can call it plugin artifact interface?
|
||
``` | ||
pluginClass=dividezero.DivideZero | ||
``` |
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.
Is this relevant to this section? Maybe this should go in a section called "Writing compiler plugins"?
addCompilerPlugin("org.divbyzero" % "divbyzero" % "1.0") | ||
``` | ||
|
||
## Standard Plugin |
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.
Maybe call this "Writing your first plugin", and move the content of plugin.properties
here?
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.
That can be more friendly, but I feel the tutorial-like style doesn't fit the documentation style of other pages.
6aebe80
to
eafa497
Compare
Otherwise, LGTM. Thanks a lot @allanrenucci @Duhemm ! |
add documentation for compiler plugin