mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
git-svn-id: svn://ultimatepp.org/upp/trunk@8494 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b59afc5231
commit
c1b2a4a5dc
10 changed files with 89 additions and 56 deletions
|
|
@ -107,6 +107,9 @@ struct FlatPP {
|
|||
|
||||
const FlatPP& GetFlatPPFile(const char *path); // with #includes resolved
|
||||
|
||||
String NormalizeSourcePath(const String& path, const String& currdir);
|
||||
String NormalizeSourcePath(const String& path);
|
||||
|
||||
void ClearSources();
|
||||
const Index<String>& GetAllSources();
|
||||
void GatherSources(const String& master_path, const String& path_);
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ void Cpp::DoFlatInclude(const String& header_path)
|
|||
|
||||
void Cpp::Do(const String& sourcefile, Stream& in, const String& currentfile, bool get_macros)
|
||||
{
|
||||
LLOG("Cpp::Do " << sourcefile << ", current: " << currentfile);
|
||||
if(visited.Find(currentfile) >= 0 || visited.GetCount() > 20000)
|
||||
return;
|
||||
visited.Add(currentfile);
|
||||
|
|
|
|||
|
|
@ -341,11 +341,11 @@ String GetIncludePath0(const char *s, const char *filedir)
|
|||
while(*s != '\r' && *s != '\n') {
|
||||
if(*s == type) {
|
||||
if(type == '\"') {
|
||||
String fn = NormalizePath(name, filedir);
|
||||
String fn = NormalizeSourcePath(name, filedir);
|
||||
if(FileExists(fn))
|
||||
return fn;
|
||||
}
|
||||
return GetFileOnPath(name, GetIncludePath(), false);
|
||||
return NormalizeSourcePath(GetFileOnPath(name, GetIncludePath(), false));
|
||||
}
|
||||
name.Cat(*s++);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,21 @@ NAMESPACE_UPP
|
|||
static VectorMap<String, String> sSrcFile;
|
||||
static Index<uint64> sIncludes;
|
||||
|
||||
String NormalizeSourcePath(const String& path, const String& currdir)
|
||||
{
|
||||
LTIMING("NormalizeSourcePath");
|
||||
#ifdef PLATFORM_WIN32
|
||||
return ToLower(NormalizePath(path, currdir));
|
||||
#else
|
||||
return NormalizePath(path, currdir);
|
||||
#endif
|
||||
}
|
||||
|
||||
String NormalizeSourcePath(const String& path)
|
||||
{
|
||||
return NormalizeSourcePath(path, GetCurrentDirectory());
|
||||
}
|
||||
|
||||
void ClearSources()
|
||||
{
|
||||
sSrcFile.Clear();
|
||||
|
|
@ -26,7 +41,7 @@ const VectorMap<String, String>& GetAllSourceMasters()
|
|||
void GatherSources(const String& master_path, const String& path_, Vector<int>& parents)
|
||||
{
|
||||
RHITCOUNT("GatherSources");
|
||||
String path = NormalizePath(path_);
|
||||
String path = NormalizeSourcePath(path_);
|
||||
if(sSrcFile.Find(path) >= 0)
|
||||
return;
|
||||
int ii = sSrcFile.GetCount();
|
||||
|
|
@ -47,7 +62,7 @@ void GatherSources(const String& master_path, const String& path)
|
|||
{
|
||||
LTIMING("GatherSources");
|
||||
Vector<int> parents;
|
||||
GatherSources(master_path, path, parents);
|
||||
GatherSources(NormalizeSourcePath(master_path), path, parents);
|
||||
}
|
||||
|
||||
String GetMasterFile(const String& file)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
#define LLOG(x)
|
||||
#endif
|
||||
|
||||
#define LTIMING(x)
|
||||
|
||||
class IndexSeparatorFrameCls : public CtrlFrame {
|
||||
virtual void FrameLayout(Rect& r) { r.right -= 1; }
|
||||
virtual void FramePaint(Draw& w, const Rect& r) {
|
||||
|
|
@ -286,41 +288,37 @@ Vector<String> AssistEditor::ReadBack(int q)
|
|||
return r;
|
||||
}
|
||||
|
||||
int memcmp_i(const char *s, const char *t, int n)
|
||||
{
|
||||
while(n--) {
|
||||
int q = ToUpper(*s++) - ToUpper(*t++);
|
||||
if(q)
|
||||
return q;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AssistEditor::SyncAssist()
|
||||
{
|
||||
String name;
|
||||
name = ReadIdBack(GetCursor(), include_assist);
|
||||
LTIMING("SyncAssist");
|
||||
String name = ReadIdBack(GetCursor(), include_assist);
|
||||
String uname = ToUpper(name);
|
||||
assist.Clear();
|
||||
int typei = type.GetCursor() - 1;
|
||||
for(int p = 0; p < 2; p++) {
|
||||
Buffer<bool> found(assist_item.GetCount(), false);
|
||||
for(int pass = 0; pass < 2; pass++) {
|
||||
VectorMap<String, int> over;
|
||||
LTIMING("FindPass");
|
||||
for(int i = 0; i < assist_item.GetCount(); i++) {
|
||||
const CppItemInfo& m = assist_item[i];
|
||||
if((typei < 0 || m.typei == typei) &&
|
||||
(p ? memcmp_i(name, m.name, name.GetCount()) == 0
|
||||
&& memcmp(name, m.name, name.GetCount())
|
||||
: memcmp(name, m.name, name.GetCount()) == 0)) {
|
||||
int q = include_assist ? -1 : over.Find(m.name);
|
||||
if(q < 0 || over[q] == m.typei && m.scope.GetCount()) {
|
||||
assist.Add(RawToValue(m));
|
||||
if(q < 0)
|
||||
over.Add(m.name, m.typei);
|
||||
}
|
||||
if(!found[i] &&
|
||||
(typei < 0 || m.typei == typei) &&
|
||||
(pass ? m.uname.StartsWith(uname) : m.name.StartsWith(name))) {
|
||||
int q = include_assist ? -1 : over.Find(m.name);
|
||||
if(q < 0 || over[q] == m.typei && m.scope.GetCount()) {
|
||||
LTIMING("Assist Add");
|
||||
found[i] = true;
|
||||
assist.Add(RawToValue(m));
|
||||
if(q < 0)
|
||||
over.Add(m.name, m.typei);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!include_assist)
|
||||
if(!include_assist) {
|
||||
LTIMING("Sort assist");
|
||||
assist.Sort(0, CppItemInfoOrder);
|
||||
}
|
||||
}
|
||||
|
||||
bool AssistEditor::IncludeAssist()
|
||||
|
|
@ -408,6 +406,7 @@ bool AssistEditor::IncludeAssist()
|
|||
|
||||
void AssistEditor::Assist()
|
||||
{
|
||||
LTIMING("Assist");
|
||||
if(!assist_active)
|
||||
return;
|
||||
CloseAssist();
|
||||
|
|
@ -432,6 +431,7 @@ void AssistEditor::Assist()
|
|||
thisback = true;
|
||||
thisbackn = false;
|
||||
GatherItems(parser.current_scope, false, in_types, false);
|
||||
RemoveDuplicates();
|
||||
PopUpAssist();
|
||||
return;
|
||||
}
|
||||
|
|
@ -439,6 +439,7 @@ void AssistEditor::Assist()
|
|||
thisback = true;
|
||||
thisbackn = true;
|
||||
GatherItems(parser.current_scope, false, in_types, false);
|
||||
RemoveDuplicates();
|
||||
PopUpAssist();
|
||||
return;
|
||||
}
|
||||
|
|
@ -461,13 +462,15 @@ void AssistEditor::Assist()
|
|||
}
|
||||
else {
|
||||
GatherItems(parser.current_scope, false, in_types, true);
|
||||
Index<String> in_types2;
|
||||
Vector<String> usings = Split(parser.context.namespace_using, ';');
|
||||
for(int i = 0; i < usings.GetCount(); i++)
|
||||
GatherItems(usings[i], false, in_types2, true);
|
||||
GatherItems("", false, in_types2, true);
|
||||
if(parser.current_scope != usings[i]) // Do not scan namespace already scanned
|
||||
GatherItems(usings[i], false, in_types, true);
|
||||
if(parser.current_scope.GetCount()) // Do not scan global namespace twice
|
||||
GatherItems("", false, in_types, true);
|
||||
}
|
||||
}
|
||||
RemoveDuplicates();
|
||||
PopUpAssist();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,10 +201,9 @@ struct AssistEditor : CodeEditor, Navigator {
|
|||
void Virtuals();
|
||||
void Thisbacks();
|
||||
void AssistItemAdd(const String& scope, const CppItem& m, int typei);
|
||||
void GatherItems0(const String& type, bool only_public, Index<String>& in_types,
|
||||
bool types);
|
||||
void GatherItems(const String& type, bool only_public, Index<String>& in_types,
|
||||
bool types);
|
||||
void RemoveDuplicates();
|
||||
|
||||
void SelParam();
|
||||
int Ch(int q);
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ void BaseInfoSync(Progress& pi)
|
|||
|
||||
int GetSourceFileIndex(const String& path)
|
||||
{
|
||||
return source_file.FindPut(path);
|
||||
return source_file.FindPut(NormalizeSourcePath(path));
|
||||
}
|
||||
|
||||
String GetSourceFilePath(int file)
|
||||
|
|
@ -232,7 +232,8 @@ bool CheckFile(SourceFileInfo& f, const String& path)
|
|||
return true;
|
||||
Cpp pp;
|
||||
FileIn in(path);
|
||||
pp.Preprocess(path, in, GetMasterFile(path), true);
|
||||
String npath = NormalizeSourcePath(path);
|
||||
pp.Preprocess(npath, in, GetMasterFile(npath), true);
|
||||
String included_id_macros = pp.GetIncludedMacroValues(f.ids.GetKeys());
|
||||
if(f.included_id_macros != included_id_macros) {
|
||||
f.depends_time = Null;
|
||||
|
|
|
|||
|
|
@ -297,14 +297,17 @@ void Ide::ContextGoto0(int pos)
|
|||
q = CodeBase().Find(scope[j]);
|
||||
if(q >= 0) {
|
||||
const Array<CppItem>& n = CodeBase()[q];
|
||||
for(int pass = 0; pass < 2; pass++)
|
||||
for(int i = 0; i < n.GetCount(); i++) {
|
||||
if((pass || !istype[j] || n[i].IsType()) && n[i].name == id) {
|
||||
JumpToDefinition(n, i, scope[j]);
|
||||
FindId(id);
|
||||
return;
|
||||
for(int anyfile = 0; anyfile < 2; anyfile++)
|
||||
for(int pass = 0; pass < 2; pass++)
|
||||
for(int i = 0; i < n.GetCount(); i++) {
|
||||
if(n[i].name == id
|
||||
&& (pass || !istype[j] || n[i].IsType())
|
||||
&& (anyfile || findarg(n[i].filetype, FILE_CPP, FILE_C) >= 0)) {
|
||||
JumpToDefinition(n, i, scope[j]);
|
||||
FindId(id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
#define LLOG(x)
|
||||
#endif
|
||||
|
||||
#define LTIMING(x)
|
||||
|
||||
static Array<CppItem> sEmpty;
|
||||
|
||||
const Array<CppItem>& GetTypeItems(const String& type)
|
||||
|
|
@ -117,12 +119,15 @@ void AssistScanError(int line, const String& text)
|
|||
|
||||
void AssistEditor::Context(Parser& parser, int pos)
|
||||
{
|
||||
LTIMING("Context");
|
||||
|
||||
theide->ScanFile(false);
|
||||
String s = Get(0, pos);
|
||||
StringStream ss(s);
|
||||
|
||||
Cpp cpp;
|
||||
cpp.Preprocess(theide->editfile, ss, GetMasterFile(theide->editfile));
|
||||
String path = NormalizeSourcePath(theide->editfile);
|
||||
cpp.Preprocess(path, ss, GetMasterFile(path));
|
||||
|
||||
parser.dobody = true;
|
||||
StringStream pin(cpp.output);
|
||||
|
|
@ -273,13 +278,15 @@ int CharFilterT(int c)
|
|||
|
||||
void AssistEditor::AssistItemAdd(const String& scope, const CppItem& m, int typei)
|
||||
{
|
||||
if(*m.name == '.' || m.name.GetCount() == 0)
|
||||
return;
|
||||
CppItemInfo& f = assist_item.Add(m.name);
|
||||
f.typei = typei;
|
||||
f.scope = scope;
|
||||
(CppItem&)f = m;
|
||||
}
|
||||
|
||||
void AssistEditor::GatherItems0(const String& type, bool only_public, Index<String>& in_types, bool types)
|
||||
void AssistEditor::GatherItems(const String& type, bool only_public, Index<String>& in_types, bool types)
|
||||
{
|
||||
LLOG("GatherItems " << type);
|
||||
if(in_types.Find(type) >= 0) {
|
||||
|
|
@ -292,6 +299,7 @@ void AssistEditor::GatherItems0(const String& type, bool only_public, Index<Stri
|
|||
int q = CodeBase().Find(ntp);
|
||||
if(q >= 0) {
|
||||
if(types) {
|
||||
LLOG("GatherItems types");
|
||||
if(ntp.GetCount())
|
||||
ntp << "::";
|
||||
int typei = assist_type.FindAdd("<types>");
|
||||
|
|
@ -338,7 +346,7 @@ void AssistEditor::GatherItems0(const String& type, bool only_public, Index<Stri
|
|||
ResolveTParam(b, tparam);
|
||||
for(int i = 0; i < b.GetCount(); i++)
|
||||
if(b[i].GetCount())
|
||||
GatherItems0(b[i], only_public, in_types, types);
|
||||
GatherItems(b[i], only_public, in_types, types);
|
||||
}
|
||||
}
|
||||
in_types.Drop();
|
||||
|
|
@ -346,24 +354,24 @@ void AssistEditor::GatherItems0(const String& type, bool only_public, Index<Stri
|
|||
|
||||
bool OrderAssistItems(const CppItemInfo& a, const CppItemInfo& b)
|
||||
{
|
||||
if(a.impl != b.impl)
|
||||
return b.impl;
|
||||
if(a.typei != b.typei)
|
||||
return a.typei < b.typei;
|
||||
return a.qitem < b.qitem;
|
||||
}
|
||||
|
||||
void AssistEditor::GatherItems(const String& type, bool only_public, Index<String>& in_types, bool types)
|
||||
void AssistEditor::RemoveDuplicates()
|
||||
{
|
||||
int i0 = assist_item.GetCount();
|
||||
GatherItems0(type, only_public, in_types, types);
|
||||
StableSort(assist_item.Begin() + i0, assist_item.End(), OrderAssistItems);
|
||||
LTIMING("RemoveDuplicates");
|
||||
StableSort(assist_item, OrderAssistItems);
|
||||
Vector<int> remove;
|
||||
int i = i0;
|
||||
while(i < assist_item.GetCount()) {
|
||||
int i = 0;
|
||||
while(i < assist_item.GetCount()) { // Remove identical items
|
||||
int ii = i;
|
||||
i++;
|
||||
while(i < assist_item.GetCount() && assist_item[i].qitem == assist_item[ii].qitem)
|
||||
while(i < assist_item.GetCount()
|
||||
&& assist_item[ii].typei == assist_item[i].typei
|
||||
&& assist_item[ii].qitem == assist_item[i].qitem)
|
||||
remove.Add(i++);
|
||||
i++;
|
||||
}
|
||||
assist_item.Remove(remove);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ file
|
|||
EditorTabBar.cpp,
|
||||
Bottom.cpp,
|
||||
t.cpp,
|
||||
Cpp.cpp,
|
||||
Assist.h,
|
||||
Cpp.cpp,
|
||||
Assist.cpp,
|
||||
DCopy.cpp,
|
||||
ContextGoto.cpp,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue