Verified Commit 83be952c authored by Camil Staps's avatar Camil Staps 🚀

Include type in fe_representation of macros; fix issue where documentation was...

Include type in fe_representation of macros; fix issue where documentation was not found for macros with an infix specification
parent 616eb28e
...@@ -11,11 +11,32 @@ import StdOverloadedList ...@@ -11,11 +11,32 @@ import StdOverloadedList
import StdString import StdString
import StdTuple import StdTuple
from Clean.Doc import :: ModuleDoc, :: FunctionDoc{vars,description}, :: ClassDoc,
:: TypeDoc{fields,constructors}, :: ConstructorDoc, :: ClassMemberDoc,
:: Description, :: ParseWarning(UsedReturn,IllegalField), :: ParseError,
generic docBlockToDoc, parseDoc, parseSingleLineDoc, :: DocBlock,
class docType(..), instance docType FunctionDoc,
class docConstructors(..), instance docConstructors TypeDoc,
class docFields(..), instance docFields TypeDoc,
traceParseError, traceParseWarnings,
constructorToFunctionDoc, functionToClassMemberDoc, addClassMemberDoc
import Clean.Idents
import Clean.Parse
import Clean.Parse.Comments
import Clean.PrettyPrint
from Clean.Types import instance == Type
import qualified Clean.Types as T
from Clean.Types.Tree import :: TypeTree, instance zero (TypeTree v), addType
from Clean.Types.Unify import isomorphic_to
import qualified Clean.Types.Unify as TU
from Clean.Types.Util import class print(print), instance print Type,
instance print Priority, instance toString Type
import Clean.Types.CoclTransform
import Control.Applicative import Control.Applicative
import Control.Monad import Control.Monad
import Data.Either import Data.Either
import Data.Error import Data.Error
from Data.Func import $, mapSt, on, `on` from Data.Func import $, mapSt, on, `on`, instance Functor ((->) a)
import Data.Functor import Data.Functor
import Data.GenDefault import Data.GenDefault
import Data.List import Data.List
...@@ -56,30 +77,6 @@ from syntax import :: ClassDef{class_args,class_context,class_ident,class_pos}, ...@@ -56,30 +77,6 @@ from syntax import :: ClassDef{class_args,class_context,class_ident,class_pos},
:: ParsedConstructor{pc_cons_ident}, :: ParsedSelector{ps_field_ident}, :: ParsedConstructor{pc_cons_ident}, :: ParsedSelector{ps_field_ident},
:: ParsedImport, :: Import{import_module} :: ParsedImport, :: Import{import_module}
import Clean.PrettyPrint
from Clean.Types import instance == Type
import qualified Clean.Types as T
from Clean.Types.Tree import :: TypeTree, instance zero (TypeTree v), addType
from Clean.Types.Unify import isomorphic_to
import qualified Clean.Types.Unify as TU
from Clean.Types.Util import class print(print), instance print Type,
instance print Priority
import Clean.Types.CoclTransform
from Clean.Doc import :: ModuleDoc, :: FunctionDoc{vars,description}, :: ClassDoc,
:: TypeDoc{fields,constructors}, :: ConstructorDoc, :: ClassMemberDoc,
:: Description, :: ParseWarning(UsedReturn,IllegalField), :: ParseError,
generic docBlockToDoc, parseDoc, parseSingleLineDoc, :: DocBlock,
class docType(..), instance docType FunctionDoc,
class docConstructors(..), instance docConstructors TypeDoc,
class docFields(..), instance docFields TypeDoc,
traceParseError, traceParseWarnings,
constructorToFunctionDoc, functionToClassMemberDoc, addClassMemberDoc
import Clean.Idents
import Clean.Parse
import Clean.Parse.Comments
from Cloogle.API import :: FunctionKind(..), instance == FunctionKind from Cloogle.API import :: FunctionKind(..), instance == FunctionKind
import qualified Cloogle.DB as CDB import qualified Cloogle.DB as CDB
from Cloogle.DB import from Cloogle.DB import
...@@ -572,24 +569,25 @@ where ...@@ -572,24 +569,25 @@ where
pd_rewriterules :: !Bool ![ParsedDefinition] !CollectedComments -> [(LocationInModule, 'CDB'.FunctionEntry, 'S'.Set String)] pd_rewriterules :: !Bool ![ParsedDefinition] !CollectedComments -> [(LocationInModule, 'CDB'.FunctionEntry, 'S'.Set String)]
pd_rewriterules dcl defs comments pd_rewriterules dcl defs comments
= [( setLine dcl pos {LocationInModule | zero & name=Just id.id_name} = [( setLine dcl pos {LocationInModule | zero & name=Just id.id_name}
, let doc = findDoc hideIsUsedReturn pd comments in , let infixts = findTypeSpec id defs
doc = findDoc hideIsUsedReturn pd comments <|> (flip (findDoc hideIsUsedReturn) comments =<< infixts)
type = (docType =<< doc) <|> pdType pd in
trace_type_warning id trace_type_warning id
{ zero { zero
& fe_kind=Macro & fe_kind=Macro
, fe_type=(docType =<< doc) <|> pdType pd , fe_type=type
, fe_representation=Just $ priostring id pd +++ cpp pd , fe_representation=Just $ signature id infixts type +++ cpp pd
, fe_priority=findPrio id >>= 'T'.toMaybePriority , fe_priority=findPrio id >>= 'T'.toMaybePriority
, fe_documentation=doc , fe_documentation=doc
} }
, (idents ICExpression pd).globals , (idents ICExpression pd).globals
) \\ pd=:(PD_Function pos id isinfix args rhs _) <- defs] ) \\ pd=:(PD_Function pos id isinfix args rhs _) <- defs]
where where
priostring :: Ident ParsedDefinition -> String signature :: Ident (Maybe ParsedDefinition) (Maybe 'T'.Type) -> String
priostring id pd = case findTypeSpec id defs of signature _ Nothing Nothing = ""
Just td -> cpp td +++ "\n" signature id Nothing (Just t) = id.id_name <+ " :: " <+ t <+ "\n"
Nothing -> case pdType pd of signature _ (Just pd) Nothing = cpp pd +++ "\n"
Just t -> id.id_name +++ " :: " +++ concat (print False t) +++ "\n" signature _ (Just pd) (Just t) = cpp pd <+ " :: " <+ t <+ "\n"
Nothing -> ""
findPrio :: Ident -> Maybe Priority findPrio :: Ident -> Maybe Priority
findPrio id = (\(PD_TypeSpec _ _ p _ _) -> p) <$> findTypeSpec id defs findPrio id = (\(PD_TypeSpec _ _ p _ _) -> p) <$> findTypeSpec id defs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment