clang-tools  16.0.0git
SemanticSelection.h
Go to the documentation of this file.
1 //===--- SemanticSelection.h -------------------------------------*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Features for giving interesting semantic ranges around the cursor.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSELECTION_H
14 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSELECTION_H
15 #include "ParsedAST.h"
16 #include "Protocol.h"
17 #include "llvm/Support/Error.h"
18 #include <string>
19 #include <vector>
20 namespace clang {
21 namespace clangd {
22 
23 /// Returns the list of all interesting ranges around the Position \p Pos.
24 /// The interesting ranges corresponds to the AST nodes in the SelectionTree
25 /// containing \p Pos.
26 /// If pos is not in any interesting range, return [Pos, Pos).
27 llvm::Expected<SelectionRange> getSemanticRanges(ParsedAST &AST, Position Pos);
28 
29 /// Returns a list of ranges whose contents might be collapsible in an editor.
30 /// This should include large scopes, preprocessor blocks etc.
31 llvm::Expected<std::vector<FoldingRange>> getFoldingRanges(ParsedAST &AST);
32 
33 /// Returns a list of ranges whose contents might be collapsible in an editor.
34 /// This version uses the pseudoparser which does not require the AST.
35 llvm::Expected<std::vector<FoldingRange>>
36 getFoldingRanges(const std::string &Code, bool LineFoldingOnly);
37 
38 } // namespace clangd
39 } // namespace clang
40 
41 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICSELECTION_H
clang::clangd::getFoldingRanges
llvm::Expected< std::vector< FoldingRange > > getFoldingRanges(ParsedAST &AST)
Returns a list of ranges whose contents might be collapsible in an editor.
Definition: SemanticSelection.cpp:169
clang::clangd::getSemanticRanges
llvm::Expected< SelectionRange > getSemanticRanges(ParsedAST &AST, Position Pos)
Returns the list of all interesting ranges around the Position Pos.
Definition: SemanticSelection.cpp:111
Pos
size_t Pos
Definition: NoLintDirectiveHandler.cpp:97
Protocol.h
Code
std::string Code
Definition: FindTargetTests.cpp:67
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
ParsedAST.h