Skip to content

Commit d49a000

Browse files
committed
working test message cabal file
1 parent efe8913 commit d49a000

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

ghcide/src/Development/IDE/LSP/Outline.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Language.LSP.Protocol.Types (DocumentSymbol (..),
2626
DocumentSymbolParams (DocumentSymbolParams, _textDocument),
2727
SymbolKind (..),
2828
TextDocumentIdentifier (TextDocumentIdentifier),
29-
type (|?) (InL, InR), uriToFilePath)
29+
type (|?) (InL, InR), uriToFilePath, mkRange, SymbolInformation (_deprecated))
3030
import Language.LSP.Protocol.Message
3131

3232
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]

haskell-language-server.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ library hls-cabal-plugin
242242
Ide.Plugin.Cabal.Completion.Types
243243
Ide.Plugin.Cabal.LicenseSuggest
244244
Ide.Plugin.Cabal.Orphans
245+
Ide.Plugin.Cabal.Outline
245246
Ide.Plugin.Cabal.Parse
246247

247248

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import qualified Ide.Plugin.Cabal.Diagnostics as Diagnostics
3939
import qualified Ide.Plugin.Cabal.LicenseSuggest as LicenseSuggest
4040
import Ide.Plugin.Cabal.Orphans ()
4141
import qualified Ide.Plugin.Cabal.Parse as Parse
42+
import Ide.Plugin.Cabal.Outline
4243
import Ide.Types
4344
import qualified Language.LSP.Protocol.Lens as JL
4445
import qualified Language.LSP.Protocol.Message as LSP
@@ -88,6 +89,7 @@ descriptor recorder plId =
8889
mconcat
8990
[ mkPluginHandler LSP.SMethod_TextDocumentCodeAction licenseSuggestCodeAction
9091
, mkPluginHandler LSP.SMethod_TextDocumentCompletion $ completion recorder
92+
, mkPluginHandler LSP.SMethod_TextDocumentDocumentSymbol moduleOutline
9193
]
9294
, pluginNotificationHandlers =
9395
mconcat
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{-# LANGUAGE CPP #-}
2+
3+
{-# LANGUAGE DuplicateRecordFields #-}
4+
{-# LANGUAGE GADTs #-}
5+
6+
{-# LANGUAGE DataKinds #-}
7+
{-# LANGUAGE ViewPatterns #-}
8+
{-# LANGUAGE OverloadedStrings #-}
9+
10+
11+
module Ide.Plugin.Cabal.Outline
12+
( moduleOutline
13+
)
14+
where
15+
16+
import Control.Monad.IO.Class
17+
import Data.Foldable (toList)
18+
import Data.Functor
19+
import Data.List.NonEmpty (nonEmpty)
20+
import Data.Maybe
21+
import Development.IDE.Core.Rules
22+
import Development.IDE.Core.Shake
23+
import Development.IDE.GHC.Compat
24+
import Development.IDE.GHC.Error (rangeToRealSrcSpan,
25+
realSrcSpanToRange)
26+
import Development.IDE.Types.Location
27+
import Development.IDE.GHC.Util (printOutputable)
28+
import Ide.Types
29+
import Language.LSP.Protocol.Types (DocumentSymbol (..),
30+
DocumentSymbolParams (DocumentSymbolParams, _textDocument),
31+
SymbolKind (..),
32+
TextDocumentIdentifier (TextDocumentIdentifier),
33+
type (|?) (InL, InR), uriToFilePath, mkRange, SymbolInformation (_deprecated))
34+
import Language.LSP.Protocol.Message
35+
( Method(Method_TextDocumentDocumentSymbol) )
36+
37+
import qualified Data.Text as T
38+
39+
moduleOutline :: PluginMethodHandler IdeState Method_TextDocumentDocumentSymbol
40+
moduleOutline ideState _ DocumentSymbolParams{ _textDocument = TextDocumentIdentifier uri }
41+
= liftIO $ case uriToFilePath uri of
42+
Just (toNormalizedFilePath' -> fp) -> pure $ InR (InL [DocumentSymbol {_name="hello!"
43+
,_detail=Nothing
44+
,_kind=SymbolKind_Module
45+
,_tags=Nothing
46+
,_range=mkRange 1 0 1 11
47+
,_deprecated=Nothing
48+
,_selectionRange=mkRange 1 0 1 11
49+
,_children=Nothing}])
50+
Nothing -> pure $ InL []

0 commit comments

Comments
 (0)