| 1157 | } |
| 1158 | |
| 1159 | void CommandLineInterface::handleAst() |
| 1160 | { |
| 1161 | solAssert(CompilerInputModes.count(m_options.input.mode) == 1); |
| 1162 | |
| 1163 | if (!m_options.compiler.outputs.astCompactJson) |
| 1164 | return; |
| 1165 | |
| 1166 | std::vector<ASTNode const*> asts; |
| 1167 | for (auto const& sourceCode: m_fileReader.sourceUnits()) |
| 1168 | asts.push_back(&m_compiler->ast(sourceCode.first)); |
| 1169 | |
| 1170 | if (!m_options.output.dir.empty()) |
| 1171 | { |
| 1172 | for (auto const& sourceCode: m_fileReader.sourceUnits()) |
| 1173 | { |
| 1174 | std::stringstream data; |
| 1175 | std::string postfix = ""; |
| 1176 | ASTJsonExporter(m_compiler->state(), m_compiler->sourceIndices()).print(data, m_compiler->ast(sourceCode.first), m_options.formatting.json); |
| 1177 | postfix += "_json"; |
| 1178 | boost::filesystem::path path(sourceCode.first); |
| 1179 | createFile(path.filename().string() + postfix + ".ast", data.str()); |
| 1180 | } |
| 1181 | } |
| 1182 | else |
| 1183 | { |
| 1184 | sout() << "JSON AST (compact format):" << std::endl << std::endl; |
| 1185 | for (auto const& sourceCode: m_fileReader.sourceUnits()) |
| 1186 | { |
| 1187 | sout() << std::endl << "======= " << sourceCode.first << " =======" << std::endl; |
| 1188 | ASTJsonExporter(m_compiler->state(), m_compiler->sourceIndices()).print(sout(), m_compiler->ast(sourceCode.first), m_options.formatting.json); |
| 1189 | } |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | void CommandLineInterface::serveLSP() |
| 1194 | { |
nothing calls this directly
no test coverage detected