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
import StdString
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.Monad
import Data.Either
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.GenDefault
import Data.List
......@@ -56,30 +77,6 @@ from syntax import :: ClassDef{class_args,class_context,class_ident,class_pos},
:: ParsedConstructor{pc_cons_ident}, :: ParsedSelector{ps_field_ident},
:: 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
import qualified Cloogle.DB as CDB
from Cloogle.DB import
......@@ -572,24 +569,25 @@ where
pd_rewriterules :: !Bool ![ParsedDefinition] !CollectedComments -> [(LocationInModule, 'CDB'.FunctionEntry, 'S'.Set String)]
pd_rewriterules dcl defs comments
= [( 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
{ zero
& fe_kind=Macro
, fe_type=(docType =<< doc) <|> pdType pd
, fe_representation=Just $ priostring id pd +++ cpp pd
, fe_type=type
, fe_representation=Just $ signature id infixts type +++ cpp pd
, fe_priority=findPrio id >>= 'T'.toMaybePriority
, fe_documentation=doc
}
, (idents ICExpression pd).globals
) \\ pd=:(PD_Function pos id isinfix args rhs _) <- defs]
where
priostring :: Ident ParsedDefinition -> String
priostring id pd = case findTypeSpec id defs of
Just td -> cpp td +++ "\n"
Nothing -> case pdType pd of
Just t -> id.id_name +++ " :: " +++ concat (print False t) +++ "\n"
Nothing -> ""
signature :: Ident (Maybe ParsedDefinition) (Maybe 'T'.Type) -> String
signature _ Nothing Nothing = ""
signature id Nothing (Just t) = id.id_name <+ " :: " <+ t <+ "\n"
signature _ (Just pd) Nothing = cpp pd +++ "\n"
signature _ (Just pd) (Just t) = cpp pd <+ " :: " <+ t <+ "\n"
findPrio :: Ident -> Maybe Priority
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