mirror of
https://github.com/github/semantic.git
synced 2024-12-24 15:35:14 +03:00
Define a custom ToTagBy instance for ClassDeclaration.
This commit is contained in:
parent
1d8e0cdc3d
commit
074967337a
@ -47,6 +47,7 @@ type family ToTagsInstance t :: Strategy where
|
||||
ToTagsInstance (_ :+: _) = 'Custom
|
||||
ToTagsInstance Java.Program = 'Custom
|
||||
ToTagsInstance Java.MethodDeclaration = 'Custom
|
||||
ToTagsInstance Java.ClassDeclaration = 'Custom
|
||||
ToTagsInstance _ = 'Generic
|
||||
|
||||
|
||||
@ -82,6 +83,17 @@ instance ToTagsBy 'Custom Java.MethodDeclaration where
|
||||
traverse_ tags extraChildren
|
||||
traverse_ tags body
|
||||
|
||||
instance ToTagsBy 'Custom Java.ClassDeclaration where
|
||||
tags' t@Java.ClassDeclaration
|
||||
{ ann = Loc Range { start } span
|
||||
, name = Java.Identifier { bytes = name }
|
||||
, body = Java.ClassBody { ann = Loc Range { start = end } _ }
|
||||
} = do
|
||||
src <- ask @Source
|
||||
let sliced = slice src (Range start end)
|
||||
Tags.yield (Tag name Function span (firstLine sliced) Nothing)
|
||||
gtags t
|
||||
|
||||
firstLine :: Source -> Text
|
||||
firstLine = Text.takeWhile (/= '\n') . toText . Source.take 180
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user