mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Generalize patch rendering over the syntax functor.
This commit is contained in:
parent
ec66e575d3
commit
8c5d0bf2da
@ -26,7 +26,7 @@ import Term
|
||||
|
||||
|
||||
data Renderer input output where
|
||||
PatchRenderer :: HasField fields Range => Renderer (Both SourceBlob, Diff (Syntax Text) (Record fields)) File
|
||||
PatchRenderer :: (HasField fields Range, Traversable f) => Renderer (Both SourceBlob, Diff f (Record fields)) File
|
||||
JSONRenderer :: (ToJSON a, Foldable t) => Renderer (t SourceBlob, a) [Value]
|
||||
SExpressionDiffRenderer :: (HasField fields Category, HasField fields SourceSpan, Foldable f) => Renderer (Both SourceBlob, Diff f (Record fields)) ByteString
|
||||
ToCRenderer :: (HasField fields Category, HasField fields (Maybe Declaration), HasField fields SourceSpan) => Renderer (Both SourceBlob, Diff (Syntax Text) (Record fields)) Summaries
|
||||
|
@ -18,7 +18,6 @@ import Prologue hiding (fst, snd)
|
||||
import Range
|
||||
import qualified Source
|
||||
import Source hiding (break, drop, length, null, take)
|
||||
import Syntax
|
||||
import SplitDiff
|
||||
|
||||
-- | Render a timed out file as a truncated diff.
|
||||
@ -26,7 +25,7 @@ truncatePatch :: Both SourceBlob -> Text
|
||||
truncatePatch blobs = header blobs <> "#timed_out\nTruncating diff: timeout reached.\n"
|
||||
|
||||
-- | Render a diff in the traditional patch format.
|
||||
patch :: HasField fields Range => Both SourceBlob -> Diff (Syntax Text) (Record fields) -> Text
|
||||
patch :: (HasField fields Range, Traversable f) => Both SourceBlob -> Diff f (Record fields) -> Text
|
||||
patch blobs diff = if not (Text.null text) && Text.last text /= '\n'
|
||||
then text <> "\n\\ No newline at end of file\n"
|
||||
else text
|
||||
|
Loading…
Reference in New Issue
Block a user