Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call hierarchy support #1955

Merged
merged 33 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
67ce370
Initialize structure
July541 Jun 3, 2021
4b9a6e7
Add basic tests
July541 Jun 3, 2021
f8cfe98
prepareCallHierarchy
July541 Jun 9, 2021
118acd7
Add prepare call hierarchy tests
July541 Jun 12, 2021
38b5b47
resolve conflicts
July541 Jun 21, 2021
7a8979d
Prepare call hierarchy support
July541 Jun 21, 2021
0058639
Merge branch 'master' of https://github.com/haskell/haskell-language-…
July541 Jul 6, 2021
3c809f0
add outgoing calls
July541 Jul 6, 2021
2b84f2d
Rename incoming to outgoing
July541 Jul 7, 2021
7a41397
Add incoming calls support
July541 Jul 11, 2021
0018dd0
Fix panic error caused by parameters
July541 Jul 12, 2021
04679f1
Prepare callhierarchy tests
July541 Jul 13, 2021
59e2432
Duplication items support
July541 Jul 15, 2021
ad133b7
Format and add missing components for review
July541 Jul 15, 2021
db5bb4d
Use local lsp
July541 Jul 15, 2021
ec420ad
Add CI test
July541 Jul 15, 2021
eec1c98
Fix typo
July541 Jul 15, 2021
047174f
Add flag for 9.0.1
July541 Jul 15, 2021
25927ef
Change lsp repo
July541 Jul 16, 2021
a529246
Fix query error in data declaration
July541 Jul 21, 2021
dcf8aab
Add incoming/outgoing call tests
July541 Jul 21, 2021
68bc9e9
Merge branch 'master' of https://github.com/haskell/haskell-language-…
July541 Jul 21, 2021
649a70f
Add flag for test ghc 9.0.1
July541 Jul 21, 2021
6ca0629
Ignore test on 9.0.1
July541 Jul 21, 2021
b6ead8f
Add 9.0.1 test
July541 Jul 22, 2021
fd11a10
Specifying lsp for cabal
July541 Jul 22, 2021
61d9df9
Merge branch 'master' of https://github.com/haskell/haskell-language-…
July541 Jul 26, 2021
c2bd211
Refresh hiedb before incoming/outgoing calls
July541 Jul 26, 2021
a7fee5f
Add moduleUnit on ghc 9.0.1
July541 Jul 26, 2021
09a8898
Compatible with ghc 9.0.1
July541 Jul 27, 2021
0405d2f
Add missing qualifier
July541 Jul 27, 2021
492c48f
Remove ghcide capability test
July541 Jul 27, 2021
cbbd56e
Merge branch 'master' into call-hierarchy
July541 Jul 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,7 @@ jobs:
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
name: Test hls-refine-imports-plugin test suite
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"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc }}
July541 marked this conversation as resolved.
Show resolved Hide resolved
name: Test hls-call-hierarchy-plugin test suite
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"
1 change: 1 addition & 0 deletions cabal-ghc901.project
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ packages:
./plugins/hls-pragmas-plugin
./plugins/hls-module-name-plugin
-- ./plugins/hls-ormolu-plugin
./plugins/hls-call-hierarchy-plugin
tests: true

package *
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ packages:
./plugins/hls-pragmas-plugin
./plugins/hls-module-name-plugin
./plugins/hls-ormolu-plugin
./plugins/hls-call-hierarchy-plugin
tests: true

package *
Expand Down Expand Up @@ -83,4 +84,3 @@ allow-newer:
svg-builder:base,
these:base,
time-compat:base

7 changes: 7 additions & 0 deletions exe/Plugins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import Ide.Plugin.Example2 as Example2

-- haskell-language-server optional plugins

#if callHierarchy
import Ide.Plugin.CallHierarchy as CallHierarchy
#endif

#if class
import Ide.Plugin.Class as Class
#endif
Expand Down Expand Up @@ -117,6 +121,9 @@ idePlugins includeExamples = pluginDescToIdePlugins allPlugins
#if brittany
Brittany.descriptor "brittany" :
#endif
#if callHierarchy
CallHierarchy.descriptor "callHierarchy":
#endif
#if class
Class.descriptor "class" :
#endif
Expand Down
1 change: 1 addition & 0 deletions ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ initializeResponseTests = withResource acquire release tests where
, chk "NO folding range" _foldingRangeProvider (Just $ InL False)
, che " execute command" _executeCommandProvider [extendImportCommandId, typeLensCommandId, blockCommandId]
, chk " workspace" _workspace (Just $ WorkspaceServerCapabilities (Just WorkspaceFoldersServerCapabilities{_supported = Just True, _changeNotifications = Just ( InR True )}))
, chk " call hierarchy" _callHierarchyProvider (Just $ InL True)
, chk "NO experimental" _experimental Nothing
] where

Expand Down
13 changes: 13 additions & 0 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ flag class
default: True
manual: True

flag callHierarchy
description: Enable call hierarchy plugin
default: True
manual: True

flag haddockComments
description: Enable haddockComments plugin
default: True
Expand Down Expand Up @@ -193,6 +198,11 @@ common class
build-depends: hls-class-plugin ^>= 1.0.0.1
cpp-options: -Dclass

common callHierarchy
if flag(callHierarchy) || flag(all-plugins)
build-depends: hls-call-hierarchy-plugin ^>= 1.0.0.0
cpp-options: -DcallHierarchy

common haddockComments
if flag(haddockComments) || flag(all-plugins)
build-depends: hls-haddock-comments-plugin ^>= 1.0.0.1
Expand Down Expand Up @@ -274,6 +284,7 @@ executable haskell-language-server
import: common-deps
-- plugins
, example-plugins
, callHierarchy
, class
, haddockComments
, eval
Expand Down Expand Up @@ -426,6 +437,8 @@ test-suite func-test
if flag(pedantic)
ghc-options: -Werror -Wredundant-constraints

