mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-03 22:04:24 +00:00 
			
		
		
		
	Clean
This commit is contained in:
		
							parent
							
								
									bd8d065da9
								
							
						
					
					
						commit
						f737ac31db
					
				@ -90,7 +90,7 @@ int main(int argc, char **argv) {
 | 
			
		||||
    if (!opt_init.empty()) {
 | 
			
		||||
      // We check syntax error here but override client-side
 | 
			
		||||
      // initializationOptions in messages/initialize.cc
 | 
			
		||||
      g_init_options = opt_init;
 | 
			
		||||
      g_init_options = opt_init.getValue();
 | 
			
		||||
      rapidjson::Document reader;
 | 
			
		||||
      rapidjson::ParseResult ok = reader.Parse(g_init_options.c_str());
 | 
			
		||||
      if (!ok) {
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,6 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "lru_cache.h"
 | 
			
		||||
#include "lsp.h"
 | 
			
		||||
#include "method.h"
 | 
			
		||||
#include "query.h"
 | 
			
		||||
 | 
			
		||||
@ -179,24 +179,26 @@ std::vector<Project::Entry> LoadFromDirectoryListing(ProjectConfig *config) {
 | 
			
		||||
 | 
			
		||||
  std::unordered_map<std::string, std::vector<const char *>> folder_args;
 | 
			
		||||
  std::vector<std::string> files;
 | 
			
		||||
  const std::string &project_dir = config->project_dir;
 | 
			
		||||
 | 
			
		||||
  GetFilesInFolder(config->project_dir, true /*recursive*/,
 | 
			
		||||
  GetFilesInFolder(project_dir, true /*recursive*/,
 | 
			
		||||
                   true /*add_folder_to_path*/,
 | 
			
		||||
                   [&folder_args, &files](const std::string &path) {
 | 
			
		||||
                     if (SourceFileLanguage(path) != LanguageId::Unknown) {
 | 
			
		||||
                       files.push_back(path);
 | 
			
		||||
                     } else if (sys::path::filename(path) == ".ccls") {
 | 
			
		||||
                       LOG_S(INFO) << "Using .ccls arguments from " << path;
 | 
			
		||||
                       folder_args.emplace(sys::path::parent_path(path),
 | 
			
		||||
                                           ReadCompilerArgumentsFromFile(path));
 | 
			
		||||
                       std::vector<const char *> args = ReadCompilerArgumentsFromFile(path);
 | 
			
		||||
                       folder_args.emplace(sys::path::parent_path(path), args);
 | 
			
		||||
                       std::string l;
 | 
			
		||||
                       for (size_t i = 0; i < args.size(); i++) {
 | 
			
		||||
                         if (i)
 | 
			
		||||
                           l += ' ';
 | 
			
		||||
                         l += args[i];
 | 
			
		||||
                       }
 | 
			
		||||
                       LOG_S(INFO) << "use " << path << ": " << l;
 | 
			
		||||
                     }
 | 
			
		||||
                   });
 | 
			
		||||
 | 
			
		||||
  const std::string &project_dir = config->project_dir;
 | 
			
		||||
  const auto &project_dir_args = folder_args[project_dir];
 | 
			
		||||
  LOG_IF_S(INFO, !project_dir_args.empty())
 | 
			
		||||
      << "Using .ccls arguments " << StringJoin(project_dir_args);
 | 
			
		||||
 | 
			
		||||
  auto GetCompilerArgumentForFile = [&project_dir,
 | 
			
		||||
                                     &folder_args](std::string cur) {
 | 
			
		||||
    while (!(cur = sys::path::parent_path(cur)).empty()) {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										21
									
								
								src/utils.h
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/utils.h
									
									
									
									
									
								
							@ -7,7 +7,6 @@
 | 
			
		||||
#include <string_view>
 | 
			
		||||
 | 
			
		||||
#include <iterator>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
@ -30,26 +29,6 @@ std::vector<std::string> SplitString(const std::string &str,
 | 
			
		||||
 | 
			
		||||
std::string LowerPathIfInsensitive(const std::string &path);
 | 
			
		||||
 | 
			
		||||
template <typename TValues, typename TMap>
 | 
			
		||||
std::string StringJoinMap(const TValues &values, const TMap &map,
 | 
			
		||||
                          const std::string &sep = ", ") {
 | 
			
		||||
  std::string result;
 | 
			
		||||
  bool first = true;
 | 
			
		||||
  for (auto &entry : values) {
 | 
			
		||||
    if (!first)
 | 
			
		||||
      result += sep;
 | 
			
		||||
    first = false;
 | 
			
		||||
    result += map(entry);
 | 
			
		||||
  }
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename TValues>
 | 
			
		||||
std::string StringJoin(const TValues &values, const std::string &sep = ", ") {
 | 
			
		||||
  return StringJoinMap(values, [](const std::string &entry) { return entry; },
 | 
			
		||||
                       sep);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Ensures that |path| ends in a slash.
 | 
			
		||||
void EnsureEndsInSlash(std::string &path);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user