Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync upstream changes. #3

Merged
merged 46 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
81aaab9
Update outdated Javadoc links
anthonyvdotbe Dec 18, 2019
ed40e47
Fix a crash on c-style arrays in parameters
cushon Dec 19, 2019
45e4afb
Add SBT plugin to readme
benmccann Dec 20, 2019
8a215cd
annotation/parameterless annotation
cushon Dec 20, 2019
1288c85
Tell maven-javadoc-plugin to target JDK 8
cgrushko Jan 3, 2020
05f57ec
Remove trailing tabs from comments to make behavior idempotent.
Eckaaaaaat Jan 6, 2020
eb76f92
Migrate from JSR-305 to the Checker Framework annotations
cushon Mar 13, 2020
cdf7665
Add Java 11 regression tests
cushon Mar 17, 2020
3c191c1
Use the built-in JDK 11 javac
cushon Mar 18, 2020
20e38aa
Increase minimum required JDK version to 11
cushon Mar 19, 2020
d6d0b4d
Use the default / latest supported language level
cushon Mar 20, 2020
b810032
Preserve tabular arguments for mixed sign numeric lists.
andrewkreid Mar 26, 2020
4ddb914
Add initial support for Java 14 language features
cushon Mar 27, 2020
16b56a3
Make re-parsing of var more robust
cushon Apr 21, 2020
7ba82f7
Update the open-source google-java-format plugin for 2020.1.
plumpy Apr 27, 2020
ca529a2
Fix formatting of records without an explicit constructor
cushon Apr 27, 2020
e19b763
Support `var` in enhanced for loops
cushon Apr 28, 2020
b53d614
Minor Javadoc improvement.
a-googler May 1, 2020
d1c2aef
Fix javadoc syntax
sormuras May 1, 2020
c525db0
Pre-release javadoc fixes
cushon May 1, 2020
0354f02
Increment versions for 1.8 release
cushon May 1, 2020
f5a9280
Fix a crash in expression switches
cushon May 11, 2020
98c8525
Split up the string "M" + "OE:(begin|end)_intracomment_stripping," as…
cpovirk May 13, 2020
2ddcfd3
Addition of a third party: Github Actions
av1m May 27, 2020
22d8c55
Java 14 integration tests
cushon Jun 3, 2020
5202af9
Add support for yield statement
ntkoopman Jun 4, 2020
1e4f14f
Support --skip-removing-unused-imports in google-java-format-diff.py
taesu82 Jun 9, 2020
c2c8a51
Update the IDEA plugin to use google-java-format 1.8.
java-team-github-bot Jun 26, 2020
02a072f
Add missing license headers.
Jul 11, 2020
1715884
Disable Appveyor builds on branches.
Jul 11, 2020
45fb41a
Fix the google-java-format IDEA plugin for 2020.2 IDEs.
java-team-github-bot Jul 13, 2020
062e5d2
Update links to Spotless' new documentation layout
nedtwigg Jul 23, 2020
1c45fa5
Bump versions to 1.9
cushon Aug 24, 2020
1614b6a
Increment versions after 1.10 release
cushon Aug 24, 2020
6bde01e
Bump checker-qual from 2.0.0 to 3.6.1
mernst Sep 15, 2020
f77e927
Update the IntelliJ plugin to google-java-format 1.9.
plumpy Sep 17, 2020
ea4828a
Upgrade junit dependency to 4.13.1
cushon Oct 13, 2020
b769e81
Tolerate extra semi-colons in import lists
cushon Oct 14, 2020
93d649d
Move import ordering tests out of the AOSP section
cushon Oct 16, 2020
3ce0935
Remove typo period in flags documentation.
java-team-github-bot Nov 20, 2020
c1dd08d
Introduce GitHub Actions based CI workflow
sormuras Nov 25, 2020
fcf7671
Check build with JDK 16-ea
sormuras Nov 30, 2020
d25a844
Fix GitHub Actions-based snapshot deployment
cushon Nov 30, 2020
cc58ed3
Delete google-java-format appveyor and travis configs
cushon Dec 2, 2020
8ba2b05
Miscellaneous cleanups
cushon Dec 4, 2020
0a2f864
Prepare google-java-format for JDK 16 ea
cushon Dec 14, 2020
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
100 changes: 100 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Copyright 2020 The Error Prone Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: CI

