MLIR 22.0.0git
CodeComplete.h
Go to the documentation of this file.
1//===- CodeComplete.h - PDLL Frontend CodeComplete Context ------*- 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 MLIR_TOOLS_PDLL_PARSER_CODECOMPLETE_H_
10#define MLIR_TOOLS_PDLL_PARSER_CODECOMPLETE_H_
11
12#include "mlir/Support/LLVM.h"
13#include "llvm/Support/SourceMgr.h"
14#include <optional>
15
16namespace mlir {
17namespace pdll {
18namespace ast {
19class CallableDecl;
20class DeclScope;
21class Expr;
22class OperationType;
23class TupleType;
24class Type;
25class VariableDecl;
26} // namespace ast
27
28/// This class provides an abstract interface into the parser for hooking in
29/// code completion events.
31public:
33
34 /// Return the location used to provide code completion.
35 SMLoc getCodeCompleteLoc() const { return codeCompleteLoc; }
36
37 //===--------------------------------------------------------------------===//
38 // Completion Hooks
39 //===--------------------------------------------------------------------===//
40
41 /// Signal code completion for a member access into the given tuple type.
42 virtual void codeCompleteTupleMemberAccess(ast::TupleType tupleType);
43
44 /// Signal code completion for a member access into the given operation type.
46
47 /// Signal code completion for a member access into the given operation type.
48 virtual void codeCompleteOperationAttributeName(StringRef opName) {}
49
50 /// Signal code completion for a constraint name with an optional decl scope.
51 /// `currentType` is the current type of the variable that will use the
52 /// constraint, or nullptr if a type is unknown. `allowInlineTypeConstraints`
53 /// enables inline type constraints for Attr/Value/ValueRange.
54 virtual void codeCompleteConstraintName(ast::Type currentType,
55 bool allowInlineTypeConstraints,
56 const ast::DeclScope *scope);
57
58 /// Signal code completion for a dialect name.
59 virtual void codeCompleteDialectName() {}
60
61 /// Signal code completion for an operation name in the given dialect.
62 virtual void codeCompleteOperationName(StringRef dialectName) {}
63
64 /// Signal code completion for Pattern metadata.
66
67 /// Signal code completion for an include filename.
68 virtual void codeCompleteIncludeFilename(StringRef curPath) {}
69
70 //===--------------------------------------------------------------------===//
71 // Signature Hooks
72 //===--------------------------------------------------------------------===//
73
74 /// Signal code completion for the signature of a callable.
75 virtual void codeCompleteCallSignature(const ast::CallableDecl *callable,
76 unsigned currentNumArgs) {}
77
78 /// Signal code completion for the signature of an operation's operands.
79 virtual void
80 codeCompleteOperationOperandsSignature(std::optional<StringRef> opName,
81 unsigned currentNumOperands) {}
82
83 /// Signal code completion for the signature of an operation's results.
84 virtual void
85 codeCompleteOperationResultsSignature(std::optional<StringRef> opName,
86 unsigned currentNumResults) {}
87
88protected:
89 /// Create a new code completion context with the given code complete
90 /// location.
91 explicit CodeCompleteContext(SMLoc codeCompleteLoc)
92 : codeCompleteLoc(codeCompleteLoc) {}
93
94private:
95 /// The location used to code complete.
96 SMLoc codeCompleteLoc;
97};
98} // namespace pdll
99} // namespace mlir
100
101#endif // MLIR_TOOLS_PDLL_PARSER_CODECOMPLETE_H_
virtual void codeCompleteConstraintName(ast::Type currentType, bool allowInlineTypeConstraints, const ast::DeclScope *scope)
Signal code completion for a constraint name with an optional decl scope.
CodeCompleteContext(SMLoc codeCompleteLoc)
Create a new code completion context with the given code complete location.
virtual void codeCompleteOperationAttributeName(StringRef opName)
Signal code completion for a member access into the given operation type.
virtual void codeCompleteOperationOperandsSignature(std::optional< StringRef > opName, unsigned currentNumOperands)
Signal code completion for the signature of an operation's operands.
virtual void codeCompleteOperationName(StringRef dialectName)
Signal code completion for an operation name in the given dialect.
virtual void codeCompleteOperationResultsSignature(std::optional< StringRef > opName, unsigned currentNumResults)
Signal code completion for the signature of an operation's results.
virtual void codeCompleteDialectName()
Signal code completion for a dialect name.
SMLoc getCodeCompleteLoc() const
Return the location used to provide code completion.
virtual void codeCompleteOperationMemberAccess(ast::OperationType opType)
Signal code completion for a member access into the given operation type.
virtual void codeCompleteTupleMemberAccess(ast::TupleType tupleType)
Signal code completion for a member access into the given tuple type.
virtual void codeCompletePatternMetadata()
Signal code completion for Pattern metadata.
virtual void codeCompleteCallSignature(const ast::CallableDecl *callable, unsigned currentNumArgs)
Signal code completion for the signature of a callable.
virtual void codeCompleteIncludeFilename(StringRef curPath)
Signal code completion for an include filename.
This decl represents a shared interface for all callable decls.
Definition Nodes.h:1194
This class represents a scope for named AST decls.
Definition Nodes.h:64
This class represents a base AST Expression node.
Definition Nodes.h:348
This class represents a PDLL type that corresponds to an mlir::Operation.
Definition Types.h:134
This class represents a PDLL tuple type, i.e.
Definition Types.h:222
This Decl represents the definition of a PDLL variable.
Definition Nodes.h:1248
Include the generated interface declarations.