Skip to content

Commit

Permalink
validate string
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Nov 17, 2023
1 parent 3ad9449 commit e8abc40
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/elixir_sense/core/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ defmodule ElixirSense.Core.Parser do

@spec parse_string(String.t(), boolean, boolean, pos_integer | nil) :: Metadata.t()
def parse_string(source, try_to_fix_parse_error, try_to_fix_line_not_found, cursor_line_number) do
unless String.valid?(source) do
raise ArgumentError, message: "invalid string passed to parse_string"
end

case string_to_ast(source, if(try_to_fix_parse_error, do: 6, else: 0), cursor_line_number) do
{:ok, ast, modified_source, error} ->
acc = MetadataBuilder.build(ast)
Expand Down

0 comments on commit e8abc40

Please sign in to comment.