Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
1a50748b
Commit
1a50748b
authored
Dec 25, 2013
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added extension completion for :extension directive, closes #60
parent
c4176b3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
15 deletions
+30
-15
Completion.hs
IHaskell/Eval/Completion.hs
+30
-15
No files found.
IHaskell/Eval/Completion.hs
View file @
1a50748b
...
...
@@ -17,27 +17,29 @@
-}
module
IHaskell.Eval.Completion
(
complete
,
completionTarget
,
completionType
,
CompletionType
(
..
))
where
import
Prelude
import
Control.Applicative
((
<$>
))
import
Data.ByteString.UTF8
hiding
(
drop
,
take
)
import
Data.Char
import
Data.List
(
find
,
isPrefixOf
,
nub
,
findIndex
,
intercalate
,
elemIndex
)
import
Data.List.Split
import
Data.List.Split.Internals
import
Data.Maybe
import
Data.String.Utils
(
strip
,
startswith
,
replace
)
import
Prelude
import
GHC
import
DynFlags
import
GhcMonad
import
PackageConfig
import
Outputable
(
showPpr
)
import
Data.Char
import
Data.ByteString.UTF8
hiding
(
drop
,
take
)
import
Data.List.Split
import
Data.List.Split.Internals
import
Data.String.Utils
(
strip
,
startswith
,
replace
)
import
Data.Maybe
import
IHaskell.Types
import
Control.Applicative
((
<$>
))
import
Debug.Trace
data
CompletionType
=
Empty
|
Identifier
String
|
Extension
String
|
Qualified
String
String
|
ModuleName
String
String
deriving
(
Show
,
Eq
)
...
...
@@ -61,20 +63,29 @@ complete line pos = do
options
<-
case
completionType
line
target
of
Empty
->
return
[]
Identifier
candidate
->
return
$
filter
(
candidate
`
isPrefixOf
`)
unqualNames
Qualified
moduleName
candidate
->
do
trueName
<-
getTrueModuleName
moduleName
let
prefix
=
intercalate
"."
[
trueName
,
candidate
]
completions
=
filter
(
prefix
`
isPrefixOf
`)
qualNames
falsifyName
=
replace
trueName
moduleName
return
$
map
falsifyName
completions
ModuleName
previous
candidate
->
do
let
prefix
=
if
null
previous
then
candidate
else
intercalate
"."
[
previous
,
candidate
]
return
$
filter
(
prefix
`
isPrefixOf
`)
moduleNames
Extension
ext
->
do
let
extName
(
name
,
_
,
_
)
=
name
names
=
map
extName
xFlags
nonames
=
map
(
"No"
++
)
names
return
$
filter
(
ext
`
isPrefixOf
`)
$
names
++
nonames
return
(
matchedText
,
options
)
getTrueModuleName
::
GhcMonad
m
=>
String
->
m
String
...
...
@@ -98,12 +109,16 @@ getTrueModuleName name = do
completionType
::
String
->
[
String
]
->
CompletionType
completionType
line
[]
=
Empty
completionType
line
target
|
startswith
"import"
(
strip
line
)
&&
isModName
=
ModuleName
dotted
candidate
|
isModName
&&
(
not
.
null
.
init
)
target
=
Qualified
dotted
candidate
|
otherwise
=
Identifier
candidate
where
dotted
=
dots
target
|
startswith
"import"
stripped
&&
isModName
=
ModuleName
dotted
candidate
|
isModName
&&
(
not
.
null
.
init
)
target
=
Qualified
dotted
candidate
|
startswith
":e"
stripped
=
Extension
candidate
|
otherwise
=
Identifier
candidate
where
stripped
=
strip
line
dotted
=
dots
target
candidate
=
last
target
dots
=
intercalate
"."
.
init
isModName
=
all
isCapitalized
(
init
target
)
...
...
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