| 135 | } |
| 136 | |
| 137 | bool LuaFormat::ReformatWorkspace(const FormatContext &context) { |
| 138 | auto workspace = context.GetWorkspace(); |
| 139 | FileFinder finder(workspace); |
| 140 | finder.AddFindExtension(".lua"); |
| 141 | finder.AddFindExtension(".lua.txt"); |
| 142 | finder.AddIgnoreDirectory(".git"); |
| 143 | finder.AddIgnoreDirectory(".github"); |
| 144 | finder.AddIgnoreDirectory(".svn"); |
| 145 | finder.AddIgnoreDirectory(".idea"); |
| 146 | finder.AddIgnoreDirectory(".vs"); |
| 147 | finder.AddIgnoreDirectory(".vscode"); |
| 148 | for (const auto &pattern: context.GetIgnorePattern()) { |
| 149 | finder.AddIgnorePatterns(pattern); |
| 150 | } |
| 151 | |
| 152 | auto files = finder.FindFiles(); |
| 153 | for (auto &filePath: files) { |
| 154 | auto opText = ReadFile(filePath); |
| 155 | std::string relativePath = filePath; |
| 156 | if (!workspace.empty()) { |
| 157 | relativePath = string_util::GetFileRelativePath(workspace, filePath); |
| 158 | } |
| 159 | if (opText.has_value()) { |
| 160 | auto style = context.GetStyle(relativePath); |
| 161 | if (ReformatSingleFile(context, filePath, std::move(opText.value()), style)) { |
| 162 | std::cerr << util::format("Reformat {} succeed.", relativePath) << std::endl; |
| 163 | } else { |
| 164 | std::cerr << util::format("Reformat {} fail.", relativePath) << std::endl; |
| 165 | } |
| 166 | } else { |
| 167 | std::cerr << util::format("Can not read file {}", relativePath) << std::endl; |
| 168 | } |
| 169 | } |
| 170 | return true; |
| 171 | } |
nothing calls this directly
no test coverage detected