mirror of
https://github.com/github/semantic.git
synced 2025-01-05 05:58:34 +03:00
Use the new input string with length API.
This commit is contained in:
parent
c7366062b4
commit
2108d7287a
@ -31,15 +31,13 @@ treeSitterParser :: Language -> Ptr TS.Language -> Parser (Syntax.Syntax Text) (
|
|||||||
treeSitterParser language grammar blob = do
|
treeSitterParser language grammar blob = do
|
||||||
document <- ts_document_new
|
document <- ts_document_new
|
||||||
ts_document_set_language document grammar
|
ts_document_set_language document grammar
|
||||||
let termWithCString (source, len) = do
|
Foreign.withCStringLen (toText $ source blob) $ \ (source, len)
|
||||||
ts_document_set_input_string2 document source len
|
ts_document_set_input_string_with_length document source len
|
||||||
ts_document_parse document
|
ts_document_parse document
|
||||||
term <- documentToTerm language document blob
|
term <- documentToTerm language document blob
|
||||||
ts_document_free document
|
ts_document_free document
|
||||||
pure term
|
pure term
|
||||||
if Source.null (source blob)
|
|
||||||
then FString.withCStringLen "" termWithCString
|
|
||||||
else Foreign.withCStringLen (toText $ source blob) termWithCString
|
|
||||||
|
|
||||||
-- | Return a parser for a tree sitter language & document.
|
-- | Return a parser for a tree sitter language & document.
|
||||||
documentToTerm :: Language -> Ptr Document -> Parser (Syntax.Syntax Text) (Record '[Range, Category, SourceSpan])
|
documentToTerm :: Language -> Ptr Document -> Parser (Syntax.Syntax Text) (Record '[Range, Category, SourceSpan])
|
||||||
|
Loading…
Reference in New Issue
Block a user