Skip to content

Commit

Permalink
refactor: Add missing @Override to overriding and implementing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek and TeamModerne committed Mar 12, 2024
1 parent 2bdf2c6 commit 892b93c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/openrewrite/kotlin/KotlinParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ private Collection<Path> resolvedClasspath() {
return classpath;
}

@Override
public KotlinParser build() {
return new KotlinParser(resolvedClasspath(), styles, logCompilationWarningsAndErrors, typeCache, moduleName, languageLevel, isKotlinScript);
}
Expand All @@ -338,6 +339,7 @@ public String getDslName() {
return "kotlin";
}

@Override
public KotlinParser.Builder clone() {
KotlinParser.Builder clone = (KotlinParser.Builder) super.clone();
clone.typeCache = this.typeCache.clone();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/openrewrite/kotlin/KotlinTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static class Builder extends JavaTemplate.Builder {
this.code = code;
}

@Override
public Builder imports(String... fullyQualifiedTypeNames) {
for (String typeName : fullyQualifiedTypeNames) {
validateImport(typeName);
Expand All @@ -105,16 +106,19 @@ Builder parser(KotlinParser.Builder parser) {
return this;
}

@Override
public Builder doAfterVariableSubstitution(Consumer<String> afterVariableSubstitution) {
this.onAfterVariableSubstitution = afterVariableSubstitution;
return this;
}

@Override
public Builder doBeforeParseTemplate(Consumer<String> beforeParseTemplate) {
this.onBeforeParseTemplate = beforeParseTemplate;
return this;
}

@Override
public KotlinTemplate build() {
return new KotlinTemplate(false, parser, code, imports,
onAfterVariableSubstitution, onBeforeParseTemplate);
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/openrewrite/kotlin/tree/K.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ default <P> J acceptKotlin(KotlinVisitor<P> v, P p) {
return v.defaultValue(this, p);
}

@Override
Space getPrefix();

@Override
default List<Comment> getComments() {
return getPrefix().getComments();
}
Expand Down Expand Up @@ -191,20 +193,24 @@ public SourceFile withCharset(Charset charset) {
JRightPadded<Package> packageDeclaration;

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

@Override
public K.CompilationUnit withPackageDeclaration(Package packageDeclaration) {
return getPadding().withPackageDeclaration(JRightPadded.withElement(this.packageDeclaration, packageDeclaration));
}

List<JRightPadded<Import>> imports;

@Override
public List<Import> getImports() {
return JRightPadded.getElements(imports);
}

@Override
public K.CompilationUnit withImports(List<Import> imports) {
return getPadding().withImports(JRightPadded.withElements(this.imports, imports));
}
Expand All @@ -223,6 +229,7 @@ public K.CompilationUnit withStatements(List<Statement> statements) {
@Getter
Space eof;

@Override
@Transient
public List<J.ClassDeclaration> getClasses() {
return statements.stream()
Expand All @@ -242,6 +249,7 @@ public K.CompilationUnit withClasses(List<J.ClassDeclaration> classes) {
return getPadding().withClasses(JRightPadded.withElements(this.getPadding().getClasses(), classes));
}

@Override
public <P> J acceptKotlin(KotlinVisitor<P> v, P p) {
return v.visitCompilationUnit(this, p);
}
Expand All @@ -251,6 +259,7 @@ public <P> TreeVisitor<?, PrintOutputCapture<P>> printer(Cursor cursor) {
return new KotlinPrinter<>();
}

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

@Override
public Padding getPadding() {
Padding p;
if (this.padding == null) {
Expand Down Expand Up @@ -1104,6 +1114,7 @@ final class FunctionType implements K, TypeTree, Expression {
@With
Space prefix;

@Override
public Space getPrefix() {
//noinspection ConstantConditions
return prefix == null ? returnType.getElement().getPrefix() : prefix;
Expand All @@ -1112,6 +1123,7 @@ public Space getPrefix() {
@With
Markers markers;

@Override
public Markers getMarkers() {
// For backwards compatibility with older LST before there was a prefix field
//noinspection ConstantConditions
Expand Down Expand Up @@ -1168,6 +1180,7 @@ public FunctionType withParameters(List<TypeTree> parameters) {
return returnType != null && returnType.getElement() != null ? returnType.getElement().getType() : null;
}

@Override
public <T extends J> T withType(@Nullable JavaType type) {
TypeTree newType = returnType.getElement().withType(type);
//noinspection unchecked
Expand Down

0 comments on commit 892b93c

Please sign in to comment.