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