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
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
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cloogle
Cloogle
Commits
b8d51e33
Commit
b8d51e33
authored
Jan 10, 2018
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add instances for classes
parent
f0113bdb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
10 deletions
+37
-10
CloogleDB.dcl
CloogleDB.dcl
+3
-1
CloogleDB.icl
CloogleDB.icl
+7
-2
CloogleDBFactory.icl
CloogleDBFactory.icl
+19
-5
Search.icl
Search.icl
+8
-2
No files found.
CloogleDB.dcl
View file @
b8d51e33
...
...
@@ -114,7 +114,8 @@ derive JSONDecode CloogleEntry
* Information about a class instance
*/
::
InstanceEntry
=
{
ie_types
::
![(
Type
,
String
)]
//* The instantiated type and a string representation for each class variable
=
{
ie_class
::
!
Name
//* The class
,
ie_types
::
![(
Type
,
String
)]
//* The instantiated type and a string representation for each class variable
,
ie_locations
::
![
Location
]
//* The places where this instance is found
}
...
...
@@ -207,6 +208,7 @@ saveDB :: *CloogleDB *File -> *(*CloogleDB, *File)
openDB
::
!*
File
->
*(!
Maybe
*
CloogleDB
,
!*
File
)
getIndex
::
!
Index
!*
CloogleDB
->
*(
Entry
CloogleEntry
AnnotationKey
Annotation
,
*
CloogleDB
)
getIndices
::
![
Index
]
!*
CloogleDB
->
*([
Entry
CloogleEntry
AnnotationKey
Annotation
],
*
CloogleDB
)
filterDB
::
(
CloogleEntry
->
Bool
)
!*
CloogleDB
->
*
CloogleDB
filterLocations
::
(
Location
->
Bool
)
!*
CloogleDB
->
*
CloogleDB
...
...
CloogleDB.icl
View file @
b8d51e33
...
...
@@ -36,7 +36,7 @@ import Type
import
Cloogle
from
DB
import
::
DB
,
::
Index
,
::
Entry
{..},
getIndex
,
getIndices
,
from
DB
import
::
DB
,
::
Index
,
::
Entry
{..},
instance
==
Index
,
instance
<
Index
import
qualified
DB
import
Doc
...
...
@@ -275,6 +275,11 @@ getIndex idx wrap=:{db}
#
(
e
,
db
)
=
'
DB
'.
getIndex
idx
db
=
(
e
,
{
wrap
&
db
=
db
})
getIndices
::
![
Index
]
!*
CloogleDB
->
*([
Entry
CloogleEntry
AnnotationKey
Annotation
],
*
CloogleDB
)
getIndices
idxs
wrap
=:{
db
}
#
(
es
,
db
)
=
'
DB
'.
getIndices
idxs
db
=
(
es
,
{
wrap
&
db
=
db
})
filterDB
::
(
CloogleEntry
->
Bool
)
!*
CloogleDB
->
*
CloogleDB
filterDB
f
db
=
{
db
&
db
=
'
DB
'.
search
(\
v
->
(
f
v
,
[]))
db
.
db
}
...
...
@@ -322,7 +327,7 @@ where
allModules
::
!*
CloogleDB
->
*([
ModuleEntry
],
*
CloogleDB
)
allModules
wrap
=:{
db
,
module_index
}
#
(
mods
,
db
)
=
getIndices
(
elems
module_index
)
db
#
(
mods
,
db
)
=
'
DB
'.
getIndices
(
elems
module_index
)
db
=
([
me
\\
{
value
=
ModuleEntry
me
}
<-
mods
],
{
wrap
&
db
=
db
})
allTypeDefs
::
!*
CloogleDB
->
*([
TypeDefEntry
],
*
CloogleDB
)
...
...
CloogleDBFactory.icl
View file @
b8d51e33
...
...
@@ -7,6 +7,7 @@ import StdFile
from
StdFunc
import
const
,
flip
,
id
,
o
import
StdList
import
StdMisc
import
StdOrdList
import
StdOverloadedList
import
StdString
import
StdTuple
...
...
@@ -73,8 +74,9 @@ from CloogleDB import
::
ModuleEntry
{
me_loc
,
me_is_core
,
me_is_app
,
me_documentation
},
::
FunctionEntry
{
fe_loc
,
fe_type
,
fe_kind
,
fe_generic_vars
,
fe_priority
,
fe_representation
,
fe_documentation
,
fe_class
},
::
TypeDefEntry
{
tde_loc
},
::
ClassEntry
{
ce_loc
},
::
SyntaxEntry
,
::
DeriveEntry
,
::
InstanceEntry
,
::
ClassEntry
{
ce_loc
,
ce_instances
},
::
SyntaxEntry
,
::
DeriveEntry
,
::
InstanceEntry
{
ie_class
,
ie_types
,
ie_locations
},
instance
zero
FunctionEntry
,
instance
zero
ModuleEntry
,
class
getLocation
,
instance
getLocation
CloogleEntry
,
instance
==
Location
...
...
@@ -131,7 +133,7 @@ where
[
FunctionEntry
fun
\\
funs
<-
tdb
.
temp_functions
,
fun
<-
funs
]
++
map
TypeDefEntry
typedefs
++
[
ModuleEntry
mod
\\
mod
<-
tdb
.
temp_modules
]
++
[
ClassEntry
cls
\\
clss
<-
tdb
.
temp_classes
,
(
cls
,
funs
)
<-
clss
]
++
map
ClassEntry
classes
++
[
FunctionEntry
{
fun
&
fe_kind
=
case
fun
.
fe_kind
of
Function
->
ClassMember
;
Macro
->
ClassMacro
...
...
@@ -140,11 +142,23 @@ where
ClassEntry
ce
->
ce
.
ce_loc
==
cls
.
ce_loc
_
->
False
}
\\
clss
<-
tdb
.
temp_classes
,
(
cls
,
funs
)
<-
clss
,
(
fname
,
fun
)
<-
funs
]
\\
clss
<-
tdb
.
temp_classes
,
(
cls
,
funs
)
<-
clss
,
(
fname
,
fun
)
<-
funs
]
++
[
InstanceEntry
{
ie_class
=
cls
,
ie_types
=
types
,
ie_locations
=
map
thd3
is
}
// TODO combine locations
\\
is
=:[(
cls
,
types
,_):_]
<-
groupBy
instanceEq
$
sortBy
((<)
`
on`
(\(
c
,
ts
,_)
->
(
c
,
map
snd
ts
)))
$
flatten
tdb
.
temp_instances
]
entridxs
=
zip2
[
Index
i
\\
i
<-
[
0
..]]
entries
idxhd
f
=
hd
[
idx
\\
(
idx
,
e
)
<-
entridxs
|
f
e
]
idxfilter
f
=
[
idx
\\
(
idx
,
e
)
<-
entridxs
|
f
e
]
idxhd
=
hd
o
idxfilter
typedefs
=
[
td
\\
tds
<-
tdb
.
temp_types
,
td
<-
tds
]
classes
=
[{
cls
&
ce_instances
=
idxfilter
\
e
->
case
e
of
InstanceEntry
ie
->
ie
.
ie_class
==
'
CDB
'.
getName
cls
.
ce_loc
_
->
False
}
\\
clss
<-
tdb
.
temp_classes
,
(
cls
,_)
<-
clss
]
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
// Exclude Root Library Aux Base module
findModules
::
![
String
]
!
String
!'
CDB
'.
Library
!
a
!
String
!*
World
...
...
Search.icl
View file @
b8d51e33
...
...
@@ -11,7 +11,7 @@ import StdTuple
import
Control
.
Applicative
import
Control
.
Monad
import
qualified
Data
.
Foldable
as
Foldable
from
Data
.
Func
import
$,
on
,
instance
Functor
((->)
r
),
mapSt
from
Data
.
Func
import
$,
on
,
`
on`
,
instance
Functor
((->)
r
),
mapSt
import
Data
.
Functor
import
Data
.
List
import
qualified
Data
.
Map
as
M
...
...
@@ -138,12 +138,15 @@ makeResult orgsearchtype tdes usedsyns (entry, annots) db
}),
db
)
|
entry
=:
(
ClassEntry
_)
#
(
ClassEntry
ce
)
=
entry
#
(
ies
,
db
)
=
getIndices
ce
.
ce_instances
db
=
(
ClassResult
(
general
,
{
class_name
=
name
,
class_heading
=
foldl
((+)
o
(
flip
(+)
" "
))
name
ce
.
ce_vars
+
if
(
isEmpty
ce
.
ce_context
)
""
" | "
+
concat
(
print
False
ce
.
ce_context
)
,
class_funs
=
[]
// TODO
,
class_instances
=
[]
// TODO
,
class_instances
=
sortBy
((<)
`
on`
fst
)
[(
map
snd
ie
.
ie_types
,
map
locResult
ie
.
ie_locations
)
\\
{
value
=
InstanceEntry
ie
}
<-
ies
]
,
class_derivations
=
[]
// TODO
}),
db
)
// TODO
...
...
@@ -167,6 +170,9 @@ where
Just
(
IntAnnot
n
)
->
100
-
toInt
(
toReal
n
*
100.0
/
toReal
(
size
$
getName
$
fromJust
mbLoc
))
]
locResult
::
Location
->
LocationResult
locResult
(
Location
lib
mod
filename
dcl
icl
_)
=
(
lib
,
mod
,
filename
,
dcl
,
icl
)
isModMatch
::
![
String
]
Location
->
Bool
isModMatch
mods
(
Location
_
mod
_
_
_
_)
=
isMember
mod
mods
isModMatch
_
(
Builtin
_
_)
=
False
...
...
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