|
7 | 7 |
|
8 | 8 | -- | Go to the definition of a variable. |
9 | 9 | module Development.IDE.Plugin.CodeAction |
10 | | - ( |
11 | | - -- * For haskell-language-server |
12 | | - codeAction |
13 | | - , rulePackageExports |
| 10 | + ( descriptor |
14 | 11 |
|
15 | 12 | -- * For testing |
16 | 13 | , matchRegExMultipleImports |
@@ -55,16 +52,25 @@ import qualified Data.HashSet as Set |
55 | 52 | import Control.Concurrent.Extra (readVar) |
56 | 53 | import Development.IDE.GHC.Util (printRdrName) |
57 | 54 | import Ide.PluginUtils (subRange) |
| 55 | +import Ide.Types |
| 56 | + |
| 57 | +descriptor :: PluginId -> PluginDescriptor IdeState |
| 58 | +descriptor plId = |
| 59 | + (defaultPluginDescriptor plId) |
| 60 | + { pluginRules = rulePackageExports, |
| 61 | + pluginCodeActionProvider = Just codeAction |
| 62 | + } |
58 | 63 |
|
59 | 64 | -- | Generate code actions. |
60 | 65 | codeAction |
61 | 66 | :: LSP.LspFuncs c |
62 | 67 | -> IdeState |
| 68 | + -> PluginId |
63 | 69 | -> TextDocumentIdentifier |
64 | 70 | -> Range |
65 | 71 | -> CodeActionContext |
66 | | - -> IO (Either ResponseError [CAResult]) |
67 | | -codeAction lsp state (TextDocumentIdentifier uri) _range CodeActionContext{_diagnostics=List xs} = do |
| 72 | + -> IO (Either ResponseError (List CAResult)) |
| 73 | +codeAction lsp state _ (TextDocumentIdentifier uri) _range CodeActionContext{_diagnostics=List xs} = do |
68 | 74 | contents <- LSP.getVirtualFileFunc lsp $ toNormalizedUri uri |
69 | 75 | let text = Rope.toText . (_text :: VirtualFile -> Rope.Rope) <$> contents |
70 | 76 | mbFile = toNormalizedFilePath' <$> uriToFilePath uri |
@@ -98,7 +104,7 @@ codeAction lsp state (TextDocumentIdentifier uri) _range CodeActionContext{_diag |
98 | 104 | <> actions |
99 | 105 | <> actions' |
100 | 106 | <> caRemoveInvalidExports parsedModule text diag xs uri |
101 | | - pure $ Right actions'' |
| 107 | + pure $ Right $ List actions'' |
102 | 108 |
|
103 | 109 | mkCA :: T.Text -> [Diagnostic] -> WorkspaceEdit -> CAResult |
104 | 110 | mkCA title diags edit = |
|
0 commit comments