@@ -157,12 +157,12 @@ enum class CursorInfoKind {
157
157
158
158
struct ResolvedCursorInfo {
159
159
CursorInfoKind Kind = CursorInfoKind::Invalid;
160
+ SourceFile *SF;
161
+ SourceLoc Loc;
160
162
ValueDecl *ValueD = nullptr ;
161
163
TypeDecl *CtorTyRef = nullptr ;
162
164
ExtensionDecl *ExtTyRef = nullptr ;
163
- SourceFile *SF = nullptr ;
164
165
ModuleEntity Mod;
165
- SourceLoc Loc;
166
166
bool IsRef = true ;
167
167
bool IsKeywordArgument = false ;
168
168
Type Ty;
@@ -172,39 +172,36 @@ struct ResolvedCursorInfo {
172
172
Expr *TrailingExpr = nullptr ;
173
173
174
174
ResolvedCursorInfo () = default ;
175
- ResolvedCursorInfo (ValueDecl *ValueD,
176
- TypeDecl *CtorTyRef,
177
- ExtensionDecl *ExtTyRef,
178
- SourceFile *SF,
179
- SourceLoc Loc,
180
- bool IsRef,
181
- Type Ty,
182
- Type ContainerType) :
183
- Kind (CursorInfoKind::ValueRef),
184
- ValueD (ValueD),
185
- CtorTyRef (CtorTyRef),
186
- ExtTyRef (ExtTyRef),
187
- SF (SF),
188
- Loc (Loc),
189
- IsRef (IsRef),
190
- Ty (Ty),
191
- DC (ValueD->getDeclContext ()),
192
- ContainerType(ContainerType) {}
193
- ResolvedCursorInfo (ModuleEntity Mod,
194
- SourceFile *SF,
195
- SourceLoc Loc) :
196
- Kind(CursorInfoKind::ModuleRef),
197
- SF(SF),
198
- Mod(Mod),
199
- Loc(Loc) {}
200
- ResolvedCursorInfo (Stmt *TrailingStmt, SourceFile *SF) :
201
- Kind(CursorInfoKind::StmtStart),
202
- SF(SF),
203
- TrailingStmt(TrailingStmt) {}
204
- ResolvedCursorInfo (Expr* TrailingExpr, SourceFile *SF) :
205
- Kind(CursorInfoKind::ExprStart),
206
- SF(SF),
207
- TrailingExpr(TrailingExpr) {}
175
+ ResolvedCursorInfo (SourceFile *SF) : SF(SF) {}
176
+
177
+ void setValueRef (ValueDecl *ValueD,
178
+ TypeDecl *CtorTyRef,
179
+ ExtensionDecl *ExtTyRef,
180
+ bool IsRef,
181
+ Type Ty,
182
+ Type ContainerType) {
183
+ Kind = CursorInfoKind::ValueRef;
184
+ this ->ValueD = ValueD;
185
+ this ->CtorTyRef = CtorTyRef;
186
+ this ->ExtTyRef = ExtTyRef;
187
+ this ->IsRef = IsRef;
188
+ this ->Ty = Ty;
189
+ this ->DC = ValueD->getDeclContext ();
190
+ this ->ContainerType = ContainerType;
191
+ }
192
+ void setModuleRef (ModuleEntity Mod) {
193
+ Kind = CursorInfoKind::ModuleRef;
194
+ this ->Mod = Mod;
195
+ }
196
+ void setTrailingStmt (Stmt *TrailingStmt) {
197
+ Kind = CursorInfoKind::StmtStart;
198
+ this ->TrailingStmt = TrailingStmt;
199
+ }
200
+ void setTrailingExpr (Expr* TrailingExpr) {
201
+ Kind = CursorInfoKind::ExprStart;
202
+ this ->TrailingExpr = TrailingExpr;
203
+ }
204
+
208
205
bool isValid () const { return !isInvalid (); }
209
206
bool isInvalid () const { return Kind == CursorInfoKind::Invalid; }
210
207
};
@@ -217,7 +214,8 @@ class CursorInfoResolver : public SourceEntityWalker {
217
214
llvm::SmallVector<Expr*, 4 > TrailingExprStack;
218
215
219
216
public:
220
- explicit CursorInfoResolver (SourceFile &SrcFile) : SrcFile(SrcFile) { }
217
+ explicit CursorInfoResolver (SourceFile &SrcFile) :
218
+ SrcFile(SrcFile), CursorInfo(&SrcFile) {}
221
219
ResolvedCursorInfo resolve (SourceLoc Loc);
222
220
SourceManager &getSourceMgr () const ;
223
221
private:
0 commit comments