fix(language-server): Go-to definition for path in use expression [LNG-187] (#733)

add tokens for `use` and `use-from` expressions to language server
This commit is contained in:
Dima 2023-06-06 23:40:26 +03:00 committed by GitHub
parent da0821d9d5
commit 21cb3937ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -1,7 +1,7 @@
package aqua.lsp
import aqua.parser.Ast
import aqua.parser.head.{ImportExpr, ImportFromExpr}
import aqua.parser.head.{ImportExpr, ImportFromExpr, UseExpr, UseFromExpr}
import aqua.parser.lexer.{LiteralToken, Token}
import aqua.semantics.rules.ReportError
import aqua.semantics.rules.locations.LocationsState
@ -24,6 +24,8 @@ class LspSemantics[S[_]] extends Semantics[S, LspContext[S]] {
header match {
case ImportExpr(fn) => l :+ fn
case ImportFromExpr(_, fn) => l :+ fn
case UseExpr(fn, _) => l :+ fn
case UseFromExpr(_, fn, _) => l :+ fn
case _ => l
}
}

View File

@ -24,7 +24,8 @@ case class UseExpr[F[_]](
object UseExpr extends HeaderExpr.Leaf {
override val p: Parser[HeaderExpr[Span.S]] =
(`use` *> ` ` *> ValueToken.string ~ (` as ` *> Ability.ab).?).map { case (filename, asModule) =>
(`use` *> ` ` *> ValueToken.string ~ (` as ` *> Ability.ab).?).map {
case (filename, asModule) =>
UseExpr(filename, asModule)
}
}