Skip to content

Commit 3d68956

Browse files
committed
add core actions
1 parent 5c7fa8b commit 3d68956

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

ghcide/src/Development/IDE/Core/Actions.hs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module Development.IDE.Core.Actions
44
, getDefinition
55
, getTypeDefinition
66
, highlightAtPoint
7-
, refsAtPoint
87
, workspaceSymbols
98
, lookupMod
109
) where
@@ -124,16 +123,4 @@ highlightAtPoint file pos = runMaybeT $ do
124123
let toCurrentHighlight (DocumentHighlight range t) = flip DocumentHighlight t <$> toCurrentRange mapping range
125124
mapMaybe toCurrentHighlight <$>AtPoint.documentHighlight hf rf pos'
126125

127-
-- Refs are not an IDE action, so it is OK to be slow and (more) accurate
128-
refsAtPoint :: NormalizedFilePath -> Position -> Action [Location]
129-
refsAtPoint file pos = do
130-
ShakeExtras{withHieDb} <- getShakeExtras
131-
fs <- HM.keys <$> getFilesOfInterestUntracked
132-
asts <- HM.fromList . mapMaybe sequence . zip fs <$> usesWithStale GetHieAst fs
133-
AtPoint.referencesAtPoint withHieDb file pos (AtPoint.FOIReferences asts)
134126

135-
workspaceSymbols :: T.Text -> IdeAction (Maybe [SymbolInformation])
136-
workspaceSymbols query = runMaybeT $ do
137-
ShakeExtras{withHieDb} <- ask
138-
res <- liftIO $ withHieDb (\hieDb -> HieDb.searchDef hieDb $ T.unpack query)
139-
pure $ mapMaybe AtPoint.defRowToSymbolInfo res

haskell-language-server.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,7 @@ library hls-core-plugin
16191619
buildable: True
16201620
exposed-modules:
16211621
Ide.Plugin.Core
1622+
Ide.Plugin.Core.Actions
16221623

16231624
hs-source-dirs: plugins/hls-core-plugin/src
16241625
build-depends:

plugins/hls-core-plugin/src/Ide/Plugin/Core.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import Data.Maybe (fromMaybe)
88
import Data.Text (Text)
99
import qualified Data.Text as T
1010
import Development.IDE
11-
import Development.IDE.Core.Actions (refsAtPoint, workspaceSymbols)
1211
import qualified Development.IDE.Core.Shake as Shake
12+
import Ide.Plugin.Core.Actions (refsAtPoint, workspaceSymbols)
1313
import Ide.Plugin.Error (getNormalizedFilePathE)
1414
import Ide.Types
1515
import Language.LSP.Protocol.Message
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module Ide.Plugin.Core.Actions where
2+
3+
import Control.Monad.Extra (mapMaybeM)
4+
import Control.Monad.Reader
5+
import Control.Monad.Trans.Maybe
6+
import Data.Maybe
7+
import qualified Data.Text as T
8+
import Data.Tuple.Extra
9+
import Development.IDE.Core.OfInterest
10+
import Development.IDE.Core.PluginUtils
11+
import Development.IDE.Core.PositionMapping
12+
import Development.IDE.Core.RuleTypes
13+
import Development.IDE.Core.Service
14+
import Development.IDE.Core.Shake
15+
import Development.IDE.GHC.Compat hiding (writeHieFile)
16+
import Development.IDE.Graph
17+
import qualified Development.IDE.Spans.AtPoint as AtPoint
18+
import Development.IDE.Types.HscEnvEq (hscEnv)
19+
import Development.IDE.Types.Location
20+
import Language.LSP.Protocol.Types (DocumentHighlight (..),
21+
SymbolInformation (..),
22+
normalizedFilePathToUri,
23+
uriToNormalizedFilePath)
24+
25+
26+
-- Refs are not an IDE action, so it is OK to be slow and (more) accurate
27+
refsAtPoint :: NormalizedFilePath -> Position -> Action [Location]
28+
refsAtPoint file pos = do
29+
ShakeExtras{withHieDb} <- getShakeExtras
30+
fs <- HM.keys <$> getFilesOfInterestUntracked
31+
asts <- HM.fromList . mapMaybe sequence . zip fs <$> usesWithStale GetHieAst fs
32+
AtPoint.referencesAtPoint withHieDb file pos (AtPoint.FOIReferences asts)
33+
34+
35+
workspaceSymbols :: T.Text -> IdeAction (Maybe [SymbolInformation])
36+
workspaceSymbols query = runMaybeT $ do
37+
ShakeExtras{withHieDb} <- ask
38+
res <- liftIO $ withHieDb (\hieDb -> HieDb.searchDef hieDb $ T.unpack query)
39+
pure $ mapMaybe AtPoint.defRowToSymbolInfo res

0 commit comments

Comments
 (0)