Verified Commit 64a2efb9 authored by Camil Staps's avatar Camil Staps 🚀

Update for new platform

parent a37156c9
......@@ -53,7 +53,7 @@ from syntax import :: ClassDef{class_args,class_context,class_ident,class_pos},
AbstractTypeSpec,NewTypeCons,MoreConses),
:: SymbolTable, :: SymbolTableEntry, :: SymbolType, :: Type, :: BITVECT,
:: TypeContext, :: TypeDef{td_ident,td_pos,td_rhs}, :: TypeVar,
:: ParsedConstructor{pc_cons_ident}, :: ParsedSelector{ps_selector_ident},
:: ParsedConstructor{pc_cons_ident}, :: ParsedSelector{ps_field_ident},
:: ParsedImport, :: Import{import_module}
import Clean.PrettyPrint
......@@ -475,7 +475,7 @@ findModuleContents include_locals path w
Ok (dcl,_) -> case dclcomments of
Error _ -> (zero, dcl.mod_defs, emptyCollectedComments)
Ok comments -> let coll = collectComments comments dcl in
( {zero & me_documentation=docParseResultToMaybe (const True) =<< parseDoc <$> getComment dcl.mod_ident coll}
( {zero & me_documentation=docParseResultToMaybe (const True) =<< parseDoc <$> getComment dcl coll}
, dcl.mod_defs
, coll
)
......@@ -572,7 +572,7 @@ 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 id comments in
, let doc = findDoc hideIsUsedReturn pd comments in
trace_type_warning id
{ zero
& fe_kind=Macro
......@@ -619,7 +619,7 @@ where
& fe_type=Just $ 'T'.toType gen_type
, fe_generic_vars=Just $ map 'T'.toTypeVar gen_vars
, fe_representation=Just $ cpp gen
, fe_documentation=findDoc hideIsUsedReturn id comments
, fe_documentation=findDoc hideIsUsedReturn gen comments
, fe_derivations=Just []
}
, 'S'.newSet
......@@ -632,7 +632,7 @@ where
& fe_type=Just $ 'T'.toType t
, fe_priority = 'T'.toMaybePriority p
, fe_representation = Just $ cpp ts
, fe_documentation = findDoc hideIsUsedReturn id comments
, fe_documentation = findDoc hideIsUsedReturn ts comments
}
, (idents ICExpression [pd \\ pd=:(PD_Function _ id _ _ _ _) <- defs | id.id_name == id_name]).globals
) \\ ts=:(PD_TypeSpec pos id=:{id_name} p (Yes t) funspecs) <- defs]
......@@ -660,7 +660,7 @@ where
& fe_kind=if (isNothing $ lookup n macros) fe.fe_kind Macro
, fe_representation=(fst <$> lookup n macros) <|> fe.fe_representation
, fe_documentation=if (isSingleFunction typespecs id)
((\d -> {FunctionDoc | d & vars=[]}) <$> findDoc hideIsUsedReturn id comments)
((\d -> {FunctionDoc | d & vars=[]}) <$> findDoc hideIsUsedReturn pd comments)
fe.fe_documentation
}
members = [(f,updateRepresentation f et,ids) \\ ({LocationInModule | name=Just f}, et, ids) <- typespecs]
......@@ -670,24 +670,24 @@ where
(map 'T'.toTypeVar class_args)
(all (\(_,fe,_) -> fe.fe_kind == Macro) members)
(flatten $ map 'T'.toTypeContext class_context)
(parseClassDoc typespecs id comments)
(parseClassDoc typespecs pd comments)
, members
)
\\ PD_Class {class_ident=id=:{id_name},class_pos,class_args,class_context} clsdefs <- defs
\\ pd=:(PD_Class {class_ident=id=:{id_name},class_pos,class_args,class_context} clsdefs) <- defs
]
where
// When the class has one member with the same name as the class, use
// the class documentation as the function's documentation. This is the
// case for classes like `class zero a :: a`, which do not have a where
// clause and hence no other place for the function's documentation.
parseClassDoc :: [(LocationInModule, 'CDB'.FunctionEntry, a)] Ident !CollectedComments -> Maybe ClassDoc
parseClassDoc members id comments
parseClassDoc :: [(LocationInModule, 'CDB'.FunctionEntry, a)] ParsedDefinition !CollectedComments -> Maybe ClassDoc
parseClassDoc members pd=:(PD_Class {class_ident=id} _) comments
| isSingleFunction members id = flip addClassMemberDoc
(functionToClassMemberDoc <$> findDoc hideIsUsedReturn id comments)
<$> findDoc hideFunctionOnClass id comments
(functionToClassMemberDoc <$> findDoc hideIsUsedReturn pd comments)
<$> findDoc hideFunctionOnClass pd comments
| otherwise = flip (foldl addClassMemberDoc)
[functionToClassMemberDoc <$> fe.fe_documentation \\ (_,fe,_) <- members]
<$> findDoc hideIsUsedReturn id comments
<$> findDoc hideIsUsedReturn pd comments
isSingleFunction :: [(LocationInModule, 'CDB'.FunctionEntry, a)] Ident -> Bool
isSingleFunction members id = length members == 1
......@@ -703,8 +703,8 @@ where
= [let name = 'T'.td_name td in
( setLine dcl ptd.td_pos {LocationInModule | zero & name=Just name}
, 'CDB'.toTypeDefEntry NoLocation td $ Just $ findRhsDoc ptd $ fromMaybe gDefault{|*|} $
findDoc (const True) ptd.td_ident comments
) \\ PD_Type ptd <- defs, td <- ['T'.toTypeDef ptd]]
findDoc (const True) pd comments
) \\ pd=:(PD_Type ptd) <- defs, td <- ['T'.toTypeDef ptd]]
where
findRhsDoc :: !ParsedTypeDef -> TypeDoc -> TypeDoc
findRhsDoc {td_rhs=ConsList cs} = addConses cs
......@@ -717,7 +717,7 @@ where
addFields [ps:fs] doc = {doc` & fields=Just [d:fromMaybe [] doc`.fields]}
where
doc` = addFields fs doc
d = parseSingleLineDoc <$> getComment ps.ps_selector_ident comments
d = parseSingleLineDoc <$> getComment ps comments
addConses :: ![ParsedConstructor] !TypeDoc -> TypeDoc
addConses [] doc
......@@ -725,7 +725,7 @@ where
addConses [pc:cs] doc = {doc` & constructors=Just [d:fromMaybe [] doc`.constructors]}
where
doc` = addConses cs doc
d = docParseResultToMaybe (const True) =<< parseDoc <$> getComment pc.pc_cons_ident comments
d = docParseResultToMaybe (const True) =<< parseDoc <$> getComment pc comments
toLine :: Position -> 'CDB'.LineNr
toLine (FunPos _ l _) = Just l
......@@ -742,7 +742,7 @@ where
hideIsUsedReturn :: ParseWarning -> Bool
hideIsUsedReturn w = not $ isUsedReturn w
findDoc :: (ParseWarning -> Bool) Ident CollectedComments -> Maybe d | docBlockToDoc{|*|} d
findDoc :: (ParseWarning -> Bool) a CollectedComments -> Maybe d | docBlockToDoc{|*|} d & commentIndex a
findDoc showw id coll = getComment id coll >>= \doc -> docParseResultToMaybe showw $ parseDoc doc
isUsedReturn :: ParseWarning -> Bool
......
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