Commit d0244e26 authored by Camil Staps's avatar Camil Staps 🍃

Show including apps suggestion also on typeName/className queries

parent 1ab45a97
Pipeline #16575 passed with stage
in 15 minutes and 33 seconds
......@@ -213,7 +213,7 @@ errexit msg rcode w
= setReturnCode rcode w
handle :: !RankSettings !(Maybe Request) !*CloogleDB !*World -> *(!Response, !(!Maybe CacheKey, !MicroSeconds), !*CloogleDB, !*World)
handle _ Nothing db w = (err InvalidInput "Couldn't parse input", (Nothing,0), db, w)
handle _ Nothing db w = (err InvalidInput "Couldn't parse input" Nothing, (Nothing,0), db, w)
handle rsets (Just request=:{unify,name,page}) db w
#! (start,w) = nsTime w
//Check cache
......@@ -223,13 +223,13 @@ handle rsets (Just request=:{unify,name,page}) db w
# r = fromJust mbResponse
= respond start Nothing {r & return = if (r.return == 0) 1 r.return} db w
| isJust name && size (fromJust name) > 40
= respond start Nothing (err InvalidName "Function name too long") db w
= respond start Nothing (err InvalidName "Function name too long" Nothing) db w
| isJust name && any isSpace (fromString $ fromJust name)
= respond start Nothing (err InvalidName "Name cannot contain spaces") db w
= respond start Nothing (err InvalidName "Name cannot contain spaces" Nothing) db w
| isJust unify && isNothing (parseType $ fromString $ fromJust unify)
= respond start Nothing (err InvalidType "Couldn't parse type") db w
= respond start Nothing (err InvalidType "Couldn't parse type" Nothing) db w
| all isNothing [unify,name,request.typeName,request.className] && isNothing request.using
= respond start Nothing (err InvalidInput "Empty query") db w
= respond start Nothing (err InvalidInput "Empty query" Nothing) db w
// Results
#! drop_n = fromJust (page <|> pure 0) * MAX_RESULTS
#! (res,suggs,db) = searchWithSuggestions rsets request db
......@@ -245,7 +245,7 @@ handle rsets (Just request=:{unify,name,page}) db w
#! (results,nextpages) = splitAt MAX_RESULTS results
// Response
#! response = if (isEmpty results)
(err NoResults "No results")
(err NoResults "No results" suggs)
{ zero
& data = results
, more_available = Just more
......@@ -402,10 +402,11 @@ where
}
makeLogEntry _ _ = abort "CloogleServer: failure in makeLogEntry\n"
err :: CloogleError String -> Response
err c m = { return = toInt c
, data = []
, msg = m
, more_available = Nothing
, suggestions = Nothing
}
err :: !CloogleError !String !(Maybe [(Request,Int)]) -> Response
err c m suggs =
{ return = toInt c
, data = []
, msg = m
, more_available = Nothing
, suggestions = suggs
}
......@@ -677,6 +677,10 @@ function getResults(str, libs, include_builtins, include_core, include_apps, pag
var sugstrmeta = [];
if ('name' in sug) {
sugstr.push(sug.name);
} else if ('typeName' in sug) {
sugstr.push('type ' + sug.typeName);
} else if ('className' in sug) {
sugstr.push('class ' + sug.className);
}
if ('unify' in sug) {
sugstr.push(':: ' + sug.unify);
......
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