1
1
mirror of https://github.com/github/semantic.git synced 2024-11-23 08:27:56 +03:00

Merge pull request #563 from github/symbol-node-type

Add 'node_type' field to the Symbol protobuf message
This commit is contained in:
Max Brunsfeld 2020-06-03 10:42:37 -07:00 committed by GitHub
commit e485681b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 198 additions and 145 deletions

View File

@ -1,5 +1,5 @@
# Put protoc and twirp tooling in its own image
FROM haskell:8.8.3 as haskell
FROM haskell:8.8.1 as haskell
RUN cabal v2-update && \
cabal v2-install proto-lens-protoc
RUN which proto-lens-protoc
@ -17,12 +17,12 @@ RUN go get github.com/golang/protobuf/proto && \
COPY --from=haskell /root/.cabal/bin/proto-lens-protoc /usr/local/bin/proto-lens-protoc
# Bit of a hack so that proto-lens-protoc actually runs
COPY --from=haskell /opt/ghc/8.8.3/lib/ghc-8.8.3/* /opt/ghc/8.8.3/lib/ghc-8.8.3/
COPY --from=haskell /opt/ghc/8.8.1/lib/ghc-8.8.1/* /opt/ghc/8.8.1/lib/ghc-8.8.1/
ENTRYPOINT ["/protobuf/bin/protoc", "-I/protobuf", "--plugin=protoc-gen-haskell=/usr/local/bin/proto-lens-protoc"]
# Build semantic
FROM haskell:8.8.3 as build
FROM haskell:8.8.1 as build
WORKDIR /build
# Build all of semantic

View File

@ -128,6 +128,7 @@ message Symbol {
string line = 3;
Span span = 4;
Docstring docs = 5;
NodeType node_type = 6;
}
message Docstring {
@ -152,19 +153,20 @@ message StackGraphFile {
repeated ParseError errors = 5;
}
enum NodeType {
ROOT_SCOPE = 0;
JUMP_TO_SCOPE = 1;
EXPORTED_SCOPE = 2;
DEFINITION = 3;
REFERENCE = 4;
}
message StackGraphNode {
int64 id = 1;
string name = 2;
string line = 3;
string kind = 4;
Span span = 5;
enum NodeType {
ROOT_SCOPE = 0;
JUMP_TO_SCOPE = 1;
EXPORTED_SCOPE = 2;
DEFINITION = 3;
REFERENCE = 4;
}
NodeType node_type = 6;
}

View File

@ -9,13 +9,11 @@ module Proto.Semantic (
DiffTreeVertex'DiffTerm(..), _DiffTreeVertex'Deleted,
_DiffTreeVertex'Inserted, _DiffTreeVertex'Replaced,
_DiffTreeVertex'Merged, Docstring(), File(), InsertedTerm(),
MergedTerm(), ParseError(), ParseTreeFileGraph(),
ParseTreeGraphResponse(), ParseTreeRequest(),
ParseTreeSymbolResponse(), PingRequest(), PingResponse(),
Position(), ReplacedTerm(), Span(), StackGraphFile(),
StackGraphNode(), StackGraphNode'NodeType(..),
StackGraphNode'NodeType(),
StackGraphNode'NodeType'UnrecognizedValue, StackGraphPath(),
MergedTerm(), NodeType(..), NodeType(), NodeType'UnrecognizedValue,
ParseError(), ParseTreeFileGraph(), ParseTreeGraphResponse(),
ParseTreeRequest(), ParseTreeSymbolResponse(), PingRequest(),
PingResponse(), Position(), ReplacedTerm(), Span(),
StackGraphFile(), StackGraphNode(), StackGraphPath(),
StackGraphRequest(), StackGraphResponse(), Symbol(), TermEdge(),
TermVertex()
) where
@ -2301,6 +2299,86 @@ instance Control.DeepSeq.NFData MergedTerm where
(Control.DeepSeq.deepseq
(_MergedTerm'beforeSpan x__)
(Control.DeepSeq.deepseq (_MergedTerm'afterSpan x__) ())))
newtype NodeType'UnrecognizedValue
= NodeType'UnrecognizedValue Data.Int.Int32
deriving (Prelude.Eq, Prelude.Ord, Prelude.Show)
data NodeType
= ROOT_SCOPE |
JUMP_TO_SCOPE |
EXPORTED_SCOPE |
DEFINITION |
REFERENCE |
NodeType'Unrecognized !NodeType'UnrecognizedValue
deriving (Prelude.Show, Prelude.Eq, Prelude.Ord)
instance Data.ProtoLens.MessageEnum NodeType where
maybeToEnum 0 = Prelude.Just ROOT_SCOPE
maybeToEnum 1 = Prelude.Just JUMP_TO_SCOPE
maybeToEnum 2 = Prelude.Just EXPORTED_SCOPE
maybeToEnum 3 = Prelude.Just DEFINITION
maybeToEnum 4 = Prelude.Just REFERENCE
maybeToEnum k
= Prelude.Just
(NodeType'Unrecognized
(NodeType'UnrecognizedValue (Prelude.fromIntegral k)))
showEnum ROOT_SCOPE = "ROOT_SCOPE"
showEnum JUMP_TO_SCOPE = "JUMP_TO_SCOPE"
showEnum EXPORTED_SCOPE = "EXPORTED_SCOPE"
showEnum DEFINITION = "DEFINITION"
showEnum REFERENCE = "REFERENCE"
showEnum (NodeType'Unrecognized (NodeType'UnrecognizedValue k))
= Prelude.show k
readEnum k
| (Prelude.==) k "ROOT_SCOPE" = Prelude.Just ROOT_SCOPE
| (Prelude.==) k "JUMP_TO_SCOPE" = Prelude.Just JUMP_TO_SCOPE
| (Prelude.==) k "EXPORTED_SCOPE" = Prelude.Just EXPORTED_SCOPE
| (Prelude.==) k "DEFINITION" = Prelude.Just DEFINITION
| (Prelude.==) k "REFERENCE" = Prelude.Just REFERENCE
| Prelude.otherwise
= (Prelude.>>=) (Text.Read.readMaybe k) Data.ProtoLens.maybeToEnum
instance Prelude.Bounded NodeType where
minBound = ROOT_SCOPE
maxBound = REFERENCE
instance Prelude.Enum NodeType where
toEnum k__
= Prelude.maybe
(Prelude.error
((Prelude.++)
"toEnum: unknown value for enum NodeType: " (Prelude.show k__)))
Prelude.id
(Data.ProtoLens.maybeToEnum k__)
fromEnum ROOT_SCOPE = 0
fromEnum JUMP_TO_SCOPE = 1
fromEnum EXPORTED_SCOPE = 2
fromEnum DEFINITION = 3
fromEnum REFERENCE = 4
fromEnum (NodeType'Unrecognized (NodeType'UnrecognizedValue k))
= Prelude.fromIntegral k
succ REFERENCE
= Prelude.error
"NodeType.succ: bad argument REFERENCE. This value would be out of bounds."
succ ROOT_SCOPE = JUMP_TO_SCOPE
succ JUMP_TO_SCOPE = EXPORTED_SCOPE
succ EXPORTED_SCOPE = DEFINITION
succ DEFINITION = REFERENCE
succ (NodeType'Unrecognized _)
= Prelude.error "NodeType.succ: bad argument: unrecognized value"
pred ROOT_SCOPE
= Prelude.error
"NodeType.pred: bad argument ROOT_SCOPE. This value would be out of bounds."
pred JUMP_TO_SCOPE = ROOT_SCOPE
pred EXPORTED_SCOPE = JUMP_TO_SCOPE
pred DEFINITION = EXPORTED_SCOPE
pred REFERENCE = DEFINITION
pred (NodeType'Unrecognized _)
= Prelude.error "NodeType.pred: bad argument: unrecognized value"
enumFrom = Data.ProtoLens.Message.Enum.messageEnumFrom
enumFromTo = Data.ProtoLens.Message.Enum.messageEnumFromTo
enumFromThen = Data.ProtoLens.Message.Enum.messageEnumFromThen
enumFromThenTo = Data.ProtoLens.Message.Enum.messageEnumFromThenTo
instance Data.ProtoLens.FieldDefault NodeType where
fieldDefault = ROOT_SCOPE
instance Control.DeepSeq.NFData NodeType where
rnf x__ = Prelude.seq x__ ()
{- | Fields :
* 'Proto.Semantic_Fields.error' @:: Lens' ParseError Data.Text.Text@ -}
@ -4503,14 +4581,14 @@ instance Control.DeepSeq.NFData StackGraphFile where
* 'Proto.Semantic_Fields.kind' @:: Lens' StackGraphNode Data.Text.Text@
* 'Proto.Semantic_Fields.span' @:: Lens' StackGraphNode Span@
* 'Proto.Semantic_Fields.maybe'span' @:: Lens' StackGraphNode (Prelude.Maybe Span)@
* 'Proto.Semantic_Fields.nodeType' @:: Lens' StackGraphNode StackGraphNode'NodeType@ -}
* 'Proto.Semantic_Fields.nodeType' @:: Lens' StackGraphNode NodeType@ -}
data StackGraphNode
= StackGraphNode'_constructor {_StackGraphNode'id :: !Data.Int.Int64,
_StackGraphNode'name :: !Data.Text.Text,
_StackGraphNode'line :: !Data.Text.Text,
_StackGraphNode'kind :: !Data.Text.Text,
_StackGraphNode'span :: !(Prelude.Maybe Span),
_StackGraphNode'nodeType :: !StackGraphNode'NodeType,
_StackGraphNode'nodeType :: !NodeType,
_StackGraphNode'_unknownFields :: !Data.ProtoLens.FieldSet}
deriving (Prelude.Eq, Prelude.Ord)
instance Prelude.Show StackGraphNode where
@ -4560,7 +4638,7 @@ instance Data.ProtoLens.Field.HasField StackGraphNode "maybe'span" (Prelude.Mayb
_StackGraphNode'span
(\ x__ y__ -> x__ {_StackGraphNode'span = y__}))
Prelude.id
instance Data.ProtoLens.Field.HasField StackGraphNode "nodeType" StackGraphNode'NodeType where
instance Data.ProtoLens.Field.HasField StackGraphNode "nodeType" NodeType where
fieldOf _
= (Prelude..)
(Lens.Family2.Unchecked.lens
@ -4615,7 +4693,7 @@ instance Data.ProtoLens.Message StackGraphNode where
= Data.ProtoLens.FieldDescriptor
"node_type"
(Data.ProtoLens.ScalarField Data.ProtoLens.EnumField ::
Data.ProtoLens.FieldTypeDescriptor StackGraphNode'NodeType)
Data.ProtoLens.FieldTypeDescriptor NodeType)
(Data.ProtoLens.PlainField
Data.ProtoLens.Optional
(Data.ProtoLens.Field.field @"nodeType")) ::
@ -4841,96 +4919,6 @@ instance Control.DeepSeq.NFData StackGraphNode where
(Control.DeepSeq.deepseq
(_StackGraphNode'span x__)
(Control.DeepSeq.deepseq (_StackGraphNode'nodeType x__) ()))))))
newtype StackGraphNode'NodeType'UnrecognizedValue
= StackGraphNode'NodeType'UnrecognizedValue Data.Int.Int32
deriving (Prelude.Eq, Prelude.Ord, Prelude.Show)
data StackGraphNode'NodeType
= StackGraphNode'ROOT_SCOPE |
StackGraphNode'JUMP_TO_SCOPE |
StackGraphNode'EXPORTED_SCOPE |
StackGraphNode'DEFINITION |
StackGraphNode'REFERENCE |
StackGraphNode'NodeType'Unrecognized !StackGraphNode'NodeType'UnrecognizedValue
deriving (Prelude.Show, Prelude.Eq, Prelude.Ord)
instance Data.ProtoLens.MessageEnum StackGraphNode'NodeType where
maybeToEnum 0 = Prelude.Just StackGraphNode'ROOT_SCOPE
maybeToEnum 1 = Prelude.Just StackGraphNode'JUMP_TO_SCOPE
maybeToEnum 2 = Prelude.Just StackGraphNode'EXPORTED_SCOPE
maybeToEnum 3 = Prelude.Just StackGraphNode'DEFINITION
maybeToEnum 4 = Prelude.Just StackGraphNode'REFERENCE
maybeToEnum k
= Prelude.Just
(StackGraphNode'NodeType'Unrecognized
(StackGraphNode'NodeType'UnrecognizedValue
(Prelude.fromIntegral k)))
showEnum StackGraphNode'ROOT_SCOPE = "ROOT_SCOPE"
showEnum StackGraphNode'JUMP_TO_SCOPE = "JUMP_TO_SCOPE"
showEnum StackGraphNode'EXPORTED_SCOPE = "EXPORTED_SCOPE"
showEnum StackGraphNode'DEFINITION = "DEFINITION"
showEnum StackGraphNode'REFERENCE = "REFERENCE"
showEnum
(StackGraphNode'NodeType'Unrecognized (StackGraphNode'NodeType'UnrecognizedValue k))
= Prelude.show k
readEnum k
| (Prelude.==) k "ROOT_SCOPE"
= Prelude.Just StackGraphNode'ROOT_SCOPE
| (Prelude.==) k "JUMP_TO_SCOPE"
= Prelude.Just StackGraphNode'JUMP_TO_SCOPE
| (Prelude.==) k "EXPORTED_SCOPE"
= Prelude.Just StackGraphNode'EXPORTED_SCOPE
| (Prelude.==) k "DEFINITION"
= Prelude.Just StackGraphNode'DEFINITION
| (Prelude.==) k "REFERENCE"
= Prelude.Just StackGraphNode'REFERENCE
| Prelude.otherwise
= (Prelude.>>=) (Text.Read.readMaybe k) Data.ProtoLens.maybeToEnum
instance Prelude.Bounded StackGraphNode'NodeType where
minBound = StackGraphNode'ROOT_SCOPE
maxBound = StackGraphNode'REFERENCE
instance Prelude.Enum StackGraphNode'NodeType where
toEnum k__
= Prelude.maybe
(Prelude.error
((Prelude.++)
"toEnum: unknown value for enum NodeType: " (Prelude.show k__)))
Prelude.id
(Data.ProtoLens.maybeToEnum k__)
fromEnum StackGraphNode'ROOT_SCOPE = 0
fromEnum StackGraphNode'JUMP_TO_SCOPE = 1
fromEnum StackGraphNode'EXPORTED_SCOPE = 2
fromEnum StackGraphNode'DEFINITION = 3
fromEnum StackGraphNode'REFERENCE = 4
fromEnum
(StackGraphNode'NodeType'Unrecognized (StackGraphNode'NodeType'UnrecognizedValue k))
= Prelude.fromIntegral k
succ StackGraphNode'REFERENCE
= Prelude.error
"StackGraphNode'NodeType.succ: bad argument StackGraphNode'REFERENCE. This value would be out of bounds."
succ StackGraphNode'ROOT_SCOPE = StackGraphNode'JUMP_TO_SCOPE
succ StackGraphNode'JUMP_TO_SCOPE = StackGraphNode'EXPORTED_SCOPE
succ StackGraphNode'EXPORTED_SCOPE = StackGraphNode'DEFINITION
succ StackGraphNode'DEFINITION = StackGraphNode'REFERENCE
succ (StackGraphNode'NodeType'Unrecognized _)
= Prelude.error
"StackGraphNode'NodeType.succ: bad argument: unrecognized value"
pred StackGraphNode'ROOT_SCOPE
= Prelude.error
"StackGraphNode'NodeType.pred: bad argument StackGraphNode'ROOT_SCOPE. This value would be out of bounds."
pred StackGraphNode'JUMP_TO_SCOPE = StackGraphNode'ROOT_SCOPE
pred StackGraphNode'EXPORTED_SCOPE = StackGraphNode'JUMP_TO_SCOPE
pred StackGraphNode'DEFINITION = StackGraphNode'EXPORTED_SCOPE
pred StackGraphNode'REFERENCE = StackGraphNode'DEFINITION
pred (StackGraphNode'NodeType'Unrecognized _)
= Prelude.error
"StackGraphNode'NodeType.pred: bad argument: unrecognized value"
enumFrom = Data.ProtoLens.Message.Enum.messageEnumFrom
enumFromTo = Data.ProtoLens.Message.Enum.messageEnumFromTo
enumFromThen = Data.ProtoLens.Message.Enum.messageEnumFromThen
enumFromThenTo = Data.ProtoLens.Message.Enum.messageEnumFromThenTo
instance Data.ProtoLens.FieldDefault StackGraphNode'NodeType where
fieldDefault = StackGraphNode'ROOT_SCOPE
instance Control.DeepSeq.NFData StackGraphNode'NodeType where
rnf x__ = Prelude.seq x__ ()
{- | Fields :
* 'Proto.Semantic_Fields.startingSymbolStack' @:: Lens' StackGraphPath [Data.Text.Text]@
@ -5697,13 +5685,15 @@ instance Control.DeepSeq.NFData StackGraphResponse where
* 'Proto.Semantic_Fields.span' @:: Lens' Symbol Span@
* 'Proto.Semantic_Fields.maybe'span' @:: Lens' Symbol (Prelude.Maybe Span)@
* 'Proto.Semantic_Fields.docs' @:: Lens' Symbol Docstring@
* 'Proto.Semantic_Fields.maybe'docs' @:: Lens' Symbol (Prelude.Maybe Docstring)@ -}
* 'Proto.Semantic_Fields.maybe'docs' @:: Lens' Symbol (Prelude.Maybe Docstring)@
* 'Proto.Semantic_Fields.nodeType' @:: Lens' Symbol NodeType@ -}
data Symbol
= Symbol'_constructor {_Symbol'symbol :: !Data.Text.Text,
_Symbol'kind :: !Data.Text.Text,
_Symbol'line :: !Data.Text.Text,
_Symbol'span :: !(Prelude.Maybe Span),
_Symbol'docs :: !(Prelude.Maybe Docstring),
_Symbol'nodeType :: !NodeType,
_Symbol'_unknownFields :: !Data.ProtoLens.FieldSet}
deriving (Prelude.Eq, Prelude.Ord)
instance Prelude.Show Symbol where
@ -5754,6 +5744,12 @@ instance Data.ProtoLens.Field.HasField Symbol "maybe'docs" (Prelude.Maybe Docstr
(Lens.Family2.Unchecked.lens
_Symbol'docs (\ x__ y__ -> x__ {_Symbol'docs = y__}))
Prelude.id
instance Data.ProtoLens.Field.HasField Symbol "nodeType" NodeType where
fieldOf _
= (Prelude..)
(Lens.Family2.Unchecked.lens
_Symbol'nodeType (\ x__ y__ -> x__ {_Symbol'nodeType = y__}))
Prelude.id
instance Data.ProtoLens.Message Symbol where
messageName _ = Data.Text.pack "github.semantic.Symbol"
fieldsByTag
@ -5798,13 +5794,23 @@ instance Data.ProtoLens.Message Symbol where
(Data.ProtoLens.OptionalField
(Data.ProtoLens.Field.field @"maybe'docs")) ::
Data.ProtoLens.FieldDescriptor Symbol
nodeType__field_descriptor
= Data.ProtoLens.FieldDescriptor
"node_type"
(Data.ProtoLens.ScalarField Data.ProtoLens.EnumField ::
Data.ProtoLens.FieldTypeDescriptor NodeType)
(Data.ProtoLens.PlainField
Data.ProtoLens.Optional
(Data.ProtoLens.Field.field @"nodeType")) ::
Data.ProtoLens.FieldDescriptor Symbol
in
Data.Map.fromList
[(Data.ProtoLens.Tag 1, symbol__field_descriptor),
(Data.ProtoLens.Tag 2, kind__field_descriptor),
(Data.ProtoLens.Tag 3, line__field_descriptor),
(Data.ProtoLens.Tag 4, span__field_descriptor),
(Data.ProtoLens.Tag 5, docs__field_descriptor)]
(Data.ProtoLens.Tag 5, docs__field_descriptor),
(Data.ProtoLens.Tag 6, nodeType__field_descriptor)]
unknownFields
= Lens.Family2.Unchecked.lens
_Symbol'_unknownFields
@ -5815,6 +5821,7 @@ instance Data.ProtoLens.Message Symbol where
_Symbol'kind = Data.ProtoLens.fieldDefault,
_Symbol'line = Data.ProtoLens.fieldDefault,
_Symbol'span = Prelude.Nothing, _Symbol'docs = Prelude.Nothing,
_Symbol'nodeType = Data.ProtoLens.fieldDefault,
_Symbol'_unknownFields = []}
parseMessage
= let
@ -5887,6 +5894,16 @@ instance Data.ProtoLens.Message Symbol where
(Prelude.fromIntegral len) Data.ProtoLens.parseMessage)
"docs"
loop (Lens.Family2.set (Data.ProtoLens.Field.field @"docs") y x)
48
-> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)
(Prelude.fmap
Prelude.toEnum
(Prelude.fmap
Prelude.fromIntegral
Data.ProtoLens.Encoding.Bytes.getVarInt))
"node_type"
loop
(Lens.Family2.set (Data.ProtoLens.Field.field @"nodeType") y x)
wire
-> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire
wire
@ -5979,8 +5996,23 @@ instance Data.ProtoLens.Message Symbol where
(Data.ProtoLens.Encoding.Bytes.putBytes bs))
Data.ProtoLens.encodeMessage
_v))
(Data.ProtoLens.Encoding.Wire.buildFieldSet
(Lens.Family2.view Data.ProtoLens.unknownFields _x))))))
((Data.Monoid.<>)
(let
_v = Lens.Family2.view (Data.ProtoLens.Field.field @"nodeType") _x
in
if (Prelude.==) _v Data.ProtoLens.fieldDefault then
Data.Monoid.mempty
else
(Data.Monoid.<>)
(Data.ProtoLens.Encoding.Bytes.putVarInt 48)
((Prelude..)
((Prelude..)
Data.ProtoLens.Encoding.Bytes.putVarInt
Prelude.fromIntegral)
Prelude.fromEnum
_v))
(Data.ProtoLens.Encoding.Wire.buildFieldSet
(Lens.Family2.view Data.ProtoLens.unknownFields _x)))))))
instance Control.DeepSeq.NFData Symbol where
rnf
= \ x__
@ -5994,7 +6026,9 @@ instance Control.DeepSeq.NFData Symbol where
(_Symbol'line x__)
(Control.DeepSeq.deepseq
(_Symbol'span x__)
(Control.DeepSeq.deepseq (_Symbol'docs x__) ())))))
(Control.DeepSeq.deepseq
(_Symbol'docs x__)
(Control.DeepSeq.deepseq (_Symbol'nodeType x__) ()))))))
{- | Fields :
* 'Proto.Semantic_Fields.source' @:: Lens' TermEdge Data.Int.Int32@

View File

@ -607,12 +607,14 @@ instance FromJSONPB Symbol where
line' <- obj .: "line"
span' <- obj A..:? "span"
docs' <- obj A..:? "docs"
nodeType' <- obj .: "nodeType"
pure $ defMessage
& P.symbol .~ symbol'
& P.kind .~ kind'
& P.line .~ line'
& P.maybe'span .~ span'
& P.maybe'docs .~ docs'
& P.nodeType .~ nodeType'
instance ToJSONPB Symbol where
toJSONPB x = object
@ -621,6 +623,7 @@ instance ToJSONPB Symbol where
, "line" .= (x^.line)
, "span" .= (x^.maybe'span)
, "docs" .= (x^.maybe'docs)
, "nodeType" .= (x^.nodeType)
]
toEncodingPB x = pairs
[ "symbol" .= (x^.symbol)
@ -628,6 +631,7 @@ instance ToJSONPB Symbol where
, "line" .= (x^.line)
, "span" .= (x^.maybe'span)
, "docs" .= (x^.maybe'docs)
, "nodeType" .= (x^.nodeType)
]
instance FromJSON Symbol where
@ -786,25 +790,6 @@ instance ToJSON StackGraphNode where
toJSON = toAesonValue
toEncoding = toAesonEncoding
instance FromJSONPB StackGraphNode'NodeType where
parseJSONPB (JSONPB.String "ROOT_SCOPE") = pure StackGraphNode'ROOT_SCOPE
parseJSONPB (JSONPB.String "JUMP_TO_SCOPE") = pure StackGraphNode'JUMP_TO_SCOPE
parseJSONPB (JSONPB.String "EXPORTED_SCOPE") = pure StackGraphNode'EXPORTED_SCOPE
parseJSONPB (JSONPB.String "DEFINITION") = pure StackGraphNode'DEFINITION
parseJSONPB (JSONPB.String "REFERENCE") = pure StackGraphNode'REFERENCE
parseJSONPB x = typeMismatch "NodeType" x
instance ToJSONPB StackGraphNode'NodeType where
toJSONPB x _ = A.String . T.toUpper . T.pack $ show x
toEncodingPB x _ = E.text . T.toUpper . T.pack $ show x
instance FromJSON StackGraphNode'NodeType where
parseJSON = parseJSONPB
instance ToJSON StackGraphNode'NodeType where
toJSON = toAesonValue
toEncoding = toAesonEncoding
instance FromJSONPB StackGraphPath where
parseJSONPB = withObject "StackGraphPath" $ \obj -> do
startingSymbolStack' <- obj .: "startingSymbolStack"
@ -849,3 +834,22 @@ instance FromJSON StackGraphPath where
instance ToJSON StackGraphPath where
toJSON = toAesonValue
toEncoding = toAesonEncoding
instance FromJSONPB NodeType where
parseJSONPB (JSONPB.String "ROOT_SCOPE") = pure ROOT_SCOPE
parseJSONPB (JSONPB.String "JUMP_TO_SCOPE") = pure JUMP_TO_SCOPE
parseJSONPB (JSONPB.String "EXPORTED_SCOPE") = pure EXPORTED_SCOPE
parseJSONPB (JSONPB.String "DEFINITION") = pure DEFINITION
parseJSONPB (JSONPB.String "REFERENCE") = pure REFERENCE
parseJSONPB x = typeMismatch "NodeType" x
instance ToJSONPB NodeType where
toJSONPB x _ = A.String . T.toUpper . T.pack $ show x
toEncodingPB x _ = E.text . T.toUpper . T.pack $ show x
instance FromJSON NodeType where
parseJSON = parseJSONPB
instance ToJSON NodeType where
toJSON = toAesonValue
toEncoding = toAesonEncoding

View File

@ -85,13 +85,13 @@ parseStackGraph blobs = do
& P.endingScopeStack .~ pathEndingScopeStack path
& P.endingSymbolStack .~ pathEndingSymbolStack path
nodeTypeToNodeType :: SGNodeType -> StackGraphNode'NodeType
nodeTypeToNodeType :: SGNodeType -> NodeType
nodeTypeToNodeType = \case
RootScope -> P.StackGraphNode'ROOT_SCOPE
JumpToScope -> P.StackGraphNode'JUMP_TO_SCOPE
ExportedScope -> P.StackGraphNode'EXPORTED_SCOPE
Definition -> P.StackGraphNode'DEFINITION
Reference -> P.StackGraphNode'REFERENCE
RootScope -> P.ROOT_SCOPE
JumpToScope -> P.JUMP_TO_SCOPE
ExportedScope -> P.EXPORTED_SCOPE
Definition -> P.DEFINITION
Reference -> P.REFERENCE
-- TODO: These are temporary, will replace with proper datatypes from the scope graph work.
data TempStackGraph

View File

@ -2,6 +2,7 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
@ -103,10 +104,22 @@ parseSymbols blobs = do
tagToSymbol Tag{..} = defMessage
& P.symbol .~ name
& P.kind .~ pack (show kind)
& P.nodeType .~ nodeTypeForKind kind
& P.line .~ line
& P.maybe'span ?~ converting # Loc.span loc
& P.maybe'docs .~ fmap (flip (set P.docstring) defMessage) docs
nodeTypeForKind :: Kind -> NodeType
nodeTypeForKind = \case
Function -> DEFINITION
Method -> DEFINITION
Class -> DEFINITION
Module -> DEFINITION
Interface -> DEFINITION
Call -> REFERENCE
Type -> REFERENCE
Implementation -> REFERENCE
tagsForBlob :: (Has (Error SomeException) sig m, Has Parse sig m, Has (Reader PerLanguageModes) sig m) => Blob -> m [Tag]
tagsForBlob blob = asks toTagsParsers >>= \p -> parseWith p (pure . tags symbolsToSummarize blob) blob

View File

@ -1 +1 @@
{"files":[{"path":"test/fixtures/ruby/corpus/method-declaration.A.rb","language":"Ruby","symbols":[{"symbol":"foo","kind":"Method","line":"def foo","span":{"start":{"line":1,"column":5},"end":{"line":1,"column":8}}}]}]}
{"files":[{"path":"test/fixtures/ruby/corpus/method-declaration.A.rb","language":"Ruby","symbols":[{"symbol":"foo","kind":"Method","line":"def foo","span":{"start":{"line":1,"column":5},"end":{"line":1,"column":8}},"nodeType":"DEFINITION"}]}]}

View File

@ -1,5 +1,5 @@
_
1test/fixtures/ruby/corpus/method-declaration.A.rbRuby$
a
1test/fixtures/ruby/corpus/method-declaration.A.rbRuby&
fooMethoddef foo"

0