mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 14:40:17 +00:00
feat(language-server): Pass errors to lsp context [fixes LNG-243] (#888)
This commit is contained in:
parent
d6f879ef7a
commit
f8b5017918
@ -203,9 +203,15 @@ object AquaLSP extends App with Logging {
|
||||
|
||||
val result = fileRes match {
|
||||
case Valid(lsp) =>
|
||||
val errors = lsp.errors.map(CompileError.apply).flatMap(errorToInfo)
|
||||
errors match
|
||||
case Nil =>
|
||||
logger.debug("No errors on compilation.")
|
||||
case errs =>
|
||||
logger.debug("Errors: " + errs.mkString("\n"))
|
||||
|
||||
CompilationResult(
|
||||
List.empty.toJSArray,
|
||||
errors.toJSArray,
|
||||
locationsToJs(lsp.locations),
|
||||
importsToTokenImport(lsp.importTokens)
|
||||
)
|
||||
|
@ -1,13 +1,13 @@
|
||||
package aqua.lsp
|
||||
|
||||
import aqua.parser.lexer.{Ability, LiteralToken, Name, NamedTypeToken, Token}
|
||||
import aqua.parser.lexer.{LiteralToken, NamedTypeToken, Token}
|
||||
import aqua.raw.RawContext.semiRC
|
||||
import aqua.raw.{RawContext, RawPart}
|
||||
import aqua.types.{ArrowType, Type}
|
||||
import RawContext.semiRC
|
||||
import aqua.semantics.SemanticError
|
||||
import aqua.semantics.header.Picker
|
||||
|
||||
import cats.{Monoid, Semigroup}
|
||||
import aqua.types.{ArrowType, Type}
|
||||
import cats.syntax.monoid.*
|
||||
import cats.{Monoid, Semigroup}
|
||||
|
||||
// Context with info that necessary for language server
|
||||
case class LspContext[S[_]](
|
||||
@ -17,7 +17,8 @@ case class LspContext[S[_]](
|
||||
constants: Map[String, Type] = Map.empty[String, Type],
|
||||
tokens: Map[String, Token[S]] = Map.empty[String, Token[S]],
|
||||
locations: List[(Token[S], Token[S])] = Nil,
|
||||
importTokens: List[LiteralToken[S]] = Nil
|
||||
importTokens: List[LiteralToken[S]] = Nil,
|
||||
errors: List[SemanticError[S]] = Nil
|
||||
)
|
||||
|
||||
object LspContext {
|
||||
|
@ -67,9 +67,7 @@ class LspSemantics[S[_]] extends Semantics[S, LspContext[S]] {
|
||||
RawSemantics
|
||||
.interpret(ast, initState, init.raw)
|
||||
.map { case (state, ctx) =>
|
||||
NonEmptyChain
|
||||
.fromChain(state.errors)
|
||||
.fold[ValidatedNec[SemanticError[S], LspContext[S]]] {
|
||||
// TODO: better to change return type in `process` method
|
||||
Valid(
|
||||
LspContext(
|
||||
raw = ctx,
|
||||
@ -78,10 +76,10 @@ class LspSemantics[S[_]] extends Semantics[S, LspContext[S]] {
|
||||
abDefinitions = state.abilities.definitions,
|
||||
locations = state.locations.allLocations,
|
||||
importTokens = importTokens,
|
||||
tokens = state.locations.tokens
|
||||
tokens = state.locations.tokens,
|
||||
errors = state.errors.toList
|
||||
)
|
||||
)
|
||||
}(Invalid(_))
|
||||
}
|
||||
// TODO: return as Eval
|
||||
.value
|
||||
|
Loading…
Reference in New Issue
Block a user