fix(language-server): Name clashing in LSP [LNG-342] (#1089)

This commit is contained in:
Dima 2024-02-26 16:00:25 +03:00 committed by GitHub
parent 27f132f18a
commit 3e9d385668
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 66 additions and 53 deletions

View File

@ -48,7 +48,7 @@ jobs:
with: with:
aqua-snapshots: "${{ needs.aqua.outputs.aqua-snapshots }}" aqua-snapshots: "${{ needs.aqua.outputs.aqua-snapshots }}"
registry: # registry:
needs: # needs:
- fcli-snapshot # - fcli-snapshot
uses: fluencelabs/registry/.github/workflows/tests.yml@main # uses: fluencelabs/registry/.github/workflows/tests.yml@main

View File

@ -1,29 +1,12 @@
aqua A aqua Job declares *
export haveFun import someString from "hack"
use timeout, someString from "hack.aqua" as P
ability Compute: export timeout
job() -> string
func lift() -> Compute: func timeout() -> string:
job = () -> string: res <- P.timeout()
<- "job done" b = someString()
<- Compute(job) a = P.someString()
ability Function:
run() -> string
func roundtrip{Function}() -> string:
res <- Function.run()
<- res
func disjoint_run{Compute}() -> Function:
run = func () -> string:
<- Compute.job()
<- Function(run = run)
func haveFun() -> string:
comp = lift()
fn = disjoint_run{comp}()
res <- roundtrip{fn}()
<- res <- res

View File

@ -1,18 +1,7 @@
service Peer("peer"): aqua B declares timeout, someString
hodes: -> []string
timeout: i32, string -> string
func test_timeout() -> string: func timeout() -> string:
on HOST_PEER_ID: <- "hack file"
nodes <- Peer.hodes()
results: *string
for node <- nodes par: func someString() -> string:
on node: <- "sssss"
results <<- node
timeout: *string
join results[999]
par join results[123]
<- timeout!

View File

@ -41,13 +41,6 @@ class LspSemantics[S[_]] extends Semantics[S, LspContext[S]] {
val rawState = CompilerState.init[S](init.raw) val rawState = CompilerState.init[S](init.raw)
val initState = rawState.copy( val initState = rawState.copy(
names = rawState.names.copy(
rootArrows = rawState.names.rootArrows ++ init.rootArrows,
constants = rawState.names.constants ++ init.constants
),
abilities = rawState.abilities.copy(
definitions = rawState.abilities.definitions ++ init.abDefinitions
),
locations = rawState.locations.copy( locations = rawState.locations.copy(
variables = rawState.locations.variables ++ init.variables variables = rawState.locations.variables ++ init.variables
) )

View File

@ -455,4 +455,52 @@ class AquaLSPSpec extends AnyFlatSpec with Matchers with Inside {
res.checkLocations("Srv", 0, n, main) shouldBe true res.checkLocations("Srv", 0, n, main) shouldBe true
} }
} }
it should "return right tokens with no errors when using different file" in {
val main =
"""aqua Import declares *
|
|use timeout, someString from "export2.aqua" as Export
|import someString from "export2.aqua"
|
|export timeout
|
|func timeout() -> string:
| res <- Export.timeout()
| b = someString()
| a = Export.someString()
| <- res
|
|""".stripMargin
val src = Map(
"index.aqua" -> main
)
val firstImport =
"""aqua B declares timeout, someString
|
|func timeout() -> string:
| <- "hack file"
|
|func someString() -> string:
| <- "sssss"
|
|""".stripMargin
val imports = Map(
"export2.aqua" ->
firstImport
)
val res = compile(src, imports).toOption.get.values.head
res.errors shouldBe empty
res.checkLocations("timeout", 1, 0, firstImport, Some(main)) shouldBe true
res.checkLocations("timeout", 1, 1, firstImport, Some(main)) shouldBe false
res.checkLocations("timeout", 1, 2, firstImport, Some(main)) shouldBe false
res.checkLocations("timeout", 1, 3, firstImport, Some(main)) shouldBe true
res.checkLocations("someString", 1, 0, firstImport, Some(main)) shouldBe true
res.checkLocations("someString", 1, 2, firstImport, Some(main)) shouldBe true
res.checkLocations("someString", 1, 3, firstImport, Some(main)) shouldBe true
}
} }

View File

@ -21,7 +21,7 @@ class FuncSem[S[_]](val expr: FuncExpr[S]) extends AnyVal {
case arrow: ArrowRaw => case arrow: ArrowRaw =>
N.defineArrow(expr.name, arrow.`type`, isRoot = true) as FuncRaw(expr.name.value, arrow) N.defineArrow(expr.name, arrow.`type`, isRoot = true) as FuncRaw(expr.name.value, arrow)
case m => case _ =>
Raw.error("Func must continue with an arrow definition").pure[Alg] Raw.error("Func must continue with an arrow definition").pure[Alg]
} }