mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +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:
|
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
|
||||||
|
@ -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
|
@ -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!
|
|
@ -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
|
||||||
)
|
)
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user