X Tutup
The Wayback Machine - https://web.archive.org/web/20230323154735/https://github.com/github/semantic/pull/690
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo #690

Merged
merged 6 commits into from Jul 22, 2022
Merged

Demo #690

merged 6 commits into from Jul 22, 2022

Conversation

robrix
Copy link
Member

@robrix robrix commented Jul 21, 2022

Some last tweaks to polish off the exception tracing demo.

parseFile :: (Has (Throw String) sig m, MonadIO m) => FilePath -> m (Source.Source, File Term)
parseFile path = do
contents <- liftIO (B.readFile path)
let sourcePath = replaceExtensions path "py"
-- FIXME: this is comprised of several terrible assumptions.
sourceContents <- Source.fromUTF8 . B.toStrict <$> liftIO (B.readFile sourcePath)
parseFile :: (Has (Throw String) sig m, MonadIO m) => FilePath -> FilePath -> m (Source.Source, File Term)
parseFile srcPath jsonPath = do
contents <- liftIO (B.readFile jsonPath)
-- FIXME: get this from the JSON itself (cf https://github.com/tree-sitter/tree-sitter-graph/issues/69)
let sourcePath = replaceExtensions jsonPath "py"
sourceContents <- Source.fromUTF8 . B.toStrict <$> liftIO (B.readFile srcPath)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very slightly less gross than it had been, but still pretty gross. Basically what it amounts to is a way to allow the JSON path and the loaded source file to vary: in the demo's case, I wanted both b.py and b2.py to load their respective sources correctly while still obtaining the module name b.

As of this PR, we're making one fewer assumption than we had been, so I'm content with it for the moment, but a real solution will be needed at some point.

@robrix robrix marked this pull request as ready for review July 21, 2022 13:07
@robrix robrix requested a review from a team as a code owner July 21, 2022 13:07
Copy link
Member

@rewinfrey rewinfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for including the JSON fixme note. LGTM.

@robrix robrix merged commit 793a876 into main Jul 22, 2022
2 checks passed
@robrix robrix deleted the demo branch July 22, 2022 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants
X Tutup