Commit 3012a64f authored by Camil Staps's avatar Camil Staps 🍃

Add "exact X" kind of query to HTTP frontend for exactName in backend

parent 39481b4b
Pipeline #17231 passed with stage
in 15 minutes and 27 seconds
Subproject commit 956cbd5d421b19e2b251522304b4f72c3aa2505a
Subproject commit adf2ad02144baaaf53ada465a2649adc3542c1aa
......@@ -50,17 +50,18 @@ CACHE_PREFETCH :== 5
CACHE_NS_THRESHOLD :== 20000000
:: RequestCacheKey
= { c_unify :: Maybe Type
, c_name :: Maybe String
, c_className :: Maybe String
, c_typeName :: Maybe String
, c_using :: Maybe [String]
, c_modules :: Maybe [String]
, c_libraries :: Maybe [String]
, c_include_builtins :: Bool
, c_include_core :: Bool
, c_include_apps :: Bool
, c_page :: Int
= { c_unify :: !Maybe Type
, c_name :: !Maybe String
, c_exactName :: !Maybe String
, c_className :: !Maybe String
, c_typeName :: !Maybe String
, c_using :: !Maybe [String]
, c_modules :: !Maybe [String]
, c_libraries :: !Maybe [String]
, c_include_builtins :: !Bool
, c_include_core :: !Bool
, c_include_apps :: !Bool
, c_page :: !Int
}
derive JSONEncode Kind, Type, RequestCacheKey, TypeRestriction, RankSettings
......@@ -77,6 +78,7 @@ toRequestCacheKey db r
prepare_unification True alwaysUnique allsyns <$>
(parseType o fromString =<< r.unify)
, c_name = toLowerCase <$> r.Request.name
, c_exactName = r.exactName
, c_className = r.className
, c_typeName = r.typeName
, c_using = r.using
......@@ -91,6 +93,7 @@ fromRequestCacheKey :: RequestCacheKey -> Request
fromRequestCacheKey k =
{ unify = concat <$> print False <$> unprepare <$> k.c_unify
, name = k.c_name
, exactName = k.c_exactName
, className = k.c_className
, typeName = k.c_typeName
, using = k.c_using
......@@ -233,7 +236,7 @@ handle (Just request=:{unify,name,page}) 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" Nothing) db w
| all isNothing [unify,name,request.typeName,request.className] && isNothing request.using
| all isNothing [unify,name,request.exactName,request.typeName,request.className] && isNothing request.using
= respond start Nothing (err InvalidInput "Empty query" Nothing) db w
// Results
#! drop_n = fromJust (page <|> pure 0) * MAX_RESULTS
......
......@@ -10,7 +10,7 @@ man: $(MAN)
CloogleServer: %: %.prj .FORCE
cpm project $< build
find -name '*.[di]cl' -not -path './Cloogle/compiler/*' -exec touch {} \;
find -name '*.dcl' -not -path './Cloogle/compiler/*' -exec touch {} \;
cpm project $< build
builddb: %: %.prj Cloogle/compiler .FORCE
......
......@@ -199,6 +199,8 @@ if ($_SERVER['REQUEST_METHOD'] !== 'GET'){
$command['className'] = substr($name, 9);
} elseif (substr($name, 0, 5) == 'type ') {
$command['typeName'] = substr($name, 5);
} elseif (substr($name, 0, 6) == 'exact ') {
$command['exactName'] = substr($name, 6);
} elseif ($name != '') {
$command['name'] = $name;
}
......
......@@ -100,9 +100,9 @@ function highlightQuery(query) {
return '<span class="keyword">type</span><span class="whitespace">' + q.substring(4,5) + '</span>' +
highlightType(q.substring(5));
};
} else if (query.match(/^using\s/)) {
} else if (query.match(/^using\s/) || query.match(/^exact\s/)) {
highlighter = function(q) {
return '<span class="keyword">using</span><span class="whitespace">' + q.substring(5,6) + '</span>' +
return '<span class="keyword">' + q.substring(0,5) + '</span><span class="whitespace">' + q.substring(5,6) + '</span>' +
highlightToHTML({
start: [
[/(,)/, ['punctuation']],
......
......@@ -106,13 +106,17 @@
<td class='description'>Anything that uses <code>Maybe</code> <em>and</em> <code>==</code></td>
</tr>
<tr>
<td class='code'>type Maybe</td>
<td class='description'>Types with the exact name <code>Maybe</code></td>
<td class='code'>exact Text</td>
<td class='description'>Anything with the exact name <code>Text</code></td>
</tr>
<tr>
<td class='code'>class Text</td>
<td class='description'>Classes with the exact name <code>Text</code></td>
</tr>
<tr>
<td class='code'>type Maybe</td>
<td class='description'>Types with the exact name <code>Maybe</code></td>
</tr>
</table>
<p>Besides this web app, there are <a href="https://gitlab.science.ru.nl/cloogle/cloogle-org/#frontends">other frontends</a> available.</p>
<p>You can also <a href="src">browse the index</a> and <a href="doc">read the documentation</a>.</p>
......
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