Skip to content

Commit

Permalink
Polish 'Create Visual Studio Code extension'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
philwebb committed Feb 15, 2023
1 parent 6bfc715 commit d059539
Show file tree
Hide file tree
Showing 50 changed files with 4,566 additions and 1,131 deletions.
17 changes: 16 additions & 1 deletion CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,35 @@ To add gradle classes, convert this module to a gradle project.



=== Setting up Visual Studio Code Extension Development
The `spring-javaformat-vscode-extension` extension consists of a formatter written in Java and an extension written in TypeScript.
If you want to work on the TypeScript code it can opened directly with Visual Studio Code.

Maven delegates to `npm run package` to actually generate the extension.

Code is formatted with prettier.
If you need to reform the code you can run `npx prettier --write .`

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.
If you make changes to the extension, you should run "`Extension Tests`" from vscode.



=== Importing Into Other IDEs
Maven is well supported by most Java IDEs. Refer to your vendor documentation.



== Understanding the Code
There are quite a few moving parts to this project and the build is quite complex.
At the top level there are 5 projects:
At the top level there are 6 projects:

* `spring-javaformat` - The main formatter project
* `spring-javaformat-eclipse` - The Eclipse plugin
* `spring-javaformat-gradle` - The Gradle plugin
* `spring-javaformat-intellij` - The IntelliJ IDEA plugin
* `spring-javaformat-maven` - The Maven plugin
* `spring-javaformat-vscode` - The Visual Studo Code extension

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

Expand Down
8 changes: 6 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,12 @@ Once the configuration file is created, configure your IDE to use it:


=== Visual Studio Code
The vscode extension provides custom formatter support for Visual Studio Code.
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.
The Visual Studio Code extension provides custom formatter support for Microsoft Visual Studio Code.
The extension using the [`DocumentFormattingEditProvider`](https://code.visualstudio.com/api/references/vscode-api#DocumentFormattingEditProvider) API.
Once installed it may be activated by using the "`Format Document`" action available in the editor context menu or from the Command Palette.

To install the extension select "`Install from VSIX`" in the extensions panel and choose the `spring-javaformat-vscode-extension` vsix file.
You can download the latest version from https://repo1.maven.org/maven2/io/spring/javaformat/spring-javaformat-vscode-extension/{release-version}[Maven Central].



Expand Down
29 changes: 27 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.1</version>
</plugin>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
Expand Down Expand Up @@ -362,6 +367,25 @@
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.github.eirslett
</groupId>
<artifactId>
frontend-maven-plugin
</artifactId>
<versionRange>
[1.12.1,)
</versionRange>
<goals>
<goal>npx</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
Expand Down Expand Up @@ -597,10 +621,11 @@
</dependencies>
<modules>
<module>spring-javaformat</module>
<module>spring-javaformat-maven</module>
<module>spring-javaformat-gradle</module>
<module>spring-javaformat-eclipse</module>
<module>spring-javaformat-gradle</module>
<module>spring-javaformat-intellij-idea</module>
<module>spring-javaformat-maven</module>
<module>spring-javaformat-vscode</module>
</modules>
<profiles>
<profile>
Expand Down
10 changes: 10 additions & 0 deletions spring-javaformat-maven/spring-javaformat-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>out</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion spring-javaformat-vscode/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
<main.basedir>${basedir}/..</main.basedir>
</properties>
<modules>
<module>spring-javaformat-format-service</module>
<module>spring-javaformat-vscode-extension</module>
</modules>
</project>

This file was deleted.

This file was deleted.

121 changes: 0 additions & 121 deletions spring-javaformat-vscode/spring-javaformat-format-service/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit d059539

Please sign in to comment.