MCPcopy Create free account
hub / github.com/argotorg/solidity / compile

Method compile

libsolidity/lsp/LanguageServer.cpp:239–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239void LanguageServer::compile()
240{
241 // For files that are not open, we have to take changes on disk into account,
242 // so we just remove all non-open files.
243
244 FileRepository oldRepository(m_fileRepository.basePath(), m_fileRepository.includePaths());
245 std::swap(oldRepository, m_fileRepository);
246
247 // Load all solidity files from project.
248 if (m_fileLoadStrategy == FileLoadStrategy::ProjectDirectory)
249 for (auto const& projectFile: allSolidityFilesFromProject())
250 {
251 lspDebug(fmt::format("adding project file: {}", projectFile.generic_string()));
252 m_fileRepository.setSourceByUri(
253 m_fileRepository.sourceUnitNameToUri(projectFile.generic_string()),
254 util::readFileAsString(projectFile)
255 );
256 }
257
258 // Overwrite all files as opened by the client, including the ones which might potentially have changes.
259 for (std::string const& fileName: m_openFiles)
260 m_fileRepository.setSourceByUri(
261 fileName,
262 oldRepository.sourceUnits().at(oldRepository.uriToSourceUnitName(fileName))
263 );
264
265 // TODO: optimize! do not recompile if nothing has changed (file(s) not flagged dirty).
266
267 m_compilerStack.reset(false);
268 m_compilerStack.setSources(m_fileRepository.sourceUnits());
269 m_compilerStack.compile(CompilerStack::State::AnalysisSuccessful);
270}
271
272void LanguageServer::compileAndUpdateDiagnostics()
273{

Callers 1

compileFunction · 0.45

Calls 6

setSourceByUriMethod · 0.80
sourceUnitNameToUriMethod · 0.80
atMethod · 0.80
uriToSourceUnitNameMethod · 0.80
setSourcesMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected