• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at*
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0*
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FIND_REFERENCES_H
17 #define FIND_REFERENCES_H
18 
19 #include <cstddef>
20 #include <string>
21 #include <tuple>
22 #include <vector>
23 
24 #include "es2panda.h"
25 #include "cancellation_token.h"
26 
27 namespace ark::es2panda::lsp {
28 
29 // NOLINTBEGIN(misc-non-private-member-variables-in-classes)
30 struct ReferencedNode {
31     std::string filePath;
32     size_t start = 0;
33     size_t end = 0;
34     size_t line = 0;
35     bool isDefinition = false;
36 
37     bool operator<(const ReferencedNode &other) const
38     {
39         return std::tie(filePath, start, end, line, isDefinition) <
40                std::tie(other.filePath, other.start, other.end, other.line, other.isDefinition);
41     }
42 };
43 // NOLINTEND(misc-non-private-member-variables-in-classes)
44 
45 // Returns a map of file path and reference position list
46 std::set<ReferencedNode> FindReferences(CancellationToken *tkn, const std::vector<SourceFile> &files,
47                                         const SourceFile &file, size_t position);
48 }  // namespace ark::es2panda::lsp
49 
50 #endif