Fixing issues...

This commit is contained in:
Mirek Fidler 2022-08-06 19:39:35 +02:00
parent aaa25f9682
commit e40bd48ee0
11 changed files with 110 additions and 61 deletions

View file

@ -436,14 +436,14 @@ bool AssistEditor::IncludeAssist()
return true;
}
CurrentFileContext AssistEditor::CurrentContext()
CurrentFileContext AssistEditor::CurrentContext(int pos)
{
CurrentFileContext cfx;
cfx.filename = cfx.real_filename = NormalizePath(theide->editfile);
cfx.includes = theide->GetCurrentIncludePath();
cfx.defines = theide->GetCurrentDefines();
if(!IsView() && GetLength() < 200000) {
cfx.content = Get();
cfx.content = Get(0, min(GetLength(), pos));
if(!IsSourceFile(cfx.filename)) {
if(master_source.GetCount()) {
MakeIncludeTrick(cfx);
@ -459,7 +459,7 @@ CurrentFileContext AssistEditor::CurrentContext()
DDUMP(cfx.filename);
DDUMP(cfx.real_filename);
if(cfx.content.GetCount())
SaveFile(ConfigFile("pseudo_header_src.cpp"), cfx.content);
SaveFile(ConfigFile("CurrentContext.cpp"), cfx.content);
#endif
return cfx;
}
@ -514,9 +514,10 @@ void AssistEditor::Assist(bool macros)
return;
int pos = GetCursor();
int line = GetLinePos(pos); // TODO: limit, solve subincludes
ReadIdBackPos(pos, false); // libclang does now work well if file is not truncated for autocomplete
CurrentFileContext cfx = CurrentContext(pos);
int line = GetLinePos(pos);
int line_delta;
CurrentFileContext cfx = CurrentContext();
if(cfx.content.GetCount())
StartAutoComplete(cfx, line + line_delta + 1, pos + 1, macros, [=](const Vector<AutoCompleteItem>& items) {
for(const AutoCompleteItem& m : items) {

View file

@ -153,7 +153,7 @@ struct AssistEditor : CodeEditor, Navigator {
PPInfo hdepend2;
String master_source;
CurrentFileContext CurrentContext();
CurrentFileContext CurrentContext(int pos = INT_MAX);
void SyncCurrentFile(const CurrentFileContext& ctx);
void SyncCurrentFile();
void SyncHeaders();

View file

@ -19,13 +19,15 @@ void AssistEditor::SyncHeaders()
master_source = FindMasterSource(hdepend2, GetIdeWorkspace(), editfile);
LLOG("Master source " << editfile << " -> " << master_source);
}
#ifdef _DEBUG
// TODO: Remove
hdepend2.WhenBlitzBlock = [=](const String& inc, const String& path) {
PutConsole(String() << inc << " blocks BLITZ of " << path);
};
if(hdepend2.BlitzApproved(editfile))
PutConsole(editfile + " BLITZ approved");
#endif
}
bool AssistEditor::DoIncludeTrick(Index<String>& visited, int level, StringBuffer& out, String path, const String& target_path, int& line_delta)

View file

@ -1,7 +1,7 @@
#include "clang.h"
#define LTIMING(x) //TIMING(x)
#define LTIMESTOP(x) DTIMESTOP(x)
#define LTIMESTOP(x) //DTIMESTOP(x)
#define LLOG(x) //DLOG(x)
#define LDUMP(x) //DDUMP(x)
#define LDUMPM(x) //DDUMPM(x)
@ -179,7 +179,7 @@ void Indexer::IndexerThread()
VectorMap<String, bool> do_file_cache;
v.WhenFile = [&](const String& path) {
DTIMING("WhenFile");
LTIMING("WhenFile");
if(IsNull(path))
return false;
if(current_file != path) {
@ -193,7 +193,7 @@ void Indexer::IndexerThread()
current_file = path;
int q = do_file_cache.Find(path);
if(q < 0) {
DTIMING("WhenFile 2");
LTIMING("WhenFile 2");
Mutex::Lock __(mutex);
do_file = job.file_times.Find(NormalizePath(path)) >= 0;
do_file_cache.Add(path, do_file);
@ -222,7 +222,7 @@ void Indexer::IndexerThread()
f.includes = job.includes;
(CppFileInfo&)f = pick(m.value);
f.time = job.file_times.Get(path, Time::Low());
DLOG("Storing " << path);
LLOG("Storing " << path);
// TODO: Compress ?
SaveChangedFile(CachedAnnotationPath(path, f.defines, f.includes, job.master_files.Get(path, Null)), StoreAsString(f), true);
GuiLock __;
@ -234,7 +234,7 @@ void Indexer::IndexerThread()
{
Mutex::Lock __(mutex);
if(--running_indexers == 0 && jobs.GetCount()) {
DLOG("Done everything " << (msecs() - tm0) / 1000.0 << " s");
LLOG("Done everything " << (msecs() - tm0) / 1000.0 << " s");
jobs.Clear();
scheduler.Broadcast();
last = true;
@ -242,7 +242,7 @@ void Indexer::IndexerThread()
}
#ifdef _DEBUG
if(last)
DumpIndex(); // TODO remove
DumpIndex(); // TODO remove?
#endif
if(Thread::IsShutdownThreads())
break;
@ -281,7 +281,7 @@ void Indexer::SchedulerThread()
while(!Thread::IsShutdownThreads()) {
scheduler.Wait();
DTIMESTOP("Scheduler");
LTIMESTOP("Scheduler");
Mutex::Lock __(mutex);
String includes, defines;
@ -303,7 +303,7 @@ void Indexer::SchedulerThread()
ppi.Dirty();
{
DTIMING("Load workspace");
LTIMING("Load workspace");
Workspace wspc;
wspc.Scan(main);
@ -325,7 +325,7 @@ void Indexer::SchedulerThread()
}
{ // TODO different master header currentfile / index issue
DTIMING("Dependencies");
LTIMING("Dependencies");
for(const Vector<Tuple<String, bool>>& pk : sources)
for(const Tuple<String, bool>& m : pk) {
if(IsCSourceFile(m.a)) {
@ -346,9 +346,6 @@ void Indexer::SchedulerThread()
Index<String> dirty_files; // files that need to be recompiled (including headers)
DDUMPM(files);
DDUMP(dirty_files);
{
LTIMESTOP("Loading from cache, checking filetimes");
for(const auto& m : ~files) {
@ -390,7 +387,6 @@ void Indexer::SchedulerThread()
{
LTIMESTOP("Create indexer jobs");
LDUMP(includes);
jobs.Clear();
jobi = 0;
for(const auto& pkg : ~sources) {
@ -401,7 +397,7 @@ void Indexer::SchedulerThread()
job.file_times.Add(path, files.Get(path, Time::Low()));
for(int q = master.Find(path); q >= 0; q = master.FindNext(q)) {
String hpath = header[q];
if(dirty_files.Find(hpath) >= 0) {
if(dirty_files.Find(hpath) >= 0) { // TODO: Ignore external includes if times are ok
job.file_times.Add(hpath, files.Get(hpath, Time::Low()));
job.master_files.Add(header[q], path);
}
@ -438,7 +434,7 @@ void Indexer::SchedulerThread()
}
}
if(jobs.GetCount()) {
DLOG("======= Unleash indexers");
LLOG("======= Unleash indexers");
event.Broadcast();
}
}

View file

@ -76,38 +76,45 @@ String CleanupId(const char *s)
};
while(*s && *s != '{') {
if(iscid(*s)) {
auto IsOperator = [](const char *s) {
return memcmp(s, "operator", 8) == 0;
};
const char *b = s;
String id;
while(iscid(*s) || *s == ':') {
s++;
if(*s == '<' && !operator_def) {
id.Cat(b, s);
SkipT();
id.Cat(*s++);
if(*s == '<') {
if(id.GetCount() == 8 && IsOperator(id))
break;
if(id.GetCount() > 8) {
const char *s = ~id + id.GetCount() - 8;
if(IsOperator(s) && !iscid(s[-1]))
break;
}
SkipT(); // Skip template arguments like in Foo<Bar>::Method() -> Foo::Method
b = s;
}
}
id.Cat(b, s);
if(id == s_attribute) {
while(mm.GetCount() && mm[mm.GetCount() - 1] == ' ')
mm.SetLength(mm.GetCount() - 1);
break;
}
if((*s == ',' || *s == ')') && was_param_type) {
if((*s == ',' || *s == ')' || *s == '[') && was_param_type) {
was_param_type = false;
continue;
}
if(IsIgnored(id))
continue;
auto IsOperator = [](const char *s) {
return memcmp(s, "operator", 8) == 0;
};
if(was_id)
mm.Cat(' ');
if(!operator_def) // because of conversion operators e.g. Foo::operator bool()
name_pos = mm.GetCount();
if(id.GetCount() == 8 && IsOperator(id))
operator_def = true;
if(id.GetCount() > 8) { // conversion operator?
if(id.GetCount() > 8) {
const char *s = ~id + id.GetCount() - 8;
operator_def = IsOperator(s) && !iscid(s[-1]);
}

View file

@ -245,9 +245,7 @@ bool ClangVisitor::ProcessNode(CXCursor cursor)
CXCursor ref = clang_getCursorReferenced(cursor);
String id = ci.Id();
DHITCOUNT("Resolved ID");
if(id.GetCount()) {
DTIMING("Has ID");
LoadLocation();
AnnotationItem& r = info.GetAdd(loc.path).items.Add();
r.kind = ci.Kind();
@ -284,7 +282,6 @@ bool ClangVisitor::ProcessNode(CXCursor cursor)
}
if(!clang_Cursor_isNull(ref)) {
DTIMING("Ref");
LoadLocation();
SourceLocation ref_loc = GetLocation(clang_getCursorLocation(ref));
int q = tfn.Find(ref_loc);

View file

@ -20,7 +20,7 @@ ISUES:
- Do TODOs
- header header
- header without .cpp speed
- aux files / autocomplete
@ -76,8 +76,6 @@ ISUES:
- reduce cache
- id = main(int,const char*argv[]) - argv[] should not be there
- first macro in the file (AssistTest) is ignored
- when scope is selected in navigator, search should be ingored
@ -86,11 +84,12 @@ ISUES:
- AutoComplete remove duplicate lines
- Indexer.cpp refs
[3, 417] Upp::Stream::operator // operator<< ?
- Indexer.cpp refs (issue with macro)
[3, 417] Upp::operator
[3, 417] Upp::VppLog()
[3, 417] Upp::EOL
- Indexer.cpp refs
[3, 418] CoEvent::Broadcast() // somehow choose Indexer::event here
[9, 418] CoEvent::Broadcast()
[3, 418] Indexer::event
@ -120,16 +119,25 @@ ISUES:
- Time GatherDependencies(const String& path, VectorMap<String, Time>& result, Index<String>& define_includes,
Alt+I next line "No relevant..."
- No autocomplete in void MainConfigDlg::FlagDlg()
- void MainConfigDlg::FlagDlg() no Upp function on Ctrl+Space
- TriggerIndexer should probably also restart CurrentFile and maybe autocomplete
- TriggerIndexer on theide exit
- different master header currentfile / index issue
- DLOG(CleanupId(s)); - jump on CleanupId does go to DLOG (it has a good reason to, but anyway...)
- In CONSOLE_APP_MAIN jumps do not wrok
- Alt-K - maybe should show declaration/definition too?
- Indexer.cpp [7, 423] (Indexer::Job&,const Upp::String&)const
- Indexer.cpp [32, 368] FileAnnotation&&)(false)
- Alt-K in void AssistEditor::Assist(bool macros) does not show all (_Bool problem?)
- In Navigator, Assist should be before AssistEditor, when search is "Assist"
GREAT CODEBASE PURGE:
@ -204,6 +212,15 @@ LATER:
DONE:
- No autocomplete in void MainConfigDlg::FlagDlg()
- void MainConfigDlg::FlagDlg() no Upp function on Ctrl+Space
- id = main(int,const char*argv[]) - argv[] should not be there
- Indexer.cpp refs
[3, 417] Upp::Stream::operator // operator<< ?
- FlagDlg
- Size SplashCtrl::MakeLogo(Ctrl& parent, Array<Ctrl>& ctrl)

View file

@ -386,10 +386,8 @@ void Ide::SaveFile0(bool always)
FindFile ff(editfile);
fd.filetime = edittime = ff.GetLastWriteTime();
if(editor.IsDirty()) {
DLOG("========= Saved " << editfile);
if(editor.IsDirty())
TriggerIndexer();
}
editor.ClearDirty();

View file

@ -118,15 +118,6 @@ GUI_APP_MAIN
void AppMain___()
#endif
{
#if 0 _DBG_
PPInfo ppi;
VectorMap<String, Time> files;
ppi.SetIncludes("C:\\u\\llvm_ide\\uppsrc\\Core");
ppi.GatherDependencies("C:\\u\\llvm_ide\\uppsrc\\Core\\Cpu.cpp", files);
DDUMPM(files);
return;
#endif
// Ctrl::ShowRepaint(50);
#ifdef flagPEAKMEM

View file

@ -1,4 +1,26 @@
* C:\upp\out\llvm_tests\CLANGx64.Debug.Debug_Full\ide_CleanupId.exe 29.07.2022 01:06:12, user: cxl
* C:\upp\out\llvm_tests\CLANGx64.Debug.Debug_Full\ide_CleanupId.exe 06.08.2022 14:31:04, user: cxl
CleanupId("Upp::Index<Upp::String>::Find(const Upp::String &k) const") = Upp::Index::Find(const Upp::String&)const
CleanupId("clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property, unsigned int Value) __attribute__((dllimport))") = clang_PrintingPolicy_setProperty(CXPrintingPolicy,CXPrintingPolicyProperty,unsigned int)
======
Foo1::operator<<(int)
Foo1::operator<<(int)
======
Foo1::operator<(int)
Foo1::operator<(int)
======
Upp::Index<Upp::String>::Find(const Upp::String &k) const
Upp::Index::Find(const Upp::String&)const
======
clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property, unsigned int Value) __attribute__((dllimport))
clang_PrintingPolicy_setProperty(CXPrintingPolicy,CXPrintingPolicyProperty,unsigned int)
======
Foo1::Method()
Foo1::Method()
======
Foo3<int>::Foo3() noexcept
Foo3::Foo3()
======
Foo1::operator*(int)
Foo1::operator*(int)
======
main(int argc, const char *argv[])
main(int,const char*[])

View file

@ -6,8 +6,26 @@ CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
DDUMP(CleanupId("Upp::Index<Upp::String>::Find(const Upp::String &k) const"));
DDUMP(CleanupId("clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property, unsigned int Value) __attribute__((dllimport))"));
#if 0
String s = CleanupId("main(int argc, const char *argv[])");
DDUMP(s);
return;
#endif
for(String s : {
"Foo1::operator<<(int)",
"Foo1::operator<(int)",
"Upp::Index<Upp::String>::Find(const Upp::String &k) const",
"clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property, unsigned int Value) __attribute__((dllimport))",
"Foo1::Method()",
"Foo3<int>::Foo3() noexcept",
"Foo1::operator*(int)",
"main(int argc, const char *argv[])",
}) {
DLOG("======");
DLOG(s);
DLOG(CleanupId(s));
}
CheckLogEtalon();
}