mirror of
https://github.com/github/semantic.git
synced 2024-11-27 12:57:49 +03:00
Merge pull request #1975 from github/no-more-tags-output
🔥 the --tags output and associated code
This commit is contained in:
commit
88499cb0ae
@ -12,7 +12,6 @@ module Rendering.Renderer
|
||||
, renderToSymbols
|
||||
, ImportSummary(..)
|
||||
, renderToImports
|
||||
, renderToTags
|
||||
, renderTreeGraph
|
||||
, Summaries(..)
|
||||
, TOCSummary(..)
|
||||
@ -21,7 +20,6 @@ module Rendering.Renderer
|
||||
, parseSymbolFields
|
||||
) where
|
||||
|
||||
import Data.Aeson (Value)
|
||||
import Data.ByteString.Builder
|
||||
import Data.Graph
|
||||
import Rendering.Graph as R
|
||||
@ -52,8 +50,6 @@ data TermRenderer output where
|
||||
JSONTermRenderer :: TermRenderer (JSON "trees" SomeJSON)
|
||||
-- | Render to a 'ByteString' formatted as nested s-expressions.
|
||||
SExpressionTermRenderer :: TermRenderer Builder
|
||||
-- | Render to a list of tags (deprecated).
|
||||
TagsTermRenderer :: TermRenderer [Value]
|
||||
-- | Render to a list of symbols.
|
||||
SymbolsTermRenderer :: SymbolFields -> TermRenderer (JSON "files" SomeJSON)
|
||||
-- | Render to a list of modules that represent the import graph.
|
||||
|
@ -1,7 +1,6 @@
|
||||
{-# LANGUAGE RankNTypes, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
module Rendering.Symbol
|
||||
( renderToSymbols
|
||||
, renderToTags
|
||||
, SymbolFields(..)
|
||||
, defaultSymbolFields
|
||||
, parseSymbolFields
|
||||
@ -20,18 +19,6 @@ import qualified Data.Text as T
|
||||
import Rendering.TOC
|
||||
|
||||
|
||||
-- | Render a 'Term' to a ctags like output (See 'Tag').
|
||||
--
|
||||
-- This format is going away. Prefer the new 'renderToSymbols' as it provides a
|
||||
-- more compact data representation and custom field selection. This exists to
|
||||
-- back support the staff shipped tag generation in github/github.
|
||||
renderToTags :: (HasField fields (Maybe Declaration), HasField fields Span, Foldable f, Functor f) => Blob -> Term f (Record fields) -> [Value]
|
||||
renderToTags Blob{..} = fmap toJSON . termToC blobPath
|
||||
where
|
||||
termToC :: (HasField fields (Maybe Declaration), HasField fields Span, Foldable f, Functor f) => FilePath -> Term f (Record fields) -> [Symbol]
|
||||
termToC path = mapMaybe (symbolSummary defaultTagSymbolFields path "unchanged") . termTableOfContentsBy declaration
|
||||
|
||||
|
||||
-- | Render a 'Term' to a list of symbols (See 'Symbol').
|
||||
renderToSymbols :: (HasField fields (Maybe Declaration), HasField fields Span, Foldable f, Functor f) => SymbolFields -> Blob -> Term f (Record fields) -> [Value]
|
||||
renderToSymbols fields Blob{..} term = [toJSON (termToC fields blobPath term)]
|
||||
@ -100,9 +87,6 @@ data SymbolFields = SymbolFields
|
||||
defaultSymbolFields :: SymbolFields
|
||||
defaultSymbolFields = SymbolFields True False False True False True
|
||||
|
||||
defaultTagSymbolFields :: SymbolFields
|
||||
defaultTagSymbolFields = SymbolFields True True True True True True
|
||||
|
||||
parseSymbolFields :: String -> SymbolFields
|
||||
parseSymbolFields arg =
|
||||
let fields = splitWhen (== ',') arg in
|
||||
|
@ -64,7 +64,6 @@ arguments = info (version <*> helper <*> ((,) <$> optionsParser <*> argumentsPar
|
||||
parseArgumentsParser = do
|
||||
renderer <- flag (Parse.runParse SExpressionTermRenderer) (Parse.runParse SExpressionTermRenderer) (long "sexpression" <> help "Output s-expression parse trees (default)")
|
||||
<|> flag' (Parse.runParse JSONTermRenderer) (long "json" <> help "Output JSON parse trees")
|
||||
<|> flag' (Parse.runParse TagsTermRenderer) (long "tags" <> help "Output JSON tags")
|
||||
<|> flag' (Parse.runParse . SymbolsTermRenderer) (long "symbols" <> help "Output JSON symbol list")
|
||||
<*> (option symbolFieldsReader ( long "fields"
|
||||
<> help "Comma delimited list of specific fields to return (symbols output only)."
|
||||
|
@ -21,7 +21,6 @@ runParse :: (Member (Distribute WrappedTask) effs, Member Task effs) => TermRend
|
||||
runParse JSONTermRenderer = withParsedBlobs (render . renderJSONTerm) >=> serialize JSON
|
||||
runParse SExpressionTermRenderer = withParsedBlobs (const (serialize (SExpression ByConstructorName)))
|
||||
runParse ShowTermRenderer = withParsedBlobs (const (serialize Show))
|
||||
runParse TagsTermRenderer = withParsedBlobs (\ blob -> decorate (declarationAlgebra blob) >=> render (renderToTags blob)) >=> serialize JSON
|
||||
runParse ImportsTermRenderer = withParsedBlobs (\ blob -> decorate (declarationAlgebra blob) >=> decorate (packageDefAlgebra blob) >=> render (renderToImports blob)) >=> serialize JSON
|
||||
runParse (SymbolsTermRenderer fields) = withParsedBlobs (\ blob -> decorate (declarationAlgebra blob) >=> render (renderSymbolTerms . renderToSymbols fields blob)) >=> serialize JSON
|
||||
runParse DOTTermRenderer = withParsedBlobs (const (render renderTreeGraph)) >=> serialize (DOT (termStyle "terms"))
|
||||
|
@ -37,7 +37,6 @@ parseFixtures =
|
||||
, (show JSONTermRenderer, runParse JSONTermRenderer, path', prefix </> "parse-trees.json")
|
||||
, (show JSONTermRenderer, runParse JSONTermRenderer, [], prefix </> "parse-tree-empty.json")
|
||||
, (show (SymbolsTermRenderer defaultSymbolFields), runParse (SymbolsTermRenderer defaultSymbolFields), path'', prefix </> "parse-tree.symbols.json")
|
||||
, (show TagsTermRenderer, runParse TagsTermRenderer, path'', prefix </> "parse-tree.tags.json")
|
||||
]
|
||||
where path = [File "test/fixtures/ruby/corpus/and-or.A.rb" Ruby]
|
||||
path' = [File "test/fixtures/ruby/corpus/and-or.A.rb" Ruby, File "test/fixtures/ruby/corpus/and-or.B.rb" Ruby]
|
||||
|
13
test/fixtures/cli/parse-tree.tags.json
vendored
13
test/fixtures/cli/parse-tree.tags.json
vendored
@ -1,13 +0,0 @@
|
||||
[
|
||||
{
|
||||
"span":
|
||||
{
|
||||
"start": [1, 1],
|
||||
"end": [2, 4]
|
||||
},
|
||||
"path": "test/fixtures/ruby/corpus/method-declaration.A.rb",
|
||||
"kind": "Method",
|
||||
"symbol": "foo",
|
||||
"line": "def foo",
|
||||
"language": "Ruby"
|
||||
}]
|
Loading…
Reference in New Issue
Block a user