@@ -16,7 +16,7 @@ span0 = P.SourceSpan "ModuleLevel" (P.SourcePos 0 0) (P.SourcePos 1 1)
1616span1 = P.SourceSpan "" (P.SourcePos 1 1) (P.SourcePos 2 2)
1717span2 = P.SourceSpan "" (P.SourcePos 2 2) (P.SourcePos 3 3)
1818
19−typeAnnotation1, value1, synonym1, class1, class2, data1, data2, foreign1, foreign2, foreign3, member1 :: P.Declaration
19+typeAnnotation1, value1, synonym1, class1, class2, data1, data2, valueFixity, typeFixity, foreign1, foreign2, foreign3, member1 :: P.Declaration
2020typeAnnotation1 = P.TypeDeclaration (P.Ident "value1") P.REmpty
2121value1 = P.ValueDeclaration (P.Ident "value1") P.Public [] (Left [])
2222synonym1 = P.TypeSynonymDeclaration (P.ProperName "Synonym1") [] P.REmpty
@@ -25,6 +25,16 @@ class2 = P.TypeClassDeclaration (P.ProperName "Class2") [] [] []
2525 [P.PositionedDeclaration span2 [] member1]
2626data1 = P.DataDeclaration P.Newtype (P.ProperName "Data1") [] []
2727data2 = P.DataDeclaration P.Data (P.ProperName "Data2") [] [(P.ProperName "Cons1", [])]
28+valueFixity =
29+ P.ValueFixityDeclaration
30+ (P.Fixity P.Infix 0)
31+ (P.Qualified Nothing (Left (P.Ident "")))
32+ (P.OpName "<$>")
33+typeFixity =
34+ P.TypeFixityDeclaration
35+ (P.Fixity P.Infix 0)
36+ (P.Qualified Nothing (P.ProperName ""))
37+ (P.OpName "~>")
2838foreign1 = P.ExternDeclaration (P.Ident "foreign1") P.REmpty
2939foreign2 = P.ExternDataDeclaration (P.ProperName "Foreign2") P.kindType
3040foreign3 = P.ExternKindDeclaration (P.ProperName "Foreign3")
@@ -45,6 +55,10 @@ spec = do
4555 extractSpans span0 (P.PositionedDeclaration span1 [] data1) `shouldBe` [(IdeNSType "Data1", span1)]
4656 it "extracts spans for a data declaration and its constructors" $
4757 extractSpans span0 (P.PositionedDeclaration span1 [] data2) `shouldBe` [(IdeNSType "Data2", span1), (IdeNSValue "Cons1", span1)]
58+ it "extracts a span for a value operator fixity declaration" $
59+ extractSpans span0 (P.PositionedDeclaration span1 [] valueFixity) `shouldBe` [(IdeNSValue "<$>", span1)]
60+ it "extracts a span for a type operator fixity declaration" $
61+ extractSpans span0 (P.PositionedDeclaration span1 [] typeFixity) `shouldBe` [(IdeNSType "~>", span1)]
4862 it "extracts a span for a foreign declaration" $
4963 extractSpans span0 (P.PositionedDeclaration span1 [] foreign1) `shouldBe` [(IdeNSValue "foreign1", span1)]
5064 it "extracts a span for a data foreign declaration" $
@@ -67,6 +81,12 @@ spec = do
6781 it "finds a class declaration" $ do
6882 Just r <- getLocation "SFClass"
6983 r `shouldBe` classSS
84+ it "finds a value operator declaration" $ do
85+ Just r <- getLocation "<$>"
86+ r `shouldBe` valueOpSS
87+ it "finds a type operator declaration" $ do
88+ Just r <- getLocation "~>"
89+ r `shouldBe` typeOpSS
7090
7191getLocation :: Text -> IO (Maybe P.SourceSpan)
7292getLocation s = do
@@ -83,14 +103,20 @@ getLocation s = do
83103 , ideDtor "SFTwo" "SFData" Nothing `annLoc` typeSS
84104 , ideDtor "SFThree" "SFData" Nothing `annLoc` typeSS
85105 , ideTypeClass "SFClass" [] `annLoc` classSS
106+ , ideValueOp "<$>" (P.Qualified Nothing (Left "")) 0 Nothing Nothing
107+ `annLoc` valueOpSS
108+ , ideTypeOp "~>" (P.Qualified Nothing "") 0 Nothing Nothing
109+ `annLoc` typeOpSS
86110 ])
87111 ]
88112
89−valueSS, synonymSS, typeSS, classSS :: P.SourceSpan
113+valueSS, synonymSS, typeSS, classSS, valueOpSS, typeOpSS :: P.SourceSpan
90114valueSS = ss 3 1
91115synonymSS = ss 5 1
92116typeSS = ss 7 1
93117classSS = ss 8 1
118+valueOpSS = ss 12 1
119+typeOpSS = ss 13 1
94120
95121ss :: Int -> Int -> P.SourceSpan
96122ss x y = P.SourceSpan "Test.purs" (P.SourcePos x y) (P.SourcePos x y)