• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2022-2024 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 PANDA_TOOLING_INSPECTOR_TYPES_LOCATION_H
17 #define PANDA_TOOLING_INSPECTOR_TYPES_LOCATION_H
18 
19 #include "tooling/inspector/json_serialization/serializable.h"
20 
21 #include <cstddef>
22 #include <functional>
23 #include <string>
24 
25 #include "utils/expected.h"
26 
27 #include "types/numeric_id.h"
28 
29 namespace ark {
30 class JsonObject;
31 class JsonObjectBuilder;
32 }  // namespace ark
33 
34 namespace ark::tooling::inspector {
35 class Location final : public JsonSerializable {
36 public:
Location(ScriptId scriptId,size_t lineNumber)37     Location(ScriptId scriptId, size_t lineNumber) : scriptId_(scriptId), lineNumber_(lineNumber) {}
38 
39     static Expected<Location, std::string> FromJsonProperty(const JsonObject &object, const char *propertyName);
40 
GetScriptId()41     ScriptId GetScriptId() const
42     {
43         return scriptId_;
44     }
45 
GetLineNumber()46     size_t GetLineNumber() const
47     {
48         return lineNumber_;
49     }
50 
SetLineNumber(size_t lineNumber)51     void SetLineNumber(size_t lineNumber)
52     {
53         lineNumber_ = lineNumber;
54     }
55 
56     void Serialize(JsonObjectBuilder &builder) const override;
57 
58 private:
59     ScriptId scriptId_;
60     size_t lineNumber_;
61 };
62 }  // namespace ark::tooling::inspector
63 
64 #endif  // PANDA_TOOLING_INSPECTOR_TYPES_LOCATION_H
65