Skip to content

Commit d059539

Browse files
committed
Polish 'Create Visual Studio Code extension'
Refine extension to use stdin/stdout to communicate with the Java code rather than using an HTTP endpoint. This commit also restructures the way that the extension is built and reduces the number of Maven projects. It also drops Markdown formatting support. See gh-142
1 parent 6bfc715 commit d059539

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4566
-1131
lines changed

Diff for: CONTRIBUTING.adoc

+16-1
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,35 @@ To add gradle classes, convert this module to a gradle project.
167167

168168

169169

170+
=== Setting up Visual Studio Code Extension Development
171+
The `spring-javaformat-vscode-extension` extension consists of a formatter written in Java and an extension written in TypeScript.
172+
If you want to work on the TypeScript code it can opened directly with Visual Studio Code.
173+
174+
Maven delegates to `npm run package` to actually generate the extension.
175+
176+
Code is formatted with prettier.
177+
If you need to reform the code you can run `npx prettier --write .`
178+
179+
There is a basic test included with the project, but since it needs UI elements it doesn't run as part of the regular build.
180+
If you make changes to the extension, you should run "`Extension Tests`" from vscode.
181+
182+
183+
170184
=== Importing Into Other IDEs
171185
Maven is well supported by most Java IDEs. Refer to your vendor documentation.
172186

173187

174188

175189
== Understanding the Code
176190
There are quite a few moving parts to this project and the build is quite complex.
177-
At the top level there are 5 projects:
191+
At the top level there are 6 projects:
178192

179193
* `spring-javaformat` - The main formatter project
180194
* `spring-javaformat-eclipse` - The Eclipse plugin
181195
* `spring-javaformat-gradle` - The Gradle plugin
182196
* `spring-javaformat-intellij` - The IntelliJ IDEA plugin
183197
* `spring-javaformat-maven` - The Maven plugin
198+
* `spring-javaformat-vscode` - The Visual Studo Code extension
184199

185200
Under `spring-javaformat` the following projects are defined:
186201

Diff for: README.adoc

+6-2
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,12 @@ Once the configuration file is created, configure your IDE to use it:
269269

270270

271271
=== Visual Studio Code
272-
The vscode extension provides custom formatter support for Visual Studio Code.
273-
The extension is automatically activated whenever a `.java` file is opened. And it requires a few seconds to warm-up while you start with the first workspace.
272+
The Visual Studio Code extension provides custom formatter support for Microsoft Visual Studio Code.
273+
The extension using the [`DocumentFormattingEditProvider`](https://code.visualstudio.com/api/references/vscode-api#DocumentFormattingEditProvider) API.
274+
Once installed it may be activated by using the "`Format Document`" action available in the editor context menu or from the Command Palette.
275+
276+
To install the extension select "`Install from VSIX`" in the extensions panel and choose the `spring-javaformat-vscode-extension` vsix file.
277+
You can download the latest version from https://repo1.maven.org/maven2/io/spring/javaformat/spring-javaformat-vscode-extension/{release-version}[Maven Central].
274278

275279

276280

Diff for: pom.xml

+27-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
<build>
6060
<pluginManagement>
6161
<plugins>
62+
<plugin>
63+
<groupId>com.github.eirslett</groupId>
64+
<artifactId>frontend-maven-plugin</artifactId>
65+
<version>1.12.1</version>
66+
</plugin>
6267
<plugin>
6368
<groupId>com.github.wvengen</groupId>
6469
<artifactId>proguard-maven-plugin</artifactId>
@@ -362,6 +367,25 @@
362367
<ignore />
363368
</action>
364369
</pluginExecution>
370+
<pluginExecution>
371+
<pluginExecutionFilter>
372+
<groupId>
373+
com.github.eirslett
374+
</groupId>
375+
<artifactId>
376+
frontend-maven-plugin
377+
</artifactId>
378+
<versionRange>
379+
[1.12.1,)
380+
</versionRange>
381+
<goals>
382+
<goal>npx</goal>
383+
</goals>
384+
</pluginExecutionFilter>
385+
<action>
386+
<ignore></ignore>
387+
</action>
388+
</pluginExecution>
365389
</pluginExecutions>
366390
</lifecycleMappingMetadata>
367391
</configuration>
@@ -597,10 +621,11 @@
597621
</dependencies>
598622
<modules>
599623
<module>spring-javaformat</module>
600-
<module>spring-javaformat-maven</module>
601-
<module>spring-javaformat-gradle</module>
602624
<module>spring-javaformat-eclipse</module>
625+
<module>spring-javaformat-gradle</module>
603626
<module>spring-javaformat-intellij-idea</module>
627+
<module>spring-javaformat-maven</module>
628+
<module>spring-javaformat-vscode</module>
604629
</modules>
605630
<profiles>
606631
<profile>

Diff for: spring-javaformat-maven/spring-javaformat-maven-plugin/pom.xml

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
</properties>
1616
<build>
1717
<plugins>
18+
<plugin>
19+
<artifactId>maven-clean-plugin</artifactId>
20+
<configuration>
21+
<filesets>
22+
<fileset>
23+
<directory>out</directory>
24+
</fileset>
25+
</filesets>
26+
</configuration>
27+
</plugin>
1828
<plugin>
1929
<groupId>org.apache.maven.plugins</groupId>
2030
<artifactId>maven-invoker-plugin</artifactId>

Diff for: spring-javaformat-vscode/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
<main.basedir>${basedir}/..</main.basedir>
1616
</properties>
1717
<modules>
18-
<module>spring-javaformat-format-service</module>
18+
<module>spring-javaformat-vscode-extension</module>
1919
</modules>
2020
</project>

Diff for: spring-javaformat-vscode/spring-javaformat-format-service/.vscode/launch.json

-11
This file was deleted.

Diff for: spring-javaformat-vscode/spring-javaformat-format-service/.vscode/settings.json

-4
This file was deleted.

Diff for: spring-javaformat-vscode/spring-javaformat-format-service/pom.xml

-121
This file was deleted.

Diff for: spring-javaformat-vscode/spring-javaformat-format-service/src/main/java/io/spring/format/controllers/FormatController.java

-42
This file was deleted.

Diff for: spring-javaformat-vscode/spring-javaformat-format-service/src/main/java/io/spring/format/controllers/HealthController.java

-43
This file was deleted.

0 commit comments

Comments
 (0)