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
a7e1dca0
Commit
a7e1dca0
authored
Jan 11, 2018
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add core and app filtering
parent
b8d51e33
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
26 deletions
+59
-26
CloogleDB.dcl
CloogleDB.dcl
+4
-4
CloogleDB.icl
CloogleDB.icl
+19
-20
CloogleDBFactory.icl
CloogleDBFactory.icl
+17
-1
DB.dcl
DB.dcl
+1
-0
DB.icl
DB.icl
+16
-0
Search.icl
Search.icl
+2
-1
No files found.
CloogleDB.dcl
View file @
a7e1dca0
...
...
@@ -26,7 +26,8 @@ from TypeTree import :: TypeTree
{
db
::
!*
DB
CloogleEntry
AnnotationKey
Annotation
,
name_ngrams
::
!
NGramIndex
Index
,
types
::
!
TypeTree
Index
,
module_index
::
!
Map
Location
Index
,
core
::
![
Index
]
,
apps
::
![
Index
]
}
::
AnnotationKey
...
...
@@ -176,8 +177,6 @@ getIclLine :: Location -> Maybe Int
getName
::
Location
->
Name
setName
::
Name
Location
->
Location
isBuiltin
::
Location
->
Bool
isCore
::
!
Location
!*
CloogleDB
->
*(
Bool
,
*
CloogleDB
)
isApp
::
!
Location
!*
CloogleDB
->
*(
Bool
,
*
CloogleDB
)
toTypeDefEntry
::
Location
TypeDef
(
Maybe
TypeDoc
)
->
TypeDefEntry
getTypeDef
::
TypeDefEntry
->
TypeDef
...
...
@@ -212,10 +211,11 @@ getIndices :: ![Index] !*CloogleDB -> *([Entry CloogleEntry AnnotationKey Annota
filterDB
::
(
CloogleEntry
->
Bool
)
!*
CloogleDB
->
*
CloogleDB
filterLocations
::
(
Location
->
Bool
)
!*
CloogleDB
->
*
CloogleDB
excludeCore
::
!*
CloogleDB
->
*
CloogleDB
excludeApps
::
!*
CloogleDB
->
*
CloogleDB
filterName
::
!
String
!*
CloogleDB
->
*
CloogleDB
filterUnifying
::
!
Type
!*
CloogleDB
->
*
CloogleDB
allModules
::
!*
CloogleDB
->
*([
ModuleEntry
],
*
CloogleDB
)
allTypeDefs
::
!*
CloogleDB
->
*([
TypeDefEntry
],
*
CloogleDB
)
getEntries
::
!*
CloogleDB
->
*([(
CloogleEntry
,
Map
AnnotationKey
Annotation
)],
*
CloogleDB
)
CloogleDB.icl
View file @
a7e1dca0
...
...
@@ -189,16 +189,6 @@ isBuiltin :: Location -> Bool
isBuiltin
(
Builtin
_
_)
=
True
isBuiltin
_
=
False
isCore
::
!
Location
!*
CloogleDB
->
*(
Bool
,
*
CloogleDB
)
isCore
loc
wrap
=:{
db
,
module_index
}
=
case
get
loc
module_index
of
Nothing
->
(
False
,
wrap
)
Just
id
->
let
({
value
=
ModuleEntry
me
},
db`
)
=
'
DB
'.
getIndex
id
db
in
(
me
.
me_is_core
,
{
wrap
&
db
=
db`
})
isApp
::
!
Location
!*
CloogleDB
->
*(
Bool
,
*
CloogleDB
)
isApp
loc
wrap
=:{
db
,
module_index
}
=
case
get
loc
module_index
of
Nothing
->
(
False
,
wrap
)
Just
id
->
let
({
value
=
ModuleEntry
me
},
db`
)
=
'
DB
'.
getIndex
id
db
in
(
me
.
me_is_app
,
{
wrap
&
db
=
db`
})
toTypeDefEntry
::
Location
TypeDef
(
Maybe
TypeDoc
)
->
TypeDefEntry
toTypeDefEntry
loc
td
doc
=
{
tde_loc
=
loc
...
...
@@ -234,11 +224,12 @@ syncDB :: !Int !*CloogleDB -> *CloogleDB
syncDB
_
db
=
db
saveDB
::
*
CloogleDB
*
File
->
*(*
CloogleDB
,
*
File
)
saveDB
wrapper
=:{
db
,
module_index
,
name_ngrams
,
types
}
f
saveDB
wrapper
=:{
db
,
name_ngrams
,
types
,
core
,
apps
}
f
#
(
db
,
f
)
=
'
DB
'.
saveDB
db
f
#
f
=
write
module_index
f
#
f
=
write
name_ngrams
f
#
f
=
write
types
f
#
f
=
write
core
f
#
f
=
write
apps
f
=
({
wrapper
&
db
=
db
},
f
)
where
write
::
a
*
File
->
*
File
|
JSONEncode
{|*|}
a
...
...
@@ -248,17 +239,20 @@ openDB :: !*File -> *(!Maybe *CloogleDB, !*File)
openDB
f
#
((
ok
,
db
),
f
)
=
appFst
isJustU
$
'
DB
'.
openDB
f
|
not
ok
=
(
Nothing
,
f
)
#
((
ok
,
module_index
),
f
)
=
appFst
isJustU
$
read
f
|
not
ok
=
(
Nothing
,
f
)
#
((
ok
,
name_ngrams
),
f
)
=
appFst
isJustU
$
read
f
|
not
ok
=
(
Nothing
,
f
)
#
((
ok
,
types
),
f
)
=
appFst
isJustU
$
read
f
|
not
ok
=
(
Nothing
,
f
)
#
((
ok
,
core
),
f
)
=
appFst
isJustU
$
read
f
|
not
ok
=
(
Nothing
,
f
)
#
((
ok
,
apps
),
f
)
=
appFst
isJustU
$
read
f
|
not
ok
=
(
Nothing
,
f
)
=
(
Just
{
db
=
fromJust
db
,
module_index
=
fromJust
module_index
,
name_ngrams
=
fromJust
name_ngrams
,
types
=
fromJust
types
,
core
=
fromJust
core
,
apps
=
fromJust
apps
}
,
f
)
...
...
@@ -291,6 +285,16 @@ filterLocations f db =
Just
loc
->
(
f
loc
,
[]))
db
.
db
}
excludeCore
::
!*
CloogleDB
->
*
CloogleDB
excludeCore
wrap
=:{
db
,
core
}
#
db
=
'
DB
'.
unsearchIndices
core
db
=
{
wrap
&
db
=
db
}
excludeApps
::
!*
CloogleDB
->
*
CloogleDB
excludeApps
wrap
=:{
db
,
apps
}
#
db
=
'
DB
'.
unsearchIndices
apps
db
=
{
wrap
&
db
=
db
}
filterName
::
!
String
!*
CloogleDB
->
*
CloogleDB
filterName
s
wrap
=:{
db
,
name_ngrams
}
#
db
=
'
DB
'.
searchIndices
indices
db
...
...
@@ -325,11 +329,6 @@ where
typeComplexity
(
Arrow
(
Just
t
))
=
5.0
+
typeComplexity
t
typeComplexity
(
Arrow
Nothing
)
=
5.0
allModules
::
!*
CloogleDB
->
*([
ModuleEntry
],
*
CloogleDB
)
allModules
wrap
=:{
db
,
module_index
}
#
(
mods
,
db
)
=
'
DB
'.
getIndices
(
elems
module_index
)
db
=
([
me
\\
{
value
=
ModuleEntry
me
}
<-
mods
],
{
wrap
&
db
=
db
})
allTypeDefs
::
!*
CloogleDB
->
*([
TypeDefEntry
],
*
CloogleDB
)
allTypeDefs
wrap
=:{
db
}
#
(
es
,
db
)
=
'
DB
'.
allEntries
db
...
...
CloogleDBFactory.icl
View file @
a7e1dca0
...
...
@@ -118,11 +118,12 @@ finaliseDb tdb
#
name_ngrams
=
foldr
(
uncurry
index
)
(
newNGramIndex
3
True
)
names
=
{
db
=
db
,
module_index
=
'M'
.
newMap
,
name_ngrams
=
name_ngrams
,
types
=
foldr
(
uncurry
addType
)
zero
[(
snd
$
'T'
.
prepare_unification
False
(
map
'
CDB
'.
getTypeDef
typedefs
)
$
'T'
.
removeTypeContexts
t
,
i
)
\\
(
i
,
FunctionEntry
fe
)
<-
entridxs
,
Just
t
<-
[
fe
.
fe_type
<|>
(
docType
=<<
fe
.
fe_documentation
)]]
,
core
=
coreidxs
,
apps
=
appidxs
}
where
collectNames
=
'
DB
'.
scan
(\
i
v
ivs
->
case
'
CDB
'.
getLocation
v
of
...
...
@@ -157,6 +158,21 @@ where
_
->
False
}
\\
clss
<-
tdb
.
temp_classes
,
(
cls
,_)
<-
clss
]
coreidxs
=
idxfilter
\
e
->
case
'
CDB
'.
getLocation
e
of
Nothing
->
False
Just
l
->
case
('
CDB
'.
getLibrary
l
,
'
CDB
'.
getModule
l
)
of
(
Just
l
,
Just
m
)
->
isMember
(
l
,
m
)
coremods
_
->
False
where
coremods
=
[(
fromJust
$
'
CDB
'.
getLibrary
me
.
me_loc
,
fromJust
$
'
CDB
'.
getModule
me
.
me_loc
)
\\
me
<-
tdb
.
temp_modules
|
me
.
me_is_core
]
appidxs
=
idxfilter
\
e
->
case
'
CDB
'.
getLocation
e
of
Nothing
->
False
Just
l
->
case
('
CDB
'.
getLibrary
l
,
'
CDB
'.
getModule
l
)
of
(
Just
l
,
Just
m
)
->
isMember
(
l
,
m
)
appmods
_
->
False
where
appmods
=
[(
fromJust
$
'
CDB
'.
getLibrary
me
.
me_loc
,
fromJust
$
'
CDB
'.
getModule
me
.
me_loc
)
\\
me
<-
tdb
.
temp_modules
|
me
.
me_is_app
]
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.dcl
View file @
a7e1dca0
...
...
@@ -43,5 +43,6 @@ mapInPlace :: (v -> v) *(DB v ak a) -> *(DB v ak a)
scan
::
(
Index
v
t
->
t
)
t
*(
DB
v
ak
a
)
->
*(
t
,
*(
DB
v
ak
a
))
search
::
(
v
->
(
Bool
,
[(
ak
,
a
)]))
*(
DB
v
ak
a
)
->
*
DB
v
ak
a
|
==,
<
ak
searchIndices
::
![(!
Index
,
![(!
ak
,
!
a
)])]
!*(
DB
v
ak
a
)
->
*
DB
v
ak
a
|
==,
<
ak
unsearchIndices
::
![
Index
]
!*(
DB
v
ak
a
)
->
*
DB
v
ak
a
getIndex
::
!
Index
!*(
DB
v
ak
a
)
->
*(!
Entry
v
ak
a
,
!*(
DB
v
ak
a
))
getIndices
::
![
Index
]
!*(
DB
v
ak
a
)
->
*(![
Entry
v
ak
a
],
!*(
DB
v
ak
a
))
DB.icl
View file @
a7e1dca0
...
...
@@ -145,6 +145,22 @@ where
where
include
=
i
==
idx
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
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
getIndex
::
!
Index
!*(
DB
v
ak
a
)
->
*(!
Entry
v
ak
a
,
!*(
DB
v
ak
a
))
getIndex
(
Index
n
)
(
DB
db
)
#
(
e
,
db
)
=
db
![
n
]
...
...
Search.icl
View file @
a7e1dca0
...
...
@@ -31,6 +31,8 @@ search {unify,name,className,typeName,modules,libraries,page,include_builtins,in
#
include_builtins
=
fromJust
(
include_builtins
<|>
Just
DEFAULT_INCLUDE_BUILTINS
)
#
include_core
=
fromJust
(
include_core
<|>
Just
DEFAULT_INCLUDE_CORE
)
#
include_apps
=
fromJust
(
include_apps
<|>
Just
DEFAULT_INCLUDE_APPS
)
#
cdb
=
if
include_core
cdb
(
excludeCore
cdb
)
#
cdb
=
if
include_apps
cdb
(
excludeApps
cdb
)
#
cdb
=
case
libraries
of
(
Just
ls
)
=
filterLocations
(
isLibMatch
ls
)
cdb
Nothing
=
cdb
...
...
@@ -38,7 +40,6 @@ search {unify,name,className,typeName,modules,libraries,page,include_builtins,in
(
Just
ms
)
=
filterLocations
(
isModMatch
ms
)
cdb
Nothing
=
cdb
#
cdb
=
if
include_builtins
id
(
filterLocations
(
not
o
isBuiltin
))
cdb
#
(
mods
,
cdb
)
=
allModules
cdb
#
cdb
=
case
typeName
of
Nothing
->
cdb
Just
_
->
filterDB
(\
ce
->
ce
=:(
TypeDefEntry
_))
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