lexical-lsp / lexical

Lexical is a next-generation elixir language server
888 stars 82 forks source link

textDocument/documentSymbol failed while writing unifex spec file #830

Open harrisi opened 1 month ago

harrisi commented 1 month ago

When writing a unifex spec file (example), I'm seeing a textDocument/documentSymbol failed error.

Using Lexical v0.7.1 in VSCode.

Error (this repeats continuously):

2024-09-26 10:28:22.603 [info] [Error - 10:28:22 AM] Request textDocument/documentSymbol failed.
2024-09-26 10:28:22.604 [info]   Message: ** (ErlangError) Erlang error: {:exception, {:badmatch, :error}, [{LXical.RemoteControl.Search.Indexer.Extractors.ExUnit, :extract, 2, [file: ~c"lib/lexical/remote_control/search/indexer/extractors/ex_unit.ex", line: 17]}, {LXical.RemoteControl.Search.Indexer.Source.Reducer, :"-apply_extractors/2-fun-0-", 2, [file: ~c"lib/lexical/remote_control/search/indexer/source/reducer.ex", line: 97]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: ~c"lib/enum.ex", line: 2531]}, {LXical.RemoteControl.Search.Indexer.Quoted, :"-index/2-fun-0-", 2, [file: ~c"lib/lexical/remote_control/search/indexer/quoted.ex", line: 19]}, {Macro, :"-do_traverse_args/4-fun-0-", 4, [file: ~c"lib/macro.ex", line: 639]}, {:lists, :mapfoldl_1, 3, [file: ~c"lists.erl", line: 2343]}, {Macro, :do_traverse, 4, [file: ~c"lib/macro.ex", line: 604]}, {:lists, :mapfoldl_1, 3, [file: ~c"lists.erl", line: 2343]}]}
    (kernel 10.1) erpc.erl:1368: :erpc.call/5
    (lx_server 0.5.0) lib/lexical/server/provider/handlers/document_symbols.ex:16: LXical.Server.Provider.Handlers.DocumentSymbols.handle/2
    (lx_server 0.5.0) lib/lexical/server/task_queue.ex:77: anonymous fn/4 in LXical.Server.TaskQueue.State.as_task/2
    (elixir 1.17.3) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
    (elixir 1.17.3) lib/task/supervised.ex:36: Task.Supervised.reply/4

  Code: -32603 

EDIT: the file I'm using:

module Assimp

interface [NIF, CNode]

spec foo(num :: int) :: {:ok :: label, answer :: int}

type vertex :: %Assimp.Vertex{
  position: {float, float, float},
  normal: {float, float},
  tex_coords: {float, float},
  tangent: {float, float},
  bitangent: {float, float, float},
  bone_ids: [int],
  weights: [float]
}

type texture :: %Assimp.Texture{
  id: unsigned,
  type: string,
  path: string
}

type mesh :: %Assimp.Mesh{
  vertices: [vertex],
  indices: [unsigned],
  textures: [texture],
  vao: unsigned,
  vbo: unsigned,
  ebo: unsigned
}

type model :: %Assimp.Model{
  textures_loaded: [texture],
  meshes: [mesh],
  directory: string,
  gamma_correction: bool
}

type shader :: unsigned

spec new(vertices :: [vertex], indices :: [unsigned], textures :: [texture]) :: {:ok :: label, result :: mesh}
spec draw(mesh :: mesh, shader :: shader) :: :ok :: label
spec setup(mesh :: mesh) :: :ok :: label