Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP: imports -> sources #1518

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ In sbt, you can check what versions of smithy4s are used by your dependencies us

We apologize for the inconvenience.

## Changes

* `smithy4sUpdateLSPConfig`: Replace `imports` with `sources` to be more in line with idiomatic smithy-build config in https://github.com/disneystreaming/smithy4s/pull/1518 (see https://github.com/disneystreaming/smithy4s/issues/1459)
* Update smithy: 1.45.0 to 1.49.0 (binary breaking) in https://github.com/disneystreaming/smithy4s/pull/1485

# 0.18.18
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.0",
"imports": ["src/main/smithy"],
"sources": ["src/main/smithy"],
"maven": {
"dependencies": ["software.amazon.smithy:smithy-waiters:1.38.0"],
"repositories": []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version" : "1.0",
"imports" : [
"sources" : [
"subproj2/src/main/smithy",
"subproj2/target/scala-2.12/src_managed/main/smithy"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import Smithy4sCodegenPlugin.autoImport._
import scala.collection.immutable.ListSet

private final case class SmithyBuildData(
imports: ListSet[String],
sources: ListSet[String],
deps: ListSet[String],
repos: ListSet[String]
) {
def addAll(
imports: ListSet[String],
sources: ListSet[String],
deps: ListSet[String],
repos: ListSet[String]
): SmithyBuildData = {
SmithyBuildData(
this.imports ++ imports,
this.sources ++ sources,
this.deps ++ deps,
this.repos ++ repos
)
Expand All @@ -53,9 +53,9 @@ private[codegen] object GenerateSmithyBuild {

val rootDir = new File(extracted.structure.root)

val SmithyBuildData(imports, deps, repos) = extractInfo(extracted, rootDir)
val SmithyBuildData(sources, deps, repos) = extractInfo(extracted, rootDir)

val json = SmithyBuildJson.toJson(imports, deps, repos)
val json = SmithyBuildJson.toJson(sources, deps, repos)
val target = rootDir / "smithy-build.json"
val content = if (target.exists()) {
val content = IO.readLines(target).mkString("\n")
Expand All @@ -75,7 +75,7 @@ private[codegen] object GenerateSmithyBuild {
.foldLeft(SmithyBuildData(ListSet.empty, ListSet.empty, ListSet.empty)) {
case (gsb, pr) =>
gsb.addAll(
extractImports(pr, extracted.structure.data, rootDir),
extractSources(pr, extracted.structure.data, rootDir),
extractDeps(pr, extracted.structure.data),
extractRepos(pr, extracted.structure.data)
)
Expand Down Expand Up @@ -108,7 +108,7 @@ private[codegen] object GenerateSmithyBuild {
.to[ListSet]
}

private def extractImports(
private def extractSources(
pr: ProjectRef,
settings: Settings[Scope],
rootDir: File
Expand Down
4 changes: 2 additions & 2 deletions modules/codegen/src/smithy4s/codegen/SmithyBuildJson.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import scala.collection.immutable.ListSet

private[codegen] object SmithyBuildJson {
def toJson(
imports: ListSet[String],
sources: ListSet[String],
dependencies: ListSet[String],
repositories: ListSet[String]
): String = {
SmithyBuild.writeJson(
SmithyBuild.Serializable(
version = "1.0",
imports,
sources,
SmithyBuildMaven(
dependencies,
repositories.map(SmithyBuildMavenRepository.apply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import scala.util.Try

private[internals] final case class SmithyBuild(
version: String,
imports: Set[os.FilePath],
sources: Set[os.FilePath],
plugins: Set[SmithyBuildPlugin],
maven: Option[SmithyBuildMaven]
) {
Expand Down Expand Up @@ -71,7 +71,7 @@ private[codegen] object SmithyBuild {
*/
case class Serializable(
version: String,
imports: Set[String],
sources: Set[String],
maven: SmithyBuildMaven
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class SmithyBuildSpec extends munit.FunSuite {
actual,
"""|{
| "version" : "1.0",
| "imports" : [
| "sources" : [
| "src/"
| ],
| "maven" : {
Expand All @@ -58,7 +58,7 @@ final class SmithyBuildSpec extends munit.FunSuite {
val actual = SmithyBuildJson.merge(
"""|{
| "version": "1.0",
| "imports": ["src/main/smithy"],
| "sources": ["src/main/smithy"],
| "maven": {
| "dependencies": ["oterh"],
| "repositories": []
Expand All @@ -68,7 +68,7 @@ final class SmithyBuildSpec extends munit.FunSuite {
|""".stripMargin,
"""|{
| "version": "1.0",
| "imports": ["src/main/smithy"],
| "sources": ["src/main/smithy"],
| "maven": {
| "dependencies": ["dep1"],
| "repositories": []
Expand All @@ -80,7 +80,7 @@ final class SmithyBuildSpec extends munit.FunSuite {
actual,
"""|{
| "version" : "1.0",
| "imports" : [
| "sources" : [
| "src/main/smithy"
| ],
| "maven" : {
Expand All @@ -100,7 +100,7 @@ final class SmithyBuildSpec extends munit.FunSuite {
val actual = SmithyBuildJson.merge(
"""|{
| "version": "1.0",
| "imports": ["src/main/smithy"],
| "sources": ["src/main/smithy"],
| "maven": {
| "dependencies": ["oterh", "dep1"],
| "repositories": []
Expand All @@ -109,7 +109,7 @@ final class SmithyBuildSpec extends munit.FunSuite {
|""".stripMargin,
"""|{
| "version": "1.0",
| "imports": ["src/main/smithy"],
| "sources": ["src/main/smithy"],
| "maven": {
| "dependencies": ["dep1"],
| "repositories": []
Expand All @@ -122,7 +122,7 @@ final class SmithyBuildSpec extends munit.FunSuite {
actual,
"""|{
| "version" : "1.0",
| "imports" : [
| "sources" : [
| "src/main/smithy"
| ],
| "maven" : {
Expand All @@ -143,7 +143,7 @@ final class SmithyBuildSpec extends munit.FunSuite {
"""
|{
| "version": "1.0",
| "imports": [ "foo.smithy", "some/directory" ],
| "sources": [ "foo.smithy", "some/directory" ],
| "plugins": {
| "openapi": {
| "service": "example.weather#Weather",
Expand All @@ -166,7 +166,7 @@ final class SmithyBuildSpec extends munit.FunSuite {
os.FilePath("foo.smithy"),
os.FilePath("some/directory")
),
actual.imports.toSet
actual.sources.toSet
)
val actualOpenApiConfig = actual
.getPlugin[SmithyBuildPlugin.OpenApi]
Expand Down Expand Up @@ -197,7 +197,7 @@ final class SmithyBuildSpec extends munit.FunSuite {

assertEquals(actual.maven, None)
assertEquals("1.0", actual.version)
assertEquals(Set.empty[os.FilePath], actual.imports.toSet)
assertEquals(Set.empty[os.FilePath], actual.sources.toSet)
assertEquals(Set.empty[SmithyBuildPlugin], actual.plugins.toSet)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SmithyLSPConfigSpec extends munit.FunSuite {
val expectedJson = ujson.read {
s"""|{
| "version": "1.0",
| "imports": ["./foo/smithy"],
| "sources": ["./foo/smithy"],
| "maven": {
| "dependencies": [
| "com.disneystreaming.alloy:alloy-core:${smithy4s.codegen.BuildInfo.alloyVersion}",
Expand Down
2 changes: 1 addition & 1 deletion smithy-build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.0",
"imports": ["./sampleSpecs", "./modules/protocol/resources"],
"sources": ["./sampleSpecs", "./modules/protocol/resources"],
"maven": {
"dependencies": [
"software.amazon.smithy:smithy-protocol-test-traits:1.49.0",
Expand Down