git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #2318 from kRITZCREEK/psc-ide-lens-experiments
d324debChristoph Hegemann
purescript.cabal+1
@@ -122,6 +122,7 @@ library
122 http-client >= 0.4.30 && <0.5,
122 http-client >= 0.4.30 && <0.5,
123 http-types -any,
123 http-types -any,
124 language-javascript == 0.6.*,
124 language-javascript == 0.6.*,
125+ lens == 4.*,
125 lifted-base >= 0.2.3 && < 0.2.4,
126 lifted-base >= 0.2.3 && < 0.2.4,
126 monad-control >= 1.0.0.0 && < 1.1,
127 monad-control >= 1.0.0.0 && < 1.1,
127 monad-logger >= 0.3 && < 0.4,
128 monad-logger >= 0.3 && < 0.4,
src/Language/PureScript/Ide/CaseSplit.hs+6−6
@@ -12,7 +12,7 @@
12-- Casesplitting and adding function clauses
12-- Casesplitting and adding function clauses
13-----------------------------------------------------------------------------
13-----------------------------------------------------------------------------
14
14
15−{-# LANGUAGE OverloadedStrings #-}
15+{-# LANGUAGE OverloadedStrings #-}
16
16
17module Language.PureScript.Ide.CaseSplit
17module Language.PureScript.Ide.CaseSplit
18 ( WildcardAnnotations()
18 ( WildcardAnnotations()
@@ -23,10 +23,10 @@ module Language.PureScript.Ide.CaseSplit
23 , caseSplit
23 , caseSplit
24 ) where
24 ) where
25
25
26−import Protolude hiding (Constructor)
26+import Protolude hiding (Constructor)
27
27
28−import qualified Data.Text as T
28+import qualified Data.Text as T
29−import qualified Language.PureScript as P
29+import qualified Language.PureScript as P
30
30
31import Language.PureScript.Externs
31import Language.PureScript.Externs
32import Language.PureScript.Ide.Error
32import Language.PureScript.Ide.Error
@@ -34,8 +34,8 @@ import Language.PureScript.Ide.State
34import Language.PureScript.Ide.Types
34import Language.PureScript.Ide.Types
35import Language.PureScript.Ide.Util
35import Language.PureScript.Ide.Util
36
36
37−import Text.Parsec as Parsec
37+import Text.Parsec as Parsec
38−import qualified Text.PrettyPrint.Boxes as Box
38+import qualified Text.PrettyPrint.Boxes as Box
39
39
40type Constructor = (P.ProperName 'P.ConstructorName, [P.Type])
40type Constructor = (P.ProperName 'P.ConstructorName, [P.Type])
41
41
src/Language/PureScript/Ide/Command.hs+2−1
@@ -12,7 +12,8 @@
12-- Datatypes for the commands psc-ide accepts
12-- Datatypes for the commands psc-ide accepts
13-----------------------------------------------------------------------------
13-----------------------------------------------------------------------------
14
14
15−{-# LANGUAGE OverloadedStrings #-}
15+{-# LANGUAGE OverloadedStrings #-}
16+
16
17
17module Language.PureScript.Ide.Command where
18module Language.PureScript.Ide.Command where
18
19
src/Language/PureScript/Ide/Conversions.hs+9−3
@@ -14,16 +14,23 @@
14
14
15module Language.PureScript.Ide.Conversions where
15module Language.PureScript.Ide.Conversions where
16
16
17−import Protolude
17+import Control.Lens.Iso
18−import Data.Text (unwords, lines, strip)
18+import Data.Text (lines, strip, unwords)
19import qualified Language.PureScript as P
19import qualified Language.PureScript as P
20+import Protolude
20
21
21runProperNameT :: P.ProperName a -> Text
22runProperNameT :: P.ProperName a -> Text
22runProperNameT = toS . P.runProperName
23runProperNameT = toS . P.runProperName
23
24
25+properNameT :: Iso' (P.ProperName a) Text
26+properNameT = iso (toS . P.runProperName) (P.ProperName . toS)
27+
24runIdentT :: P.Ident -> Text
28runIdentT :: P.Ident -> Text
25runIdentT = toS . P.runIdent
29runIdentT = toS . P.runIdent
26
30
31+identT :: Iso' P.Ident Text
32+identT = iso (toS . P.runIdent) (P.Ident . toS)
33+
27runOpNameT :: P.OpName a -> Text
34runOpNameT :: P.OpName a -> Text
28runOpNameT = toS . P.runOpName
35runOpNameT = toS . P.runOpName
29
36
@@ -32,4 +39,3 @@ runModuleNameT = toS . P.runModuleName
32
39
33prettyTypeT :: P.Type -> Text
40prettyTypeT :: P.Type -> Text
34prettyTypeT = unwords . map strip . lines . toS . P.prettyPrintType
41prettyTypeT = unwords . map strip . lines . toS . P.prettyPrintType
35−
src/Language/PureScript/Ide/Error.hs+3−3
@@ -17,11 +17,11 @@ module Language.PureScript.Ide.Error
17 ( PscIdeError(..)
17 ( PscIdeError(..)
18 ) where
18 ) where
19
19
20−import Protolude
21import Data.Aeson
20import Data.Aeson
22import Language.PureScript.Errors.JSON
21import Language.PureScript.Errors.JSON
23−import Language.PureScript.Ide.Types (ModuleIdent)
22+import Language.PureScript.Ide.Types (ModuleIdent)
23+import Protolude
24−import qualified Text.Parsec.Error as P
24+import qualified Text.Parsec.Error as P
25
25
26data PscIdeError
26data PscIdeError
27 = GeneralError Text
27 = GeneralError Text
src/Language/PureScript/Ide/Externs.hs+29−28
@@ -14,7 +14,6 @@
14
14
15{-# LANGUAGE OverloadedStrings #-}
15{-# LANGUAGE OverloadedStrings #-}
16{-# LANGUAGE RecordWildCards #-}
16{-# LANGUAGE RecordWildCards #-}
17−{-# LANGUAGE FlexibleContexts #-}
18
17
19module Language.PureScript.Ide.Externs
18module Language.PureScript.Ide.Externs
20 ( readExternFile
19 ( readExternFile
@@ -24,10 +23,11 @@ module Language.PureScript.Ide.Externs
24
23
25import Protolude
24import Protolude
26
25
26+import Control.Lens ((^.))
27import Data.Aeson (decodeStrict)
27import Data.Aeson (decodeStrict)
28+import qualified Data.ByteString as BS
28import Data.List (nub)
29import Data.List (nub)
29import qualified Data.Map as Map
30import qualified Data.Map as Map
30−import qualified Data.ByteString as BS
31import Language.PureScript.Ide.Error (PscIdeError (..))
31import Language.PureScript.Ide.Error (PscIdeError (..))
32import Language.PureScript.Ide.Types
32import Language.PureScript.Ide.Types
33import Language.PureScript.Ide.Util
33import Language.PureScript.Ide.Util
@@ -58,14 +58,14 @@ convertExterns ef =
58 cleanDeclarations = nub $ appEndo typeClassFilter declarations
58 cleanDeclarations = nub $ appEndo typeClassFilter declarations
59
59
60removeTypeDeclarationsForClass :: IdeDeclaration -> Endo [IdeDeclaration]
60removeTypeDeclarationsForClass :: IdeDeclaration -> Endo [IdeDeclaration]
61−removeTypeDeclarationsForClass (IdeTypeClass n) = Endo (filter notDuplicate)
61+removeTypeDeclarationsForClass (IdeDeclTypeClass n) = Endo (filter notDuplicate)
62− where notDuplicate (IdeType n' _) = runProperNameT n /= runProperNameT n'
62+ where notDuplicate (IdeDeclType t) = n ^. properNameT /= t ^. ideTypeName . properNameT
63− notDuplicate (IdeTypeSynonym n' _) = runProperNameT n /= runProperNameT n'
63+ notDuplicate (IdeDeclTypeSynonym s) = n ^. properNameT /= s ^. ideSynonymName . properNameT
64 notDuplicate _ = True
64 notDuplicate _ = True
65removeTypeDeclarationsForClass _ = mempty
65removeTypeDeclarationsForClass _ = mempty
66
66
67isTypeClassDeclaration :: IdeDeclaration -> Bool
67isTypeClassDeclaration :: IdeDeclaration -> Bool
68−isTypeClassDeclaration IdeTypeClass{} = True
68+isTypeClassDeclaration IdeDeclTypeClass{} = True
69isTypeClassDeclaration _ = False
69isTypeClassDeclaration _ = False
70
70
71convertExport :: P.DeclarationRef -> Maybe (P.ModuleName, P.DeclarationRef)
71convertExport :: P.DeclarationRef -> Maybe (P.ModuleName, P.DeclarationRef)
@@ -73,19 +73,20 @@ convertExport (P.ReExportRef m r) = Just (m, r)
73convertExport _ = Nothing
73convertExport _ = Nothing
74
74
75convertDecl :: P.ExternsDeclaration -> Maybe IdeDeclaration
75convertDecl :: P.ExternsDeclaration -> Maybe IdeDeclaration
76+convertDecl P.EDType{..} = Just $ IdeDeclType $
76−convertDecl P.EDType{..} = Just (IdeType edTypeName edTypeKind)
77+ IdeType edTypeName edTypeKind
77−convertDecl P.EDTypeSynonym{..} =
78+convertDecl P.EDTypeSynonym{..} = Just $ IdeDeclTypeSynonym
78− Just (IdeTypeSynonym edTypeSynonymName edTypeSynonymType)
79+ (IdeSynonym edTypeSynonymName edTypeSynonymType)
79−convertDecl P.EDDataConstructor{..} = Just $
80+convertDecl P.EDDataConstructor{..} = Just $ IdeDeclDataConstructor $
80 IdeDataConstructor edDataCtorName edDataCtorTypeCtor edDataCtorType
81 IdeDataConstructor edDataCtorName edDataCtorTypeCtor edDataCtorType
81−convertDecl P.EDValue{..} = Just $
82+convertDecl P.EDValue{..} = Just $ IdeDeclValue $
82 IdeValue edValueName edValueType
83 IdeValue edValueName edValueType
83−convertDecl P.EDClass{..} = Just (IdeTypeClass edClassName)
84+convertDecl P.EDClass{..} = Just (IdeDeclTypeClass edClassName)
84convertDecl P.EDInstance{} = Nothing
85convertDecl P.EDInstance{} = Nothing
85
86
86convertOperator :: P.ExternsFixity -> IdeDeclaration
87convertOperator :: P.ExternsFixity -> IdeDeclaration
87convertOperator P.ExternsFixity{..} =
88convertOperator P.ExternsFixity{..} =
88− IdeValueOperator
89+ IdeDeclValueOperator $ IdeValueOperator
89 efOperator
90 efOperator
90 efAlias
91 efAlias
91 efPrecedence
92 efPrecedence
@@ -94,7 +95,7 @@ convertOperator P.ExternsFixity{..} =
94
95
95convertTypeOperator :: P.ExternsTypeFixity -> IdeDeclaration
96convertTypeOperator :: P.ExternsTypeFixity -> IdeDeclaration
96convertTypeOperator P.ExternsTypeFixity{..} =
97convertTypeOperator P.ExternsTypeFixity{..} =
97− IdeTypeOperator
98+ IdeDeclTypeOperator $ IdeTypeOperator
98 efTypeOperator
99 efTypeOperator
99 efTypeAlias
100 efTypeAlias
100 efTypePrecedence
101 efTypePrecedence
@@ -110,20 +111,20 @@ annotateModule (defs, types) (moduleName, decls) =
110 where
111 where
111 convertDeclaration :: IdeDeclarationAnn -> IdeDeclarationAnn
112 convertDeclaration :: IdeDeclarationAnn -> IdeDeclarationAnn
112 convertDeclaration (IdeDeclarationAnn ann d) = case d of
113 convertDeclaration (IdeDeclarationAnn ann d) = case d of
113− IdeValue i t ->
114+ IdeDeclValue v ->
114− annotateFunction i (IdeValue i t)
115+ annotateFunction (v ^. ideValueIdent) (IdeDeclValue v)
115− IdeType i k ->
116+ IdeDeclType t ->
116− annotateType (runProperNameT i) (IdeType i k)
117+ annotateType (t ^. ideTypeName . properNameT) (IdeDeclType t)
117− IdeTypeSynonym i t ->
118+ IdeDeclTypeSynonym s ->
118− annotateType (runProperNameT i) (IdeTypeSynonym i t)
119+ annotateType (s ^. ideSynonymName . properNameT) (IdeDeclTypeSynonym s)
119− IdeDataConstructor i tn t ->
120+ IdeDeclDataConstructor dtor ->
120− annotateValue (runProperNameT i) (IdeDataConstructor i tn t)
121+ annotateValue (dtor ^. ideDtorName . properNameT) (IdeDeclDataConstructor dtor)
121− IdeTypeClass i ->
122+ IdeDeclTypeClass i ->
122− annotateType (runProperNameT i) (IdeTypeClass i)
123+ annotateType (runProperNameT i) (IdeDeclTypeClass i)
123− IdeValueOperator n i p a t ->
124+ IdeDeclValueOperator op ->
124− annotateValue (valueOperatorAliasT i) (IdeValueOperator n i p a t)
125+ annotateValue (op ^. ideValueOpAlias & valueOperatorAliasT) (IdeDeclValueOperator op)
125− IdeTypeOperator n i p a k ->
126+ IdeDeclTypeOperator op ->
126− annotateType (typeOperatorAliasT i) (IdeTypeOperator n i p a k)
127+ annotateType (op ^. ideTypeOpAlias & typeOperatorAliasT) (IdeDeclTypeOperator op)
127 where
128 where
128 annotateFunction x = IdeDeclarationAnn (ann { annLocation = Map.lookup (Left (runIdentT x)) defs
129 annotateFunction x = IdeDeclarationAnn (ann { annLocation = Map.lookup (Left (runIdentT x)) defs
129 , annTypeAnnotation = Map.lookup x types
130 , annTypeAnnotation = Map.lookup x types
src/Language/PureScript/Ide/Filter.hs+3−4
@@ -23,13 +23,13 @@ module Language.PureScript.Ide.Filter
23 , applyFilters
23 , applyFilters
24 ) where
24 ) where
25
25
26−import Protolude hiding (isPrefixOf)
26+import Protolude hiding (isPrefixOf)
27
27
28import Data.Aeson
28import Data.Aeson
29import Data.Text (isPrefixOf)
29import Data.Text (isPrefixOf)
30+import qualified Language.PureScript as P
30import Language.PureScript.Ide.Types
31import Language.PureScript.Ide.Types
31import Language.PureScript.Ide.Util
32import Language.PureScript.Ide.Util
32−import qualified Language.PureScript as P
33
33
34newtype Filter = Filter (Endo [Module]) deriving(Monoid)
34newtype Filter = Filter (Endo [Module]) deriving(Monoid)
35
35
@@ -65,8 +65,7 @@ identFilter predicate search =
65 where
65 where
66 filterModuleDecls :: Module -> Module
66 filterModuleDecls :: Module -> Module
67 filterModuleDecls (moduleIdent, decls) =
67 filterModuleDecls (moduleIdent, decls) =
68− (moduleIdent, filter (flip predicate search . getDeclaration) decls)
68+ (moduleIdent, filter (flip predicate search . discardAnn) decls)
69− getDeclaration (IdeDeclarationAnn _ d) = d
70
69
71runFilter :: Filter -> [Module] -> [Module]
70runFilter :: Filter -> [Module] -> [Module]
72runFilter (Filter f) = appEndo f
71runFilter (Filter f) = appEndo f
src/Language/PureScript/Ide/Imports.hs+21−15
@@ -30,8 +30,10 @@ module Language.PureScript.Ide.Imports
30 where
30 where
31
31
32import Protolude
32import Protolude
33+
34+import Control.Lens ((^.))
35+import Data.List (findIndex, nubBy)
33import qualified Data.Text as T
36import qualified Data.Text as T
34−import Data.List (nubBy, findIndex)
35import qualified Data.Text.IO as TIO
37import qualified Data.Text.IO as TIO
36import qualified Language.PureScript as P
38import qualified Language.PureScript as P
37import Language.PureScript.Ide.Completion
39import Language.PureScript.Ide.Completion
@@ -197,16 +199,16 @@ addExplicitImport' decl moduleName imports =
197 then imports
199 then imports
198 else updateAtFirstOrPrepend matches (insertDeclIntoImport decl) freshImport imports
200 else updateAtFirstOrPrepend matches (insertDeclIntoImport decl) freshImport imports
199 where
201 where
200− refFromDeclaration (IdeTypeClass n) =
202+ refFromDeclaration (IdeDeclTypeClass n) =
201 P.TypeClassRef n
203 P.TypeClassRef n
202− refFromDeclaration (IdeDataConstructor n tn _) =
204+ refFromDeclaration (IdeDeclDataConstructor dtor) =
203− P.TypeRef tn (Just [n])
205+ P.TypeRef (dtor ^. ideDtorTypeName) (Just [dtor ^. ideDtorName])
204− refFromDeclaration (IdeType n _) =
206+ refFromDeclaration (IdeDeclType t) =
205− P.TypeRef n (Just [])
207+ P.TypeRef (t ^. ideTypeName) (Just [])
206− refFromDeclaration (IdeValueOperator op _ _ _ _) =
208+ refFromDeclaration (IdeDeclValueOperator op) =
207− P.ValueOpRef op
209+ P.ValueOpRef (op ^. ideValueOpName)
208− refFromDeclaration (IdeTypeOperator op _ _ _ _) =
210+ refFromDeclaration (IdeDeclTypeOperator op) =
209− P.TypeOpRef op
211+ P.TypeOpRef (op ^. ideTypeOpName)
210 refFromDeclaration d =
212 refFromDeclaration d =
211 P.ValueRef $ P.Ident $ T.unpack (identifierFromIdeDeclaration d)
213 P.ValueRef $ P.Ident $ T.unpack (identifierFromIdeDeclaration d)
212
214
@@ -218,8 +220,12 @@ addExplicitImport' decl moduleName imports =
218 insertDeclIntoImport _ is = is
220 insertDeclIntoImport _ is = is
219
221
220 insertDeclIntoRefs :: IdeDeclaration -> [P.DeclarationRef] -> [P.DeclarationRef]
222 insertDeclIntoRefs :: IdeDeclaration -> [P.DeclarationRef] -> [P.DeclarationRef]
221− insertDeclIntoRefs (IdeDataConstructor dtor tn _) refs =
223+ insertDeclIntoRefs d@(IdeDeclDataConstructor dtor) refs =
222− updateAtFirstOrPrepend (matchType tn) (insertDtor dtor) (P.TypeRef tn (Just [dtor])) refs
224+ updateAtFirstOrPrepend
225+ (matchType (dtor ^. ideDtorTypeName))
226+ (insertDtor (dtor ^. ideDtorName))
227+ (refFromDeclaration d)
228+ refs
223 insertDeclIntoRefs dr refs = nubBy ((==) `on` P.prettyPrintRef) (refFromDeclaration dr : refs)
229 insertDeclIntoRefs dr refs = nubBy ((==) `on` P.prettyPrintRef) (refFromDeclaration dr : refs)
224
230
225 insertDtor dtor (P.TypeRef tn' dtors) =
231 insertDtor dtor (P.TypeRef tn' dtors) =
@@ -294,9 +300,9 @@ addImportForIdentifier fp ident filters = do
294 xs ->
300 xs ->
295 pure $ Left xs
301 pure $ Left xs
296 where
302 where
297− decideRedundantCase dtor@(IdeDataConstructor _ t _) (IdeType t' _) =
303+ decideRedundantCase d@(IdeDeclDataConstructor dtor) (IdeDeclType t) =
298− if t == t' then Just dtor else Nothing
304+ if dtor ^. ideDtorTypeName == t ^. ideTypeName then Just d else Nothing
299− decideRedundantCase IdeType{} ts@IdeTypeSynonym{} =
305+ decideRedundantCase IdeDeclType{} ts@IdeDeclTypeSynonym{} =
300 Just ts
306 Just ts
301 decideRedundantCase _ _ = Nothing
307 decideRedundantCase _ _ = Nothing
302
308
src/Language/PureScript/Ide/Matcher.hs+1−1
@@ -12,9 +12,9 @@
12-- Matchers for psc-ide commands
12-- Matchers for psc-ide commands
13-----------------------------------------------------------------------------
13-----------------------------------------------------------------------------
14
14
15+{-# LANGUAGE FlexibleInstances #-}
15{-# LANGUAGE GeneralizedNewtypeDeriving #-}
16{-# LANGUAGE GeneralizedNewtypeDeriving #-}
16{-# LANGUAGE OverloadedStrings #-}
17{-# LANGUAGE OverloadedStrings #-}
17−{-# LANGUAGE FlexibleInstances #-}
18
18
19module Language.PureScript.Ide.Matcher
19module Language.PureScript.Ide.Matcher
20 ( Matcher
20 ( Matcher
src/Language/PureScript/Ide/Pursuit.hs+1−1
@@ -12,7 +12,7 @@
12-- Pursuit client for psc-ide
12-- Pursuit client for psc-ide
13-----------------------------------------------------------------------------
13-----------------------------------------------------------------------------
14
14
15−{-# LANGUAGE OverloadedStrings #-}
15+{-# LANGUAGE OverloadedStrings #-}
16
16
17module Language.PureScript.Ide.Pursuit
17module Language.PureScript.Ide.Pursuit
18 ( searchPursuitForDeclarations
18 ( searchPursuitForDeclarations
src/Language/PureScript/Ide/Rebuild.hs+1−1
@@ -11,7 +11,7 @@ module Language.PureScript.Ide.Rebuild
11import Protolude
11import Protolude
12
12
13import "monad-logger" Control.Monad.Logger
13import "monad-logger" Control.Monad.Logger
14−import qualified Data.List as List
14+import qualified Data.List as List
15import qualified Data.Map.Lazy as M
15import qualified Data.Map.Lazy as M
16import Data.Maybe (fromJust)
16import Data.Maybe (fromJust)
17import qualified Data.Set as S
17import qualified Data.Set as S
src/Language/PureScript/Ide/Reexports.hs+13−16
@@ -25,16 +25,18 @@ module Language.PureScript.Ide.Reexports
25
25
26import Protolude
26import Protolude
27
27
28+import Control.Lens hiding ((&))
29+
28import qualified Data.Map as Map
30import qualified Data.Map as Map
31+import qualified Language.PureScript as P
29import Language.PureScript.Ide.Types
32import Language.PureScript.Ide.Types
30import Language.PureScript.Ide.Util
33import Language.PureScript.Ide.Util
31−import qualified Language.PureScript as P
32
34
33-- | Contains the module with resolved reexports, and eventual failures
35-- | Contains the module with resolved reexports, and eventual failures
34data ReexportResult a
36data ReexportResult a
35 = ReexportResult
37 = ReexportResult
36 { reResolved :: a
38 { reResolved :: a
37− , reFailed :: [(P.ModuleName, P.DeclarationRef)]
39+ , reFailed :: [(P.ModuleName, P.DeclarationRef)]
38 } deriving (Show, Eq, Functor)
40 } deriving (Show, Eq, Functor)
39
41
40-- | Uses the passed formatter to format the resolved module, and adds eventual
42-- | Uses the passed formatter to format the resolved module, and adds eventual
@@ -79,7 +81,7 @@ resolveRef
79 -> Either P.DeclarationRef [IdeDeclarationAnn]
81 -> Either P.DeclarationRef [IdeDeclarationAnn]
80resolveRef decls ref = case ref of
82resolveRef decls ref = case ref of
81 P.TypeRef tn mdtors ->
83 P.TypeRef tn mdtors ->
82− case findRef (\case IdeType name _ -> name == tn; _ -> False) of
84+ case findRef (\x -> x ^? _IdeDeclType . ideTypeName <&> (== tn) & fromMaybe False) of
83 Nothing -> Left ref
85 Nothing -> Left ref
84 Just d -> Right $ d : case mdtors of
86 Just d -> Right $ d : case mdtors of
85 Nothing ->
87 Nothing ->
@@ -89,28 +91,23 @@ resolveRef decls ref = case ref of
89 findDtors tn
91 findDtors tn
90 Just dtors -> mapMaybe lookupDtor dtors
92 Just dtors -> mapMaybe lookupDtor dtors
91 P.ValueRef i ->
93 P.ValueRef i ->
92− findWrapped (\case IdeValue i' _ -> i' == i; _ -> False)
94+ findWrapped (\x -> x ^? _IdeDeclValue . ideValueIdent <&> (== i) & fromMaybe False)
93− P.TypeOpRef name ->
94− findWrapped (\case IdeTypeOperator n _ _ _ _ -> n == name; _ -> False)
95 P.ValueOpRef name ->
95 P.ValueOpRef name ->
96− findWrapped (\case IdeValueOperator n _ _ _ _ -> n == name; _ -> False)
96+ findWrapped (\x -> x ^? _IdeDeclValueOperator . ideValueOpName <&> (== name) & fromMaybe False)
97+ P.TypeOpRef name ->
98+ findWrapped (\x -> x ^? _IdeDeclTypeOperator . ideTypeOpName <&> (== name) & fromMaybe False)
97 P.TypeClassRef name ->
99 P.TypeClassRef name ->
98− findWrapped (\case IdeTypeClass n -> n == name; _ -> False)
100+ findWrapped (\case IdeDeclTypeClass n -> n == name; _ -> False)
99 _ ->
101 _ ->
100 Left ref
102 Left ref
101 where
103 where
102− findWrapped = wrapSingle . findRef
103− wrapSingle = maybe (Left ref) (Right . pure)
104+ findWrapped = maybe (Left ref) (Right . pure) . findRef
104 findRef f = find (f . discardAnn) decls
105 findRef f = find (f . discardAnn) decls
105
106
106 lookupDtor name =
107 lookupDtor name =
107− findRef (\case IdeDataConstructor name' _ _ -> name == name'
108+ findRef (\x -> x ^? _IdeDeclDataConstructor . ideDtorName <&> (== name) & fromMaybe False)
108− _ -> False)
109
109
110 findDtors tn = filter (f . discardAnn) decls
110 findDtors tn = filter (f . discardAnn) decls
111 where
111 where
112 f :: IdeDeclaration -> Bool
112 f :: IdeDeclaration -> Bool
113− f decl
113+ f decl = decl ^? _IdeDeclDataConstructor . ideDtorTypeName <&> (== tn) & fromMaybe False
114− | (IdeDataConstructor _ tn' _) <- decl
115− , tn == tn' = True
116− | otherwise = False
src/Language/PureScript/Ide/SourceFile.hs+5−5
@@ -12,7 +12,7 @@
12-- Getting declarations from PureScript sourcefiles
12-- Getting declarations from PureScript sourcefiles
13-----------------------------------------------------------------------------
13-----------------------------------------------------------------------------
14
14
15−{-# LANGUAGE OverloadedStrings #-}
15+{-# LANGUAGE OverloadedStrings #-}
16
16
17module Language.PureScript.Ide.SourceFile
17module Language.PureScript.Ide.SourceFile
18 ( parseModule
18 ( parseModule
@@ -25,12 +25,12 @@ module Language.PureScript.Ide.SourceFile
25
25
26import Protolude
26import Protolude
27
27
28−import qualified Data.Map as Map
28+import qualified Data.Map as Map
29−import qualified Language.PureScript as P
29+import qualified Language.PureScript as P
30import Language.PureScript.Ide.Error
30import Language.PureScript.Ide.Error
31−import Language.PureScript.Ide.Util
32import Language.PureScript.Ide.Types
31import Language.PureScript.Ide.Types
32+import Language.PureScript.Ide.Util
33−import System.IO.UTF8 (readUTF8File)
33+import System.IO.UTF8 (readUTF8File)
34
34
35parseModule
35parseModule
36 :: (MonadIO m)
36 :: (MonadIO m)
src/Language/PureScript/Ide/State.hs+37−45
@@ -32,20 +32,20 @@ module Language.PureScript.Ide.State
32 , resolveOperatorsForModule
32 , resolveOperatorsForModule
33 ) where
33 ) where
34
34
35−import Protolude
36import qualified Prelude
35import qualified Prelude
36+import Protolude
37
37
38import Control.Concurrent.STM
38import Control.Concurrent.STM
39+import Control.Lens hiding (op, (&))
39import "monad-logger" Control.Monad.Logger
40import "monad-logger" Control.Monad.Logger
40−import qualified Data.Map.Lazy as Map
41+import qualified Data.Map.Lazy as Map
41−import qualified Data.List as List
42+import qualified Language.PureScript as P
42import Language.PureScript.Externs
43import Language.PureScript.Externs
43import Language.PureScript.Ide.Externs
44import Language.PureScript.Ide.Externs
44import Language.PureScript.Ide.Reexports
45import Language.PureScript.Ide.Reexports
45import Language.PureScript.Ide.SourceFile
46import Language.PureScript.Ide.SourceFile
46import Language.PureScript.Ide.Types
47import Language.PureScript.Ide.Types
47import Language.PureScript.Ide.Util
48import Language.PureScript.Ide.Util
48−import qualified Language.PureScript as P
49import System.Clock
49import System.Clock
50
50
51-- | Resets all State inside psc-ide
51-- | Resets all State inside psc-ide
@@ -235,47 +235,39 @@ resolveOperatorsForModule
235 :: Map P.ModuleName [IdeDeclarationAnn]
235 :: Map P.ModuleName [IdeDeclarationAnn]
236 -> [IdeDeclarationAnn]
236 -> [IdeDeclarationAnn]
237 -> [IdeDeclarationAnn]
237 -> [IdeDeclarationAnn]
238−resolveOperatorsForModule modules = map (mapIdeDeclaration resolveOperator)
238+resolveOperatorsForModule modules = map ((over idaDeclaration) resolveOperator)
239 where
239 where
240+ hasName :: Eq b => Lens' a b -> b -> a -> Bool
241+ hasName l a x = x ^. l == a
242+
243+ getDeclarations :: P.ModuleName -> [IdeDeclaration]
244+ getDeclarations moduleName =
245+ Map.lookup moduleName modules
246+ & fromMaybe []
247+ & map discardAnn
248+
240− resolveOperator (IdeValueOperator
249+ resolveOperator (IdeDeclValueOperator op)
241− opName
242− i@(P.Qualified (Just moduleName)
250+ | (P.Qualified (Just mn) (Left ident)) <- op ^. ideValueOpAlias =
243− (Left ident)) precedence assoc _) =
251+ let t = getDeclarations mn
244− let t = do
252+ & mapMaybe (preview _IdeDeclValue)
245− sourceModule <- Map.lookup moduleName modules
253+ & filter (hasName ideValueIdent ident)
246− IdeValue _ tP <-
254+ & map (view ideValueType)
247− List.find (\case
255+ & listToMaybe
248− IdeValue iP _ -> iP == ident
256+ in IdeDeclValueOperator (op & ideValueOpType .~ t)
249− _ -> False) (discardAnn <$> sourceModule)
250− pure tP
251−
252− in IdeValueOperator opName i precedence assoc t
253− resolveOperator (IdeValueOperator
254− opName
255− i@(P.Qualified (Just moduleName)
257+ | (P.Qualified (Just mn) (Right dtor)) <- op ^. ideValueOpAlias =
256− (Right ctor)) precedence assoc _) =
258+ let t = getDeclarations mn
257− let t = do
259+ & mapMaybe (preview _IdeDeclDataConstructor)
258− sourceModule <- Map.lookup moduleName modules
260+ & filter (hasName ideDtorName dtor)
259− IdeDataConstructor _ _ tP <-
261+ & map (view ideDtorType)
260− List.find (\case
262+ & listToMaybe
261− IdeDataConstructor cname _ _ -> ctor == cname
263+ in IdeDeclValueOperator (op & ideValueOpType .~ t)
262− _ -> False) (discardAnn <$> sourceModule)
263− pure tP
264−
265− in IdeValueOperator opName i precedence assoc t
266− resolveOperator (IdeTypeOperator
264+ resolveOperator (IdeDeclTypeOperator op)
267− opName
268− i@(P.Qualified (Just moduleName) properName) precedence assoc _) =
265+ | P.Qualified (Just mn) properName <- op ^. ideTypeOpAlias =
269− let k = do
266+ let k = getDeclarations mn
270− sourceModule <- Map.lookup moduleName modules
267+ & mapMaybe (preview _IdeDeclType)
271− IdeType _ kP <-
268+ & filter (hasName ideTypeName properName)
272− List.find (\case
269+ & map (view ideTypeKind)
273− IdeType name _ -> name == properName
270+ & listToMaybe
274− _ -> False) (discardAnn <$> sourceModule)
271+ in IdeDeclTypeOperator (op & ideTypeOpKind .~ k)
275− pure kP
276−
277− in IdeTypeOperator opName i precedence assoc k
278 resolveOperator x = x
272 resolveOperator x = x
279
273
280−mapIdeDeclaration :: (IdeDeclaration -> IdeDeclaration) -> IdeDeclarationAnn -> IdeDeclarationAnn
281−mapIdeDeclaration f (IdeDeclarationAnn ann decl) = IdeDeclarationAnn ann (f decl)
src/Language/PureScript/Ide/Types.hs+72−21
@@ -12,42 +12,93 @@
12-- Type definitions for psc-ide
12-- Type definitions for psc-ide
13-----------------------------------------------------------------------------
13-----------------------------------------------------------------------------
14
14
15−{-# LANGUAGE OverloadedStrings #-}
16{-# LANGUAGE DeriveFoldable #-}
15{-# LANGUAGE DeriveFoldable #-}
16+{-# LANGUAGE OverloadedStrings #-}
17+{-# LANGUAGE TemplateHaskell #-}
17
18
18module Language.PureScript.Ide.Types where
19module Language.PureScript.Ide.Types where
19
20
20import Protolude
21import Protolude
21
22
22import Control.Concurrent.STM
23import Control.Concurrent.STM
24+import Control.Lens.TH
23import Data.Aeson
25import Data.Aeson
24−import qualified Data.Map.Lazy as M
26+import qualified Data.Map.Lazy as M
25−import qualified Language.PureScript.Errors.JSON as P
27+import qualified Language.PureScript as P
26−import qualified Language.PureScript as P
28+import qualified Language.PureScript.Errors.JSON as P
27import Language.PureScript.Ide.Conversions
29import Language.PureScript.Ide.Conversions
28
30
29type ModuleIdent = Text
31type ModuleIdent = Text
30
32
31data IdeDeclaration
33data IdeDeclaration
32− = IdeValue P.Ident P.Type
34+ = IdeDeclValue IdeValue
33− | IdeType (P.ProperName 'P.TypeName) P.Kind
35+ | IdeDeclType IdeType
34− | IdeTypeSynonym (P.ProperName 'P.TypeName) P.Type
36+ | IdeDeclTypeSynonym IdeSynonym
35− | IdeDataConstructor (P.ProperName 'P.ConstructorName) (P.ProperName 'P.TypeName) P.Type
37+ | IdeDeclDataConstructor IdeDataConstructor
36− | IdeTypeClass (P.ProperName 'P.ClassName)
38+ | IdeDeclTypeClass (P.ProperName 'P.ClassName)
37− | IdeValueOperator (P.OpName 'P.ValueOpName) (P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName))) P.Precedence P.Associativity (Maybe P.Type)
39+ | IdeDeclValueOperator IdeValueOperator
38− | IdeTypeOperator (P.OpName 'P.TypeOpName) (P.Qualified (P.ProperName 'P.TypeName)) P.Precedence P.Associativity (Maybe P.Kind)
40+ | IdeDeclTypeOperator IdeTypeOperator
39 deriving (Show, Eq, Ord)
41 deriving (Show, Eq, Ord)
40
42
43+data IdeValue = IdeValue
44+ { _ideValueIdent :: P.Ident
45+ , _ideValueType :: P.Type
46+ } deriving (Show, Eq, Ord)
47+
48+data IdeType = IdeType
49+ { _ideTypeName :: P.ProperName 'P.TypeName
50+ , _ideTypeKind :: P.Kind
51+ } deriving (Show, Eq, Ord)
52+
53+data IdeSynonym = IdeSynonym
54+ { _ideSynonymName :: P.ProperName 'P.TypeName
55+ , _ideSynonymType :: P.Type
56+ } deriving (Show, Eq, Ord)
57+
58+data IdeDataConstructor = IdeDataConstructor
59+ { _ideDtorName :: P.ProperName 'P.ConstructorName
60+ , _ideDtorTypeName :: P.ProperName 'P.TypeName
61+ , _ideDtorType :: P.Type
62+ } deriving (Show, Eq, Ord)
63+
64+data IdeValueOperator = IdeValueOperator
65+ { _ideValueOpName :: P.OpName 'P.ValueOpName
66+ , _ideValueOpAlias :: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName))
67+ , _ideValueOpPrecedence :: P.Precedence
68+ , _ideValueOpAssociativity :: P.Associativity
69+ , _ideValueOpType :: Maybe P.Type
70+ } deriving (Show, Eq, Ord)
71+
72+data IdeTypeOperator = IdeTypeOperator
73+ { _ideTypeOpName :: P.OpName 'P.TypeOpName
74+ , _ideTypeOpAlias :: P.Qualified (P.ProperName 'P.TypeName)
75+ , _ideTypeOpPrecedence :: P.Precedence
76+ , _ideTypeOpAssociativity :: P.Associativity
77+ , _ideTypeOpKind :: Maybe P.Kind
78+ } deriving (Show, Eq, Ord)
79+
80+makePrisms ''IdeDeclaration
81+makeLenses ''IdeValue
82+makeLenses ''IdeType
83+makeLenses ''IdeSynonym
84+makeLenses ''IdeDataConstructor
85+makeLenses ''IdeValueOperator
86+makeLenses ''IdeTypeOperator
87+
41−data IdeDeclarationAnn = IdeDeclarationAnn Annotation IdeDeclaration
88+data IdeDeclarationAnn = IdeDeclarationAnn
89+ { _idaAnnotation :: Annotation
90+ , _idaDeclaration :: IdeDeclaration
42− deriving (Show, Eq, Ord)
91+ } deriving (Show, Eq, Ord)
43
92
44data Annotation
93data Annotation
45 = Annotation
94 = Annotation
46− { annLocation :: Maybe P.SourceSpan
95+ { annLocation :: Maybe P.SourceSpan
47− , annExportedFrom :: Maybe P.ModuleName
96+ , annExportedFrom :: Maybe P.ModuleName
48 , annTypeAnnotation :: Maybe P.Type
97 , annTypeAnnotation :: Maybe P.Type
49 } deriving (Show, Eq, Ord)
98 } deriving (Show, Eq, Ord)
50
99
100+makeLenses ''IdeDeclarationAnn
101+
51emptyAnn :: Annotation
102emptyAnn :: Annotation
52emptyAnn = Annotation Nothing Nothing Nothing
103emptyAnn = Annotation Nothing Nothing Nothing
53
104
@@ -103,7 +154,7 @@ data Stage2 = Stage2
103 }
154 }
104
155
105data Stage3 = Stage3
156data Stage3 = Stage3
106− { s3Declarations :: M.Map P.ModuleName [IdeDeclarationAnn]
157+ { s3Declarations :: M.Map P.ModuleName [IdeDeclarationAnn]
107 , s3CachedRebuild :: Maybe (P.ModuleName, P.ExternsFile)
158 , s3CachedRebuild :: Maybe (P.ModuleName, P.ExternsFile)
108 }
159 }
109
160
@@ -112,11 +163,11 @@ newtype Match a = Match (P.ModuleName, a)
112
163
113-- | A completion as it gets sent to the editors
164-- | A completion as it gets sent to the editors
114data Completion = Completion
165data Completion = Completion
115− { complModule :: Text
166+ { complModule :: Text
116− , complIdentifier :: Text
167+ , complIdentifier :: Text
117− , complType :: Text
168+ , complType :: Text
118− , complExpandedType :: Text
169+ , complExpandedType :: Text
119− , complLocation :: Maybe P.SourceSpan
170+ , complLocation :: Maybe P.SourceSpan
120 , complDocumentation :: Maybe Text
171 , complDocumentation :: Maybe Text
121 } deriving (Show, Eq)
172 } deriving (Show, Eq)
122
173
src/Language/PureScript/Ide/Util.hs+26−24
@@ -29,23 +29,25 @@ module Language.PureScript.Ide.Util
29 , module Language.PureScript.Ide.Conversions
29 , module Language.PureScript.Ide.Conversions
30 ) where
30 ) where
31
31
32−import Protolude hiding (decodeUtf8, encodeUtf8)
32+import Control.Lens ((^.))
33import Data.Aeson
33import Data.Aeson
34−import qualified Data.Text as T
34+import qualified Data.Text as T
35−import Data.Text.Lazy.Encoding (decodeUtf8, encodeUtf8)
35+import Data.Text.Lazy.Encoding (decodeUtf8, encodeUtf8)
36−import qualified Language.PureScript as P
36+import qualified Language.PureScript as P
37−import Language.PureScript.Ide.Types
38import Language.PureScript.Ide.Conversions
37import Language.PureScript.Ide.Conversions
38+import Language.PureScript.Ide.Types
39+import Protolude hiding (decodeUtf8,
40+ encodeUtf8)
39
41
40identifierFromIdeDeclaration :: IdeDeclaration -> Text
42identifierFromIdeDeclaration :: IdeDeclaration -> Text
41identifierFromIdeDeclaration d = case d of
43identifierFromIdeDeclaration d = case d of
42− IdeValue name _ -> runIdentT name
44+ IdeDeclValue v -> v ^. ideValueIdent . identT
43− IdeType name _ -> runProperNameT name
45+ IdeDeclType t -> t ^. ideTypeName . properNameT
44− IdeTypeSynonym name _ -> runProperNameT name
46+ IdeDeclTypeSynonym s -> s ^. ideSynonymName . properNameT
45− IdeDataConstructor name _ _ -> runProperNameT name
47+ IdeDeclDataConstructor dtor -> dtor ^. ideDtorName . properNameT
46− IdeTypeClass name -> runProperNameT name
48+ IdeDeclTypeClass name -> runProperNameT name
47− IdeValueOperator op _ _ _ _ -> runOpNameT op
49+ IdeDeclValueOperator op -> op ^. ideValueOpName & runOpNameT
48− IdeTypeOperator op _ _ _ _ -> runOpNameT op
50+ IdeDeclTypeOperator op -> op ^. ideTypeOpName & runOpNameT
49
51
50discardAnn :: IdeDeclarationAnn -> IdeDeclaration
52discardAnn :: IdeDeclarationAnn -> IdeDeclaration
51discardAnn (IdeDeclarationAnn _ d) = d
53discardAnn (IdeDeclarationAnn _ d) = d
@@ -61,24 +63,24 @@ completionFromMatch (Match (m, IdeDeclarationAnn ann decl)) =
61 Completion {..}
63 Completion {..}
62 where
64 where
63 (complIdentifier, complExpandedType) = case decl of
65 (complIdentifier, complExpandedType) = case decl of
64− IdeValue name type' -> (runIdentT name, prettyTypeT type')
66+ IdeDeclValue v -> (v ^. ideValueIdent . identT, v ^. ideValueType & prettyTypeT)
65− IdeType name kind -> (runProperNameT name, toS (P.prettyPrintKind kind))
67+ IdeDeclType t -> (t ^. ideTypeName . properNameT, t ^. ideTypeKind & P.prettyPrintKind & toS )
66− IdeTypeSynonym name kind -> (runProperNameT name, prettyTypeT kind)
68+ IdeDeclTypeSynonym s -> (s ^. ideSynonymName . properNameT, s ^. ideSynonymType & prettyTypeT)
67− IdeDataConstructor name _ type' -> (runProperNameT name, prettyTypeT type')
69+ IdeDeclDataConstructor d -> (d ^. ideDtorName . properNameT, d ^. ideDtorType & prettyTypeT)
68− IdeTypeClass name -> (runProperNameT name, "class")
70+ IdeDeclTypeClass name -> (runProperNameT name, "class")
69− IdeValueOperator op ref precedence associativity typeP ->
71+ IdeDeclValueOperator (IdeValueOperator op ref precedence associativity typeP) ->
70− (runOpNameT op, maybe (showFixity precedence associativity (valueOperatorAliasT ref) op) prettyTypeT typeP)
72+ (runOpNameT op, maybe (showFixity precedence associativity (valueOperatorAliasT ref) op) prettyTypeT typeP)
71− IdeTypeOperator op ref precedence associativity kind ->
73+ IdeDeclTypeOperator (IdeTypeOperator op ref precedence associativity kind) ->
72 (runOpNameT op, maybe (showFixity precedence associativity (typeOperatorAliasT ref) op) (toS . P.prettyPrintKind) kind)
74 (runOpNameT op, maybe (showFixity precedence associativity (typeOperatorAliasT ref) op) (toS . P.prettyPrintKind) kind)
73−
75+
74 complModule = runModuleNameT m
76 complModule = runModuleNameT m
75
77
76 complType = maybe complExpandedType prettyTypeT (annTypeAnnotation ann)
78 complType = maybe complExpandedType prettyTypeT (annTypeAnnotation ann)
77−
79+
78 complLocation = annLocation ann
80 complLocation = annLocation ann
79
81
80 complDocumentation = Nothing
82 complDocumentation = Nothing
81−
83+
82 showFixity p a r o =
84 showFixity p a r o =
83 let asso = case a of
85 let asso = case a of
84 P.Infix -> "infix"
86 P.Infix -> "infix"
@@ -95,7 +97,7 @@ typeOperatorAliasT
95 :: P.Qualified (P.ProperName 'P.TypeName) -> Text
97 :: P.Qualified (P.ProperName 'P.TypeName) -> Text
96typeOperatorAliasT i =
98typeOperatorAliasT i =
97 toS (P.showQualified P.runProperName i)
99 toS (P.showQualified P.runProperName i)
98−
100+
99encodeT :: (ToJSON a) => a -> Text
101encodeT :: (ToJSON a) => a -> Text
100encodeT = toS . decodeUtf8 . encode
102encodeT = toS . decodeUtf8 . encode
101
103
tests/Language/PureScript/Ide/FilterSpec.hs+1−1
@@ -9,7 +9,7 @@ import qualified Language.PureScript as P
9import Test.Hspec
9import Test.Hspec
10
10
11value :: Text -> IdeDeclarationAnn
11value :: Text -> IdeDeclarationAnn
12−value s = IdeDeclarationAnn emptyAnn (IdeValue (P.Ident (toS s)) P.REmpty)
12+value s = IdeDeclarationAnn emptyAnn (IdeDeclValue (IdeValue (P.Ident (toS s)) P.REmpty))
13
13
14moduleA, moduleB :: Module
14moduleA, moduleB :: Module
15moduleA = (P.moduleNameFromString "Module.A", [value "function1"])
15moduleA = (P.moduleNameFromString "Module.A", [value "function1"])
tests/Language/PureScript/Ide/ImportsSpec.hs+3−3
@@ -68,11 +68,11 @@ spec = do
68 describe "import commands" $ do
68 describe "import commands" $ do
69 let simpleFileImports = let (_, _, i, _) = splitSimpleFile in i
69 let simpleFileImports = let (_, _, i, _) = splitSimpleFile in i
70 addValueImport i mn is =
70 addValueImport i mn is =
71− prettyPrintImportSection (addExplicitImport' (IdeValue (P.Ident i) wildcard) mn is)
71+ prettyPrintImportSection (addExplicitImport' (IdeDeclValue (IdeValue (P.Ident i) wildcard)) mn is)
72 addOpImport op mn is =
72 addOpImport op mn is =
73− prettyPrintImportSection (addExplicitImport' (IdeValueOperator op (P.Qualified Nothing (Left (P.Ident ""))) 2 P.Infix Nothing) mn is)
73+ prettyPrintImportSection (addExplicitImport' (IdeDeclValueOperator (IdeValueOperator op (P.Qualified Nothing (Left (P.Ident ""))) 2 P.Infix Nothing)) mn is)
74 addDtorImport i t mn is =
74 addDtorImport i t mn is =
75− prettyPrintImportSection (addExplicitImport' (IdeDataConstructor (P.ProperName i) t wildcard) mn is)
75+ prettyPrintImportSection (addExplicitImport' (IdeDeclDataConstructor (IdeDataConstructor (P.ProperName i) t wildcard)) mn is)
76 it "adds an implicit unqualified import" $
76 it "adds an implicit unqualified import" $
77 shouldBe
77 shouldBe
78 (addImplicitImport' simpleFileImports (P.moduleNameFromString "Data.Map"))
78 (addImplicitImport' simpleFileImports (P.moduleNameFromString "Data.Map"))
tests/Language/PureScript/Ide/MatcherSpec.hs+1−1
@@ -13,7 +13,7 @@ import Language.PureScript.Ide.Util
13import Test.Hspec
13import Test.Hspec
14
14
15value :: Text -> IdeDeclarationAnn
15value :: Text -> IdeDeclarationAnn
16−value s = withEmptyAnn (IdeValue (P.Ident (toS s)) P.REmpty)
16+value s = withEmptyAnn (IdeDeclValue (IdeValue (P.Ident (toS s)) P.REmpty))
17
17
18firstResult, secondResult, fiult :: Match IdeDeclarationAnn
18firstResult, secondResult, fiult :: Match IdeDeclarationAnn
19firstResult = Match (P.moduleNameFromString "Match", value "firstResult")
19firstResult = Match (P.moduleNameFromString "Match", value "firstResult")
tests/Language/PureScript/Ide/ReexportsSpec.hs+5−5
@@ -18,11 +18,11 @@ d :: IdeDeclaration -> IdeDeclarationAnn
18d = IdeDeclarationAnn emptyAnn
18d = IdeDeclarationAnn emptyAnn
19
19
20valueA, typeA, classA, dtorA1, dtorA2 :: IdeDeclarationAnn
20valueA, typeA, classA, dtorA1, dtorA2 :: IdeDeclarationAnn
21−valueA = d (IdeValue (P.Ident "valueA") P.REmpty)
21+valueA = d (IdeDeclValue (IdeValue (P.Ident "valueA") P.REmpty))
22−typeA = d (IdeType (P.ProperName "TypeA") P.Star)
22+typeA = d (IdeDeclType (IdeType(P.ProperName "TypeA") P.Star))
23−classA = d (IdeTypeClass (P.ProperName "ClassA"))
23+classA = d (IdeDeclTypeClass (P.ProperName "ClassA"))
24−dtorA1 = d (IdeDataConstructor (P.ProperName "DtorA1") (P.ProperName "TypeA") P.REmpty)
24+dtorA1 = d (IdeDeclDataConstructor (IdeDataConstructor (P.ProperName "DtorA1") (P.ProperName "TypeA") P.REmpty))
25−dtorA2 = d (IdeDataConstructor (P.ProperName "DtorA2") (P.ProperName "TypeA") P.REmpty)
25+dtorA2 = d (IdeDeclDataConstructor (IdeDataConstructor (P.ProperName "DtorA2") (P.ProperName "TypeA") P.REmpty))
26
26
27env :: Map P.ModuleName [IdeDeclarationAnn]
27env :: Map P.ModuleName [IdeDeclarationAnn]
28env = Map.fromList
28env = Map.fromList
tests/Language/PureScript/Ide/StateSpec.hs+6−6
@@ -11,20 +11,20 @@ import qualified Data.Map as Map
11
11
12valueOperator :: Maybe P.Type -> IdeDeclarationAnn
12valueOperator :: Maybe P.Type -> IdeDeclarationAnn
13valueOperator =
13valueOperator =
14− d . IdeValueOperator (P.OpName "<$>") (P.Qualified (Just (mn "Test")) (Left (P.Ident "function"))) 2 P.Infix
14+ d . IdeDeclValueOperator . IdeValueOperator (P.OpName "<$>") (P.Qualified (Just (mn "Test")) (Left (P.Ident "function"))) 2 P.Infix
15
15
16ctorOperator :: Maybe P.Type -> IdeDeclarationAnn
16ctorOperator :: Maybe P.Type -> IdeDeclarationAnn
17ctorOperator =
17ctorOperator =
18− d . IdeValueOperator (P.OpName ":") (P.Qualified (Just (mn "Test")) (Right (P.ProperName "Cons"))) 2 P.Infix
18+ d . IdeDeclValueOperator . IdeValueOperator (P.OpName ":") (P.Qualified (Just (mn "Test")) (Right (P.ProperName "Cons"))) 2 P.Infix
19
19
20typeOperator :: Maybe P.Kind -> IdeDeclarationAnn
20typeOperator :: Maybe P.Kind -> IdeDeclarationAnn
21typeOperator =
21typeOperator =
22− d . IdeTypeOperator (P.OpName ":") (P.Qualified (Just (mn "Test")) (P.ProperName "List")) 2 P.Infix
22+ d . IdeDeclTypeOperator . IdeTypeOperator (P.OpName ":") (P.Qualified (Just (mn "Test")) (P.ProperName "List")) 2 P.Infix
23
23
24testModule :: Module
24testModule :: Module
25−testModule = (mn "Test", [ d (IdeValue (P.Ident "function") P.REmpty)
25+testModule = (mn "Test", [ d (IdeDeclValue (IdeValue (P.Ident "function") P.REmpty))
26− , d (IdeDataConstructor (P.ProperName "Cons") (P.ProperName "List") (P.REmpty))
26+ , d (IdeDeclDataConstructor (IdeDataConstructor (P.ProperName "Cons") (P.ProperName "List") (P.REmpty)))
27− , d (IdeType (P.ProperName "List") P.Star)
27+ , d (IdeDeclType (IdeType (P.ProperName "List") P.Star))
28 , valueOperator Nothing
28 , valueOperator Nothing
29 , ctorOperator Nothing
29 , ctorOperator Nothing
30 , typeOperator Nothing
30 , typeOperator Nothing