on: [ push, pull_request ]

jobs:
test:
name: "JDK ${{ matrix.java }} on ${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
java: [ 15, 11 ]
runs-on: ${{ matrix.os }}
steps:
- name: 'Check out repository'
uses: actions/checkout@v2
- name: 'Cache local Maven repository'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: 'Set up JDK ${{ matrix.java }}'
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: 'Install'
shell: bash
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
- name: 'Test'
shell: bash
run: mvn test -B

early_access:
name: 'JDK Early-Access'
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: 'Check out repository'
uses: actions/checkout@v2
- name: 'Cache local Maven repository'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: 'Set up JDK ${{ matrix.java }}'
uses: actions/setup-java@v1
with:
java-version: 16-ea
- name: 'Install'
shell: bash
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
- name: 'Test'
shell: bash
run: mvn test -B

publish_snapshot:
name: 'Publish snapshot'
needs: test
if: github.event_name == 'push' && github.repository == 'google/google-java-format' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: 'Check out repository'
uses: actions/checkout@v2
- name: 'Cache local Maven repository'
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: 'Set up JDK 15'
uses: actions/setup-java@v1
with:
java-version: 15
server-id: sonatype-nexus-snapshots
server-username: CI_DEPLOY_USERNAME
server-password: CI_DEPLOY_PASSWORD
- name: 'Publish'
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
run: mvn source:jar deploy -B -DskipTests=true -Dinvoker.skip=true -Dmaven.javadoc.skip=true
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
and run it with:

```
java -jar /path/to/google-java-format-1.7-all-deps.jar <options> [files...]
java -jar /path/to/google-java-format-1.9-all-deps.jar <options> [files...]
```

The formatter can act on whole files, on limited lines (`--lines`), on specific
Expand Down Expand Up @@ -55,7 +55,7 @@ and import it into File→Settings→Editor→Code Style.

### Eclipse

