unison-cli-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.LSP.Queries

Description

Rewrites of some codebase queries, but which check the scratch file for info first.

Synopsis

Documentation

markdownDocsForFQN :: Lspish m => Uri -> HashQualified Name -> m [Text] Source #

Renders all docs for a given FQN to markdown.

getTypeOfReferent :: Lspish m => Uri -> Referent -> MaybeT m (Type Symbol Ann) Source #

Gets the type of a reference from either the parsed file or the codebase.

getTypeDeclaration :: forall m. Lspish m => Uri -> Id -> MaybeT m (Decl Symbol Ann) Source #

Gets a decl from either the parsed file or the codebase.

refAtPosition :: forall m. Lspish m => Uri -> Position -> MaybeT m LabeledDependency Source #

Returns a reference to whatever the symbol at the given position refers to.

nodeAtPosition :: Lspish m => Uri -> Position -> MaybeT m (SourceNode Ann) Source #

Returns the ABT node at the provided position. Does not return Decl nodes.

nodeAtPositionMatching :: Lspish m => Uri -> Position -> (SourceNode Ann -> MaybeT m a) -> MaybeT m a Source #

Search the ABT for nodes which intersect at a given position, running the provided selector on them and aligning results to prefer smaller containing nodes first. The caller may use either pure or empty in the selector to select or ignore a given option.

Does not return Decl nodes.

refInTerm :: Term v a -> Maybe LabeledDependency Source #

Returns the reference a given term node refers to, if any.

findSmallestEnclosingNode :: Pos -> Term Symbol Ann -> Maybe (SourceNode Ann) Source #

Find the node in a term which contains the specified position, but none of its children contain that position.

findSmallestEnclosingType :: Pos -> Type Symbol Ann -> Maybe (Type Symbol Ann) Source #

Find the node in a type which contains the specified position, but none of its children contain that position. This is helpful for finding the specific type reference of a given argument within a type arrow that a position references.

findSmallestEnclosingTypeMatching :: Alternative m => Pos -> (Type Symbol Ann -> m a) -> Type Symbol Ann -> m a Source #

Find the node in a type which contains the specified position, but none of its children contain that position. This is helpful for finding the specific type reference of a given argument within a type arrow that a position references.

findSmallestEnclosingNodeMatching :: forall m a. MonadPlus m => Pos -> (SourceNode Ann -> m a) -> Term Symbol Ann -> m a Source #

Find the node in a term which contains the specified position, but none of its children contain that position

refInDecl :: Pos -> Decl Symbol Ann -> Maybe TypeReference Source #

Returns the type reference the given position applies to within a Decl, if any.

I.e. if the cursor is over a type reference within a constructor signature or ability request signature, that type reference will be returned.

data SourceNode a Source #

Instances

Instances details
Functor SourceNode Source # 
Instance details

Defined in Unison.LSP.Queries

Methods

fmap :: (a -> b) -> SourceNode a -> SourceNode b #

(<$) :: a -> SourceNode b -> SourceNode a #

Show (SourceNode a) Source # 
Instance details

Defined in Unison.LSP.Queries

Eq a => Eq (SourceNode a) Source # 
Instance details

Defined in Unison.LSP.Queries

Methods

(==) :: SourceNode a -> SourceNode a -> Bool #

(/=) :: SourceNode a -> SourceNode a -> Bool #