Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: pr-check

on:
pull_request:
types:
# default types
- opened
- reopened
- synchronize
# run when PR title or body changes
- edited
branches:
- main
jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/iron"
cache: "npm"

- name: Install dependencies
run: npm install

- name: Check that project is able to be packaged
run: npm run package

- name: Check that PR title follows conventional commits using regex
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
echo "Your PR title is '$TITLE'"

regex="(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z[[:space:]]+\))?:[[:space:]].+"

if [[ $TITLE =~ $regex ]]; then
echo "PR title follows conventional commits"
else
echo "PR title does not follow conventional commits format"
echo "Prefix your PR title with a descriptor such as 'feat:' and then summarize your change"
echo "See the following link for more information: https://www.conventionalcommits.org/en/v1.0.0/"
exit 1
fi
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
dist
.vsix
*.vsix
4 changes: 0 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
Expand Down
2 changes: 0 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
Expand Down
17 changes: 9 additions & 8 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.vscode/**
out/**
.github
.vscode
node_modules/**
!node_modules/prettier
src/**
**/*.map
.gitignore
.yarnrc
.prettierrc
esbuild.js
vsc-extension-quickstart.md
**/tsconfig.json
**/eslint.config.mjs
**/*.map
**/*.ts
eslint.config.mjs
package-lock.json
tsconfig.json
*.vsix
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Change Log
# Changelog

All notable changes to the "prettier-plugin-java-vscode" extension will be documented in this file.
All notable changes to this project will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.0.0]

- Initial release
- Initial release
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2025] [Rudra Patel]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
68 changes: 13 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,29 @@
# prettier-plugin-java-vscode README
# Prettier Java Plugin

This is the README for your extension "prettier-plugin-java-vscode". After writing up a brief description, we recommend including the following sections.
A VSCode extension to format Java files with Prettier using prettier-plugin-java.

## Features

Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.

For example if there is an image subfolder under your extension project workspace:

\!\[feature X\]\(images/feature-x.png\)

> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.

## Requirements

If you have any requirements or dependencies, add a section describing those and how to install and configure them.
- Format Java files with no configuration necessary
- Specify a Prettier config file to use if desired

## Extension Settings

Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
To set this formatter as the default formatter for Java files, add the following to your VSCode settings:

For example:
```json
"[java]": {
"editor.defaultFormatter": "RudraPatel.prettier-plugin-java-vscode"
}
```

This extension contributes the following settings:

* `myExtension.enable`: Enable/disable this extension.
* `myExtension.thing`: Set to `blah` to do something.

## Known Issues

Calling out known issues can help limit users opening duplicate issues against your extension.
- `prettier-plugin-java-vscode.enabled`: Enable/disable the plugin.
- `prettier-plugin-java-vscode.prettierConfigPath`: Provide a absolution path to your prettier configuration file.

## Release Notes

Users appreciate release notes as you update your extension.

### 1.0.0

Initial release of ...

### 1.0.1

Fixed issue #.

### 1.1.0

Added features X, Y, and Z.

---

## Following extension guidelines

Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.

* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines)

## Working with Markdown

You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:

* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux).
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux).
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets.

## For more information

* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)

**Enjoy!**
- Initial release
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "prettier-plugin-java-vscode",
"displayName": "prettier-plugin-java For VSCode",
"description": "A VSCode plugin that uses prettier-plugin-java to format .java files. Based on the now removed mwpb.java-prettier-formatter extension.",
"displayName": "Prettier Java Plugin",
"description": "Format Java files with Prettier using prettier-plugin-java.",
"version": "1.0.0",
"publisher": "RudraPatel",
"license": "MIT",
Expand All @@ -25,8 +25,9 @@
"categories": [
"Formatters"
],
"icon": "icon.png",
"activationEvents": [
"onLanguage:java"
"onStartupFinished"
],
"main": "./dist/extension.js",
"contributes": {
Expand All @@ -43,7 +44,7 @@
}
],
"configuration": {
"title": "Prettier Plugin Java VSCode",
"title": "Prettier Java Plugin",
"properties": {
"prettier-plugin-java-vscode.prettierConfigPath": {
"type": ["string", "null"],
Expand Down
6 changes: 3 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function formatJavaDocument(
const isEnabled = checkIfEnabled();

if (!isEnabled) {
log("Prettier Plugin Java VSCode is disabled");
log("Prettier Plugin Java VSCode is disabled\n");
return null;
}

Expand Down Expand Up @@ -50,13 +50,13 @@ async function formatJavaDocument(

const elapsedTime = Date.now() - start;

log(`Formatted ${document.fileName} in ${elapsedTime}ms.`);
log(`Formatted ${document.fileName} in ${elapsedTime}ms\n`);

return [TextEdit.replace(entireDocumentRange, formattedText)];
}

export function activate(context: ExtensionContext) {
log("Prettier Plugin Java VSCode activated.");
log("Prettier Plugin Java VSCode activated\n");

const disposable = languages.registerDocumentFormattingEditProvider("java", {
provideDocumentFormattingEdits: formatJavaDocument,
Expand Down
4 changes: 1 addition & 3 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { window } from "vscode";

// Create the output channel once at the module level
export const outputChannel = window.createOutputChannel(
"Prettier Plugin Java VSCode",
);
export const outputChannel = window.createOutputChannel("Prettier Java Plugin");

function getFormattedTime(): string {
return new Date().toLocaleTimeString("en-US");
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function getPretterConfigPath(document: TextDocument): Promise<string> {

if (!fileExists) {
log(
`Specified Prettier config file (${userProvidedConfigPath}) does not exist.`,
`Specified Prettier config file (${userProvidedConfigPath}) does not exist`,
);
log(
`Prettier will attempt to resolve the config file from the document file name (${document.fileName})`,
Expand All @@ -45,7 +45,7 @@ async function getPretterConfigPath(document: TextDocument): Promise<string> {
return userProvidedConfigPath;
}

log("No specified Prettier config file.");
log("No specified Prettier config file");
log(
`Prettier will attempt to resolve the config file from the document file name (${document.fileName})`,
);
Expand Down
48 changes: 0 additions & 48 deletions vsc-extension-quickstart.md

This file was deleted.

Loading