Skip to content

Commit

Permalink
Merge branch 'main' into run-subset-of-best-practices-on-PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Jun 7, 2024
2 parents 9a4702a + 0fffdf6 commit 120e9e9
Show file tree
Hide file tree
Showing 105 changed files with 232 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@
public @interface DocumentExample {
String value() default "";
}

Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public <T> T pollMessage(String key) {
return (T) messages.remove(key);
}

@Override
public Consumer<Throwable> getOnError() {
return onError;
}
Expand Down
6 changes: 1 addition & 5 deletions rewrite-core/src/main/java/org/openrewrite/RecipeRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
import org.openrewrite.config.DataTableDescriptor;
import org.openrewrite.internal.lang.Nullable;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.*;
import java.lang.reflect.Field;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down
1 change: 1 addition & 0 deletions rewrite-core/src/main/java/org/openrewrite/SourceFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ default String printAllTrimmed() {
return printAllTrimmed(0);
}

@Override
default <P> TreeVisitor<?, PrintOutputCapture<P>> printer(Cursor cursor) {
throw new UnsupportedOperationException("SourceFile implementations should override this method");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package org.openrewrite.binary;

import org.openrewrite.ExecutionContext;
import org.openrewrite.tree.ParseError;
import org.openrewrite.Parser;
import org.openrewrite.SourceFile;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.Markers;
import org.openrewrite.tree.ParseError;

import java.nio.file.Path;
import java.util.stream.Stream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private Root() {
super();
}

@Override
public CategoryTree.Root<G> removeAll(G group) {
// increase visibility and cast
return (Root<G>) super.removeAll(group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void write(String name, byte[] data) {
);
}

@Override
public Writer getSourceWriter(String className) {
return new Writer() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

import lombok.Value;
import lombok.With;
import org.openrewrite.Incubating;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.jgit.api.Git;
import org.openrewrite.jgit.api.errors.GitAPIException;
import org.openrewrite.jgit.lib.*;
import org.openrewrite.jgit.revwalk.RevCommit;
import org.openrewrite.jgit.transport.RemoteConfig;
import org.openrewrite.jgit.transport.URIish;
import org.openrewrite.jgit.treewalk.WorkingTreeOptions;
import org.openrewrite.Incubating;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.ci.BuildEnvironment;
import org.openrewrite.marker.ci.IncompleteGitConfigException;
import org.openrewrite.marker.ci.JenkinsBuildEnvironment;
Expand Down
2 changes: 2 additions & 0 deletions rewrite-core/src/main/java/org/openrewrite/remote/Remote.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ public interface Remote extends SourceFile {
<R extends Remote> R withDescription(String description);

@Nullable
@Override
default Checksum getChecksum() {
return null;
}

@Override
default <T extends SourceFile> T withChecksum(@Nullable Checksum checksum) {
//noinspection unchecked
return (T) this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public boolean isAcceptable(SourceFile sourceFile, P p) {
return sourceFile instanceof PlainText;
}

@Override
public boolean isAdaptableTo(@SuppressWarnings("rawtypes") Class<? extends TreeVisitor> adaptTo) {
if (adaptTo.isAssignableFrom(getClass())) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package org.openrewrite.internal;

import org.openrewrite.jgit.lib.FileMode;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openrewrite.jgit.lib.FileMode;

import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
*/
package org.openrewrite.marker;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.openrewrite.jgit.api.Git;
import org.openrewrite.jgit.api.errors.GitAPIException;
import org.openrewrite.jgit.lib.Constants;
import org.openrewrite.jgit.lib.RepositoryCache;
import org.openrewrite.jgit.transport.TagOpt;
import org.openrewrite.jgit.transport.URIish;
import org.openrewrite.jgit.util.FS;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.openrewrite.marker.ci.*;

import java.io.ByteArrayOutputStream;
Expand All @@ -44,9 +44,9 @@

import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.openrewrite.jgit.lib.ConfigConstants.CONFIG_BRANCH_SECTION;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.openrewrite.Tree.randomId;
import static org.openrewrite.jgit.lib.ConfigConstants.CONFIG_BRANCH_SECTION;

@SuppressWarnings({"ConstantConditions", "HttpUrlsUsage"})
class GitProvenanceTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public Builder settingsClasspathFromResources(ExecutionContext ctx, String... ar
return this;
}

@Override
public GradleParser build() {
return new GradleParser(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ void nullArgument() {
);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,32 @@

public class GroovyIsoVisitor<P> extends GroovyVisitor<P> {

@Override
public G.CompilationUnit visitCompilationUnit(G.CompilationUnit cu, P p) {
return (G.CompilationUnit) super.visitCompilationUnit(cu, p);
}

@Override
public G.GString visitGString(G.GString gString, P p) {
return (G.GString) super.visitGString(gString, p);
}

@Override
public G.GString.Value visitGStringValue(G.GString.Value value, P p) {
return (G.GString.Value) super.visitGStringValue(value, p);
}

@Override
public G.ListLiteral visitListLiteral(G.ListLiteral listLiteral, P p) {
return (G.ListLiteral) super.visitListLiteral(listLiteral, p);
}

@Override
public G.MapLiteral visitMapLiteral(G.MapLiteral mapLiteral, P p) {
return (G.MapLiteral) super.visitMapLiteral(mapLiteral, p);
}

@Override
public G.Binary visitBinary(G.Binary binary, P p) {
return (G.Binary) super.visitBinary(binary, p);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ private Collection<Path> resolvedClasspath() {
return classpath;
}

@Override
public GroovyParser build() {
return new GroovyParser(resolvedClasspath(), styles, logCompilationWarningsAndErrors, typeCache, compilerCustomizers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import org.openrewrite.java.internal.JavaTypeCache;
import org.openrewrite.java.marker.ImplicitReturn;
import org.openrewrite.java.marker.Semicolon;
import org.openrewrite.java.tree.*;
import org.openrewrite.java.tree.Expression;
import org.openrewrite.java.tree.Statement;
import org.openrewrite.java.tree.*;
import org.openrewrite.marker.Markers;

import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class GroovyTypeMapping implements JavaTypeMapping<ASTNode> {
this.reflectionTypeMapping = new JavaReflectionTypeMapping(typeCache);
}

@Override
public JavaType type(@Nullable ASTNode type) {
if (type == null) {
return JavaType.Class.Unknown.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ default <P> J acceptGroovy(GroovyVisitor<P> v, P p) {
return v.defaultValue(this, p);
}

@Override
Space getPrefix();

@Override
default List<Comment> getComments() {
return getPrefix().getComments();
}
Expand Down Expand Up @@ -132,10 +134,12 @@ public SourceFile withCharset(Charset charset) {
JRightPadded<Package> packageDeclaration;

@Nullable
@Override
public Package getPackageDeclaration() {
return packageDeclaration == null ? null : packageDeclaration.getElement();
}

@Override
public G.CompilationUnit withPackageDeclaration(Package packageDeclaration) {
return getPadding().withPackageDeclaration(JRightPadded.withElement(this.packageDeclaration, packageDeclaration));
}
Expand Down Expand Up @@ -175,6 +179,7 @@ public G.CompilationUnit withStatements(List<Statement> statements) {
@Getter
Space eof;

@Override
@Transient
public List<Import> getImports() {
return statements.stream()
Expand All @@ -184,10 +189,12 @@ public List<Import> getImports() {
.collect(Collectors.toList());
}

@Override
public G.CompilationUnit withImports(List<Import> imports) {
return getPadding().withImports(JRightPadded.withElements(this.getPadding().getImports(), imports));
}

@Override
@Transient
public List<ClassDeclaration> getClasses() {
return statements.stream()
Expand All @@ -212,6 +219,7 @@ public <P> TreeVisitor<?, PrintOutputCapture<P>> printer(Cursor cursor) {
return new GroovyPrinter<>();
}

@Override
@Transient
public TypesInUse getTypesInUse() {
TypesInUse cache;
Expand All @@ -228,6 +236,7 @@ public TypesInUse getTypesInUse() {
return cache;
}

@Override
public Padding getPadding() {
Padding p;
if (this.padding == null) {
Expand Down
3 changes: 2 additions & 1 deletion rewrite-hcl/src/main/java/org/openrewrite/hcl/HclParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.antlr.v4.runtime.*;
import org.openrewrite.ExecutionContext;
import org.openrewrite.tree.ParseError;
import org.openrewrite.Parser;
import org.openrewrite.SourceFile;
import org.openrewrite.hcl.internal.HclParserVisitor;
Expand All @@ -28,6 +27,7 @@
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.Markers;
import org.openrewrite.style.NamedStyles;
import org.openrewrite.tree.ParseError;
import org.openrewrite.tree.ParsingEventListener;
import org.openrewrite.tree.ParsingExecutionContextView;

Expand Down Expand Up @@ -124,6 +124,7 @@ public Builder styles(Iterable<? extends NamedStyles> styles) {
return this;
}

@Override
public HclParser build() {
return new HclParser(styles);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ private enum CurlyType {
OBJECT
}

private Stack<CurlyType> leftCurlyStack = new Stack<CurlyType>();
private Stack<String> heredocIdentifier = new Stack<String>();
private Stack<CurlyType> leftCurlyStack = new Stack<>();
private Stack<String> heredocIdentifier = new Stack<>();


public HCLLexer(CharStream input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,8 @@ public final TemplateInterpolationContext templateInterpolation() throws Recogni
return _localctx;
}

public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
@Override
public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
case 6:
return expression_sempred((ExpressionContext)_localctx, predIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,8 @@ public final IndexesContext indexes() throws RecognitionException {
return _localctx;
}

public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
@Override
public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
case 7:
return binaryExpression_sempred((BinaryExpressionContext)_localctx, predIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
package org.openrewrite.hcl.tree;

public interface BodyContent extends Hcl {
@Override
BodyContent withPrefix(Space prefix);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
package org.openrewrite.hcl.tree;

public interface CollectionValue extends Expression {
@Override
CollectionValue withPrefix(Space prefix);
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public HclCoordinates add(Comparator<BodyContent> idealOrdering) {
return new HclCoordinates(tree, Space.Location.BLOCK_CLOSE, HclCoordinates.Mode.BEFORE, idealOrdering);
}

@Override
public HclCoordinates replace() {
return replace(Space.Location.BLOCK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ public <T> T getAttributeValue(String attrName) {
@With
Space end;

@Override
public CoordinateBuilder.Block getCoordinates() {
return new CoordinateBuilder.Block(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.objectweb.asm.Opcodes;
import org.openrewrite.ExecutionContext;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.tree.ParseError;
import org.openrewrite.SourceFile;
import org.openrewrite.internal.MetricsHelper;
import org.openrewrite.internal.StringUtils;
Expand All @@ -41,6 +40,7 @@
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.Space;
import org.openrewrite.style.NamedStyles;
import org.openrewrite.tree.ParseError;
import org.openrewrite.tree.ParsingEventListener;
import org.openrewrite.tree.ParsingExecutionContextView;

Expand Down Expand Up @@ -252,6 +252,7 @@ public JavaParser reset(Collection<URI> uris) {
return this;
}

@Override
public void setClasspath(Collection<Path> classpath) {
this.classpath = classpath;
}
Expand Down
Loading

0 comments on commit 120e9e9

Please sign in to comment.