Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
cloogle.org
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cloogle
cloogle.org
Commits
8413b35e
Verified
Commit
8413b35e
authored
Jun 19, 2016
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix suggestions for searches with names
parent
29dd709d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
19 deletions
+20
-19
CloogleServer.icl
CloogleServer.icl
+19
-18
api.js
api.js
+1
-1
No files found.
CloogleServer.icl
View file @
8413b35e
...
...
@@ -15,7 +15,7 @@ import Data.Functor
import
Control
.
Applicative
import
Control
.
Monad
from
Text
import
class
Text
(
concat
,
trim
,
indexOf
,
toLowerCase
),
instance
Text
String
instance
Text
String
,
instance
+
String
import
System
.
Time
...
...
@@ -90,7 +90,7 @@ where
,
page
=
Nothing
}
instance
toString
Response
where
toString
r
=
toString
(
toJSON
r
)
+
++
"
\n
"
instance
toString
Response
where
toString
r
=
toString
(
toJSON
r
)
+
"
\n
"
instance
toString
Request
where
toString
r
=
toString
$
toJSON
r
instance
fromString
(
Maybe
Request
)
where
fromString
s
=
fromJSON
$
fromString
s
...
...
@@ -150,13 +150,13 @@ where
#
drop_n
=
fromJust
(
page
<|>
pure
0
)
*
MAX_RESULTS
#
results
=
drop
drop_n
$
sort
$
search
request
db
#
more
=
max
0
(
length
results
-
MAX_RESULTS
)
#
results
=
take
MAX_RESULTS
results
// Suggestions
#
mbType
=
unify
>>=
parseType
o
fromString
#
suggestions
=
sortBy
(\
a
b
->
snd
a
>
snd
b
)
<$>
filter
((<)(
length
results
)
o
snd
)
<$>
(
mbType
>>=
flip
suggs
db
)
(
mbType
>>=
\
t
->
suggs
name
t
db
)
#
results
=
take
MAX_RESULTS
results
// Response
|
isEmpty
results
=
(
err
E_NORESULTS
"No results"
,
w
)
=
(
{
return
=
0
...
...
@@ -167,13 +167,14 @@ where
}
,
w
)
suggs
::
!
Type
!
TypeDB
->
Maybe
[(
String
,
Int
)]
suggs
(
Func
is
r
cc
)
db
suggs
::
!
(
Maybe
String
)
!
Type
!
TypeDB
->
Maybe
[(
String
,
Int
)]
suggs
n
(
Func
is
r
cc
)
db
|
length
is
<
3
=
Just
[
let
t`
=
concat
$
print
False
$
Func
is`
r
cc
in
(
t`
,
length
$
search
{
zero
&
unify
=
Just
t`
}
db
)
let
s
=
if
(
isJust
n
)
(
fromJust
n
+
" "
)
""
+
":: "
+
t`
in
(
s
,
length
$
search
{
zero
&
name
=
n
,
unify
=
Just
t`
}
db
)
\\
is`
<-
permutations
is
|
is`
<>
is
]
suggs
_
_
=
Nothing
suggs
_
_
_
=
Nothing
search
::
!
Request
!
TypeDB
->
[
Result
]
search
{
unify
,
name
,
className
,
modules
,
page
}
db
...
...
@@ -223,9 +224,9 @@ where
,
distance
=
-100
}
,
{
class_name
=
cls
,
class_heading
=
foldl
((+
++)
o
(
flip
(+++)
" "
))
cls
vars
++
+
if
(
isEmpty
cc
)
""
" "
+
++
concat
(
print
False
cc
)
,
class_funs
=
[
f
+
++
concat
(
print
False
t
)
\\
(
f
,
t
)
<-
funs
]
,
class_heading
=
foldl
((+
)
o
(
flip
(+)
" "
))
cls
vars
+
if
(
isEmpty
cc
)
""
" "
+
concat
(
print
False
cc
)
,
class_funs
=
[
f
+
concat
(
print
False
t
)
\\
(
f
,
t
)
<-
funs
]
,
class_instances
=
sort
[
concat
(
print
False
t
)
\\
t
<-
getInstances
cls
db
]
}
...
...
@@ -253,7 +254,7 @@ where
,
modul
=
mod
,
distance
=
distance
}
,
{
func
=
fname
+
++
concat
(
print
False
et
)
,
{
func
=
fname
+
concat
(
print
False
et
)
,
unifier
=
toStrUnifier
<$>
finish_unification
<$>
(
orgsearchtype
>>=
unify
[]
(
prepare_unification
False
type
))
,
cls
=
mbCls
...
...
@@ -292,7 +293,7 @@ where
modToFilename
::
String
->
String
modToFilename
mod
=
(
toString
$
reverse
$
takeWhile
((<>)
'.'
)
$
reverse
$
fromString
mod
)
+
++
".dcl"
$
reverse
$
fromString
mod
)
+
".dcl"
isUnifiable
::
Type
ExtendedType
->
Bool
isUnifiable
t1
(
ET
t2
_)
=
isJust
(
unify
[]
t1
(
prepare_unification
False
t2
))
...
...
@@ -324,11 +325,11 @@ where
msgToString
::
(
LogMessage
(
Maybe
Request
)
Response
)
IPAddress
->
String
msgToString
(
Received
Nothing
)
ip
=
toString
ip
+
++
" <-- Nothing
\n
"
=
toString
ip
+
" <-- Nothing
\n
"
msgToString
(
Received
(
Just
a
))
ip
=
toString
ip
+
++
" <-- "
+++
toString
a
++
+
"
\n
"
=
toString
ip
+
" <-- "
+
toString
a
+
"
\n
"
msgToString
(
Sent
{
return
,
data
,
msg
,
more_available
})
ip
=
toString
ip
+
++
" --> "
++
+
toString
(
length
data
)
+
++
" results ("
+++
toString
return
+++
"; "
+++
msg
++
+
if
(
isJust
more_available
)
(
"; "
+
++
toString
(
fromJust
more_available
)
+++
" more"
)
""
++
+
")
\n
"
=
toString
ip
+
" --> "
+
toString
(
length
data
)
+
" results ("
+
toString
return
+
"; "
+
msg
+
if
(
isJust
more_available
)
(
"; "
+
toString
(
fromJust
more_available
)
+
" more"
)
""
+
")
\n
"
msgToString
_
_
=
""
api.js
View file @
8413b35e
...
...
@@ -136,7 +136,7 @@ function getResults(str, page) {
function
makeSuggestions
(
suggs
)
{
var
str
=
'
<hr/><div id="suggestions"><b>Did you mean...</b><table>
'
;
for
(
i
in
suggs
)
{
var
sug
=
'
::
'
+
suggs
[
i
][
0
];
var
sug
=
suggs
[
i
][
0
];
str
+=
'
<tr><td><a class="hidden" href="#
'
+
encodeURIComponent
(
sug
)
+
'
"><code>
'
+
highlightFunction
(
sug
)
+
'
</code></a></td><td>
'
+
suggs
[
i
][
1
]
+
'
results</td></tr>
'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment