Skip to content

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

Merged
merged 8 commits into from
Jul 4, 2018

Conversation

liufengyun
Copy link
Contributor

add documentation for compiler plugin

@liufengyun liufengyun requested a review from allanrenucci June 14, 2018 13:51
Copy link
Contributor

@allanrenucci allanrenucci left a 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,
Copy link
Contributor

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
Copy link
Contributor

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:
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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
```
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@allanrenucci allanrenucci force-pushed the plugin-doc branch 2 times, most recently from 6aebe80 to eafa497 Compare July 3, 2018 15:00
@liufengyun
Copy link
Contributor Author

Otherwise, LGTM. Thanks a lot @allanrenucci @Duhemm !

@allanrenucci allanrenucci merged commit cf7b589 into scala:master Jul 4, 2018
@allanrenucci allanrenucci deleted the plugin-doc branch July 4, 2018 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants