@@ -25,6 +25,7 @@ import Language.PureScript.Types
2525import Language.PureScript.Names
2626import Language.PureScript.Kinds
2727import Language.PureScript.TypeClassDictionaries
28+ import Language.PureScript.Parser.Lexer
2829import Language.PureScript.CodeGen.JS.AST
2930import Language.PureScript.Environment
3031
@@ -40,7 +41,7 @@ data Module = Module ModuleName [Declaration] (Maybe [DeclarationRef]) deriving
4041isExported :: Maybe [DeclarationRef ] -> Declaration -> Bool
4142isExported Nothing _ = True
4243isExported _ TypeInstanceDeclaration {} = True
43- isExported exps (PositionedDeclaration _ d) = isExported exps d
44+ isExported exps (PositionedDeclaration _ _ d) = isExported exps d
4445isExported (Just exps) decl = any (matches decl) exps
4546 where
4647 matches (TypeDeclaration ident _) (ValueRef ident') = ident == ident'
@@ -49,8 +50,8 @@ isExported (Just exps) decl = any (matches decl) exps
4950 matches (ExternDataDeclaration ident _) (TypeRef ident' _) = ident == ident'
5051 matches (TypeSynonymDeclaration ident _ _) (TypeRef ident' _) = ident == ident'
5152 matches (TypeClassDeclaration ident _ _ _) (TypeClassRef ident') = ident == ident'
52- matches (PositionedDeclaration _ d) r = d `matches` r
53- matches d (PositionedDeclarationRef _ r) = d `matches` r
53+ matches (PositionedDeclaration _ _ d) r = d `matches` r
54+ matches d (PositionedDeclarationRef _ _ r) = d `matches` r
5455 matches _ _ = False
5556
5657exportedDeclarations :: Module -> [Declaration ]
@@ -63,7 +64,7 @@ isDctorExported :: ProperName -> Maybe [DeclarationRef] -> ProperName -> Bool
6364isDctorExported _ Nothing _ = True
6465isDctorExported ident (Just exps) ctor = test `any` exps
6566 where
66- test (PositionedDeclarationRef _ d) = test d
67+ test (PositionedDeclarationRef _ _ d) = test d
6768 test (TypeRef ident' Nothing ) = ident == ident'
6869 test (TypeRef ident' (Just ctors)) = ident == ident' && ctor `elem` ctors
6970 test _ = False
@@ -102,16 +103,16 @@ data DeclarationRef
102103 -- |
103104 -- A declaration reference with source position information
104105 --
105- | PositionedDeclarationRef SourceSpan DeclarationRef
106+ | PositionedDeclarationRef SourceSpan [ Comment ] DeclarationRef
106107 deriving (Show , D.Data , D.Typeable )
107108
108109instance Eq DeclarationRef where
109110 (TypeRef name dctors) == (TypeRef name' dctors') = name == name' && dctors == dctors'
110111 (ValueRef name) == (ValueRef name') = name == name'
111112 (TypeClassRef name) == (TypeClassRef name') = name == name'
112113 (TypeInstanceRef name) == (TypeInstanceRef name') = name == name'
113- (PositionedDeclarationRef _ r) == r' = r == r'
114- r == (PositionedDeclarationRef _ r') = r == r'
114+ (PositionedDeclarationRef _ _ r) == r' = r == r'
115+ r == (PositionedDeclarationRef _ _ r') = r == r'
115116 _ == _ = False
116117
117118-- |
@@ -192,15 +193,15 @@ data Declaration
192193 -- |
193194 -- A declaration with source position information
194195 --
195- | PositionedDeclaration SourceSpan Declaration
196+ | PositionedDeclaration SourceSpan [ Comment ] Declaration
196197 deriving (Show , D.Data , D.Typeable )
197198
198199-- |
199200-- Test if a declaration is a value declaration
200201--
201202isValueDecl :: Declaration -> Bool
202203isValueDecl ValueDeclaration {} = True
203- isValueDecl (PositionedDeclaration _ d) = isValueDecl d
204+ isValueDecl (PositionedDeclaration _ _ d) = isValueDecl d
204205isValueDecl _ = False
205206
206207-- |
@@ -209,47 +210,47 @@ isValueDecl _ = False
209210isDataDecl :: Declaration -> Bool
210211isDataDecl DataDeclaration {} = True
211212isDataDecl TypeSynonymDeclaration {} = True
212- isDataDecl (PositionedDeclaration _ d) = isDataDecl d
213+ isDataDecl (PositionedDeclaration _ _ d) = isDataDecl d
213214isDataDecl _ = False
214215
215216-- |
216217-- Test if a declaration is a module import
217218--
218219isImportDecl :: Declaration -> Bool
219220isImportDecl ImportDeclaration {} = True
220- isImportDecl (PositionedDeclaration _ d) = isImportDecl d
221+ isImportDecl (PositionedDeclaration _ _ d) = isImportDecl d
221222isImportDecl _ = False
222223
223224-- |
224225-- Test if a declaration is a data type foreign import
225226--
226227isExternDataDecl :: Declaration -> Bool
227228isExternDataDecl ExternDataDeclaration {} = True
228- isExternDataDecl (PositionedDeclaration _ d) = isExternDataDecl d
229+ isExternDataDecl (PositionedDeclaration _ _ d) = isExternDataDecl d
229230isExternDataDecl _ = False
230231
231232-- |
232233-- Test if a declaration is a type class instance foreign import
233234--
234235isExternInstanceDecl :: Declaration -> Bool
235236isExternInstanceDecl ExternInstanceDeclaration {} = True
236- isExternInstanceDecl (PositionedDeclaration _ d) = isExternInstanceDecl d
237+ isExternInstanceDecl (PositionedDeclaration _ _ d) = isExternInstanceDecl d
237238isExternInstanceDecl _ = False
238239
239240-- |
240241-- Test if a declaration is a fixity declaration
241242--
242243isFixityDecl :: Declaration -> Bool
243244isFixityDecl FixityDeclaration {} = True
244- isFixityDecl (PositionedDeclaration _ d) = isFixityDecl d
245+ isFixityDecl (PositionedDeclaration _ _ d) = isFixityDecl d
245246isFixityDecl _ = False
246247
247248-- |
248249-- Test if a declaration is a foreign import
249250--
250251isExternDecl :: Declaration -> Bool
251252isExternDecl ExternDeclaration {} = True
252- isExternDecl (PositionedDeclaration _ d) = isExternDecl d
253+ isExternDecl (PositionedDeclaration _ _ d) = isExternDecl d
253254isExternDecl _ = False
254255
255256-- |
@@ -258,7 +259,7 @@ isExternDecl _ = False
258259isTypeClassDeclaration :: Declaration -> Bool
259260isTypeClassDeclaration TypeClassDeclaration {} = True
260261isTypeClassDeclaration TypeInstanceDeclaration {} = True
261- isTypeClassDeclaration (PositionedDeclaration _ d) = isTypeClassDeclaration d
262+ isTypeClassDeclaration (PositionedDeclaration _ _ d) = isTypeClassDeclaration d
262263isTypeClassDeclaration _ = False
263264
264265-- |
@@ -369,7 +370,7 @@ data Expr
369370 -- |
370371 -- A value with source position information
371372 --
372- | PositionedValue SourceSpan Expr deriving (Show , D.Data , D.Typeable )
373+ | PositionedValue SourceSpan [ Comment ] Expr deriving (Show , D.Data , D.Typeable )
373374
374375-- |
375376-- An alternative in a case statement
@@ -404,4 +405,4 @@ data DoNotationElement
404405 -- |
405406 -- A do notation element with source position information
406407 --
407- | PositionedDoNotationElement SourceSpan DoNotationElement deriving (Show , D.Data , D.Typeable )
408+ | PositionedDoNotationElement SourceSpan [ Comment ] DoNotationElement deriving (Show , D.Data , D.Typeable )
0 commit comments