Skip to content

Commit

Permalink
Merge branch 'main' into 4269_maven-activebydefault-profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
sambsnyd authored Oct 11, 2024
2 parents 17c836c + 49df680 commit 00da607
Show file tree
Hide file tree
Showing 355 changed files with 11,186 additions and 4,811 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/receive-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,9 @@ jobs:
displayName: Recipe nullability best practices
description: Use OpenRewrite internal nullability annotations; drop JetBrains annotations; use `package-info.java` instead.
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.jetbrains.annotations.Nullable
newFullyQualifiedTypeName: org.openrewrite.internal.lang.Nullable
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.annotation.Nullable
newFullyQualifiedTypeName: org.openrewrite.internal.lang.Nullable
- org.openrewrite.staticanalysis.NullableOnMethodReturnType
- org.openrewrite.java.RemoveAnnotation:
annotationPattern: '@org.jetbrains.annotations.NotNull'
- org.openrewrite.java.RemoveAnnotation:
annotationPattern: '@jakarta.annotation.Nonnull'
- org.openrewrite.java.jspecify.MigrateToJspecify
8 changes: 4 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -178,15 +178,15 @@ Apache License
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file formatPrefix. We also recommend that a
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=5b9c5eb3f9fc2c94abaea57d90bd78747ca117ddbbf96c859d3741181a12bf2a
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@State(Scope.Benchmark)
Expand All @@ -38,10 +39,13 @@ public void setup() throws URISyntaxException, IOException {
throw new RuntimeException("Unable to create directory");
}

sourceFiles = new ArrayList<>(1_000);
for (int i = 0; i < 1_000; i++) {
Files.writeString(test.resolve("Test" + i + ".java"),
"package test; class Test" + i + " {}");
sourceFiles = new ArrayList<>(100);
// to add some "meat to the bones"
String whitespace = String.join("", Collections.nCopies(1_000, " "));
for (int i = 0; i < 100; i++) {
Path path = test.resolve("Test" + i + ".java");
Files.writeString(path, "package test; class Test%d {%s}".formatted(i, whitespace));
sourceFiles.add(path);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,53 @@
package org.openrewrite.benchmarks.java;

import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.Parser;
import org.openrewrite.java.JavaParser;
import org.openrewrite.tree.ParsingExecutionContextView;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;

import static java.util.stream.Collectors.toList;

@Fork(1)
@Measurement(iterations = 2)
@Warmup(iterations = 2)
@BenchmarkMode(Mode.SampleTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@Threads(4)
public class ParserInputBenchmark {

@Benchmark
public void readFromDisk(JavaFiles state) {
//language=java
public void detectCharset(JavaFiles state, Blackhole bh) {
JavaParser.fromJavaVersion().build()
.parseInputs(state.getSourceFiles().stream()
.map(sourceFile -> new Parser.Input(sourceFile, () -> {
try {
return Files.newInputStream(sourceFile);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
})
)
.map(Parser.Input::fromFile)
.collect(toList()),
null,
new InMemoryExecutionContext());
new InMemoryExecutionContext()
)
.forEach(bh::consume);
}

@Benchmark
public void readFromDiskWithBufferedInputStream(JavaFiles state) {
//language=java
public void knownCharset(JavaFiles state, Blackhole bh) {
ParsingExecutionContextView ctx = ParsingExecutionContextView.view(new InMemoryExecutionContext())
.setCharset(StandardCharsets.UTF_8);
JavaParser.fromJavaVersion().build()
.parseInputs(state.getSourceFiles().stream()
.map(sourceFile -> new Parser.Input(sourceFile, () -> {
try {
return new BufferedInputStream(Files.newInputStream(sourceFile));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
})
)
.map(Parser.Input::fromFile)
.collect(toList()),
null,
new InMemoryExecutionContext());
ctx
)
.forEach(bh::consume);
}

public static void main(String[] args) throws RunnerException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.openrewrite.internal.lang.NonNull;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

import java.nio.file.Path;
Expand Down
4 changes: 2 additions & 2 deletions rewrite-core/src/main/java/org/openrewrite/Cursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public String toString() {
.map(t -> t instanceof Tree ?
t.getClass().getSimpleName() :
t.toString())
.collect(Collectors.joining("->"))
+ "}";
.collect(Collectors.joining("->")) +
"}";
}

public Cursor dropParentUntil(Predicate<Object> valuePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Tree postVisit(Tree tree, ExecutionContext ctx) {
return tree;
}

String snippet = tree instanceof SourceFile ? null : tree.printTrimmed(getCursor());
String snippet = tree instanceof SourceFile ? null : tree.printTrimmed(getCursor().getParentTreeCursor());
if (snippet != null && maxSnippetLength != null && snippet.length() > maxSnippetLength) {
snippet = snippet.substring(0, maxSnippetLength);
}
Expand Down
Loading

0 comments on commit 00da607

Please sign in to comment.