Skip to content

Commit

Permalink
Java 21: review reformart code + default gradle jdk compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
npeters committed Oct 29, 2023
1 parent c8e90f3 commit 396d2aa
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 31 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ subprojects {
apply plugin: 'java-library'
apply plugin: 'org.inferred.processors'


sourceCompatibility = 11
targetCompatibility = 11

tasks.withType(Checkstyle) {
enabled = false
Expand Down
5 changes: 1 addition & 4 deletions gradle-palantir-java-format/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ configurations {
implicitDependencies
pluginClasspath
}
java{
sourceCompatibility = 11
targetCompatibility = 11
}


dependencies {
implementation gradleApi()
Expand Down
4 changes: 0 additions & 4 deletions idea-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ configurations {
}
}

java{
sourceCompatibility = 11
targetCompatibility = 11
}

dependencies {
implementation project(':palantir-java-format-jdk-bootstrap')
Expand Down
5 changes: 0 additions & 5 deletions palantir-java-format-jdk-bootstrap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ apply plugin: 'java-library'
apply plugin: 'com.palantir.external-publish-jar'
apply plugin: 'com.palantir.revapi'

java{
sourceCompatibility = 11
targetCompatibility = 11
}

dependencies {
annotationProcessor "org.immutables:value"

Expand Down
4 changes: 0 additions & 4 deletions palantir-java-format-spi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ apply plugin: 'java-library'
apply plugin: 'com.palantir.external-publish-jar'
apply plugin: 'com.palantir.revapi'

java{
sourceCompatibility = 11
targetCompatibility = 11
}

dependencies {
api 'com.google.guava:guava'
Expand Down
10 changes: 2 additions & 8 deletions palantir-java-format/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ def exports = [
'jdk.compiler/com.sun.tools.javac.api'
]

java{
sourceCompatibility = 11
targetCompatibility = 11
}

def jvmArgList = exports.stream().map(new Function<String, String>() {
@Override
Expand All @@ -64,7 +60,6 @@ tasks.withType(JavaCompile).configureEach {
if (JavaVersion.current() < JavaVersion.VERSION_14) {
exclude '**/Java14InputAstVisitor.java'
}

}

tasks.withType(Test).configureEach {
Expand Down Expand Up @@ -93,7 +88,7 @@ tasks.test {

// necessary to compile Java14InputAstVisitor
idea {
module.languageLevel = new org.gradle.plugins.ide.idea.model.IdeaLanguageLevel(17)
module.languageLevel = new org.gradle.plugins.ide.idea.model.IdeaLanguageLevel(14)
}

// This block may be replaced by BaselineExportsExtension exports
Expand All @@ -106,8 +101,7 @@ jar {

tasks.named('jar', Jar){
// hack to get java21 Class ...
// the build script should be completely review to handle java 21
// the build script should be completely rewritten to handle java 21
from ('build/classes/java/main', '../palantir-java-format21/build/classes/java/main')

include('**/*')
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ static JavaOutput format(
OpsBuilder opsBuilder = new OpsBuilder(javaInput);

JavaInputAstVisitor visitor;

if (getRuntimeVersion() >= 21) {
try {
visitor = Class.forName("com.palantir.javaformat.java.java21.Java21InputAstVisitor")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOExcept
if (stringFragmentKind) {
stringFragmentEndPos = t.endPos();
}

} else if (tokText.startsWith("//") || tokText.startsWith("/*")) {
// For compatibility with an earlier lexer, the newline after a // comment is its own tok.
if (tokText.startsWith("//") && (originalTokText.endsWith("\n") || originalTokText.endsWith("\r"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ protected void handleModule(boolean first, CompilationUnitTree node) {}

/** Skips over extra semi-colons at the top-level, or in a class member declaration lists. */
protected void dropEmptyDeclarations() {

if (builder.peekToken().equals(Optional.of(";"))) {
while (builder.peekToken().equals(Optional.of(";"))) {
builder.forcedBreak();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ public Void visitDeconstructionPattern(DeconstructionPatternTree node, Void unus

Void r = scan(node.getDeconstructor(), unused);
token("(");

// r = scanAndReduceVoid(, unused, r);
boolean firstInRow = true;
for (PatternTree item : node.getNestedPatterns()) {
if (!firstInRow) {
Expand Down

0 comments on commit 396d2aa

Please sign in to comment.