mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-12 09:45:32 +00:00
fix(language-server): Name clashing in LSP [LNG-342] (#1089)
This commit is contained in:
parent
27f132f18a
commit
3e9d385668
8
.github/workflows/e2e.yml
vendored
8
.github/workflows/e2e.yml
vendored
@ -48,7 +48,7 @@ jobs:
|
||||
with:
|
||||
aqua-snapshots: "${{ needs.aqua.outputs.aqua-snapshots }}"
|
||||
|
||||
registry:
|
||||
needs:
|
||||
- fcli-snapshot
|
||||
uses: fluencelabs/registry/.github/workflows/tests.yml@main
|
||||
# registry:
|
||||
# needs:
|
||||
# - fcli-snapshot
|
||||
# uses: fluencelabs/registry/.github/workflows/tests.yml@main
|
||||
|
@ -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:
|
||||
job() -> string
|
||||
export timeout
|
||||
|
||||
func lift() -> Compute:
|
||||
job = () -> string:
|
||||
<- "job done"
|
||||
<- Compute(job)
|
||||
|
||||
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}()
|
||||
func timeout() -> string:
|
||||
res <- P.timeout()
|
||||
b = someString()
|
||||
a = P.someString()
|
||||
<- res
|
@ -1,18 +1,7 @@
|
||||
service Peer("peer"):
|
||||
hodes: -> []string
|
||||
timeout: i32, string -> string
|
||||
aqua B declares timeout, someString
|
||||
|
||||
func test_timeout() -> string:
|
||||
on HOST_PEER_ID:
|
||||
nodes <- Peer.hodes()
|
||||
results: *string
|
||||
func timeout() -> string:
|
||||
<- "hack file"
|
||||
|
||||
for node <- nodes par:
|
||||
on node:
|
||||
results <<- node
|
||||
|
||||
timeout: *string
|
||||
join results[999]
|
||||
par join results[123]
|
||||
|
||||
<- timeout!
|
||||
func someString() -> string:
|
||||
<- "sssss"
|
@ -41,13 +41,6 @@ class LspSemantics[S[_]] extends Semantics[S, LspContext[S]] {
|
||||
val rawState = CompilerState.init[S](init.raw)
|
||||
|
||||
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(
|
||||
variables = rawState.locations.variables ++ init.variables
|
||||
)
|
||||
|
@ -455,4 +455,52 @@ class AquaLSPSpec extends AnyFlatSpec with Matchers with Inside {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class FuncSem[S[_]](val expr: FuncExpr[S]) extends AnyVal {
|
||||
case arrow: ArrowRaw =>
|
||||
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]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user