1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Module def has it's own analysis now

This commit is contained in:
Timothy Clem 2018-01-25 11:45:05 -08:00
parent 184d25bccc
commit 479606fb35
2 changed files with 0 additions and 9 deletions

View File

@ -34,7 +34,6 @@ data Declaration
| FunctionDeclaration { declarationIdentifier :: T.Text, declarationText :: T.Text, declarationLanguage :: Maybe Language } | FunctionDeclaration { declarationIdentifier :: T.Text, declarationText :: T.Text, declarationLanguage :: Maybe Language }
| HeadingDeclaration { declarationIdentifier :: T.Text, declarationText :: T.Text, declarationLanguage :: Maybe Language, declarationLevel :: Int } | HeadingDeclaration { declarationIdentifier :: T.Text, declarationText :: T.Text, declarationLanguage :: Maybe Language, declarationLevel :: Int }
| CallReference { declarationIdentifier :: T.Text, declarationImportIdentifier :: Maybe T.Text } | CallReference { declarationIdentifier :: T.Text, declarationImportIdentifier :: Maybe T.Text }
| ModuleDeclaration { declarationIdentifier :: T.Text }
| ErrorDeclaration { declarationIdentifier :: T.Text, declarationText :: T.Text, declarationLanguage :: Maybe Language } | ErrorDeclaration { declarationIdentifier :: T.Text, declarationText :: T.Text, declarationLanguage :: Maybe Language }
deriving (Eq, Generic, Show) deriving (Eq, Generic, Show)
@ -131,11 +130,6 @@ instance CustomHasDeclaration Expression.Call where
| otherwise = Just $ CallReference (getSource fromAnn) Nothing | otherwise = Just $ CallReference (getSource fromAnn) Nothing
where getSource = toText . flip Source.slice blobSource . getField where getSource = toText . flip Source.slice blobSource . getField
instance CustomHasDeclaration Declaration.Module where
customToDeclaration Blob{..} _ (Declaration.Module (Term (In fromAnn _), _) _)
= Just $ ModuleDeclaration (getSource fromAnn)
where getSource = toText . flip Source.slice blobSource . getField
-- | Produce a 'Declaration' for 'Union's using the 'HasDeclaration' instance & therefore using a 'CustomHasDeclaration' instance when one exists & the type is listed in 'DeclarationStrategy'. -- | Produce a 'Declaration' for 'Union's using the 'HasDeclaration' instance & therefore using a 'CustomHasDeclaration' instance when one exists & the type is listed in 'DeclarationStrategy'.
instance Apply HasDeclaration fs => CustomHasDeclaration (Union fs) where instance Apply HasDeclaration fs => CustomHasDeclaration (Union fs) where
customToDeclaration blob ann = apply (Proxy :: Proxy HasDeclaration) (toDeclaration blob ann) customToDeclaration blob ann = apply (Proxy :: Proxy HasDeclaration) (toDeclaration blob ann)
@ -163,7 +157,6 @@ type family DeclarationStrategy syntax where
DeclarationStrategy Declaration.Method = 'Custom DeclarationStrategy Declaration.Method = 'Custom
DeclarationStrategy Markdown.Heading = 'Custom DeclarationStrategy Markdown.Heading = 'Custom
DeclarationStrategy Expression.Call = 'Custom DeclarationStrategy Expression.Call = 'Custom
DeclarationStrategy Declaration.Module = 'Custom
DeclarationStrategy Syntax.Error = 'Custom DeclarationStrategy Syntax.Error = 'Custom
DeclarationStrategy (Union fs) = 'Custom DeclarationStrategy (Union fs) = 'Custom
DeclarationStrategy a = 'Default DeclarationStrategy a = 'Default

View File

@ -171,7 +171,6 @@ diffTOC = mapMaybe entrySummary . dedupe . filter extraDeclarations . tableOfCon
extraDeclarations :: HasField fields (Maybe Declaration) => Entry (Record fields) -> Bool extraDeclarations :: HasField fields (Maybe Declaration) => Entry (Record fields) -> Bool
extraDeclarations entry = case getDeclaration (entryPayload entry) of extraDeclarations entry = case getDeclaration (entryPayload entry) of
Just ImportDeclaration{..} -> False Just ImportDeclaration{..} -> False
Just ModuleDeclaration{..} -> False
Just CallReference{..} -> False Just CallReference{..} -> False
_ -> True _ -> True
@ -192,6 +191,5 @@ toCategoryName declaration = case declaration of
FunctionDeclaration{} -> "Function" FunctionDeclaration{} -> "Function"
MethodDeclaration{} -> "Method" MethodDeclaration{} -> "Method"
CallReference{} -> "Call" CallReference{} -> "Call"
ModuleDeclaration{} -> "Module"
HeadingDeclaration _ _ _ l -> "Heading " <> T.pack (show l) HeadingDeclaration _ _ _ l -> "Heading " <> T.pack (show l)
ErrorDeclaration{} -> "ParseError" ErrorDeclaration{} -> "ParseError"