if flag(callHierarchy) || flag(all-plugins)
cpp-options: -DcallHierarchy
if flag(class) || flag(all-plugins)
cpp-options: -Dclass
if flag(haddockComments) || flag(all-plugins)
Expand Down
78 changes: 41 additions & 37 deletions hls-plugin-api/src/Ide/Plugin/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,54 +121,58 @@ instance A.ToJSON Config where
-- This provides a regular naming scheme for all plugin config.
data PluginConfig =
PluginConfig
{ plcGlobalOn :: !Bool
, plcCodeActionsOn :: !Bool
, plcCodeLensOn :: !Bool
, plcDiagnosticsOn :: !Bool
, plcHoverOn :: !Bool
, plcSymbolsOn :: !Bool
, plcCompletionOn :: !Bool
, plcRenameOn :: !Bool
, plcConfig :: !A.Object
{ plcGlobalOn :: !Bool
, plcCallHierarchyOn :: !Bool
, plcCodeActionsOn :: !Bool
, plcCodeLensOn :: !Bool
, plcDiagnosticsOn :: !Bool
, plcHoverOn :: !Bool
, plcSymbolsOn :: !Bool
, plcCompletionOn :: !Bool
, plcRenameOn :: !Bool
, plcConfig :: !A.Object
} deriving (Show,Eq)

instance Default PluginConfig where
def = PluginConfig
{ plcGlobalOn = True
, plcCodeActionsOn = True
, plcCodeLensOn = True
, plcDiagnosticsOn = True
, plcHoverOn = True
, plcSymbolsOn = True
, plcCompletionOn = True
, plcRenameOn = True
, plcConfig = mempty
{ plcGlobalOn = True
, plcCallHierarchyOn = True
, plcCodeActionsOn = True
, plcCodeLensOn = True
, plcDiagnosticsOn = True
, plcHoverOn = True
, plcSymbolsOn = True
, plcCompletionOn = True
, plcRenameOn = True
, plcConfig = mempty
}

instance A.ToJSON PluginConfig where
toJSON (PluginConfig g ca cl d h s c rn cfg) = r
toJSON (PluginConfig g ch ca cl d h s c rn cfg) = r
where
r = object [ "globalOn" .= g
, "codeActionsOn" .= ca
, "codeLensOn" .= cl
, "diagnosticsOn" .= d
, "hoverOn" .= h
, "symbolsOn" .= s
, "completionOn" .= c
, "renameOn" .= rn
, "config" .= cfg
r = object [ "globalOn" .= g
, "callHierarchyOn" .= ch
, "codeActionsOn" .= ca
, "codeLensOn" .= cl
, "diagnosticsOn" .= d
, "hoverOn" .= h
, "symbolsOn" .= s
, "completionOn" .= c
, "renameOn" .= rn
, "config" .= cfg
]

instance A.FromJSON PluginConfig where
parseJSON = A.withObject "PluginConfig" $ \o -> PluginConfig
<$> o .:? "globalOn" .!= plcGlobalOn def
<*> o .:? "codeActionsOn" .!= plcCodeActionsOn def
<*> o .:? "codeLensOn" .!= plcCodeLensOn def
<*> o .:? "diagnosticsOn" .!= plcDiagnosticsOn def -- AZ
<*> o .:? "hoverOn" .!= plcHoverOn def
<*> o .:? "symbolsOn" .!= plcSymbolsOn def
<*> o .:? "completionOn" .!= plcCompletionOn def
<*> o .:? "renameOn" .!= plcRenameOn def
<*> o .:? "config" .!= plcConfig def
<$> o .:? "globalOn" .!= plcGlobalOn def
<*> o .:? "callHierarchyOn" .!= plcCallHierarchyOn def
<*> o .:? "codeActionsOn" .!= plcCodeActionsOn def
<*> o .:? "codeLensOn" .!= plcCodeLensOn def
<*> o .:? "diagnosticsOn" .!= plcDiagnosticsOn def -- AZ
<*> o .:? "hoverOn" .!= plcHoverOn def
<*> o .:? "symbolsOn" .!= plcSymbolsOn def
<*> o .:? "completionOn" .!= plcCompletionOn def
<*> o .:? "renameOn" .!= plcRenameOn def
<*> o .:? "config" .!= plcConfig def

-- ---------------------------------------------------------------------
11 changes: 11 additions & 0 deletions hls-plugin-api/src/Ide/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@ instance PluginMethod TextDocumentRangeFormatting where
pluginEnabled _ pid conf = (PluginId $ formattingProvider conf) == pid
combineResponses _ _ _ _ (x :| _) = x

instance PluginMethod TextDocumentPrepareCallHierarchy where
pluginEnabled _ = pluginEnabledConfig plcCallHierarchyOn

instance PluginMethod CallHierarchyIncomingCalls where
pluginEnabled _ = pluginEnabledConfig plcCallHierarchyOn

instance PluginMethod CallHierarchyOutgoingCalls where
pluginEnabled _ = pluginEnabledConfig plcCallHierarchyOn

-- ---------------------------------------------------------------------

-- | Methods which have a PluginMethod instance
Expand Down Expand Up @@ -452,6 +461,8 @@ instance HasTracing InitializeParams
instance HasTracing (Maybe InitializedParams)
instance HasTracing WorkspaceSymbolParams where
traceWithSpan sp (WorkspaceSymbolParams _ _ query) = setTag sp "query" (encodeUtf8 query)
instance HasTracing CallHierarchyIncomingCallsParams
instance HasTracing CallHierarchyOutgoingCallsParams

-- ---------------------------------------------------------------------

Expand Down