mirror of
https://github.com/github/semantic.git
synced 2024-12-24 15:35:14 +03:00
Select a Language for a given file name extension.
This commit is contained in:
parent
0769c00d1d
commit
53046e4b0d
@ -63,15 +63,15 @@ constructorForProductions keyed fixed source info@(Info range categories) = (inf
|
|||||||
|
|
||||||
data Language = Language { getConstructor :: Constructor, getTsLanguage :: Ptr TSLanguage }
|
data Language = Language { getConstructor :: Constructor, getTsLanguage :: Ptr TSLanguage }
|
||||||
|
|
||||||
languageForType :: String -> Maybe (Ptr TSLanguage)
|
languageForType :: String -> Maybe Language
|
||||||
languageForType mediaType = case mediaType of
|
languageForType mediaType = case mediaType of
|
||||||
".h" -> Just ts_language_c
|
".h" -> Just $ Language (constructorForProductions mempty mempty) ts_language_c
|
||||||
".c" -> Just ts_language_c
|
".c" -> Just $ Language (constructorForProductions mempty mempty) ts_language_c
|
||||||
".js" -> Just ts_language_javascript
|
".js" -> Just $ Language (constructorForProductions keyedProductions fixedProductions) ts_language_javascript
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
parseTreeSitterFile :: Ptr TSLanguage -> String -> IO (Term String Info)
|
parseTreeSitterFile :: Language -> String -> IO (Term String Info)
|
||||||
parseTreeSitterFile language contents = do
|
parseTreeSitterFile (Language constructor language) contents = do
|
||||||
document <- ts_document_make
|
document <- ts_document_make
|
||||||
ts_document_set_language document language
|
ts_document_set_language document language
|
||||||
withCString contents (\source -> do
|
withCString contents (\source -> do
|
||||||
|
Loading…
Reference in New Issue
Block a user