@@ -16,7 +16,7 @@ span0 = P.SourceSpan "ModuleLevel" (P.SourcePos 0 0) (P.SourcePos 1 1)
16span1 = P.SourceSpan "" (P.SourcePos 1 1) (P.SourcePos 2 2)
16span1 = P.SourceSpan "" (P.SourcePos 1 1) (P.SourcePos 2 2)
17span2 = P.SourceSpan "" (P.SourcePos 2 2) (P.SourcePos 3 3)
17span2 = P.SourceSpan "" (P.SourcePos 2 2) (P.SourcePos 3 3)
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
20typeAnnotation1 = P.TypeDeclaration (P.Ident "value1") P.REmpty
20typeAnnotation1 = P.TypeDeclaration (P.Ident "value1") P.REmpty
21value1 = P.ValueDeclaration (P.Ident "value1") P.Public [] (Left [])
21value1 = P.ValueDeclaration (P.Ident "value1") P.Public [] (Left [])
22synonym1 = P.TypeSynonymDeclaration (P.ProperName "Synonym1") [] P.REmpty
22synonym1 = P.TypeSynonymDeclaration (P.ProperName "Synonym1") [] P.REmpty
@@ -25,6 +25,16 @@ class2 = P.TypeClassDeclaration (P.ProperName "Class2") [] [] []
25 [P.PositionedDeclaration span2 [] member1]
25 [P.PositionedDeclaration span2 [] member1]
26data1 = P.DataDeclaration P.Newtype (P.ProperName "Data1") [] []
26data1 = P.DataDeclaration P.Newtype (P.ProperName "Data1") [] []
27data2 = P.DataDeclaration P.Data (P.ProperName "Data2") [] [(P.ProperName "Cons1", [])]
27data2 = P.DataDeclaration P.Data (P.ProperName "Data2") [] [(P.ProperName "Cons1", [])]
29+ P.ValueFixityDeclaration
31+ (P.Qualified Nothing (Left (P.Ident "")))
34+ P.TypeFixityDeclaration
36+ (P.Qualified Nothing (P.ProperName ""))
28foreign1 = P.ExternDeclaration (P.Ident "foreign1") P.REmpty
38foreign1 = P.ExternDeclaration (P.Ident "foreign1") P.REmpty
29foreign2 = P.ExternDataDeclaration (P.ProperName "Foreign2") P.kindType
39foreign2 = P.ExternDataDeclaration (P.ProperName "Foreign2") P.kindType
30foreign3 = P.ExternKindDeclaration (P.ProperName "Foreign3")
40foreign3 = P.ExternKindDeclaration (P.ProperName "Foreign3")
@@ -45,6 +55,10 @@ spec = do
45 extractSpans span0 (P.PositionedDeclaration span1 [] data1) `shouldBe` [(IdeNSType "Data1", span1)]
55 extractSpans span0 (P.PositionedDeclaration span1 [] data1) `shouldBe` [(IdeNSType "Data1", span1)]
46 it "extracts spans for a data declaration and its constructors" $
56 it "extracts spans for a data declaration and its constructors" $
47 extractSpans span0 (P.PositionedDeclaration span1 [] data2) `shouldBe` [(IdeNSType "Data2", span1), (IdeNSValue "Cons1", span1)]
57 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)]
48 it "extracts a span for a foreign declaration" $
62 it "extracts a span for a foreign declaration" $
49 extractSpans span0 (P.PositionedDeclaration span1 [] foreign1) `shouldBe` [(IdeNSValue "foreign1", span1)]
63 extractSpans span0 (P.PositionedDeclaration span1 [] foreign1) `shouldBe` [(IdeNSValue "foreign1", span1)]
50 it "extracts a span for a data foreign declaration" $
64 it "extracts a span for a data foreign declaration" $
@@ -67,6 +81,12 @@ spec = do
67 it "finds a class declaration" $ do
81 it "finds a class declaration" $ do
68 Just r <- getLocation "SFClass"
82 Just r <- getLocation "SFClass"
69 r `shouldBe` classSS
83 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
71getLocation :: Text -> IO (Maybe P.SourceSpan)
91getLocation :: Text -> IO (Maybe P.SourceSpan)
72getLocation s = do
92getLocation s = do
@@ -83,14 +103,20 @@ getLocation s = do
83 , ideDtor "SFTwo" "SFData" Nothing `annLoc` typeSS
103 , ideDtor "SFTwo" "SFData" Nothing `annLoc` typeSS
84 , ideDtor "SFThree" "SFData" Nothing `annLoc` typeSS
104 , ideDtor "SFThree" "SFData" Nothing `annLoc` typeSS
85 , ideTypeClass "SFClass" [] `annLoc` classSS
105 , ideTypeClass "SFClass" [] `annLoc` classSS
106+ , ideValueOp "<$>" (P.Qualified Nothing (Left "")) 0 Nothing Nothing
108+ , ideTypeOp "~>" (P.Qualified Nothing "") 0 Nothing Nothing
89−valueSS, synonymSS, typeSS, classSS :: P.SourceSpan
113+valueSS, synonymSS, typeSS, classSS, valueOpSS, typeOpSS :: P.SourceSpan
90valueSS = ss 3 1
114valueSS = ss 3 1
91synonymSS = ss 5 1
115synonymSS = ss 5 1
92typeSS = ss 7 1
116typeSS = ss 7 1
93classSS = ss 8 1
117classSS = ss 8 1
95ss :: Int -> Int -> P.SourceSpan
121ss :: Int -> Int -> P.SourceSpan
96ss x y = P.SourceSpan "Test.purs" (P.SourcePos x y) (P.SourcePos x y)
122ss x y = P.SourceSpan "Test.purs" (P.SourcePos x y) (P.SourcePos x y)