From 7bda84de8ce071cbe85560ca368e6bc7182ba14b Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 13 Jun 2015 14:39:57 +0000 Subject: [PATCH] .cpp git-svn-id: svn://ultimatepp.org/upp/trunk@8536 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CppBase/cpp.cpp | 8 ++++++-- uppsrc/ide/Browser/Base.cpp | 35 ++++++++++++++++++++++------------- uppsrc/ide/Browser/Browser.h | 3 +-- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/uppsrc/CppBase/cpp.cpp b/uppsrc/CppBase/cpp.cpp index 1af7842b6..f9c727766 100644 --- a/uppsrc/CppBase/cpp.cpp +++ b/uppsrc/CppBase/cpp.cpp @@ -362,9 +362,13 @@ void GetAllMacros(Md5Stream& md5, const String& id, Index& segment_id); String Cpp::GetDependeciesMd5(const Vector& m) { String r; - for(int i = 0; i < m.GetCount(); i++) { + Md5Stream md5; + md5.Put(Join(namespace_stack, ";")); + md5.Put('@'); + md5.Put(Join(namespace_using.GetKeys(), ";")); + md5.Put('@'); + for(int i = 0; i < m.GetCount(); i++) GetAllMacros(md5, m[i], segment_id); - } return md5.FinishString(); } diff --git a/uppsrc/ide/Browser/Base.cpp b/uppsrc/ide/Browser/Base.cpp index 9f9574d56..e027975a4 100644 --- a/uppsrc/ide/Browser/Base.cpp +++ b/uppsrc/ide/Browser/Base.cpp @@ -10,13 +10,13 @@ #define CLOG(x) RLOG(x) -#define CPP_CODEBASE_VERSION 314 +#define CPP_CODEBASE_VERSION 3141 ArrayMap source_file; void SourceFileInfo::Serialize(Stream& s) { - s % time % check_info % dependencies_md5sum % md5sum; + s % time % dependencies_md5sum % md5sum; if(s.IsLoading()) { depends.Clear(); depends_time = Null; @@ -25,7 +25,11 @@ void SourceFileInfo::Serialize(Stream& s) String CodeBaseCacheDir() { +#ifdef _DEBUG + return ConfigFile("cfg/debug_codebase"); +#else return ConfigFile("cfg/codebase"); +#endif } struct RCB_FileInfo { @@ -91,7 +95,7 @@ void SaveCodeBase() { LTIMING("SaveCodeBase"); LLOG("Save code base " << CodeBase().GetCount()); - RealizeDirectory(ConfigFile("cfg/codebase")); + RealizeDirectory(CodeBaseCacheDir()); StringStream ss; Store(callback(SerializeCodeBase), ss, CPP_CODEBASE_VERSION); String data = ss.GetResult(); @@ -225,18 +229,19 @@ Time GetDependsTime(const Vector& file) bool CheckFile(SourceFileInfo& f, const String& path) { LTIMING("CheckFile"); - if(f.time != GetFileTimeCached(path)) - return false; - if(!f.check_info) - return true; - if(!IsNull(f.depends_time) && f.depends_time == GetDependsTime(f.depends)) + Time ftm = GetFileTimeCached(path); + bool tmok = f.time == ftm; + f.time = ftm; + if(findarg(ToLower(GetFileExt(path)), ".lay", ".iml", ".sch") >= 0) + return tmok; + if(!IsNull(f.depends_time) && tmok && f.depends_time == GetDependsTime(f.depends) && f.dependencies_md5sum.GetCount()) return true; Cpp pp; FileIn in(path); String npath = NormalizeSourcePath(path); pp.Preprocess(npath, in, GetMasterFile(npath), true); String md5 = pp.GetDependeciesMd5(GetPPFile(path).keywords); - bool r = f.dependencies_md5sum == md5; + bool r = f.dependencies_md5sum == md5 && tmok; if(!r) CLOG(path << " " << f.dependencies_md5sum << " != " << md5); f.depends.Clear(); f.dependencies_md5sum = md5; @@ -317,7 +322,6 @@ void ParseSrc(Stream& in, int file, Callback2 error) String ext = ToLower(GetFileExt(path)); int filetype = FILE_OTHER; SourceFileInfo& sfi = source_file[file]; - sfi.time = FileGetTime(path); Cpp cpp; bool b = false; if(ext == ".lay") @@ -329,7 +333,6 @@ void ParseSrc(Stream& in, int file, Callback2 error) if(ext == ".sch") pp.Append(PreprocessSchFile(path)); else { - sfi.check_info = true; cpp.Preprocess(path, in, GetMasterFile(GetSourceFilePath(file))); filetype = decode(ext, ".h", FILE_H, ".hpp", FILE_HPP, ".cpp",FILE_CPP, ".c", FILE_C, FILE_OTHER); @@ -396,7 +399,11 @@ void SyncCodeBase() { LTIMING("SyncCodeBase"); LTIMESTOP("SyncCodeBase"); - LLOG("============= Sync code base"); + CLOG("============= Sync code base"); + if(IsNull(GetCurrentMainPackage())) { + ClearCodeBase(); + return; + } Progress pi; pi.Title("Parsing source files"); UpdateCodeBase(pi); @@ -406,8 +413,10 @@ void SyncCodeBase() void NewCodeBase() { ReduceCodeBaseCache(); - if(GetIdeWorkspace().GetCount() == 0) + if(IsNull(GetCurrentMainPackage())) { + ClearCodeBase(); return; + } static int start; if(start) return; start++; diff --git a/uppsrc/ide/Browser/Browser.h b/uppsrc/ide/Browser/Browser.h index d5081606c..f2c39220c 100644 --- a/uppsrc/ide/Browser/Browser.h +++ b/uppsrc/ide/Browser/Browser.h @@ -20,7 +20,6 @@ CppBase& CodeBase(); struct SourceFileInfo { Time time; - bool check_info; // this is not special file, like .iml, .sch String dependencies_md5sum; // dependencies from other files - usings, initial namespace, macros String md5sum; // preprocessing 'fingerprint' to detect changes Vector depends; // indicies of file this files depends on, for time-check @@ -28,7 +27,7 @@ struct SourceFileInfo { void Serialize(Stream& s); - SourceFileInfo() { time = Null; check_info = false; depends_time = Null; } + SourceFileInfo() { time = Null; depends_time = Null; } }; void NewCodeBase();