1 /** 2 * Copyright (c) 2022 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_SOURCE_FILE_H 17 #define PANDA_TOOLING_INSPECTOR_SOURCE_FILE_H 18 19 #include "debug_info_extractor.h" 20 21 #include <cstddef> 22 #include <functional> 23 #include <string> 24 25 namespace panda::panda_file { 26 class File; 27 } // namespace panda::panda_file 28 29 namespace panda::tooling { 30 class PtLocation; 31 } // namespace panda::tooling 32 33 namespace panda::tooling::inspector { 34 class SourceFile { 35 public: 36 SourceFile(size_t scriptId, const char *fileName, const panda_file::File *pandaFile, 37 panda_file::DebugInfoExtractor debugInfo); 38 39 void EnumerateLocations(size_t lineNumber, const std::function<bool(PtLocation)> &function) const; 40 GetScriptId()41 size_t GetScriptId() const 42 { 43 return scriptId_; 44 } 45 GetFileName()46 const std::string &GetFileName() const 47 { 48 return fileName_; 49 } 50 GetPandaFile()51 const panda_file::File *GetPandaFile() const 52 { 53 return pandaFile_; 54 } 55 GetDebugInfo()56 const panda_file::DebugInfoExtractor &GetDebugInfo() const 57 { 58 return debugInfo_; 59 } 60 GetSourceCode()61 const std::string &GetSourceCode() const 62 { 63 return sourceCode_; 64 } 65 66 private: 67 size_t scriptId_; 68 std::string fileName_; 69 const panda_file::File *pandaFile_; 70 panda_file::DebugInfoExtractor debugInfo_; 71 std::string sourceCode_; 72 }; 73 } // namespace panda::tooling::inspector 74 75 #endif // PANDA_TOOLING_INSPECTOR_SOURCE_FILE_H 76