|
40 | 40 | using namespace swift;
|
41 | 41 | using namespace ide;
|
42 | 42 |
|
43 |
| -//===----------------------------------------------------------------------===// |
44 |
| -// typeCheckContextAt(DeclContext, SourceLoc) |
45 |
| -//===----------------------------------------------------------------------===// |
46 |
| - |
47 |
| -void swift::ide::typeCheckContextAt(TypeCheckASTNodeAtLocContext TypeCheckCtx, |
48 |
| - SourceLoc Loc) { |
49 |
| - // Make sure the extension has been bound. |
50 |
| - auto DC = TypeCheckCtx.getDeclContext(); |
51 |
| - // Even if the extension is invalid (e.g. nested in a function or another |
52 |
| - // type), we want to know the "intended nominal" of the extension so that |
53 |
| - // we can know the type of 'Self'. |
54 |
| - SmallVector<ExtensionDecl *, 1> extensions; |
55 |
| - for (auto typeCtx = DC->getInnermostTypeContext(); typeCtx != nullptr; |
56 |
| - typeCtx = typeCtx->getParent()->getInnermostTypeContext()) { |
57 |
| - if (auto *ext = dyn_cast<ExtensionDecl>(typeCtx)) |
58 |
| - extensions.push_back(ext); |
59 |
| - } |
60 |
| - while (!extensions.empty()) { |
61 |
| - extensions.back()->computeExtendedNominal(); |
62 |
| - extensions.pop_back(); |
63 |
| - } |
64 |
| - |
65 |
| - // If the completion happens in the inheritance clause of the extension, |
66 |
| - // 'DC' is the parent of the extension. We need to iterate the top level |
67 |
| - // decls to find it. In theory, we don't need the extended nominal in the |
68 |
| - // inheritance clause, but ASTScope lookup requires that. We don't care |
69 |
| - // unless 'DC' is not 'SourceFile' because non-toplevel extensions are |
70 |
| - // 'canNeverBeBound()' anyway. |
71 |
| - if (auto *SF = dyn_cast<SourceFile>(DC)) { |
72 |
| - auto &SM = DC->getASTContext().SourceMgr; |
73 |
| - for (auto *decl : SF->getTopLevelDecls()) |
74 |
| - if (auto *ext = dyn_cast<ExtensionDecl>(decl)) |
75 |
| - if (SM.rangeContainsTokenLoc(ext->getSourceRange(), Loc)) |
76 |
| - ext->computeExtendedNominal(); |
77 |
| - } |
78 |
| - |
79 |
| - swift::typeCheckASTNodeAtLoc(TypeCheckCtx, Loc); |
80 |
| -} |
81 |
| - |
82 | 43 | //===----------------------------------------------------------------------===//
|
83 | 44 | // findParsedExpr(DeclContext, Expr)
|
84 | 45 | //===----------------------------------------------------------------------===//
|
|
0 commit comments