File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed
core/src/main/java/com/google/googlejavaformat/java Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -88,9 +88,33 @@ Drop it into the Eclipse
8888[ drop-ins folder] ( http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fp2_dropins_format.html )
8989to activate the plugin.
9090
91- The plugin adds a ` google-java-format ` formatter implementation that can be
92- configured in `Window > Preferences > Java > Code Style > Formatter > Formatter
93- Implementation`.
91+ The plugin adds two formatter implementations:
92+
93+ * ` google-java-format ` : using 2 spaces indent
94+ * ` aosp-java-format ` : using 4 spaces indent
95+
96+ These that can be selected in "Window" > "Preferences" > "Java" > "Code Style" >
97+ "Formatter" > "Formatter Implementation".
98+
99+ #### Eclipse JRE Config
100+
101+ The plugin uses some internal classes that aren't available without extra
102+ configuration. To use the plugin, you will need to edit the
103+ [ ` eclipse.ini ` ] ( https://wiki.eclipse.org/Eclipse.ini ) file.
104+
105+ Open the ` eclipse.ini ` file in any editor and paste in these lines towards the
106+ end (but anywhere after ` -vmargs ` will do):
107+
108+ ```
109+ --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
110+ --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
111+ --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
112+ --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
113+ --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
114+ --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
115+ ```
116+
117+ Once you've done that, restart the IDE.
94118
95119### Third-party integrations
96120
Original file line number Diff line number Diff line change @@ -60,9 +60,17 @@ public void closeBraces(int initialIndent) {
6060 }
6161
6262 private static final int INDENTATION_SIZE = 2 ;
63- private final Formatter formatter = new Formatter () ;
63+ private final Formatter formatter ;
6464 private static final CharMatcher NOT_WHITESPACE = CharMatcher .whitespace ().negate ();
6565
66+ public SnippetFormatter () {
67+ this (JavaFormatterOptions .defaultOptions ());
68+ }
69+
70+ public SnippetFormatter (JavaFormatterOptions formatterOptions ) {
71+ formatter = new Formatter (formatterOptions );
72+ }
73+
6674 public String createIndentationString (int indentationLevel ) {
6775 Preconditions .checkArgument (
6876 indentationLevel >= 0 ,
You can’t perform that action at this time.
0 commit comments