From 0d0791b4c204066796a29f9ded3f106eb1cca059 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Wed, 21 Aug 2024 07:21:04 +0000 Subject: [PATCH 1/2] refactor: OpenRewrite best practices Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.recipes.OpenRewriteBestPractices?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../main/java/org/openrewrite/CreateFileVisitor.java | 2 +- .../openrewrite/internal/RecipeIntrospectionUtils.java | 2 +- .../java/org/openrewrite/internal/StringUtils.java | 2 +- .../openrewrite/marker/OperatingSystemProvenance.java | 2 +- .../main/java/org/openrewrite/text/FindAndReplace.java | 2 +- .../org/openrewrite/config/DeclarativeRecipeTest.java | 2 +- .../openrewrite/gradle/trait/GradleDependencyTest.java | 2 ++ .../org/openrewrite/gradle/util/GradleWrapperTest.java | 2 +- .../org/openrewrite/groovy/GroovyParserVisitor.java | 2 +- .../org/openrewrite/hcl/internal/HclParserVisitor.java | 2 +- .../openrewrite/java/ChangeStaticFieldToMethod.java | 2 +- .../org/openrewrite/java/RemoveAnnotationVisitor.java | 2 +- .../java/ShortenFullyQualifiedTypeReferences.java | 2 +- .../java/format/NormalizeTabsOrSpacesVisitor.java | 2 +- .../org/openrewrite/java/marker/JavaSourceSet.java | 3 +-- .../src/main/java/org/openrewrite/java/tree/J.java | 2 +- .../openrewrite/maven/ChangePluginConfiguration.java | 1 + .../java/org/openrewrite/maven/internal/RawPom.java | 2 +- .../org/openrewrite/maven/UpdateMavenWrapperTest.java | 10 ++++++++-- .../main/java/org/openrewrite/test/RewriteTest.java | 2 +- .../xml/format/NormalizeTabsOrSpacesVisitor.java | 2 +- 21 files changed, 29 insertions(+), 21 deletions(-) diff --git a/rewrite-core/src/main/java/org/openrewrite/CreateFileVisitor.java b/rewrite-core/src/main/java/org/openrewrite/CreateFileVisitor.java index c64558009c8..5afc72f5cdd 100644 --- a/rewrite-core/src/main/java/org/openrewrite/CreateFileVisitor.java +++ b/rewrite-core/src/main/java/org/openrewrite/CreateFileVisitor.java @@ -17,8 +17,8 @@ import lombok.EqualsAndHashCode; import lombok.Value; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; +import org.openrewrite.internal.lang.NonNull; import java.nio.file.Path; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/rewrite-core/src/main/java/org/openrewrite/internal/RecipeIntrospectionUtils.java b/rewrite-core/src/main/java/org/openrewrite/internal/RecipeIntrospectionUtils.java index 8faa555adfa..d86fe2d5f03 100644 --- a/rewrite-core/src/main/java/org/openrewrite/internal/RecipeIntrospectionUtils.java +++ b/rewrite-core/src/main/java/org/openrewrite/internal/RecipeIntrospectionUtils.java @@ -15,12 +15,12 @@ */ package org.openrewrite.internal; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.*; import org.openrewrite.config.ColumnDescriptor; import org.openrewrite.config.DataTableDescriptor; import org.openrewrite.config.RecipeIntrospectionException; +import org.openrewrite.internal.lang.NonNull; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; diff --git a/rewrite-core/src/main/java/org/openrewrite/internal/StringUtils.java b/rewrite-core/src/main/java/org/openrewrite/internal/StringUtils.java index 2bf82f699a4..476cae952cd 100644 --- a/rewrite-core/src/main/java/org/openrewrite/internal/StringUtils.java +++ b/rewrite-core/src/main/java/org/openrewrite/internal/StringUtils.java @@ -15,8 +15,8 @@ */ package org.openrewrite.internal; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; +import org.openrewrite.internal.lang.NonNull; import java.io.ByteArrayOutputStream; import java.io.File; diff --git a/rewrite-core/src/main/java/org/openrewrite/marker/OperatingSystemProvenance.java b/rewrite-core/src/main/java/org/openrewrite/marker/OperatingSystemProvenance.java index f23099e8301..59a0813b7d8 100644 --- a/rewrite-core/src/main/java/org/openrewrite/marker/OperatingSystemProvenance.java +++ b/rewrite-core/src/main/java/org/openrewrite/marker/OperatingSystemProvenance.java @@ -22,9 +22,9 @@ import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.With; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.Tree; +import org.openrewrite.internal.lang.NonNull; import java.io.File; import java.nio.file.Files; diff --git a/rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java b/rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java index a1da2de1b74..27b61da5f0e 100644 --- a/rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java +++ b/rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java @@ -17,10 +17,10 @@ import lombok.EqualsAndHashCode; import lombok.Value; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.*; import org.openrewrite.binary.Binary; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.marker.AlreadyReplaced; import org.openrewrite.marker.Marker; import org.openrewrite.marker.SearchResult; diff --git a/rewrite-core/src/test/java/org/openrewrite/config/DeclarativeRecipeTest.java b/rewrite-core/src/test/java/org/openrewrite/config/DeclarativeRecipeTest.java index 4b347b23031..3ef4da16d61 100644 --- a/rewrite-core/src/test/java/org/openrewrite/config/DeclarativeRecipeTest.java +++ b/rewrite-core/src/test/java/org/openrewrite/config/DeclarativeRecipeTest.java @@ -17,10 +17,10 @@ import lombok.EqualsAndHashCode; import lombok.Value; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.Test; import org.openrewrite.*; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.marker.SearchResult; import org.openrewrite.test.RewriteTest; import org.openrewrite.text.ChangeText; diff --git a/rewrite-gradle/src/test/java/org/openrewrite/gradle/trait/GradleDependencyTest.java b/rewrite-gradle/src/test/java/org/openrewrite/gradle/trait/GradleDependencyTest.java index 43b863c2dd9..a73d5af1cf1 100644 --- a/rewrite-gradle/src/test/java/org/openrewrite/gradle/trait/GradleDependencyTest.java +++ b/rewrite-gradle/src/test/java/org/openrewrite/gradle/trait/GradleDependencyTest.java @@ -16,6 +16,7 @@ package org.openrewrite.gradle.trait; import org.junit.jupiter.api.Test; +import org.openrewrite.DocumentExample; import org.openrewrite.marker.SearchResult; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; @@ -33,6 +34,7 @@ public void defaults(RecipeSpec spec) { SearchResult.found(dep.getTree(), dep.getResolvedDependency().getGav().toString())))); } + @DocumentExample @Test void literal() { rewriteRun( diff --git a/rewrite-gradle/src/test/java/org/openrewrite/gradle/util/GradleWrapperTest.java b/rewrite-gradle/src/test/java/org/openrewrite/gradle/util/GradleWrapperTest.java index 760feadd82a..1487503fbae 100644 --- a/rewrite-gradle/src/test/java/org/openrewrite/gradle/util/GradleWrapperTest.java +++ b/rewrite-gradle/src/test/java/org/openrewrite/gradle/util/GradleWrapperTest.java @@ -21,8 +21,8 @@ import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.openrewrite.internal.lang.NonNull; import org.openrewrite.internal.StringUtils; +import org.openrewrite.internal.lang.NonNull; import java.io.IOException; import java.io.InputStream; diff --git a/rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyParserVisitor.java b/rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyParserVisitor.java index 929961c04a9..4fbbf3523cd 100644 --- a/rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyParserVisitor.java +++ b/rewrite-groovy/src/main/java/org/openrewrite/groovy/GroovyParserVisitor.java @@ -25,7 +25,6 @@ import org.codehaus.groovy.ast.stmt.*; import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.transform.stc.StaticTypesMarker; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.Cursor; import org.openrewrite.ExecutionContext; @@ -34,6 +33,7 @@ import org.openrewrite.groovy.tree.G; import org.openrewrite.internal.EncodingDetectingInputStream; import org.openrewrite.internal.ListUtils; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.java.internal.JavaTypeCache; import org.openrewrite.java.marker.ImplicitReturn; import org.openrewrite.java.marker.Semicolon; diff --git a/rewrite-hcl/src/main/java/org/openrewrite/hcl/internal/HclParserVisitor.java b/rewrite-hcl/src/main/java/org/openrewrite/hcl/internal/HclParserVisitor.java index 9eb2dbc35f3..a11740bb805 100644 --- a/rewrite-hcl/src/main/java/org/openrewrite/hcl/internal/HclParserVisitor.java +++ b/rewrite-hcl/src/main/java/org/openrewrite/hcl/internal/HclParserVisitor.java @@ -19,12 +19,12 @@ import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.TerminalNode; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.FileAttributes; import org.openrewrite.hcl.internal.grammar.HCLParser; import org.openrewrite.hcl.internal.grammar.HCLParserBaseVisitor; import org.openrewrite.hcl.tree.*; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.marker.Markers; import java.nio.charset.Charset; diff --git a/rewrite-java/src/main/java/org/openrewrite/java/ChangeStaticFieldToMethod.java b/rewrite-java/src/main/java/org/openrewrite/java/ChangeStaticFieldToMethod.java index 4aa2f34960d..ac8393d78c4 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/ChangeStaticFieldToMethod.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/ChangeStaticFieldToMethod.java @@ -19,9 +19,9 @@ import lombok.Value; import org.apache.commons.lang3.StringUtils; import org.intellij.lang.annotations.Language; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.*; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.java.search.UsesField; import org.openrewrite.java.tree.*; diff --git a/rewrite-java/src/main/java/org/openrewrite/java/RemoveAnnotationVisitor.java b/rewrite-java/src/main/java/org/openrewrite/java/RemoveAnnotationVisitor.java index 423fb41c23c..6e9056ae749 100755 --- a/rewrite-java/src/main/java/org/openrewrite/java/RemoveAnnotationVisitor.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/RemoveAnnotationVisitor.java @@ -17,9 +17,9 @@ import lombok.EqualsAndHashCode; import lombok.Value; -import org.openrewrite.internal.lang.NonNull; import org.openrewrite.ExecutionContext; import org.openrewrite.internal.ListUtils; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.java.tree.*; import java.util.ArrayList; diff --git a/rewrite-java/src/main/java/org/openrewrite/java/ShortenFullyQualifiedTypeReferences.java b/rewrite-java/src/main/java/org/openrewrite/java/ShortenFullyQualifiedTypeReferences.java index f457d298cd0..5453fcc4fb8 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/ShortenFullyQualifiedTypeReferences.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/ShortenFullyQualifiedTypeReferences.java @@ -15,10 +15,10 @@ */ package org.openrewrite.java; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.*; import org.openrewrite.internal.ListUtils; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.java.internal.DefaultJavaTypeSignatureBuilder; import org.openrewrite.java.service.ImportService; import org.openrewrite.java.tree.*; diff --git a/rewrite-java/src/main/java/org/openrewrite/java/format/NormalizeTabsOrSpacesVisitor.java b/rewrite-java/src/main/java/org/openrewrite/java/format/NormalizeTabsOrSpacesVisitor.java index 4f786477da3..947eca54671 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/format/NormalizeTabsOrSpacesVisitor.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/format/NormalizeTabsOrSpacesVisitor.java @@ -15,11 +15,11 @@ */ package org.openrewrite.java.format; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.Tree; import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.StringUtils; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.java.JavaIsoVisitor; import org.openrewrite.java.JavaVisitor; import org.openrewrite.java.JavadocVisitor; diff --git a/rewrite-java/src/main/java/org/openrewrite/java/marker/JavaSourceSet.java b/rewrite-java/src/main/java/org/openrewrite/java/marker/JavaSourceSet.java index e9ebd78a8d0..f952d50d7b0 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/marker/JavaSourceSet.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/marker/JavaSourceSet.java @@ -216,8 +216,7 @@ public static JavaSourceSet build(String sourceSetName, Collection classpa * If no GAV can be determined returns null. * */ - @Nullable - static String gavFromPath(Path path) { + static @Nullable String gavFromPath(Path path) { String pathStr = PathUtils.separatorsToUnix(path.toString()); List pathParts = Arrays.asList(pathStr.split("/")); // Example maven path: ~/.m2/repository/org/openrewrite/rewrite-core/8.32.0/rewrite-core-8.32.0.jar diff --git a/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java b/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java index 9ea13f6e1db..20738e59f5c 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java @@ -19,13 +19,13 @@ import lombok.*; import lombok.experimental.FieldDefaults; import lombok.experimental.NonFinal; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.*; import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.LoathingOfOthers; import org.openrewrite.internal.SelfLoathing; import org.openrewrite.internal.StringUtils; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.java.JavaPrinter; import org.openrewrite.java.JavaTypeVisitor; import org.openrewrite.java.JavaVisitor; diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginConfiguration.java b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginConfiguration.java index 47218c3f986..fe7ce651cf3 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginConfiguration.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangePluginConfiguration.java @@ -27,6 +27,7 @@ import org.openrewrite.xml.tree.Xml; import java.util.Optional; + import static org.openrewrite.xml.AddOrUpdateChild.addOrUpdateChild; import static org.openrewrite.xml.FilterTagChildrenVisitor.filterChildren; diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java index c794ad3c99f..5415065df25 100755 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java @@ -23,9 +23,9 @@ import lombok.*; import lombok.experimental.FieldDefaults; import lombok.experimental.NonFinal; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.internal.StringUtils; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.maven.tree.*; import javax.xml.bind.annotation.XmlRootElement; diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/UpdateMavenWrapperTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/UpdateMavenWrapperTest.java index 52fc8e4d9a1..1cb62e262da 100644 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/UpdateMavenWrapperTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/UpdateMavenWrapperTest.java @@ -43,9 +43,15 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.openrewrite.maven.utilities.MavenWrapper.*; +import static org.openrewrite.maven.utilities.MavenWrapper.ASF_LICENSE_HEADER; +import static org.openrewrite.maven.utilities.MavenWrapper.WRAPPER_BATCH_LOCATION; +import static org.openrewrite.maven.utilities.MavenWrapper.WRAPPER_DOWNLOADER_LOCATION; +import static org.openrewrite.maven.utilities.MavenWrapper.WRAPPER_JAR_LOCATION; +import static org.openrewrite.maven.utilities.MavenWrapper.WRAPPER_SCRIPT_LOCATION; import static org.openrewrite.properties.Assertions.properties; -import static org.openrewrite.test.SourceSpecs.*; +import static org.openrewrite.test.SourceSpecs.dir; +import static org.openrewrite.test.SourceSpecs.other; +import static org.openrewrite.test.SourceSpecs.text; class UpdateMavenWrapperTest implements RewriteTest { private final UnaryOperator<@Nullable String> notEmpty = actual -> { diff --git a/rewrite-test/src/main/java/org/openrewrite/test/RewriteTest.java b/rewrite-test/src/main/java/org/openrewrite/test/RewriteTest.java index 3e3bdc87f26..412f1d72785 100644 --- a/rewrite-test/src/main/java/org/openrewrite/test/RewriteTest.java +++ b/rewrite-test/src/main/java/org/openrewrite/test/RewriteTest.java @@ -18,7 +18,6 @@ import lombok.RequiredArgsConstructor; import lombok.experimental.Delegate; import org.assertj.core.api.SoftAssertions; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.*; import org.openrewrite.config.CompositeRecipe; @@ -28,6 +27,7 @@ import org.openrewrite.internal.RecipeIntrospectionUtils; import org.openrewrite.internal.StringUtils; import org.openrewrite.internal.WhitespaceValidationService; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.marker.Marker; import org.openrewrite.marker.Markers; import org.openrewrite.quark.Quark; diff --git a/rewrite-xml/src/main/java/org/openrewrite/xml/format/NormalizeTabsOrSpacesVisitor.java b/rewrite-xml/src/main/java/org/openrewrite/xml/format/NormalizeTabsOrSpacesVisitor.java index e942cb28c6a..c8625492492 100644 --- a/rewrite-xml/src/main/java/org/openrewrite/xml/format/NormalizeTabsOrSpacesVisitor.java +++ b/rewrite-xml/src/main/java/org/openrewrite/xml/format/NormalizeTabsOrSpacesVisitor.java @@ -15,10 +15,10 @@ */ package org.openrewrite.xml.format; -import org.openrewrite.internal.lang.NonNull; import org.jspecify.annotations.Nullable; import org.openrewrite.Tree; import org.openrewrite.internal.StringUtils; +import org.openrewrite.internal.lang.NonNull; import org.openrewrite.xml.XmlIsoVisitor; import org.openrewrite.xml.style.TabsAndIndentsStyle; import org.openrewrite.xml.tree.Xml; From 8d505cf34296be5495b79d512b1ec1df523a60f5 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Wed, 21 Aug 2024 09:23:47 +0200 Subject: [PATCH 2/2] Work around nested import limitation to minimize diff --- .../main/java/org/openrewrite/hcl/HclTemplate.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rewrite-hcl/src/main/java/org/openrewrite/hcl/HclTemplate.java b/rewrite-hcl/src/main/java/org/openrewrite/hcl/HclTemplate.java index d85956b54c1..bf042fcc305 100644 --- a/rewrite-hcl/src/main/java/org/openrewrite/hcl/HclTemplate.java +++ b/rewrite-hcl/src/main/java/org/openrewrite/hcl/HclTemplate.java @@ -22,7 +22,6 @@ import org.openrewrite.hcl.internal.template.Substitutions; import org.openrewrite.hcl.style.SpacesStyle; import org.openrewrite.hcl.tree.*; -import org.openrewrite.hcl.tree.Space.Location; import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.StringUtils; import org.openrewrite.template.SourceTemplate; @@ -63,14 +62,14 @@ public H apply(Cursor scope, HclCoordinates coordinates, Object. onAfterVariableSubstitution.accept(substitutedTemplate); Tree insertionPoint = coordinates.getTree(); - Location loc = coordinates.getSpaceLocation(); + Space.Location loc = coordinates.getSpaceLocation(); //noinspection unchecked H h = (H) new HclVisitor() { @Override public Hcl visitConfigFile(Hcl.ConfigFile configFile, Integer p) { Hcl.ConfigFile c = (Hcl.ConfigFile) super.visitConfigFile(configFile, p); - if (loc.equals(Location.CONFIG_FILE_EOF)) { + if (loc.equals(Space.Location.CONFIG_FILE_EOF)) { List gen = substitutions.unsubstitute(templateParser.parseBodyContent(substitutedTemplate)); if (coordinates.getComparator() != null) { @@ -101,7 +100,7 @@ public Hcl visitConfigFile(Hcl.ConfigFile configFile, Integer p) { ) ); } - } else if (loc.equals(Location.CONFIG_FILE)) { + } else if (loc.equals(Space.Location.CONFIG_FILE)) { List gen = substitutions.unsubstitute(templateParser.parseBodyContent(substitutedTemplate)); c = c.withBody( ListUtils.concatAll( @@ -117,7 +116,7 @@ public Hcl visitConfigFile(Hcl.ConfigFile configFile, Integer p) { @Override public Hcl visitBlock(Hcl.Block block, Integer p) { Hcl.Block b = (Hcl.Block) super.visitBlock(block, p); - if (loc.equals(Location.BLOCK_CLOSE)) { + if (loc.equals(Space.Location.BLOCK_CLOSE)) { if (b.isScope(insertionPoint)) { List gen = substitutions.unsubstitute(templateParser.parseBodyContent(substitutedTemplate)); @@ -146,7 +145,7 @@ public Hcl visitBlock(Hcl.Block block, Integer p) { .orElse(SpacesStyle.DEFAULT)).visit(b, p, getCursor().getParentOrThrow()); assert b != null; } - } else if (loc.equals(Location.BLOCK)) { + } else if (loc.equals(Space.Location.BLOCK)) { if (b.isScope(insertionPoint)) { b = (Hcl.Block) autoFormat(templateParser.parseBodyContent(substitutedTemplate).get(0), p, getCursor().getParentOrThrow()); @@ -159,7 +158,7 @@ public Hcl visitBlock(Hcl.Block block, Integer p) { public Hcl visitExpression(Expression expression, Integer p) { Hcl e = super.visitExpression(expression, p); - if (loc.equals(Location.EXPRESSION_PREFIX)) { + if (loc.equals(Space.Location.EXPRESSION_PREFIX)) { if (e.isScope(insertionPoint)) { e = templateParser.parseExpression(substitutedTemplate).withPrefix(expression.getPrefix()); }