mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-25 22:03:45 -06:00
ide: Fixed issue with Usage of file-static variables
This commit is contained in:
parent
9cf23b19f5
commit
dd1fb4b2fc
9 changed files with 75 additions and 28 deletions
|
|
@ -150,6 +150,7 @@ void Ide::Usage(const String& id, const String& name, Point ref_pos)
|
|||
}
|
||||
else {
|
||||
bool isvirtual = false;
|
||||
bool isstatic = false;
|
||||
bool istype = false;
|
||||
String cls;
|
||||
Progress pi("Indexing files");
|
||||
|
|
@ -160,15 +161,19 @@ void Ide::Usage(const String& id, const String& name, Point ref_pos)
|
|||
}
|
||||
for(const auto& f : ~CodeIndex())
|
||||
for(const AnnotationItem& m : f.value.items) {
|
||||
if(m.id == id && m.isvirtual) {
|
||||
isvirtual = true;
|
||||
cls = m.nest;
|
||||
break;
|
||||
}
|
||||
if(m.id == id && IsStruct(m.kind)) {
|
||||
istype = true;
|
||||
cls = m.nest;
|
||||
break;
|
||||
if(m.id == id) {
|
||||
if(m.isvirtual) {
|
||||
isvirtual = true;
|
||||
cls = m.nest;
|
||||
break;
|
||||
}
|
||||
if(IsStruct(m.kind)) {
|
||||
istype = true;
|
||||
cls = m.nest;
|
||||
break;
|
||||
}
|
||||
if(m.id == id && m.isstatic && f.key == editfile)
|
||||
isstatic = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -196,32 +201,35 @@ void Ide::Usage(const String& id, const String& name, Point ref_pos)
|
|||
GatherVirtuals(bases, cls, signature, ids, visited);
|
||||
}
|
||||
|
||||
UsageId(name, id, ids, istype, unique);
|
||||
UsageId(name, id, ids, istype, isstatic, unique);
|
||||
}
|
||||
|
||||
UsageFinish();
|
||||
}
|
||||
|
||||
void Ide::UsageId(const String& name, const String& id, const Index<String>& ids, bool istype, Index<String>& unique)
|
||||
void Ide::UsageId(const String& name, const String& id, const Index<String>& ids, bool istype, bool isstatic, Index<String>& unique)
|
||||
{
|
||||
int q = id.ReverseFind("::");
|
||||
String constructor = id + "::" + (q >= 0 ? id.Mid(q + 2) : id) + "(";
|
||||
String destructor = id + "::~(";
|
||||
SortByKey(CodeIndex());
|
||||
for(int src = 0; src < 2; src++)
|
||||
for(const auto& f : ~CodeIndex())
|
||||
if((findarg(GetFileExt(f.key), ".h", "") < 0) == src) { // headers first
|
||||
auto Add = [&](Point mpos) {
|
||||
AddReferenceLine(f.key, mpos, name, unique);
|
||||
};
|
||||
for(const AnnotationItem& m : f.value.items) {
|
||||
if(ids.Find(m.id) >= 0 || istype && (m.id.StartsWith(constructor) || m.id.StartsWith(destructor)))
|
||||
Add(m.pos);
|
||||
for(const auto& f : ~CodeIndex()) {
|
||||
if(!isstatic || f.key == editfile)
|
||||
if((findarg(GetFileExt(f.key), ".h", "") < 0) == src) { // headers first
|
||||
auto Add = [&](Point mpos) {
|
||||
AddReferenceLine(f.key, mpos, name, unique);
|
||||
};
|
||||
for(const AnnotationItem& m : f.value.items) {
|
||||
if(ids.Find(m.id) >= 0 || istype && (m.id.StartsWith(constructor) || m.id.StartsWith(destructor)))
|
||||
Add(m.pos);
|
||||
}
|
||||
for(const ReferenceItem& m : f.value.refs)
|
||||
if(ids.Find(m.id) >= 0) {
|
||||
Add(m.pos);
|
||||
}
|
||||
}
|
||||
for(const ReferenceItem& m : f.value.refs)
|
||||
if(ids.Find(m.id) >= 0)
|
||||
Add(m.pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ide::UsageFinish()
|
||||
|
|
@ -279,7 +287,7 @@ void Ide::FindDesignerItemReferences(const String& id, const String& name)
|
|||
ids.Add(m.id);
|
||||
SetFFound(ffoundi_next);
|
||||
FFound().Clear();
|
||||
UsageId(name, m.id, ids, IsStruct(m.kind), unique);
|
||||
UsageId(name, m.id, ids, IsStruct(m.kind), m.isstatic, unique);
|
||||
UsageFinish();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ void AnnotationItem::Serialize(Stream& s)
|
|||
% pos
|
||||
% definition
|
||||
% isvirtual
|
||||
% isstatic
|
||||
% name
|
||||
% type
|
||||
% id
|
||||
|
|
@ -105,7 +106,8 @@ void ReferenceItem::Serialize(Stream& s)
|
|||
{
|
||||
s % id
|
||||
% pos
|
||||
% ref_pos;
|
||||
% ref_pos
|
||||
;
|
||||
}
|
||||
|
||||
void FileAnnotation::Serialize(Stream& s)
|
||||
|
|
@ -115,7 +117,8 @@ void FileAnnotation::Serialize(Stream& s)
|
|||
% master_file
|
||||
% time
|
||||
% items
|
||||
% refs;
|
||||
% refs
|
||||
;
|
||||
}
|
||||
|
||||
String CachedAnnotationPath(const String& source_file, const String& defines, const String& includes, const String& master_file)
|
||||
|
|
|
|||
|
|
@ -299,6 +299,8 @@ bool ClangVisitor::ProcessNode(CXCursor cursor)
|
|||
r.nspace = ci.Nspace();
|
||||
r.bases = ci.Bases();
|
||||
r.isvirtual = kind == CXCursor_CXXMethod && clang_CXXMethod_isVirtual(cursor);
|
||||
r.isstatic = clang_Cursor_getStorageClass(cursor) == CX_SC_Static;
|
||||
|
||||
if(findarg(r.kind, CXCursor_Constructor, CXCursor_Destructor) >= 0) {
|
||||
int q = r.id.Find('(');
|
||||
if(q >= 0) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ FN(CXSourceLocation, clang_getCursorLocation, (CXCursor))
|
|||
FN(CXCursor, clang_getCursorReferenced, (CXCursor))
|
||||
FN(unsigned, clang_isCursorDefinition, (CXCursor))
|
||||
FN(unsigned, clang_CXXMethod_isVirtual, (CXCursor C))
|
||||
FN(unsigned, clang_CXXMethod_isStatic, (CXCursor C))
|
||||
FN(int, clang_Cursor_isNull, (CXCursor cursor))
|
||||
FN(CXCursor, clang_getTranslationUnitCursor, (CXTranslationUnit))
|
||||
FN(void, clang_PrintingPolicy_setProperty, (CXPrintingPolicy Policy,
|
||||
|
|
@ -73,3 +74,5 @@ FN(enum CXDiagnosticSeverity, clang_getDiagnosticSeverity, (CXDiagnostic))
|
|||
|
||||
FN(CXType, clang_getTypedefDeclUnderlyingType, (CXCursor C))
|
||||
FN(CXCursor, clang_getTypeDeclaration, (CXType T))
|
||||
|
||||
FN(enum CX_StorageClass, clang_Cursor_getStorageClass, (CXCursor))
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ struct AnnotationItem : Moveable<AnnotationItem> {
|
|||
int kind = Null;
|
||||
bool definition = false;
|
||||
bool isvirtual = false;
|
||||
bool isstatic = false;
|
||||
|
||||
void Serialize(Stream& s);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ file
|
|||
clang.h,
|
||||
libclang.h,
|
||||
clang.dli,
|
||||
libclang.cpp,
|
||||
util.cpp,
|
||||
macros.cpp,
|
||||
Signature.cpp,
|
||||
libclang.cpp,
|
||||
clang.cpp,
|
||||
Visitor.cpp,
|
||||
CurrentFile.cpp,
|
||||
|
|
|
|||
|
|
@ -125,6 +125,11 @@ unsigned int clang_CXXMethod_isVirtual(CXCursor cursor)
|
|||
return LibClang().clang_CXXMethod_isVirtual(cursor);
|
||||
}
|
||||
|
||||
unsigned int clang_CXXMethod_isStatic(CXCursor cursor)
|
||||
{
|
||||
return LibClang().clang_CXXMethod_isStatic(cursor);
|
||||
}
|
||||
|
||||
int clang_Cursor_isNull(CXCursor cursor)
|
||||
{
|
||||
return LibClang().clang_Cursor_isNull(cursor);
|
||||
|
|
@ -271,4 +276,9 @@ enum CXDiagnosticSeverity clang_getDiagnosticSeverity(CXDiagnostic d)
|
|||
return LibClang().clang_getDiagnosticSeverity(d);
|
||||
}
|
||||
|
||||
enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor c)
|
||||
{
|
||||
return LibClang().clang_Cursor_getStorageClass(c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1972,6 +1972,7 @@ CXSourceLocation clang_getCursorLocation(CXCursor);
|
|||
CXCursor clang_getCursorReferenced(CXCursor);
|
||||
unsigned clang_isCursorDefinition(CXCursor);
|
||||
unsigned clang_CXXMethod_isVirtual(CXCursor C);
|
||||
unsigned clang_CXXMethod_isStatic(CXCursor C);
|
||||
int clang_Cursor_isNull(CXCursor cursor);
|
||||
CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
|
||||
CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
|
||||
|
|
@ -2026,3 +2027,22 @@ enum CXDiagnosticSeverity {
|
|||
};
|
||||
|
||||
enum CXDiagnosticSeverity clang_getDiagnosticSeverity(CXDiagnostic);
|
||||
|
||||
enum CX_StorageClass {
|
||||
CX_SC_Invalid,
|
||||
CX_SC_None,
|
||||
CX_SC_Extern,
|
||||
CX_SC_Static,
|
||||
CX_SC_PrivateExtern,
|
||||
CX_SC_OpenCLWorkGroupLocal,
|
||||
CX_SC_Auto,
|
||||
CX_SC_Register
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the storage class for a function or variable declaration.
|
||||
*
|
||||
* If the passed in Cursor is not a function or variable declaration,
|
||||
* CX_SC_Invalid is returned else the storage class.
|
||||
*/
|
||||
enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
|
||||
|
|
|
|||
|
|
@ -965,7 +965,7 @@ public:
|
|||
String GetFileLine(const String& path, int linei);
|
||||
void AddReferenceLine(const String& path, Point pos, const String& name, Index<String>& unique);
|
||||
void UsageFinish();
|
||||
void UsageId(const String& name, const String& id, const Index<String>& ids, bool istype, Index<String>& unique);
|
||||
void UsageId(const String& name, const String& id, const Index<String>& ids, bool istype, bool isstatic, Index<String>& unique);
|
||||
void Usage();
|
||||
void IdUsage();
|
||||
void Usage(const String& id, const String& name, Point ref_pos);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue