Verified Commit e12095f1 authored by Camil Staps's avatar Camil Staps
Browse files

Make search more robust

parent 0965325b
......@@ -82,11 +82,11 @@ search {unify,name,className,typeName,using,modules,libraries,page,include_built
# cdb = searchStrategy strat cdb
# (es,cdb) = getEntries cdb
# (es,cdb) = mapSt (makeResult mbType allsyns usedSynonyms) es cdb
= (sort es, cdb)
= (sort $ catMaybes es, cdb)
makeResult :: (Maybe Type) (Map String [TypeDef]) [TypeDef]
(CloogleEntry, Map AnnotationKey Int) *CloogleDB
-> *(Result, *CloogleDB)
-> *(Maybe Result, *CloogleDB)
makeResult orgsearchtype allsyns usedsyns (entry, annots) db
| entry =: (FunctionEntry _)
# (FunctionEntry fe) = entry
......@@ -107,7 +107,7 @@ makeResult orgsearchtype allsyns usedsyns (entry, annots) db
# (derivs,db) = case fe.fe_derivations of
Nothing -> (Nothing, db)
Just ds -> appFst Just $ getIndices ds db
= (FunctionResult (
= (Just $ FunctionResult (
{ general
& distance = kindPenalty fe.fe_kind $ general.distance + sum
[ fromMaybe 0 $ contextPenalty <$> required_context
......@@ -205,7 +205,7 @@ makeResult orgsearchtype allsyns usedsyns (entry, annots) db
# (TypeDefEntry tde) = entry
# (insts,db) = getIndices tde.tde_instances db
# (derivs,db) = getIndices tde.tde_derivations db
= (TypeResult (
= (Just $ TypeResult (
{ general
& documentation = docDescription =<< tde.tde_doc
},
......@@ -222,7 +222,7 @@ makeResult orgsearchtype allsyns usedsyns (entry, annots) db
| entry =: (ModuleEntry _)
# (ModuleEntry me) = entry
= (ModuleResult (
= (Just $ ModuleResult (
{ general
& documentation = docDescription =<< me.me_documentation
},
......@@ -233,7 +233,7 @@ makeResult orgsearchtype allsyns usedsyns (entry, annots) db
# (ClassEntry ce) = entry
# (ies,db) = getIndices ce.ce_instances db
# (mems,db) = getIndices ce.ce_members db
= (ClassResult (
= (Just $ ClassResult (
{ general
& documentation = docDescription =<< ce.ce_documentation
},
......@@ -248,7 +248,7 @@ makeResult orgsearchtype allsyns usedsyns (entry, annots) db
| entry =: (SyntaxEntry _)
# (SyntaxEntry se) = entry
= (SyntaxResult (
= (Just $ SyntaxResult (
{ general
& distance = -1000
, documentation = Just se.syntax_description
......@@ -258,6 +258,8 @@ makeResult orgsearchtype allsyns usedsyns (entry, annots) db
, syntax_code = se.SyntaxEntry.syntax_code
, syntax_examples = se.SyntaxEntry.syntax_examples
}), db)
| otherwise // InstanceEntry / DeriveEntry cannot be returned
= (Nothing, db)
where
mbLoc = getLocation entry
name = getName $ fromJust mbLoc
......
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