mirror of
https://github.com/github/semantic.git
synced 2024-12-01 09:15:01 +03:00
Merge pull request #340 from github/bump-lingo
Bump lingo to 0.3 and remove hack associated with #333.
This commit is contained in:
commit
d3425d1b49
@ -71,7 +71,7 @@ common dependencies
|
||||
, text ^>= 1.2.3.1
|
||||
, these >= 0.7 && <1
|
||||
, unix ^>= 2.7.2.2
|
||||
, lingo ^>= 0.2
|
||||
, lingo ^>= 0.3.0.0
|
||||
|
||||
common executable-flags
|
||||
ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m"
|
||||
|
@ -93,7 +93,15 @@ extensionsForLanguage language = T.unpack <$> maybe mempty Lingo.languageExtensi
|
||||
|
||||
-- | Return a language based on a FilePath's extension.
|
||||
languageForFilePath :: FilePath -> Language
|
||||
languageForFilePath path = maybe Unknown (textToLanguage . Lingo.languageName) (Lingo.languageForPath path)
|
||||
languageForFilePath path =
|
||||
let spurious lang = lang `elem` [ "Hack" -- .php files
|
||||
, "GCC Machine Description" -- .md files
|
||||
, "XML" -- .tsx files
|
||||
]
|
||||
allResults = Lingo.languageName <$> Lingo.languagesForPath path
|
||||
in case filter (not . spurious) allResults of
|
||||
[result] -> textToLanguage result
|
||||
_ -> Unknown
|
||||
|
||||
supportedExts :: [String]
|
||||
supportedExts = foldr append mempty supportedLanguages
|
||||
@ -129,7 +137,6 @@ textToLanguage :: T.Text -> Language
|
||||
textToLanguage = \case
|
||||
"Go" -> Go
|
||||
"Haskell" -> Haskell
|
||||
"Hack" -> PHP -- working around https://github.com/github/semantic/issues/330
|
||||
"Java" -> Java
|
||||
"JavaScript" -> JavaScript
|
||||
"JSON" -> JSON
|
||||
|
@ -15,4 +15,5 @@ testTree = testGroup "Data.Language"
|
||||
, testCase "languageForFilePath works for languages with ambiguous lingo extensions" $ do
|
||||
languageForFilePath "foo.php" @=? PHP
|
||||
languageForFilePath "foo.md" @=? Markdown
|
||||
languageForFilePath "foo.tsx" @=? TSX
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user