MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / import

Method import

lib/importproject.cpp:311–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311ImportProject::Type ImportProject::import(const std::string &filename, Settings *settings, Suppressions *supprs)
312{
313 std::ifstream fin(filename);
314 if (!fin.is_open())
315 return ImportProject::Type::MISSING;
316
317 mPath = Path::getPathFromFilename(Path::fromNativeSeparators(filename));
318 if (!mPath.empty() && !endsWith(mPath,'/'))
319 mPath += '/';
320
321 const std::vector<std::string> fileFilters =
322 settings ? settings->fileFilters : std::vector<std::string>();
323
324 if (endsWith(filename, ".json")) {
325 if (importCompileCommands(fin)) {
326 setRelativePaths(filename);
327 return ImportProject::Type::COMPILE_DB;
328 }
329 } else if (endsWith(filename, ".sln")) {
330 if (importSln(fin, mPath, fileFilters)) {
331 setRelativePaths(filename);
332 return ImportProject::Type::VS_SLN;
333 }
334 } else if (endsWith(filename, ".slnx")) {
335 if (importSlnx(filename, fileFilters)) {
336 setRelativePaths(filename);
337 return ImportProject::Type::VS_SLNX;
338 }
339 } else if (endsWith(filename, ".vcxproj")) {
340 std::map<std::string, std::string, cppcheck::stricmp> variables;
341 std::vector<SharedItemsProject> sharedItemsProjects;
342 if (importVcxproj(filename, variables, "", fileFilters, sharedItemsProjects)) {
343 setRelativePaths(filename);
344 return ImportProject::Type::VS_VCXPROJ;
345 }
346 } else if (endsWith(filename, ".bpr")) {
347 if (importBcb6Prj(filename)) {
348 setRelativePaths(filename);
349 return ImportProject::Type::BORLAND;
350 }
351 } else if (settings && supprs && endsWith(filename, ".cppcheck")) {
352 if (importCppcheckGuiProject(fin, *settings, *supprs)) {
353 setRelativePaths(filename);
354 return ImportProject::Type::CPPCHECK_GUI;
355 }
356 } else {
357 return ImportProject::Type::UNKNOWN;
358 }
359 return ImportProject::Type::FAILURE;
360}
361
362bool ImportProject::importCompileCommands(std::istream &istr)
363{

Callers 4

parseFromArgsMethod · 0.80
getProjectConfigsMethod · 0.80
analyzeFilesMethod · 0.80
analyzeProjectMethod · 0.80

Calls 2

endsWithFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected