From cb33f077e1f510a15ec5b387192eefcd86ced60b Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 9 Jun 2009 16:01:59 +0000 Subject: [PATCH] Assist++ now supports .sch files git-svn-id: svn://ultimatepp.org/upp/trunk@1292 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/XML.cpp | 4 +- uppsrc/ide/Assist.cpp | 2 +- uppsrc/ide/Browser/Base.cpp | 10 ++++- uppsrc/ide/Browser/Browser.h | 1 + uppsrc/ide/Browser/Browser.upp | 1 + uppsrc/ide/Browser/Sch.cpp | 79 ++++++++++++++++++++++++++++++++++ uppsrc/ide/Browser/init | 2 +- 7 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 uppsrc/ide/Browser/Sch.cpp diff --git a/uppsrc/Core/XML.cpp b/uppsrc/Core/XML.cpp index 8d9bb8fe6..8e6c47b19 100644 --- a/uppsrc/Core/XML.cpp +++ b/uppsrc/Core/XML.cpp @@ -79,7 +79,7 @@ String XmlTag::operator()(const char* text) StringBuffer r; r << tag << '>'; if(strchr(text, '\n')) { - r << "\r\n" + r << "\r\n"; bool tab = true; while(*text) { if(tab) @@ -87,7 +87,7 @@ String XmlTag::operator()(const char* text) int c = (byte)*text++; tab = c == '\n'; if(tab) - r << "\r\n" + r << "\r\n"; else if(c == '\t' || c >= 32) r.Cat(c); diff --git a/uppsrc/ide/Assist.cpp b/uppsrc/ide/Assist.cpp index 23f2558ed..dd9cdfc2f 100644 --- a/uppsrc/ide/Assist.cpp +++ b/uppsrc/ide/Assist.cpp @@ -308,7 +308,7 @@ void AssistEditor::SyncAssist() && memcmp(name, m.name, name.GetCount()) : memcmp(name, m.name, name.GetCount()) == 0)) { int q = over.Find(m.name); - if(q < 0 || over[q] == m.typei) { + if(q < 0 || over[q] == m.typei && m.scope.GetCount()) { assist.Add(RawToValue(m)); if(q < 0) over.Add(m.name, m.typei); diff --git a/uppsrc/ide/Browser/Base.cpp b/uppsrc/ide/Browser/Base.cpp index d9421ce06..47d2f7e0a 100644 --- a/uppsrc/ide/Browser/Base.cpp +++ b/uppsrc/ide/Browser/Base.cpp @@ -181,7 +181,7 @@ void UpdateCodeBase(Progress& pi) String ext = ToUpper(GetFileExt(path)); if(ext == ".C" || ext == ".CPP" || ext == ".CC" || ext == ".CXX" || ext == ".H" || ext == ".HPP" || ext == ".HH" || ext == ".HXX" || - ext == ".LAY") { + ext == ".LAY" || ext == ".SCH") { fp.Add(path); int q = set.Find(path); Time tm = FileGetTime(path); @@ -218,6 +218,9 @@ void UpdateCodeBase(Progress& pi) String ext = ToUpper(GetFileExt(s_file)); if(ext == ".LAY") ScanLayFile(s_file); + else + if(ext == ".SCH") + ScanSchFile(s_file); else { FileIn fi(s_file); Parse(fi, ignore, base, s_file, callback(BrowserScanError)); @@ -236,7 +239,10 @@ void CodeBaseScan(Stream& s, const String& fn) remove.Add(fn); Remove(base, remove); LLOG("Scan3 " << tm); - Parse(s, IgnoreList(), base, fn, CNULL); + if(ToUpper(GetFileExt(fn)) == ".SCH") + ScanSchFile(fn); + else + Parse(s, IgnoreList(), base, fn, CNULL); LLOG("Scan4 " << tm); FinishBase(); LLOG("Scan total " << tm); diff --git a/uppsrc/ide/Browser/Browser.h b/uppsrc/ide/Browser/Browser.h index 90c32222e..42c707cb4 100644 --- a/uppsrc/ide/Browser/Browser.h +++ b/uppsrc/ide/Browser/Browser.h @@ -30,6 +30,7 @@ void ReQualifyCodeBase(); void CodeBaseScanLay(const String& fn); void ScanLayFile(const char *fn); +void ScanSchFile(const char *fn); String MakeCodeRef(const String& scope, const String& item); void SplitCodeRef(const String& ref, String& scope, String& item); diff --git a/uppsrc/ide/Browser/Browser.upp b/uppsrc/ide/Browser/Browser.upp index 9971f87bb..bb9acfc25 100644 --- a/uppsrc/ide/Browser/Browser.upp +++ b/uppsrc/ide/Browser/Browser.upp @@ -10,6 +10,7 @@ file Browser.h, Browser readonly separator, Lay.cpp, + Sch.cpp, Base.cpp optimize_speed, Util.cpp, Item.cpp, diff --git a/uppsrc/ide/Browser/Sch.cpp b/uppsrc/ide/Browser/Sch.cpp new file mode 100644 index 000000000..d08f864c6 --- /dev/null +++ b/uppsrc/ide/Browser/Sch.cpp @@ -0,0 +1,79 @@ +#include "Browser.h" + +String ReadId(CParser& p, String& rr) +{ + p.Char('('); + String id = p.ReadId(); + p.Char(','); + if(p.IsNumber()) + p.ReadNumber(); + p.Char(','); + if(p.IsNumber()) + p.ReadNumber(); + p.Char(')'); + rr << "SqlId " << id << "(\"" << id << "\");\n"; + return id; +} + +void ScanSchFile(const char *fn) +{ + String s = LoadFile(fn); + CParser p(s); + String r, rr; + while(!p.IsEof()) + try { + if(p.Id("TABLE") || p.Id("TABLE_") || p.Id("TYPE") || p.Id("TYPE_")) + r << "struct S_" << ReadId(p, rr) << " {\n"; + else + if(p.Id("END_TABLE") || p.Id("END_TYPE")) + r << "};\n"; + else + if(p.Id("LONGRAW") || p.Id("LONGRAW_") || p.Id("BLOB") || p.Id("BLOB_") || + p.Id("BOOL") || p.Id("BOOL_") || p.Id("STRING_") || p.Id("STRING")) + r << "\tString " << ReadId(p, rr) << ";\n"; + else + if(p.Id("INT") || p.Id("INT_")) + r << "\tint " << ReadId(p, rr) << ";\n"; + else + if(p.Id("DOUBLE") || p.Id("DOUBLE_")) + r << "\tdouble " << ReadId(p, rr) << ";\n"; + else + if(p.Id("TIME") || p.Id("TIME_")) + r << "\tTime " << ReadId(p, rr) << ";\n"; + else + if(p.Id("DATE") || p.Id("DATE_")) + r << "\tDate " << ReadId(p, rr) << ";\n"; + else + if(p.Id("BIT") || p.Id("BIT_")) + r << "\tbool " << ReadId(p, rr) << ";\n"; + else + if(p.Id("BOOL_ARRAY") || p.Id("BOOL_ARRAY_")) + r << "\tString " << ReadId(p, rr) << "[1];\n"; + else + if(p.Id("INT_ARRAY") || p.Id("INT_ARRAY_")) + r << "\tint " << ReadId(p, rr) << "[1];\n"; + else + if(p.Id("DOUBLE_ARRAY") || p.Id("DOUBLE_ARRAY_")) + r << "\tdouble " << ReadId(p, rr) << "[1];\n"; + else + if(p.Id("TIME_ARRAY") || p.Id("TIME_ARRAY_")) + r << "\tTime " << ReadId(p, rr) << "[1];\n"; + else + if(p.Id("DATE_ARRAY") || p.Id("DATE_ARRAY_")) + r << "\tDate " << ReadId(p, rr) << "[1];\n"; + else + if(p.Id("BIT_ARRAY") || p.Id("BIT_ARRAY_")) + r << "\tbool " << ReadId(p, rr) << "[1];\n"; + else + if(p.Id("SEQUENCE") || p.Id("SEQUENCE_")) + ReadId(p, rr); + else + p.SkipTerm(); + } + catch(CParser::Error) + {} + r << "\n" << rr; + StringStream ss(r); + CppBase& base = CodeBase(); + Parse(ss, IgnoreList(), base, fn, CNULL); +} diff --git a/uppsrc/ide/Browser/init b/uppsrc/ide/Browser/init index 12bb44486..d3d1ffd31 100644 --- a/uppsrc/ide/Browser/init +++ b/uppsrc/ide/Browser/init @@ -4,7 +4,7 @@ #include "ide\Common/init" #include "PdfDraw/init" #include "RichEdit/init" -#define BLITZ_INDEX__ FCB83C9D580625CD4EAD50BEDC296DB64 +#define BLITZ_INDEX__ FB5C792D5E6989A57EBD963D0F3A0F4E9 #include "TopicI.icpp" #undef BLITZ_INDEX__ #endif