A
Version 1.6 of the
[google-java-format Eclipse plugin](https://github.com/google/google-java-format/releases/download/google-java-format-1.6/google-java-format-eclipse-plugin_1.6.0.jar)
can be downloaded from the releases page. Drop it into the Eclipse
[drop-ins folder](http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fp2_dropins_format.html)
Expand All @@ -68,17 +68,23 @@ Implementation`.
### Third-party integrations

* Gradle plugins
* [Spotless](https://github.com/diffplug/spotless/tree/master/plugin-gradle#applying-to-java-source-google-java-format):
* [spotless](https://github.com/diffplug/spotless/tree/main/plugin-gradle#google-java-format)
* [sherter/google-java-format-gradle-plugin](https://github.com/sherter/google-java-format-gradle-plugin)
* Apache Maven plugins
* [spotless](https://github.com/diffplug/spotless/tree/main/plugin-maven#google-java-format)
* [coveo/fmt-maven-plugin](https://github.com/coveo/fmt-maven-plugin)
* [talios/googleformatter-maven-plugin](https://github.com/talios/googleformatter-maven-plugin)
* [Cosium/maven-git-code-format](https://github.com/Cosium/maven-git-code-format):
A maven plugin that automatically deploys google-java-format as a
pre-commit git hook.
* SBT plugins
* [sbt/sbt-java-formatter](https://github.com/sbt/sbt-java-formatter)
* [maltzj/google-style-precommit-hook](https://github.com/maltzj/google-style-precommit-hook):
A pre-commit (pre-commit.com) hook that will automatically run GJF whenever
you commit code to your repository
* [Github Actions](https://github.com/features/actions)
* [googlejavaformat-action](https://github.com/axel-op/googlejavaformat-action):
Automatically format your Java files when you push on github

### as a library

Expand All @@ -92,15 +98,15 @@ configuration.
<dependency>
<groupId>com.google.googlejavaformat</groupId>
<artifactId>google-java-format</artifactId>
<version>1.7</version>
<version>1.9</version>
</dependency>
```

#### Gradle

```groovy
dependencies {
compile 'com.google.googlejavaformat:google-java-format:1.7'
compile 'com.google.googlejavaformat:google-java-format:1.9'
}
```

Expand Down
32 changes: 0 additions & 32 deletions appveyor.yml

This file was deleted.

61 changes: 51 additions & 10 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.google.googlejavaformat</groupId>
<artifactId>google-java-format-parent</artifactId>
<version>1.8-SNAPSHOT</version>
<version>1.10-SNAPSHOT</version>
</parent>

<artifactId>google-java-format</artifactId>
Expand All @@ -39,15 +39,11 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>javac-shaded</artifactId>
</dependency>

<!-- Compile-time dependencies -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -83,14 +79,23 @@
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<source>11</source>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<charset>UTF-8</charset>
<links>
<link>https://google.github.io/guava/releases/${guava.version}/api/docs/</link>
<link>https://javadoc.io/page/com.google.code.findbugs/jsr305/${jsr305.version}/</link>
<link>https://docs.oracle.com/javase/8/docs/api/</link>
<link>https://guava.dev/releases/${guava.version}/api/docs/</link>
<link>https://docs.oracle.com/en/java/javase/11/docs/api</link>
</links>
<additionalJOptions>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED,com.google.googlejavaformat</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED,com.google.googlejavaformat</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED,com.google.googlejavaformat</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED,com.google.googlejavaformat</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED,com.google.googlejavaformat</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED,com.google.googlejavaformat</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,com.google.googlejavaformat</additionalJOption>
</additionalJOptions>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -238,6 +243,42 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>jdk11</id>
<activation>
<jdk>(,14)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/Java14InputAstVisitor.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<excludePackageNames>com.google.googlejavaformat.java.java14</excludePackageNames>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
3 changes: 2 additions & 1 deletion core/src/main/java/com/google/googlejavaformat/Doc.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.google.googlejavaformat;

import static com.google.common.collect.Iterables.getLast;
import static java.lang.Math.max;

import com.google.common.base.MoreObjects;
import com.google.common.collect.DiscreteDomain;
Expand Down Expand Up @@ -653,7 +654,7 @@ public State computeBreaks(State state, int lastIndent, boolean broken) {

if (broken) {
this.broken = true;
this.newIndent = Math.max(lastIndent + plusIndent.eval(), 0);
this.newIndent = max(lastIndent + plusIndent.eval(), 0);
return state.withColumn(newIndent);
} else {
this.broken = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

package com.google.googlejavaformat;

import static java.lang.Math.max;
import static java.lang.Math.min;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableList;
Expand All @@ -39,14 +42,14 @@ public int actualSize(int position, int length) {
int start = startToken.getTok().getPosition();
for (Tok tok : startToken.getToksBefore()) {
if (tok.isComment()) {
start = Math.min(start, tok.getPosition());
start = min(start, tok.getPosition());
}
}
Token endToken = input.getPositionTokenMap().get(position + length - 1);
int end = endToken.getTok().getPosition() + endToken.getTok().length();
for (Tok tok : endToken.getToksAfter()) {
if (tok.isComment()) {
end = Math.max(end, tok.getPosition() + tok.length());
end = max(end, tok.getPosition() + tok.length());
}
}
return end - start;
Expand All @@ -62,7 +65,7 @@ public Integer actualStartColumn(int position) {
return start;
}
if (tok.isComment()) {
start = Math.min(start, tok.getPosition());
start = min(start, tok.getPosition());
}
}
return start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static CommandLineOptions parse(Iterable<String> options) {
int idx = option.indexOf('=');
if (idx >= 0) {
flag = option.substring(0, idx);
value = option.substring(idx + 1, option.length());
value = option.substring(idx + 1);
} else {
flag = option;
value = null;
Expand Down
Loading