diff options
| author | Yong He <yonghe@outlook.com> | 2023-12-05 10:06:19 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-05 10:06:19 -0800 |
| commit | 1050e0eb96d6c8e7a6cfb253458155e1014625c3 (patch) | |
| tree | ce6c3cbde591759fa2fe2aeb05cb132e50a9a419 /source/slang/slang-lookup.cpp | |
| parent | 4fb3b10b81cf8c976ebd1ebb7fcde7708f022957 (diff) | |
Support `include` for pulling file into the current module. (#3377)
* Support `include` for pulling file into the current module.
* Add auto-completion, hover info and goto-def support.
* Disable warning for missing `module` declaration for now.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-lookup.cpp')
| -rw-r--r-- | source/slang/slang-lookup.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/slang/slang-lookup.cpp b/source/slang/slang-lookup.cpp index d71227b6c..ee4518c20 100644 --- a/source/slang/slang-lookup.cpp +++ b/source/slang/slang-lookup.cpp @@ -675,6 +675,10 @@ static void _lookUpInScopes( auto scope = request.scope; auto endScope = request.endScope; + + // The file decl that this scope is in. + FileDecl* thisFileDecl = nullptr; + for (;scope != endScope; scope = scope->parent) { // Note that we consider all "peer" scopes together, @@ -693,6 +697,18 @@ static void _lookUpInScopes( if (!containerDecl) continue; + if (auto fileDecl = as<FileDecl>(containerDecl)) + { + if (!thisFileDecl) + thisFileDecl = fileDecl; + else if (fileDecl == thisFileDecl) + { + // If we have already looked up in this file decl, + // we don't want to do so again. + continue; + } + } + // TODO: If we need default substitutions to be applied to // the `containerDecl`, then it might make sense to have // each `link` in the scope store a decl-ref instead of |
