Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Merge adjacent SrcSpans (#1) #36

Merged
merged 2 commits into from Oct 7, 2017
Merged

Merge adjacent SrcSpans (#1) #36

merged 2 commits into from Oct 7, 2017

Conversation

chshersh
Copy link
Contributor

@chshersh chshersh commented Oct 7, 2017

Now search results combined with empty lines, like this:

$ hgrep main main/hgrep.hs 
main/hgrep.hs:(17,1)-(32,31)



17  main :: IO ()

18  main = do
19    IO.hSetBuffering IO.stdout IO.LineBuffering
20    IO.hSetBuffering IO.stderr IO.LineBuffering
21    opts <- parseOpts
22    colour <- detectColour
23    case parseQuery (cmdQuery opts) (cmdRegex opts) of
24      Left er -> do
25        IO.hPutStrLn IO.stderr er
26        exitWith (ExitFailure 2)
27      Right q -> do
28        found <-
29          fmap sum $
30            for (cmdFiles opts) $ \fp ->
31              hgrep (HGrep.PrintOpts colour (cmdLineNums opts)) q fp
32        exitWith (exitCode found)

But after PR #32 is merged this won't be a problem.


import qualified Language.Haskell.GHC.ExactPrint as EP

import qualified System.IO as IO

import GHC.Num ((+))
Copy link
Owner

Choose a reason for hiding this comment

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

This should have been included in the project Prelude, it's an oversight on my part. Sorry about that.

@thumphries
Copy link
Owner

👍

This is great, thanks so much for contributing!

@chshersh
Copy link
Contributor Author

chshersh commented Oct 7, 2017

@thumphries I'm very sorry for massive refactoring. I moved my version of printSearchResultLocation into new Language.Haskell.HGrep.Internal.Print module renaming it to printSrcSpan because I want (according to your words):

  1. Export printSrcSpan anywhere and use it from Language.Haskell.HGrep
  2. Implement printSearchResultLocation using printSrcSpan
  3. Do not export printSrcSpan from non-internal modules because as you said you don't want to export ghc-internals.

This results in so many files changed :(
But I thought that having Language.Haskell.HGrep.Internal.Print will be useful some day anyway.

@thumphries
Copy link
Owner

Thank you, I agree with the new structure!

@thumphries thumphries merged commit 073f0da into thumphries:master Oct 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants