Skip to content

Commit b151f01

Browse files
authored
Merge branch 'haskell:master' into pragmas
2 parents 6452fe9 + d815d04 commit b151f01

28 files changed

+1411
-66
lines changed

.github/workflows/test.yml

+4
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,7 @@ jobs:
200200
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
201201
name: Test hls-refine-imports-plugin test suite
202202
run: cabal test hls-refine-imports-plugin --test-options="-j1 --rerun-update" || cabal test hls-refine-imports-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-refine-imports-plugin --test-options="-j1 --rerun"
203+
204+
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test}}
205+
name: Test hls-call-hierarchy-plugin test suite
206+
run: cabal test hls-call-hierarchy-plugin --test-options="-j1 --rerun-update" || cabal test hls-call-hierarchy-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-call-hierarchy-plugin --test-options="-j1 --rerun"

cabal-ghc901.project

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ packages:
2222
./plugins/hls-pragmas-plugin
2323
./plugins/hls-module-name-plugin
2424
-- ./plugins/hls-ormolu-plugin
25+
./plugins/hls-call-hierarchy-plugin
2526
tests: true
2627

2728
package *

cabal.project

+18
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ packages:
2222
./plugins/hls-pragmas-plugin
2323
./plugins/hls-module-name-plugin
2424
./plugins/hls-ormolu-plugin
25+
./plugins/hls-call-hierarchy-plugin
2526
tests: true
2627

2728
package *
@@ -84,3 +85,20 @@ allow-newer:
8485
these:base,
8586
time-compat:base
8687

88+
source-repository-package
89+
type: git
90+
location: https://github.com/haskell/lsp.git
91+
tag: ef59c28b41ed4c5775f0ab0c1e985839359cec96
92+
subdir: lsp-types
93+
94+
source-repository-package
95+
type: git
96+
location: https://github.com/haskell/lsp.git
97+
tag: ef59c28b41ed4c5775f0ab0c1e985839359cec96
98+
subdir: lsp-test
99+
100+
source-repository-package
101+
type: git
102+
location: https://github.com/haskell/lsp.git
103+
tag: ef59c28b41ed4c5775f0ab0c1e985839359cec96
104+
subdir: lsp

exe/Plugins.hs

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import Ide.Plugin.Example2 as Example2
1313

1414
-- haskell-language-server optional plugins
1515

16+
#if callHierarchy
17+
import Ide.Plugin.CallHierarchy as CallHierarchy
18+
#endif
19+
1620
#if class
1721
import Ide.Plugin.Class as Class
1822
#endif
@@ -117,6 +121,9 @@ idePlugins includeExamples = pluginDescToIdePlugins allPlugins
117121
#if brittany
118122
Brittany.descriptor "brittany" :
119123
#endif
124+
#if callHierarchy
125+
CallHierarchy.descriptor "callHierarchy":
126+
#endif
120127
#if class
121128
Class.descriptor "class" :
122129
#endif

ghcide/src/Development/IDE/GHC/Compat.hs

+4-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ module Development.IDE.GHC.Compat(
114114
getNodeIds,
115115
stringToUnit,
116116
rtsUnit,
117+
unitString,
117118

118119
LogActionCompat,
119120
logActionCompat,
@@ -151,6 +152,7 @@ import GHC.Core.TyCo.Ppr (pprSigmaType)
151152
import GHC.Core.TyCo.Rep (Scaled, scaledThing)
152153
import GHC.Iface.Load
153154
import GHC.Types.Unique.Set (emptyUniqSet)
155+
import Module (unitString)
154156
import qualified SrcLoc
155157
#else
156158
import Module (InstalledUnitId,
@@ -578,8 +580,8 @@ getNodeIds = nodeIdentifiers . nodeInfo
578580
nodeInfo' :: Ord a => HieAST a -> NodeInfo a
579581
nodeInfo' = nodeInfo
580582
-- type Unit = UnitId
581-
-- unitString :: Unit -> String
582-
-- unitString = unitIdString
583+
unitString :: Unit -> String
584+
unitString = Module.unitIdString
583585
stringToUnit :: String -> Unit
584586
stringToUnit = Module.stringToUnitId
585587
-- moduleUnit :: Module -> Unit

haskell-language-server.cabal

+13
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ flag class
106106
default: True
107107
manual: True
108108

109+
flag callHierarchy
110+
description: Enable call hierarchy plugin
111+
default: True
112+
manual: True
113+
109114
flag haddockComments
110115
description: Enable haddockComments plugin
111116
default: True
@@ -193,6 +198,11 @@ common class
193198
build-depends: hls-class-plugin ^>= 1.0.0.1
194199
cpp-options: -Dclass
195200

201+
common callHierarchy
202+
if flag(callHierarchy) || flag(all-plugins)
203+
build-depends: hls-call-hierarchy-plugin ^>= 1.0.0.0
204+
cpp-options: -DcallHierarchy
205+
196206
common haddockComments
197207
if flag(haddockComments) || flag(all-plugins)
198208
build-depends: hls-haddock-comments-plugin ^>= 1.0.0.1
@@ -274,6 +284,7 @@ executable haskell-language-server
274284
import: common-deps
275285
-- plugins
276286
, example-plugins
287+
, callHierarchy
277288
, class
278289
, haddockComments
279290
, eval
@@ -426,6 +437,8 @@ test-suite func-test
426437
if flag(pedantic)
427438
ghc-options: -Werror -Wredundant-constraints
428439

440+
if flag(callHierarchy) || flag(all-plugins)
441+
cpp-options: -DcallHierarchy
429442
if flag(class) || flag(all-plugins)
430443
cpp-options: -Dclass
431444
if flag(haddockComments) || flag(all-plugins)

hls-plugin-api/src/Ide/Plugin/Config.hs

+41-37
Original file line numberDiff line numberDiff line change
@@ -121,54 +121,58 @@ instance A.ToJSON Config where
121121
-- This provides a regular naming scheme for all plugin config.
122122
data PluginConfig =
123123
PluginConfig
124-
{ plcGlobalOn :: !Bool
125-
, plcCodeActionsOn :: !Bool
126-
, plcCodeLensOn :: !Bool
127-
, plcDiagnosticsOn :: !Bool
128-
, plcHoverOn :: !Bool
129-
, plcSymbolsOn :: !Bool
130-
, plcCompletionOn :: !Bool
131-
, plcRenameOn :: !Bool
132-
, plcConfig :: !A.Object
124+
{ plcGlobalOn :: !Bool
125+
, plcCallHierarchyOn :: !Bool
126+
, plcCodeActionsOn :: !Bool
127+
, plcCodeLensOn :: !Bool
128+
, plcDiagnosticsOn :: !Bool
129+
, plcHoverOn :: !Bool
130+
, plcSymbolsOn :: !Bool
131+
, plcCompletionOn :: !Bool
132+
, plcRenameOn :: !Bool
133+
, plcConfig :: !A.Object
133134
} deriving (Show,Eq)
134135

135136
instance Default PluginConfig where
136137
def = PluginConfig
137-
{ plcGlobalOn = True
138-
, plcCodeActionsOn = True
139-
, plcCodeLensOn = True
140-
, plcDiagnosticsOn = True
141-
, plcHoverOn = True
142-
, plcSymbolsOn = True
143-
, plcCompletionOn = True
144-
, plcRenameOn = True
145-
, plcConfig = mempty
138+
{ plcGlobalOn = True
139+
, plcCallHierarchyOn = True
140+
, plcCodeActionsOn = True
141+
, plcCodeLensOn = True
142+
, plcDiagnosticsOn = True
143+
, plcHoverOn = True
144+
, plcSymbolsOn = True
145+
, plcCompletionOn = True
146+
, plcRenameOn = True
147+
, plcConfig = mempty
146148
}
147149

148150
instance A.ToJSON PluginConfig where
149-
toJSON (PluginConfig g ca cl d h s c rn cfg) = r
151+
toJSON (PluginConfig g ch ca cl d h s c rn cfg) = r
150152
where
151-
r = object [ "globalOn" .= g
152-
, "codeActionsOn" .= ca
153-
, "codeLensOn" .= cl
154-
, "diagnosticsOn" .= d
155-
, "hoverOn" .= h
156-
, "symbolsOn" .= s
157-
, "completionOn" .= c
158-
, "renameOn" .= rn
159-
, "config" .= cfg
153+
r = object [ "globalOn" .= g
154+
, "callHierarchyOn" .= ch
155+
, "codeActionsOn" .= ca
156+
, "codeLensOn" .= cl
157+
, "diagnosticsOn" .= d
158+
, "hoverOn" .= h
159+
, "symbolsOn" .= s
160+
, "completionOn" .= c
161+
, "renameOn" .= rn
162+
, "config" .= cfg
160163
]
161164

162165
instance A.FromJSON PluginConfig where
163166
parseJSON = A.withObject "PluginConfig" $ \o -> PluginConfig
164-
<$> o .:? "globalOn" .!= plcGlobalOn def
165-
<*> o .:? "codeActionsOn" .!= plcCodeActionsOn def
166-
<*> o .:? "codeLensOn" .!= plcCodeLensOn def
167-
<*> o .:? "diagnosticsOn" .!= plcDiagnosticsOn def -- AZ
168-
<*> o .:? "hoverOn" .!= plcHoverOn def
169-
<*> o .:? "symbolsOn" .!= plcSymbolsOn def
170-
<*> o .:? "completionOn" .!= plcCompletionOn def
171-
<*> o .:? "renameOn" .!= plcRenameOn def
172-
<*> o .:? "config" .!= plcConfig def
167+
<$> o .:? "globalOn" .!= plcGlobalOn def
168+
<*> o .:? "callHierarchyOn" .!= plcCallHierarchyOn def
169+
<*> o .:? "codeActionsOn" .!= plcCodeActionsOn def
170+
<*> o .:? "codeLensOn" .!= plcCodeLensOn def
171+
<*> o .:? "diagnosticsOn" .!= plcDiagnosticsOn def -- AZ
172+
<*> o .:? "hoverOn" .!= plcHoverOn def
173+
<*> o .:? "symbolsOn" .!= plcSymbolsOn def
174+
<*> o .:? "completionOn" .!= plcCompletionOn def
175+
<*> o .:? "renameOn" .!= plcRenameOn def
176+
<*> o .:? "config" .!= plcConfig def
173177

174178
-- ---------------------------------------------------------------------

hls-plugin-api/src/Ide/Types.hs

+11
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ instance PluginMethod TextDocumentRangeFormatting where
255255
pluginEnabled _ pid conf = (PluginId $ formattingProvider conf) == pid
256256
combineResponses _ _ _ _ (x :| _) = x
257257

258+
instance PluginMethod TextDocumentPrepareCallHierarchy where
259+
pluginEnabled _ = pluginEnabledConfig plcCallHierarchyOn
260+
261+
instance PluginMethod CallHierarchyIncomingCalls where
262+
pluginEnabled _ = pluginEnabledConfig plcCallHierarchyOn
263+
264+
instance PluginMethod CallHierarchyOutgoingCalls where
265+
pluginEnabled _ = pluginEnabledConfig plcCallHierarchyOn
266+
258267
-- ---------------------------------------------------------------------
259268

260269
-- | Methods which have a PluginMethod instance
@@ -452,6 +461,8 @@ instance HasTracing InitializeParams
452461
instance HasTracing (Maybe InitializedParams)
453462
instance HasTracing WorkspaceSymbolParams where
454463
traceWithSpan sp (WorkspaceSymbolParams _ _ query) = setTag sp "query" (encodeUtf8 query)
464+
instance HasTracing CallHierarchyIncomingCallsParams
465+
instance HasTracing CallHierarchyOutgoingCallsParams
455466

456467
-- ---------------------------------------------------------------------
457468

0 commit comments

Comments
 (0)