Skip to content

Commit

Permalink
Add support for sources
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed May 19, 2024
1 parent 1766b59 commit 77e61a0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions modules/core/src/main/scala/playground/PlaygroundConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker

final case class PlaygroundConfig(
imports: List[String],
sources: List[String],
dependencies: List[String],
repositories: List[String],
extensions: List[String],
Expand All @@ -18,6 +19,7 @@ object PlaygroundConfig {

val empty: PlaygroundConfig = PlaygroundConfig(
imports = Nil,
sources = Nil,
dependencies = Nil,
repositories = Nil,
extensions = Nil,
Expand All @@ -29,12 +31,14 @@ object PlaygroundConfig {
mavenDependencies: List[String] = Nil,
mavenRepositories: List[String] = Nil,
imports: List[String] = Nil,
sources: List[String] = Nil,
maven: Option[MavenConfig] = None,
smithyPlayground: Option[SmithyPlaygroundPluginConfig] = None,
) {

def toPlaygroundConfig: PlaygroundConfig = PlaygroundConfig(
imports = imports,
sources = sources,
dependencies = mavenDependencies ++ maven.foldMap(_.dependencies),
repositories = mavenRepositories ++ maven.foldMap(_.repositories).map(_.url),
extensions = smithyPlayground.foldMap(_.extensions),
Expand All @@ -51,6 +55,7 @@ object PlaygroundConfig {
mavenDependencies = c.dependencies,
mavenRepositories = c.repositories,
imports = c.imports,
sources = c.sources,
smithyPlayground = c.extensions.toNel.map { e =>
SmithyPlaygroundPluginConfig(extensions = e.toList)
},
Expand Down
6 changes: 5 additions & 1 deletion modules/lsp/src/main/scala/playground/lsp/BuildLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ object BuildLoader {
.getOrElse(sys.error("impossible - no parent for " + loaded.configFilePath))

// "raw" means these can be directories etc., just like in the config file.
val rawImportPaths = loaded.config.imports.map(workspaceBase.resolve).toSet
val rawImportPaths =
(
loaded.config.imports ++
loaded.config.sources
).map(workspaceBase.resolve).toSet

for {
specs <- filterImports(rawImportPaths)
Expand Down
4 changes: 3 additions & 1 deletion modules/lsp/src/main/scala/playground/lsp/ServerLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ object ServerLoader {
)

case class WorkspaceStats(
sourceCount: Int,
importCount: Int,
dependencyCount: Int,
pluginCount: Int,
) {

def render: String =
s"$importCount imports, $dependencyCount dependencies and $pluginCount plugins"
s"$sourceCount sources, $importCount imports, $dependencyCount dependencies and $pluginCount plugins"

}

Expand All @@ -49,6 +50,7 @@ object ServerLoader {
def fromBuildConfig(
bc: PlaygroundConfig
): WorkspaceStats = WorkspaceStats(
sourceCount = bc.sources.size,
importCount = bc.imports.size,
dependencyCount = bc.dependencies.size,
pluginCount = bc.extensions.size,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"imports": ["./weather.smithy", "./no-runner.smithy"],
"sources": ["./weather.smithy", "./no-runner.smithy"],
"mavenDependencies": [
"com.disneystreaming.alloy:alloy-core:0.3.8",
"com.disneystreaming.smithy4s:smithy4s-protocol:0.18.19"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object LanguageServerIntegrationTestSharedServer
),
TestClient.MessageLog(
MessageType.Info,
"Loaded Smithy Playground server with 2 imports, 2 dependencies and 0 plugins",
"Loaded Smithy Playground server with 2 sources, 0 imports, 2 dependencies and 0 plugins",
),
)

Expand Down
2 changes: 1 addition & 1 deletion smithy-build.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"imports": ["modules/core/src/test/smithy"],
"sources": ["modules/core/src/test/smithy"],
"mavenDependencies": [
"com.disneystreaming.alloy:alloy-core:0.3.8",
"com.disneystreaming.smithy4s:smithy4s-protocol:0.18.19",
Expand Down

0 comments on commit 77e61a0

Please sign in to comment.