Skip to content

hls-notes-plugin: Initial implementation #4126

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

Merged
merged 13 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
treewide: Add missing underscores to note definitions
  • Loading branch information
jvanbruegge committed Mar 9, 2024
commit c36efe690df8fb276d133c79cad45bd2faa1c3a6
4 changes: 3 additions & 1 deletion ghcide/src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ tcRnModule hsc_env tc_helpers pmod = do


-- Note [Clearing mi_globals after generating an iface]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- GHC populates the mi_global field in interfaces for GHCi if we are using the bytecode
-- interpreter.
-- However, this field is expensive in terms of heap usage, and we don't use it in HLS
Expand Down Expand Up @@ -1366,7 +1367,7 @@ loadHieFile ncu f = do


{- Note [Recompilation avoidance in the presence of TH]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Most versions of GHC we currently support don't have a working implementation of
code unloading for object code, and no version of GHC supports this on certain
platforms like Windows. This makes it completely infeasible for interactive use,
Expand Down Expand Up @@ -1736,6 +1737,7 @@ pathToModuleName = mkModuleName . map rep
rep c = c

{- Note [Guidelines For Using CPP In GHCIDE Import Statements]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GHCIDE's interface with GHC is extensive, and unfortunately, because we have
to work with multiple versions of GHC, we have several files that need to use
a lot of CPP. In order to simplify the CPP in the import section of every file
Expand Down
3 changes: 3 additions & 0 deletions ghcide/src/Development/IDE/Core/FileExists.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import qualified System.Directory as Dir
import qualified System.FilePath.Glob as Glob

{- Note [File existence cache and LSP file watchers]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some LSP servers provide the ability to register file watches with the client, which will then notify
us of file changes. Some clients can do this more efficiently than us, or generally it's a tricky
problem
Expand Down Expand Up @@ -135,6 +136,7 @@ getFileExists :: NormalizedFilePath -> Action Bool
getFileExists fp = use_ GetFileExists fp

{- Note [Which files should we watch?]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The watcher system gives us a lot of flexibility: we can set multiple watchers, and they can all watch on glob
patterns.

Expand Down Expand Up @@ -201,6 +203,7 @@ fileExistsRulesFast recorder isWatched =
else fileExistsSlow file

{- Note [Invalidating file existence results]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We have two mechanisms for getting file existence information:
- The file existence cache
- The VFS lookup
Expand Down
1 change: 1 addition & 0 deletions ghcide/src/Development/IDE/Core/RuleTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ makeLensesWith
''Splices

{- Note [Client configuration in Rules]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The LSP client configuration is stored by `lsp` for us, and is accesible in
handlers through the LspT monad.

Expand Down
1 change: 1 addition & 0 deletions ghcide/src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ instance Default GhcSessionDepsConfig where
}

-- | Note [GhcSessionDeps]
-- ~~~~~~~~~~~~~~~~~~~~~
-- For a file 'Foo', GhcSessionDeps "Foo.hs" results in an HscEnv which includes
-- 1. HomeModInfo's (in the HUG/HPT) for all modules in the transitive closure of "Foo", **NOT** including "Foo" itself.
-- 2. ModSummary's (in the ModuleGraph) for all modules in the transitive closure of "Foo", including "Foo" itself.
Expand Down
1 change: 1 addition & 0 deletions ghcide/src/Development/IDE/GHC/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ realSrcLocToPosition real =
Position (fromIntegral $ srcLocLine real - 1) (fromIntegral $ srcLocCol real - 1)

-- Note [Unicode support]
-- ~~~~~~~~~~~~~~~~~~~~~~
-- the current situation is:
-- LSP Positions use UTF-16 code units(Unicode may count as variable columns);
-- GHC use Unicode code points(Unicode count as one column).
Expand Down
1 change: 1 addition & 0 deletions ghcide/src/Development/IDE/Plugin/HLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ instance Monoid IdeNotificationHandlers where
mempty = IdeNotificationHandlers mempty

{- Note [Exception handling in plugins]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Plugins run in LspM, and so have access to IO. This means they are likely to
throw exceptions, even if only by accident or through calling libraries that
throw exceptions. Ultimately, we're running a bunch of less-trusted IO code,
Expand Down
4 changes: 3 additions & 1 deletion haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ common pedantic
if flag(pedantic)
ghc-options:
-Werror
-- Note [unused-packages] Some packages need CPP conditioned on MIN_VERSION_ghc(x,y,z).
-- Note [unused-packages]
-- ~~~~~~~~~~~~~~~~~~~~~~
-- Some packages need CPP conditioned on MIN_VERSION_ghc(x,y,z).
-- MIN_VERSION_<pkg> is CPP macro that cabal defines only when <pkg> is declared as a dependency.
-- But -Wunused-packages still reports it as unused dependency if it's not imported.
-- For packages with such "unused" dependencies we demote -Wunused-packages error
Expand Down
5 changes: 5 additions & 0 deletions hie-compat/src-ghc92/Compat/HieAst.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import GHC.HsToCore.Expr
import GHC.HsToCore.Monad

{- Note [Updating HieAst for changes in the GHC AST]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When updating the code in this file for changes in the GHC AST, you
need to pay attention to the following things:
Expand Down Expand Up @@ -218,6 +219,7 @@ type TypecheckedSource = LHsBinds GhcTc


{- Note [Name Remapping]
~~~~~~~~~~~~~~~~~~~~~
The Typechecker introduces new names for mono names in AbsBinds.
We don't care about the distinction between mono and poly bindings,
so we replace all occurrences of the mono name with the poly name.
Expand Down Expand Up @@ -425,6 +427,7 @@ concatM :: Monad m => [m [a]] -> m [a]
concatM xs = concat <$> sequence xs

{- Note [Capturing Scopes and other non local information]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toHie is a local transformation, but scopes of bindings cannot be known locally,
hence we have to push the relevant info down into the binding nodes.
We use the following types (*Context and *Scoped) to wrap things and
Expand Down Expand Up @@ -469,6 +472,7 @@ data PScoped a = PS (Maybe Span)
deriving (Typeable, Data) -- Pattern Scope

{- Note [TyVar Scopes]
~~~~~~~~~~~~~~~~~~~
Due to -XScopedTypeVariables, type variables can be in scope quite far from
their original binding. We resolve the scope of these type variables
in a separate pass
Expand Down Expand Up @@ -522,6 +526,7 @@ tvScopes tvScope rhsScope xs =
map (\(RS sc a)-> TVS tvScope sc a) $ listScopes rhsScope xs

{- Note [Scoping Rules for SigPat]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Explicitly quantified variables in pattern type signatures are not
brought into scope in the rhs, but implicitly quantified variables
are (HsWC and HsIB).
Expand Down
1 change: 1 addition & 0 deletions hls-plugin-api/src/Ide/Plugin/Resolve.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ parseError :: Maybe A.Value -> T.Text -> PluginError
parseError value errMsg = PluginInternalError ("Ide.Plugin.Resolve: Error parsing value:"<> (T.pack $ show value) <> " Error: "<> errMsg)

{- Note [Code action resolve fallback to commands]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To make supporting code action resolve easy for plugins, we want to let them
provide one implementation that can be used both when clients support
resolve, and when they don't.
Expand Down
1 change: 1 addition & 0 deletions hls-plugin-api/src/Ide/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,7 @@ installSigUsr1Handler h = void $ installHandler sigUSR1 (Catch h) Nothing
#endif

{- Note [Resolve in PluginHandlers]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Resolve methods have a few guarantees that need to be made by HLS,
specifically they need to only be called once, as neither their errors nor
their responses can be easily combined. Whereas commands, which similarly have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ diagInRange Diagnostic {_range = dr} r = dr `subRange` extendedRange
extendedRange = extendToFullLines r

-- Note [Removing imports is preferred]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- It's good to prefer the remove imports code action because an unused import
-- is likely to be removed and less likely the warning will be disabled.
-- Therefore actions to remove a single or all redundant imports should be
Expand Down