MLIR  20.0.0git
CodeComplete.h
Go to the documentation of this file.
1 //===- CodeComplete.h - MLIR Asm 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_ASMPARSER_CODECOMPLETE_H
10 #define MLIR_ASMPARSER_CODECOMPLETE_H
11 
12 #include "mlir/Support/LLVM.h"
13 #include "llvm/ADT/StringMap.h"
14 #include "llvm/Support/SourceMgr.h"
15 
16 namespace mlir {
17 class Attribute;
18 class Type;
19 
20 /// This class provides an abstract interface into the parser for hooking in
21 /// code completion events. This class is only really useful for providing
22 /// language tooling for MLIR, general clients should not need to use this
23 /// class.
25 public:
27 
28  /// Return the source location used to provide code completion.
29  SMLoc getCodeCompleteLoc() const { return codeCompleteLoc; }
30 
31  //===--------------------------------------------------------------------===//
32  // Completion Hooks
33  //===--------------------------------------------------------------------===//
34 
35  /// Signal code completion for a dialect name, with an optional prefix.
36  virtual void completeDialectName(StringRef prefix) = 0;
38 
39  /// Signal code completion for an operation name within the given dialect.
40  virtual void completeOperationName(StringRef dialectName) = 0;
41 
42  /// Append the given SSA value as a code completion result for SSA value
43  /// completions.
44  virtual void appendSSAValueCompletion(StringRef name,
45  std::string typeData) = 0;
46 
47  /// Append the given block as a code completion result for block name
48  /// completions.
49  virtual void appendBlockCompletion(StringRef name) = 0;
50 
51  /// Signal a completion for the given expected tokens, which are optional if
52  /// `optional` is set.
54  bool optional) = 0;
55 
56  /// Signal a completion for an attribute.
57  virtual void completeAttribute(const llvm::StringMap<Attribute> &aliases) = 0;
59  const llvm::StringMap<Attribute> &aliases) = 0;
60 
61  /// Signal a completion for a type.
62  virtual void completeType(const llvm::StringMap<Type> &aliases) = 0;
63  virtual void
64  completeDialectTypeOrAlias(const llvm::StringMap<Type> &aliases) = 0;
65 
66 protected:
67  /// Create a new code completion context with the given code complete
68  /// location.
69  explicit AsmParserCodeCompleteContext(SMLoc codeCompleteLoc)
70  : codeCompleteLoc(codeCompleteLoc) {}
71 
72 private:
73  /// The location used to code complete.
74  SMLoc codeCompleteLoc;
75 };
76 } // namespace mlir
77 
78 #endif // MLIR_ASMPARSER_CODECOMPLETE_H
This class provides an abstract interface into the parser for hooking in code completion events.
Definition: CodeComplete.h:24
virtual void completeExpectedTokens(ArrayRef< StringRef > tokens, bool optional)=0
Signal a completion for the given expected tokens, which are optional if optional is set.
virtual void completeAttribute(const llvm::StringMap< Attribute > &aliases)=0
Signal a completion for an attribute.
AsmParserCodeCompleteContext(SMLoc codeCompleteLoc)
Create a new code completion context with the given code complete location.
Definition: CodeComplete.h:69
SMLoc getCodeCompleteLoc() const
Return the source location used to provide code completion.
Definition: CodeComplete.h:29
virtual void appendBlockCompletion(StringRef name)=0
Append the given block as a code completion result for block name completions.
virtual void appendSSAValueCompletion(StringRef name, std::string typeData)=0
Append the given SSA value as a code completion result for SSA value completions.
virtual void completeDialectAttributeOrAlias(const llvm::StringMap< Attribute > &aliases)=0
virtual void completeType(const llvm::StringMap< Type > &aliases)=0
Signal a completion for a type.
virtual void completeOperationName(StringRef dialectName)=0
Signal code completion for an operation name within the given dialect.
virtual void completeDialectName(StringRef prefix)=0
Signal code completion for a dialect name, with an optional prefix.
virtual void completeDialectTypeOrAlias(const llvm::StringMap< Type > &aliases)=0
@ Type
An inlay hint that for a type annotation.
Include the generated interface declarations.