diff --git a/uppsrc/Core/Parser.h b/uppsrc/Core/Parser.h index 7add18770..aa901c0b1 100644 --- a/uppsrc/Core/Parser.h +++ b/uppsrc/Core/Parser.h @@ -73,6 +73,7 @@ public: void Skip(); void SkipTerm() { Skip(); } + void SkipLine(); struct Pos { const char *ptr; diff --git a/uppsrc/Core/parser.cpp b/uppsrc/Core/parser.cpp index fb07d1fd9..fb94135dd 100644 --- a/uppsrc/Core/parser.cpp +++ b/uppsrc/Core/parser.cpp @@ -549,7 +549,7 @@ void CParser::Skip() term++; else if(IsString()) - ReadString(); + ReadString(false); else if(IsChar('\'')) ReadString('\'', false); @@ -564,6 +564,19 @@ void CParser::Skip() DoSpaces(); } +void CParser::SkipLine() +{ + while(*term) { + if(*term == '\n') { + line++; + lineptr = term + 1; + term++; + break; + } + term++; + } +} + CParser::Pos CParser::GetPos() const { Pos p; diff --git a/uppsrc/Core/src.tpp/CParser_en-us.tpp b/uppsrc/Core/src.tpp/CParser_en-us.tpp index 4221d086c..532cbefa5 100644 --- a/uppsrc/Core/src.tpp/CParser_en-us.tpp +++ b/uppsrc/Core/src.tpp/CParser_en-us.tpp @@ -373,6 +373,11 @@ is advanced by 1 character.&] [s2;%% Same as Skip, legacy name.&] [s3; &] [s4; &] +[s5;:Upp`:`:CParser`:`:SkipLine`(`): [@(0.0.255) void] [* SkipLine]()&] +[s2;%% Skips everything from current position to the end of line. +.&] +[s3; &] +[s4; &] [s5;:CParser`:`:GetPtr`(`)const: [@(0.0.255) const]_[@(0.0.255) char]_`*[* GetPtr]()_[@(0.0.255) c onst]&] [s2;%% Returns a pointer to the current position.&] diff --git a/uppsrc/ide/idebar.cpp b/uppsrc/ide/idebar.cpp index bd111d48c..f5da58889 100644 --- a/uppsrc/ide/idebar.cpp +++ b/uppsrc/ide/idebar.cpp @@ -200,7 +200,6 @@ void Ide::EditSpecial(Bar& menu) .Help("Comment code lines"); menu.Add(b && editor.IsSelection(), AK_UNCOMMENT, THISBACK(UnComment)) .Help("Uncomment code"); - FindDs(menu); menu.MenuSeparator(); menu.Add(AK_COPY_POSITION, [=] { CopyPosition(); }); menu.Add(AK_GOTO_POSITION, [=] { GotoPosition(); }); diff --git a/uppsrc/ide/idetool.cpp b/uppsrc/ide/idetool.cpp index 6e222b3d7..a08059dd3 100644 --- a/uppsrc/ide/idetool.cpp +++ b/uppsrc/ide/idetool.cpp @@ -534,9 +534,6 @@ void Ide::FindDs(int where) { SaveFile(); - static Index ds = { "DLOG", "DDUMP", "DDUMPC", "DDUMPM", "DTIMING", - "DLOGHEX", "DDUMPHEX", "DTIMESTOP", "DHITCOUNT" }; - NewFFound(); String nest_dir = GetPathNest(editfile); @@ -567,6 +564,42 @@ void Ide::FindDs(int where) for(String fn : files) { if(pi.SetCanceled(n++, files.GetCount())) break; + + if(GetFileLength(fn) < 10*1024*1024) { + String text = LoadFile(fn); + try { + CParser p(text); + bool ignore = false; + while(!p.IsEof()) { + CParser::Pos pos = p.GetPos(); + if(p.Char('#')) { + if(p.Id("if") || p.Id("ifdef")) + ignore = true; + else + if(p.Id("endif")) + ignore = false; + p.SkipLine(); + } + else + if(p.IsId()) { + static Index ds = { "DLOG", "DDUMP", "DDUMPC", "DDUMPM", "DTIMING", + "DLOGHEX", "DDUMPHEX", "DTIMESTOP", "DHITCOUNT" }; + String id = p.ReadId(); + if(ds.Find(id) >= 0 && p.Char('(') && !ignore) { + String line; + for(const char *s = pos.lineptr; findarg(*s, '\0', '\r', '\n') < 0; s++) + line.Cat(*s); + AddFoundFile(fn, pos.line, line, pos.ptr - pos.lineptr, id.GetCount()); + } + } + else + p.Skip(); + } + } + catch(CParser::Error) {} + } + } + /* FileIn in(fn); int line = 0; while(!in.IsEof()) { @@ -590,6 +623,7 @@ void Ide::FindDs(int where) catch(CParser::Error) {} } } + */ FFoundFinish(); }