1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Replace supportedExts

This commit is contained in:
Timothy Clem 2019-08-15 15:48:17 -07:00
parent 2510df0e23
commit 0aab5ebd55
4 changed files with 22 additions and 1 deletions

View File

@ -361,6 +361,7 @@ test-suite test
, Data.Functor.Listable
, Data.Graph.Spec
, Data.Mergeable
, Data.Language.Spec
, Data.Range.Spec
, Data.Scientific.Spec
, Data.Semigroup.App.Spec

View File

@ -14,6 +14,7 @@ module Data.Language
import Data.Aeson
import qualified Data.Languages as Lingo
import qualified Data.Text as T
import qualified Data.Map.Strict as Map
import Prologue
import System.FilePath.Posix
@ -129,7 +130,12 @@ languageForFilePath path = case Lingo.languageName <$> Lingo.languageForPath pat
_ -> Unknown
supportedExts :: [String]
supportedExts = [".go", ".py", ".rb", ".js", ".mjs", ".ts", ".php", ".phpt"]
supportedExts = foldr append mempty supportedLanguages
where
append (Just l) b = fmap T.unpack (Lingo.languageExtensions l) <> b
append Nothing b = b
supportedLanguages = fmap lookup ["Go", "Ruby", "Python", "JavaScript", "TypeScript", "PHP"]
lookup k = Map.lookup k Lingo.languages
codeNavLanguages :: [Language]
codeNavLanguages = [Go, Ruby, Python, JavaScript, TypeScript, PHP]

View File

@ -0,0 +1,12 @@
module Data.Language.Spec (spec) where
import Data.Language
import SpecHelpers
spec :: Spec
spec = describe "Data.Language" $ do
it "supportedExts returns expected list" $
supportedExts `shouldBe` [".go",".rb",".builder",".eye",".fcgi",".gemspec",".god",".jbuilder",".mspec",".pluginspec",".podspec",".rabl",".rake",".rbuild",".rbw",".rbx",".ru",".ruby",".spec",".thor",".watchr",".py",".bzl",".cgi",".fcgi",".gyp",".gypi",".lmi",".py3",".pyde",".pyi",".pyp",".pyt",".pyw",".rpy",".spec",".tac",".wsgi",".xpy",".js","._js",".bones",".es",".es6",".frag",".gs",".jake",".jsb",".jscad",".jsfl",".jsm",".jss",".mjs",".njs",".pac",".sjs",".ssjs",".xsjs",".xsjslib",".ts",".php",".aw",".ctp",".fcgi",".inc",".php3",".php4",".php5",".phps",".phpt"]
it "codeNavLanguages returns expected list" $
codeNavLanguages `shouldBe` [Go, Ruby, Python, JavaScript, TypeScript, PHP]

View File

@ -14,6 +14,7 @@ import qualified Data.Abstract.Name.Spec
import qualified Data.Abstract.Path.Spec
import qualified Data.Functor.Classes.Generic.Spec
import qualified Data.Graph.Spec
import qualified Data.Language.Spec
import qualified Data.Range.Spec
import qualified Data.Scientific.Spec
import qualified Data.Semigroup.App.Spec
@ -78,6 +79,7 @@ legacySpecs = parallel $ do
describe "Data.Abstract.Path" Data.Abstract.Path.Spec.spec
describe "Data.Abstract.Name" Data.Abstract.Name.Spec.spec
describe "Data.Functor.Classes.Generic" Data.Functor.Classes.Generic.Spec.spec
describe "Data.Language" Data.Language.Spec.spec
describe "Data.Range" Data.Range.Spec.spec
describe "Data.Scientific" Data.Scientific.Spec.spec
describe "Data.Semigroup.App" Data.Semigroup.App.Spec.spec