1 //===--- QueryParser.h - clang-query ----------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
13 #include "QuerySession.h"
14 #include "llvm/LineEditor/LineEditor.h"
24 /// Parse \a Line as a query.
26 /// \return A QueryRef representing the query, which may be an InvalidQuery.
27 static QueryRef
parse(StringRef Line
, const QuerySession
&QS
);
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.
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
);
38 QueryParser(StringRef Line
, const QuerySession
&QS
)
39 : Line(Line
), CompletionPos(nullptr), QS(QS
) {}
43 template <typename T
> struct LexOrCompleteWord
;
45 QueryRef
parseSetBool(bool QuerySession::*Var
);
46 QueryRef
parseSetTraversalKind(TraversalKind
QuerySession::*Var
);
47 template <typename QueryType
> QueryRef
parseSetOutputKind();
48 QueryRef
completeMatcherExpression();
50 QueryRef
endQuery(QueryRef Q
);
52 /// Parse [\p Begin,\p End).
54 /// \return A reference to the parsed query object, which may be an
55 /// \c InvalidQuery if a parse error occurs.
60 const char *CompletionPos
;
61 std::vector
<llvm::LineEditor::Completion
> Completions
;
63 const QuerySession
&QS
;
69 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H