-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
9,111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Website | ||
|
||
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. | ||
|
||
### Installation | ||
|
||
``` | ||
$ yarn | ||
``` | ||
|
||
### Local Development | ||
|
||
``` | ||
$ yarn start | ||
``` | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. | ||
|
||
### Build | ||
|
||
``` | ||
$ yarn build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static contents hosting service. | ||
|
||
### Deployment | ||
|
||
Using SSH: | ||
|
||
``` | ||
$ USE_SSH=true yarn deploy | ||
``` | ||
|
||
Not using SSH: | ||
|
||
``` | ||
$ GIT_USER=<Your GitHub username> yarn deploy | ||
``` | ||
|
||
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [require.resolve("@docusaurus/core/lib/babel/preset")] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
author: "Jordan Kiesel (@jtkiesel)" | ||
authorURL: "https://github.com/jtkiesel" | ||
title: "Prettier Java 2.5: Java 21 unnamed patterns and variables preview feature!" | ||
--- | ||
|
||
This release adds support for the Java 21 preview feature: unnamed patterns and variables ([JEP 443](https://openjdk.org/jeps/443))! | ||
|
||
<!-- truncate --> | ||
|
||
## Highlights | ||
|
||
### Support Java 21 preview feature: unnamed patterns and variables ([#620](https://github.com/jhipster/prettier-java/pull/620) by [@jtkiesel](https://github.com/jtkiesel)) | ||
|
||
We’ve added support for the Java 21 preview feature "Unnamed Patterns and Variables": | ||
|
||
#### Unnamed pattern variables | ||
|
||
```java | ||
// Example | ||
r instanceof Point _ | ||
``` | ||
|
||
#### Unnamed variables | ||
|
||
```java | ||
// Example | ||
int acc = 0; | ||
for (Order _ : orders) { | ||
if (acc < LIMIT) { | ||
// ... acc++ ... | ||
} | ||
} | ||
``` | ||
|
||
## Other Changes | ||
|
||
### New entrypoint `lexAndParse` to return both tokens and CST ([#625](https://github.com/jhipster/prettier-java/pull/625) by [@max-schaefer](https://github.com/max-schaefer)) | ||
|
||
Provide an entrypoint that exposes both the CST and the underlying token array. | ||
|
||
### No longer ignore whole block when `prettier-ignore` at start ([#603](https://github.com/jhipster/prettier-java/pull/603) by [@jtkiesel](https://github.com/jtkiesel)) | ||
|
||
When a block begins with `// prettier-ignore`, only the first statement is ignored, rather than the whole block. | ||
|
||
<!-- prettier-ignore --> | ||
```java | ||
// Input | ||
void foo() { | ||
// prettier-ignore | ||
var bar = List.of( | ||
1 | ||
); | ||
|
||
var baz = 2; | ||
} | ||
|
||
// Prettier Java 2.4 | ||
void foo() { | ||
// prettier-ignore | ||
var bar = List.of( | ||
1 | ||
); | ||
|
||
var baz = 2; | ||
} | ||
|
||
// Prettier Java 2.5 | ||
void foo() { | ||
// prettier-ignore | ||
var bar = List.of( | ||
1 | ||
); | ||
|
||
var baz = 2; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Introduction | ||
|
||
Prettier Java is an opinionated Java code formatter. | ||
|
||
It removes all original styling and ensures that all outputted code conforms to a consistent style. | ||
|
||
Prettier Java takes your code and reprints it from scratch by taking the line length into account. | ||
|
||
For example, take the following code: | ||
|
||
```java | ||
foo(arg1, arg2, arg3, arg4); | ||
``` | ||
|
||
It fits in a single line so it's going to stay as is. However, we've all run into this situation: | ||
|
||
<!-- prettier-ignore --> | ||
```java | ||
foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne()); | ||
``` | ||
|
||
Suddenly our previous format for calling function breaks down because this is too long. Prettier Java is going to do the painstaking work of reprinting it like that for you: | ||
|
||
```java | ||
foo( | ||
reallyLongArg(), | ||
omgSoManyParameters(), | ||
IShouldRefactorThis(), | ||
isThereSeriouslyAnotherOne() | ||
); | ||
``` | ||
|
||
Prettier Java enforces a consistent code **style** (i.e. code formatting that won't affect the AST) across your entire codebase because it disregards the original styling by parsing it away and re-printing the parsed AST with its own rules that take the maximum line length into account, wrapping code when necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import TabItem from "@theme/TabItem"; | ||
import Tabs from "@theme/Tabs"; | ||
|
||
# Installation | ||
|
||
## Requirements | ||
|
||
- [Node.js](https://nodejs.org/en/download/) version 10.0 or above | ||
|
||
## Install Prettier and the Prettier Java plugin | ||
|
||
<Tabs> | ||
<TabItem value="npm"> | ||
|
||
```sh | ||
npm install --save-dev --save-exact prettier prettier-plugin-java | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="Yarn"> | ||
|
||
```sh | ||
yarn add --dev --exact prettier prettier-plugin-java | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="pnpm"> | ||
|
||
```sh | ||
pnpm add --save-dev --save-exact prettier prettier-plugin-java | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import type { Options, ThemeConfig } from "@docusaurus/preset-classic"; | ||
import type { Config } from "@docusaurus/types"; | ||
import { themes } from "prism-react-renderer"; | ||
import { | ||
homepage, | ||
repository | ||
} from "../packages/prettier-plugin-java/package.json"; | ||
|
||
const { origin: url, pathname: baseUrl } = new URL(homepage); | ||
const [, organizationName, projectName] = new URL(repository).pathname.split( | ||
"/" | ||
); | ||
const editUrl = `${repository}/tree/docs/create-website/website/`; | ||
|
||
export default { | ||
title: "Prettier Java", | ||
tagline: "Prettier code formatter plugin for Java", | ||
favicon: "img/favicon.png", | ||
trailingSlash: false, | ||
url, | ||
baseUrl, | ||
organizationName, | ||
projectName, | ||
i18n: { | ||
defaultLocale: "en", | ||
locales: ["en"] | ||
}, | ||
presets: [ | ||
[ | ||
"classic", | ||
{ | ||
docs: { editUrl }, | ||
blog: { editUrl }, | ||
theme: { | ||
customCss: "./src/css/custom.css" | ||
} | ||
} satisfies Options | ||
] | ||
], | ||
themeConfig: { | ||
colorMode: { | ||
respectPrefersColorScheme: true | ||
}, | ||
image: "img/banner-dark.png", | ||
navbar: { | ||
title: "Prettier Java", | ||
logo: { | ||
alt: "Prettier Java Logo", | ||
src: "img/icon.svg", | ||
srcDark: "img/icon-dark.svg" | ||
}, | ||
items: [ | ||
{ label: "Playground", to: "/playground", position: "left" }, | ||
{ label: "Docs", to: "/docs", position: "left" }, | ||
{ label: "Blog", to: "/blog", position: "left" }, | ||
{ label: "GitHub", to: repository, position: "right" } | ||
] | ||
}, | ||
footer: { | ||
style: "dark", | ||
links: [ | ||
{ | ||
title: "Docs", | ||
items: [ | ||
{ label: "Introduction", to: "/docs" }, | ||
{ label: "Installation", to: "/docs/installation" } | ||
] | ||
}, | ||
{ | ||
title: "Community", | ||
items: [ | ||
{ | ||
label: "@JHipster on Twitter", | ||
to: "https://twitter.com/jhipster" | ||
} | ||
] | ||
}, | ||
{ | ||
title: "More", | ||
items: [ | ||
{ label: "Blog", to: "/blog" }, | ||
{ label: "GitHub", to: repository }, | ||
{ label: "Issues", to: `${repository}/issues` } | ||
] | ||
} | ||
] | ||
}, | ||
prism: { | ||
theme: themes.github, | ||
darkTheme: themes.dracula, | ||
additionalLanguages: ["bash", "java"] | ||
} | ||
} satisfies ThemeConfig | ||
} satisfies Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "website", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"docusaurus": "docusaurus", | ||
"start": "docusaurus start", | ||
"build": "docusaurus build", | ||
"swizzle": "docusaurus swizzle", | ||
"deploy": "docusaurus deploy", | ||
"clear": "docusaurus clear", | ||
"serve": "docusaurus serve", | ||
"write-translations": "docusaurus write-translations", | ||
"write-heading-ids": "docusaurus write-heading-ids", | ||
"typecheck": "tsc" | ||
}, | ||
"dependencies": { | ||
"@docusaurus/core": "3.1.0", | ||
"@docusaurus/preset-classic": "3.1.0", | ||
"@mdx-js/react": "3.0.0", | ||
"@monaco-editor/react": "4.6.0", | ||
"prettier": "3.2.2", | ||
"prettier-plugin-java": "link:./../packages/prettier-plugin-java", | ||
"prism-react-renderer": "2.3.1", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@docusaurus/module-type-aliases": "3.1.0", | ||
"@docusaurus/tsconfig": "3.1.0", | ||
"@docusaurus/types": "3.1.0", | ||
"@types/react": "18.2.47", | ||
"typescript": "5.3.3" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.5%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 3 chrome version", | ||
"last 3 firefox version", | ||
"last 5 safari version" | ||
] | ||
}, | ||
"engines": { | ||
"node": ">=18.0" | ||
} | ||
} |
Oops, something went wrong.