Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Cloogle
Cloogle
Commits
4675ccc3
Commit
4675ccc3
authored
Jan 11, 2018
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add filtering on libraries and modules
parent
a7e1dca0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
20 deletions
+53
-20
CloogleDB.dcl
CloogleDB.dcl
+4
-0
CloogleDB.icl
CloogleDB.icl
+26
-5
CloogleDBFactory.icl
CloogleDBFactory.icl
+13
-0
DB.icl
DB.icl
+6
-11
Search.icl
Search.icl
+4
-4
No files found.
CloogleDB.dcl
View file @
4675ccc3
...
...
@@ -28,6 +28,8 @@ from TypeTree import :: TypeTree
,
types
::
!
TypeTree
Index
,
core
::
![
Index
]
,
apps
::
![
Index
]
,
library_map
::
!
Map
Name
[
Index
]
,
module_map
::
!
Map
Name
[
Index
]
}
::
AnnotationKey
...
...
@@ -213,6 +215,8 @@ filterDB :: (CloogleEntry -> Bool) !*CloogleDB -> *CloogleDB
filterLocations
::
(
Location
->
Bool
)
!*
CloogleDB
->
*
CloogleDB
excludeCore
::
!*
CloogleDB
->
*
CloogleDB
excludeApps
::
!*
CloogleDB
->
*
CloogleDB
filterLibraries
::
![
Name
]
!*
CloogleDB
->
*
CloogleDB
filterModules
::
![
Name
]
!*
CloogleDB
->
*
CloogleDB
filterName
::
!
String
!*
CloogleDB
->
*
CloogleDB
filterUnifying
::
!
Type
!*
CloogleDB
->
*
CloogleDB
...
...
CloogleDB.icl
View file @
4675ccc3
...
...
@@ -20,7 +20,8 @@ from Data.Func import $, on, `on`
import
Data
.
Functor
import
Data
.
Generics
.
GenLexOrd
import
Data
.
Graphviz
from
Data
.
List
import
foldr1
,
groupBy
,
intercalate
,
intersect
,
tails
,
instance
Functor
[]
from
Data
.
List
import
concatMap
,
foldr1
,
groupBy
,
intercalate
,
intersect
,
tails
,
instance
Functor
[]
from
Data
.
Map
import
::
Map
(..),
elems
,
filterWithKey
,
foldrNoKey
,
foldrWithKey
,
fromList
,
get
,
mapSize
,
alter
,
mapWithKey
,
newMap
,
put
,
toAscList
,
toList
,
instance
Functor
(
Map
k
)
...
...
@@ -224,12 +225,14 @@ syncDB :: !Int !*CloogleDB -> *CloogleDB
syncDB
_
db
=
db
saveDB
::
*
CloogleDB
*
File
->
*(*
CloogleDB
,
*
File
)
saveDB
wrapper
=:{
db
,
name_ngrams
,
types
,
core
,
apps
}
f
saveDB
wrapper
=:{
db
,
name_ngrams
,
types
,
core
,
apps
,
library_map
,
module_map
}
f
#
(
db
,
f
)
=
'
DB
'.
saveDB
db
f
#
f
=
write
name_ngrams
f
#
f
=
write
types
f
#
f
=
write
core
f
#
f
=
write
apps
f
#
f
=
write
library_map
f
#
f
=
write
module_map
f
=
({
wrapper
&
db
=
db
},
f
)
where
write
::
a
*
File
->
*
File
|
JSONEncode
{|*|}
a
...
...
@@ -247,15 +250,19 @@ openDB f
|
not
ok
=
(
Nothing
,
f
)
#
((
ok
,
apps
),
f
)
=
appFst
isJustU
$
read
f
|
not
ok
=
(
Nothing
,
f
)
#
((
ok
,
library_map
),
f
)
=
appFst
isJustU
$
read
f
|
not
ok
=
(
Nothing
,
f
)
#
((
ok
,
module_map
),
f
)
=
appFst
isJustU
$
read
f
|
not
ok
=
(
Nothing
,
f
)
=
(
Just
{
db
=
fromJust
db
,
name_ngrams
=
fromJust
name_ngrams
,
types
=
fromJust
types
,
core
=
fromJust
core
,
apps
=
fromJust
apps
}
,
f
)
,
library_map
=
fromJust
library_map
,
module_map
=
fromJust
module_map
},
f
)
where
read
::
*
File
->
*(
Maybe
a
,
*
File
)
|
JSONDecode
{|*|}
a
read
f
...
...
@@ -295,6 +302,20 @@ excludeApps wrap=:{db,apps}
#
db
=
'
DB
'.
unsearchIndices
apps
db
=
{
wrap
&
db
=
db
}
filterLibraries
::
![
Name
]
!*
CloogleDB
->
*
CloogleDB
filterLibraries
ss
wrap
=:{
db
,
library_map
}
#
db
=
'
DB
'.
searchIndices
(
map
(
flip
tuple
[])
idxs
)
db
=
{
wrap
&
db
=
db
}
where
idxs
=
foldr
merge
[]
$
catMaybes
$
map
(
flip
get
library_map
)
ss
filterModules
::
![
Name
]
!*
CloogleDB
->
*
CloogleDB
filterModules
ss
wrap
=:{
db
,
module_map
}
#
db
=
'
DB
'.
searchIndices
(
map
(
flip
tuple
[])
idxs
)
db
=
{
wrap
&
db
=
db
}
where
idxs
=
foldr
merge
[]
$
catMaybes
$
map
(
flip
get
module_map
)
ss
filterName
::
!
String
!*
CloogleDB
->
*
CloogleDB
filterName
s
wrap
=:{
db
,
name_ngrams
}
#
db
=
'
DB
'.
searchIndices
indices
db
...
...
CloogleDBFactory.icl
View file @
4675ccc3
...
...
@@ -124,6 +124,8 @@ finaliseDb tdb
\\
(
i
,
FunctionEntry
fe
)
<-
entridxs
,
Just
t
<-
[
fe
.
fe_type
<|>
(
docType
=<<
fe
.
fe_documentation
)]]
,
core
=
coreidxs
,
apps
=
appidxs
,
library_map
=
libmap
,
module_map
=
modmap
}
where
collectNames
=
'
DB
'.
scan
(\
i
v
ivs
->
case
'
CDB
'.
getLocation
v
of
...
...
@@ -173,6 +175,17 @@ where
where
appmods
=
[(
fromJust
$
'
CDB
'.
getLibrary
me
.
me_loc
,
fromJust
$
'
CDB
'.
getModule
me
.
me_loc
)
\\
me
<-
tdb
.
temp_modules
|
me
.
me_is_app
]
libmap
=
'M'
.
fromList
[(
l
,
idxfilter
\
e
->
case
'
CDB
'.
getLocation
e
>>=
'
CDB
'.
getLibrary
of
Nothing
->
False
Just
l`
->
l
==
l`
)
\\
l
<-
libs
]
where
libs
=
removeDup
[
fromJust
('
CDB
'.
getLibrary
me
.
me_loc
)
\\
me
<-
tdb
.
temp_modules
]
modmap
=
'M'
.
fromList
[(
m
,
idxfilter
\
e
->
case
'
CDB
'.
getLocation
e
>>=
'
CDB
'.
getLibrary
of
Nothing
->
False
Just
m`
->
m
==
m`
)
\\
m
<-
mods
]
where
mods
=
removeDup
[
fromJust
('
CDB
'.
getModule
me
.
me_loc
)
\\
me
<-
tdb
.
temp_modules
]
instanceEq
::
(
String
,
[('
CDB
'.
Type
,
a
)],
b
)
(
String
,
[('
CDB
'.
Type
,
a
)],
b
)
->
Bool
instanceEq
(
s
,
ts
,
_)
(
s2
,
ts2
,
_)
=
s
==
s2
&&
map
fst
ts
==
map
fst
ts2
...
...
DB.icl
View file @
4675ccc3
...
...
@@ -147,19 +147,14 @@ where
unsearchIndices
::
![
Index
]
!*(
DB
v
ak
a
)
->
*
DB
v
ak
a
unsearchIndices
idxs
(
DB
db
)
#
(
s
,
db
)
=
usize
db
#
db
=
upd
0
(
s
-1
)
idxs
db
#
db
=
upd
idxs
db
=
(
DB
db
)
where
upd
::
!
Int
!
Int
![
Index
]
!*{!
Entry
v
ak
a
}
->
*{!
Entry
v
ak
a
}
upd
i
s
_
es
|
i
>
s
=
es
upd
i
s
[]
es
=
es
upd
i
s
allidxs
=:[
Index
idx
:
idxs
]
es
#
(
e
,
es
)
=
es
![
i
]
#
e
&
included
=
e
.
included
&&
not
remove
=
upd
(
i
+1
)
s
(
if
remove
idxs
allidxs
)
{
es
&
[
i
]=
e
}
where
remove
=
i
==
idx
upd
::
![
Index
]
!*{!
Entry
v
ak
a
}
->
*{!
Entry
v
ak
a
}
upd
[]
es
=
es
upd
[
Index
i
:
is
]
es
#
(
e
,
es
)
=
es
![
i
]
=
upd
is
{
es
&
[
i
].
included
=
False
}
getIndex
::
!
Index
!*(
DB
v
ak
a
)
->
*(!
Entry
v
ak
a
,
!*(
DB
v
ak
a
))
getIndex
(
Index
n
)
(
DB
db
)
...
...
Search.icl
View file @
4675ccc3
...
...
@@ -34,11 +34,11 @@ search {unify,name,className,typeName,modules,libraries,page,include_builtins,in
#
cdb
=
if
include_core
cdb
(
excludeCore
cdb
)
#
cdb
=
if
include_apps
cdb
(
excludeApps
cdb
)
#
cdb
=
case
libraries
of
(
Just
ls
)
=
filterL
ocations
(
isLibMatch
ls
)
cdb
Nothing
=
cdb
Just
ls
->
filterL
ibraries
ls
cdb
Nothing
->
cdb
#
cdb
=
case
modules
of
(
Just
ms
)
=
filter
Locations
(
isModMatch
ms
)
cdb
Nothing
=
cdb
Just
ms
->
filter
Modules
ms
cdb
Nothing
->
cdb
#
cdb
=
if
include_builtins
id
(
filterLocations
(
not
o
isBuiltin
))
cdb
#
cdb
=
case
typeName
of
Nothing
->
cdb
...
...
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