-
Notifications
You must be signed in to change notification settings - Fork 457
Drop pathtype, part one #687
Changes from all commits
dfb68fa
c29ed6c
56bec05
64f4f0f
ca7e7e7
9f0b837
9fda0e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ packages: semantic | |
semantic-ruby | ||
semantic-rust | ||
semantic-scope-graph | ||
semantic-source | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, and in For this PR I think that's worth it; for the next one I might end up reinstating this. But I wanted to factor the PRs out to begin with to limit scope and to be sure we're handling versioning appropriately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
To clarify, this means that the process would be to merge the PR that touches the "downstream" package, cut a new release and deploy it to hackage, and then open the PR in the "upstream" package? (Not meaning to suggest a different approach, just making sure I understand how the process would be impacted.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup. Or more precisely: reintroduce I think the real moral here is that we probably released |
||
semantic-tags | ||
semantic-tsx | ||
semantic-typescript |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# 0.2.0.0 | ||
|
||
- Finds languages for `FilePath`s. | ||
- Drops dependency on `pathtype`. | ||
|
||
|
||
# 0.1.0.2 | ||
|
||
- Support ghc 9.2. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,6 @@ import qualified Data.Languages as Lingo | |
import qualified Data.Map.Strict as Map | ||
import qualified Data.Text as T | ||
import GHC.Generics (Generic) | ||
import qualified System.Path as Path | ||
import qualified System.Path.PartClass as Path.PartClass | ||
|
||
-- | The various languages we support. | ||
data Language | ||
|
@@ -96,47 +94,47 @@ knownLanguage = (/= Unknown) | |
extensionsForLanguage :: Language -> [String] | ||
extensionsForLanguage language = fmap T.unpack (maybe mempty Lingo.languageExtensions (Map.lookup (languageToText language) Lingo.languages)) | ||
|
||
forPath :: Path.PartClass.AbsRel ar => Path.File ar -> Language | ||
forPath :: FilePath -> Language | ||
forPath path = | ||
let spurious lang = lang `elem` [ "Hack" -- .php files | ||
, "GCC Machine Description" -- .md files | ||
, "XML" -- .tsx files | ||
] | ||
allResults = Lingo.languageName <$> Lingo.languagesForPath (Path.toString path) | ||
allResults = Lingo.languageName <$> Lingo.languagesForPath path | ||
Comment on lines
-99
to
+103
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only real code change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🥲 |
||
in case filter (not . spurious) allResults of | ||
[result] -> textToLanguage result | ||
_ -> Unknown | ||
|
||
languageToText :: Language -> T.Text | ||
languageToText = \case | ||
Unknown -> "Unknown" | ||
CodeQL -> "CodeQL" | ||
Go -> "Go" | ||
Haskell -> "Haskell" | ||
Java -> "Java" | ||
Unknown -> "Unknown" | ||
CodeQL -> "CodeQL" | ||
Go -> "Go" | ||
Haskell -> "Haskell" | ||
Java -> "Java" | ||
JavaScript -> "JavaScript" | ||
JSON -> "JSON" | ||
JSX -> "JSX" | ||
Markdown -> "Markdown" | ||
PHP -> "PHP" | ||
Python -> "Python" | ||
Ruby -> "Ruby" | ||
JSON -> "JSON" | ||
JSX -> "JSX" | ||
Markdown -> "Markdown" | ||
PHP -> "PHP" | ||
Python -> "Python" | ||
Ruby -> "Ruby" | ||
TypeScript -> "TypeScript" | ||
TSX -> "TSX" | ||
TSX -> "TSX" | ||
|
||
textToLanguage :: T.Text -> Language | ||
textToLanguage = \case | ||
"CodeQL" -> CodeQL | ||
"Go" -> Go | ||
"Haskell" -> Haskell | ||
"Java" -> Java | ||
"CodeQL" -> CodeQL | ||
"Go" -> Go | ||
"Haskell" -> Haskell | ||
"Java" -> Java | ||
"JavaScript" -> JavaScript | ||
"JSON" -> JSON | ||
"JSX" -> JSX | ||
"Markdown" -> Markdown | ||
"PHP" -> PHP | ||
"Python" -> Python | ||
"Ruby" -> Ruby | ||
"JSON" -> JSON | ||
"JSX" -> JSX | ||
"Markdown" -> Markdown | ||
"PHP" -> PHP | ||
"Python" -> Python | ||
"Ruby" -> Ruby | ||
"TypeScript" -> TypeScript | ||
"TSX" -> TSX | ||
_ -> Unknown | ||
"TSX" -> TSX | ||
_ -> Unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're excluding this from the top-level project now, so we
cd
in first.