@@ -25,8 +25,6 @@ import Data.Map.Lazy as M
25import qualified Language.PureScript.Errors.JSON as P
25import qualified Language.PureScript.Errors.JSON as P
26import qualified Language.PureScript as P
26import qualified Language.PureScript as P
27import Language.PureScript.Ide.Conversions
27import Language.PureScript.Ide.Conversions
28−import Text.Parsec as Parsec
29−import Text.Parsec.Text
31type ModuleIdent = Text
29type ModuleIdent = Text
@@ -209,9 +207,9 @@ data PursuitResponse =
209 -- | A Pursuit Response for a module. Consists of the modules name and the
207 -- | A Pursuit Response for a module. Consists of the modules name and the
210 -- package it belongs to
208 -- package it belongs to
211 ModuleResponse ModuleIdent Text
209 ModuleResponse ModuleIdent Text
212− -- | A Pursuit Response for a declaration. Consist of the declarations type,
210+ -- | A Pursuit Response for a declaration. Consist of the declaration's
213− -- module, name and package
211+ -- module, name, package, type summary text
214− | DeclarationResponse Text ModuleIdent Text Text
212+ | DeclarationResponse Text ModuleIdent Text (Maybe Text) Text
215 deriving (Show,Eq)
213 deriving (Show,Eq)
217instance FromJSON PursuitResponse where
215instance FromJSON PursuitResponse where
@@ -225,42 +223,21 @@ instance FromJSON PursuitResponse where
225 pure (ModuleResponse name package)
223 pure (ModuleResponse name package)
226 "declaration" -> do
224 "declaration" -> do
227 moduleName <- info .: "module"
225 moduleName <- info .: "module"
228− Right (ident, declType) <- typeParse <$> o .: "text"
226+ ident <- info .: "title"
227+ (text :: Text) <- o .: "text"
228+ typ <- info .:? "typeText"
229− pure (DeclarationResponse declType moduleName ident package)
229+ pure (DeclarationResponse moduleName ident package typ text)
230 _ -> mzero
230 _ -> mzero
231 parseJSON _ = mzero
231 parseJSON _ = mzero
234−typeParse :: Text -> Either Text (Text, Text)
235−typeParse t = case parse parseType "" t of
236− Right (x,y) -> Right (x, y)
237− Left err -> Left (show err)
239− parseType :: Parser (Text, Text)
244− type' <- many1 anyChar
245− pure (name, toS type')
247− identifier :: Parser Text
251− -- necessary for being able to parse the following ((++), concat)
252− between (char '(') (char ')') (many1 (noneOf ", )")) Parsec.<|>
253− many1 (noneOf ", )")
257instance ToJSON PursuitResponse where
233instance ToJSON PursuitResponse where
258 toJSON (ModuleResponse name package) =
234 toJSON (ModuleResponse name package) =
259 object ["module" .= name, "package" .= package]
235 object ["module" .= name, "package" .= package]
260− toJSON (DeclarationResponse module' ident type' package) =
236+ toJSON (DeclarationResponse module' ident package type' text) =
262 [ "module" .= module'
238 [ "module" .= module'
263 , "ident" .= ident
239 , "ident" .= ident
264 , "type" .= type'
240 , "type" .= type'
265 , "package" .= package
241 , "package" .= package