clang-tools 10.0.0

QueryParser.h
Go to the documentation of this file.
1 //===--- QueryParser.h - clang-query ----------------------------*- 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 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
11
12 #include "Query.h"
13 #include "QuerySession.h"
14 #include "llvm/LineEditor/LineEditor.h"
15 #include <cstddef>
16
17 namespace clang {
18 namespace query {
19
20 class QuerySession;
21
22 class QueryParser {
23 public:
24 /// Parse \a Line as a query.
25 ///
26 /// \return A QueryRef representing the query, which may be an InvalidQuery.
27 static QueryRef parse(StringRef Line, const QuerySession &QS);
28
29 /// Compute a list of completions for \a Line assuming a cursor at
30 /// \param Pos characters past the start of \a Line, ordered from most
31 /// likely to least likely.
32 ///
33 /// \return A vector of completions for \a Line.
34 static std::vector<llvm::LineEditor::Completion>
35 complete(StringRef Line, size_t Pos, const QuerySession &QS);
36
37 private:
38 QueryParser(StringRef Line, const QuerySession &QS)
39 : Line(Line), CompletionPos(nullptr), QS(QS) {}
40
41 StringRef lexWord();
42
43 template <typename T> struct LexOrCompleteWord;
44
45 QueryRef parseSetBool(bool QuerySession::*Var);
46 template <typename QueryType> QueryRef parseSetOutputKind();
47 QueryRef completeMatcherExpression();
48
49 QueryRef endQuery(QueryRef Q);
50
51 /// Parse [\p Begin,\p End).
52 ///
53 /// \return A reference to the parsed query object, which may be an
54 /// \c InvalidQuery if a parse error occurs.
55 QueryRef doParse();
56
57 StringRef Line;
58
59 const char *CompletionPos;
60 std::vector<llvm::LineEditor::Completion> Completions;
61
62 const QuerySession &QS;
63 };
64
65 } // namespace query
66 } // namespace clang
67
68 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
clang::query::QueryParser::parse
static QueryRef parse(StringRef Line, const QuerySession &QS)
Parse Line as a query.
Definition: QueryParser.cpp:336
clang::query::QuerySession
Represents the state for a particular clang-query session.
Definition: QuerySession.h:23
clang::query::QueryParser::complete
static std::vector< llvm::LineEditor::Completion > complete(StringRef Line, size_t Pos, const QuerySession &QS)
Compute a list of completions for Line assuming a cursor at.
Definition: QueryParser.cpp:341
Query.h
QuerySession.h
clang::query::QueryParser::LexOrCompleteWord
Definition: QueryParser.cpp:52
clang::query::QueryRef
llvm::IntrusiveRefCntPtr< Query > QueryRef
Definition: Query.h:51
Pos
Position Pos
Definition: SourceCode.cpp:772
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
Line
int Line
Definition: PreprocessorTracker.cpp:526
clang::query::QueryParser
Definition: QueryParser.h:22