lsp: Code-review fixups.

This commit is contained in:
Christian Parpart
2022-08-24 16:27:05 +02:00
parent b22d149e3c
commit 3fc7debbef
2 changed files with 39 additions and 37 deletions
+19 -8
View File
@@ -53,9 +53,24 @@ using namespace solidity::lsp;
using namespace solidity::langutil;
using namespace solidity::frontend;
namespace fs = boost::filesystem;
namespace
{
bool resolvesToRegularFile(boost::filesystem::path _path)
{
fs::file_status fileStatus = fs::status(_path);
while (fileStatus.type() == fs::file_type::symlink_file)
{
_path = boost::filesystem::read_symlink(_path);
fileStatus = fs::status(_path);
}
return fileStatus.type() == fs::file_type::regular_file;
}
int toDiagnosticSeverity(Error::Type _errorType)
{
// 1=Error, 2=Warning, 3=Info, 4=Hint
@@ -198,22 +213,18 @@ void LanguageServer::changeConfiguration(Json::Value const& _settings)
vector<boost::filesystem::path> LanguageServer::allSolidityFilesFromProject() const
{
namespace fs = boost::filesystem;
std::vector<fs::path> collectedPaths{};
vector<fs::path> collectedPaths{};
// We explicitly decided against including all files from include paths but leave the possibility
// open for a future PR to enable such a feature to be optionally enabled (default disabled).
auto directoryIterator = fs::recursive_directory_iterator(m_fileRepository.basePath(), fs::symlink_option::recurse);
for (fs::directory_entry const& dirEntry: directoryIterator)
{
if (
dirEntry.status().type() == fs::file_type::regular_file &&
dirEntry.path().extension() == ".sol"
dirEntry.path().extension() == ".sol" &&
(dirEntry.status().type() == fs::file_type::regular_file || resolvesToRegularFile(dirEntry.path()))
)
collectedPaths.push_back(dirEntry.path());
}
collectedPaths.push_back(dirEntry.path());
return collectedPaths;
}