1 | // Copyright 2019 the V8 project authors. All rights reserved. |
---|---|
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | #include "src/torque/server-data.h" |
6 | |
7 | namespace v8 { |
8 | namespace internal { |
9 | namespace torque { |
10 | |
11 | DEFINE_CONTEXTUAL_VARIABLE(LanguageServerData) |
12 | |
13 | void LanguageServerData::AddDefinition(SourcePosition token, |
14 | SourcePosition definition) { |
15 | Get().definitions_map_[token.source].emplace_back(token, definition); |
16 | } |
17 | |
18 | base::Optional<SourcePosition> LanguageServerData::FindDefinition( |
19 | SourceId source, LineAndColumn pos) { |
20 | for (const DefinitionMapping& mapping : Get().definitions_map_.at(source)) { |
21 | SourcePosition current = mapping.first; |
22 | if (current.Contains(pos)) return mapping.second; |
23 | } |
24 | |
25 | return base::nullopt; |
26 | } |
27 | |
28 | } // namespace torque |
29 | } // namespace internal |
30 | } // namespace v8 |
31 |