int PHPOutlineTree::GetImageId(PHPEntityBase::Ptr_t entry) { BitmapLoader* bmpLoader = clGetManager()->GetStdIcons(); if(entry->Is(kEntityTypeFunction)) { PHPEntityFunction* func = entry->Cast<PHPEntityFunction>(); if(func->HasFlag(kFunc_Private)) return bmpLoader->GetImageIndex(BitmapLoader::kFunctionPrivate); else if(func->HasFlag(kFunc_Protected)) return bmpLoader->GetImageIndex(BitmapLoader::kFunctionProtected); else // public return bmpLoader->GetImageIndex(BitmapLoader::kFunctionPublic); } else if(entry->Is(kEntityTypeVariable)) { PHPEntityVariable* var = entry->Cast<PHPEntityVariable>(); if(!var->IsMember() && !var->IsConst()) { // A global variale return bmpLoader->GetImageIndex(BitmapLoader::kMemberPublic); } else if(var->IsMember()) { if(var->HasFlag(kVar_Const)) return bmpLoader->GetImageIndex(BitmapLoader::kConstant); // constant // Member if(var->HasFlag(kVar_Private)) return bmpLoader->GetImageIndex(BitmapLoader::kMemberPrivate); else if(var->HasFlag(kVar_Protected)) return bmpLoader->GetImageIndex(BitmapLoader::kMemberProtected); else return bmpLoader->GetImageIndex(BitmapLoader::kMemberPublic); } else if(var->IsConst()) { // Constant return bmpLoader->GetImageIndex(BitmapLoader::kConstant); } else { return bmpLoader->GetImageIndex(BitmapLoader::kMemberPublic); } } else if(entry->Is(kEntityTypeNamespace)) { // Namespace return bmpLoader->GetImageIndex(BitmapLoader::kNamespace); } else if(entry->Is(kEntityTypeClass)) { return bmpLoader->GetImageIndex(BitmapLoader::kClass); } return wxNOT_FOUND; // Unknown }
int PHPFileLayoutTree::GetImageId(PHPEntityBase::Ptr_t entry) { if(entry->Is(kEntityTypeFunction)) { PHPEntityFunction* func = entry->Cast<PHPEntityFunction>(); if(func->HasFlag(kFunc_Private)) return 1; else if(func->HasFlag(kFunc_Protected)) return 2; else // public return 3; } else if(entry->Is(kEntityTypeVariable)) { PHPEntityVariable* var = entry->Cast<PHPEntityVariable>(); if(!var->IsMember() && !var->IsConst()) { // A global variale return 6; } else if(var->IsMember()) { if(var->HasFlag(kVar_Const)) return 9; // constant // Member if(var->HasFlag(kVar_Private)) return 4; else if(var->HasFlag(kVar_Protected)) return 5; else return 6; } else if(var->IsConst()) { // Constant return 9; } else { return 6; } } else if(entry->Is(kEntityTypeNamespace)) { // Namespace return 7; } else if(entry->Is(kEntityTypeClass)) { return 8; } return -1; // Unknown }
TagEntryPtr PHPCodeCompletion::DoPHPEntityToTagEntry(PHPEntityBase::Ptr_t entry) { TagEntryPtr t(new TagEntry()); // wxString name = entry->Is(kEntityTypeNamespace) ? entry->GetFullName() : entry->GetShortName(); wxString name = entry->GetShortName(); if(entry->Is(kEntityTypeVariable) && entry->Cast<PHPEntityVariable>()->IsMember() && name.StartsWith(wxT("$")) && !entry->Cast<PHPEntityVariable>()->IsStatic()) { name.Remove(0, 1); } else if((entry->Is(kEntityTypeClass) || entry->Is(kEntityTypeNamespace)) && name.StartsWith("\\")) { name.Remove(0, 1); } t->SetName(name); t->SetParent(entry->Parent() ? entry->Parent()->GetFullName() : ""); t->SetPattern(t->GetName()); // Set the document comment wxString comment, docComment; docComment = entry->GetDocComment(); if(docComment.IsEmpty() == false) { docComment.Trim().Trim(false); // The Doc comment comment << docComment << wxT("\n<hr>"); // HLine } wxFileName fn(entry->GetFilename()); fn.MakeRelativeTo(PHPWorkspace::Get()->GetFilename().GetPath()); comment << fn.GetFullName() << wxT(" : ") << entry->GetLine(); t->SetComment(comment); // Access if(entry->Is(kEntityTypeVariable)) { PHPEntityVariable* var = entry->Cast<PHPEntityVariable>(); // visibility if(var->IsPrivate()) t->SetAccess(wxT("private")); else if(var->IsProtected()) t->SetAccess(wxT("protected")); else t->SetAccess(wxT("public")); // type (affects icon) if(var->IsConst() || var->IsDefine()) { t->SetKind("macro"); } else { t->SetKind("variable"); } t->SetReturnValue(""); } else if(entry->Is(kEntityTypeFunction) || entry->Is(kEntityTypeFunctionAlias)) { PHPEntityFunction* func = NULL; if(entry->Is(kEntityTypeFunctionAlias)) { func = entry->Cast<PHPEntityFunctionAlias>()->GetFunc()->Cast<PHPEntityFunction>(); } else { func = entry->Cast<PHPEntityFunction>(); } if(func->HasFlag(kFunc_Private)) { t->SetAccess(wxT("private")); } else if(func->HasFlag(kFunc_Protected)) { t->SetAccess("protected"); } else { t->SetAccess(wxT("public")); } t->SetSignature(func->GetSignature()); t->SetPattern(func->GetShortName() + func->GetSignature()); t->SetKind("function"); } else if(entry->Is(kEntityTypeClass)) { t->SetAccess(wxT("public")); t->SetKind("class"); } else if(entry->Is(kEntityTypeNamespace)) { t->SetAccess("public"); t->SetKind("namespace"); } else if(entry->Is(kEntityTypeKeyword)) { t->SetAccess("public"); t->SetKind("cpp_keyword"); } t->SetFlags(TagEntry::Tag_No_Signature_Format); return t; }
TagEntryPtr PHPCodeCompletion::DoPHPEntityToTagEntry(PHPEntityBase::Ptr_t entry) { TagEntryPtr t(new TagEntry()); // wxString name = entry->Is(kEntityTypeNamespace) ? entry->GetFullName() : entry->GetShortName(); wxString name = entry->GetShortName(); if(entry->Is(kEntityTypeVariable) && entry->Cast<PHPEntityVariable>()->IsMember() && name.StartsWith(wxT("$")) && !entry->Cast<PHPEntityVariable>()->IsStatic()) { name.Remove(0, 1); } else if((entry->Is(kEntityTypeClass) || entry->Is(kEntityTypeNamespace)) && name.StartsWith("\\")) { name.Remove(0, 1); } t->SetName(name); t->SetParent(entry->Parent() ? entry->Parent()->GetFullName() : ""); t->SetPattern(t->GetName()); t->SetComment(entry->GetDocComment()); // Access if(entry->Is(kEntityTypeVariable)) { PHPEntityVariable* var = entry->Cast<PHPEntityVariable>(); // visibility if(var->IsPrivate()) t->SetAccess(wxT("private")); else if(var->IsProtected()) t->SetAccess(wxT("protected")); else t->SetAccess(wxT("public")); // type (affects icon) if(var->IsConst() || var->IsDefine()) { t->SetKind("macro"); } else { t->SetKind("variable"); } t->SetReturnValue(""); } else if(entry->Is(kEntityTypeFunction)) { PHPEntityFunction* func = entry->Cast<PHPEntityFunction>(); if(func->HasFlag(kFunc_Private)) { t->SetAccess(wxT("private")); } else if(func->HasFlag(kFunc_Protected)) { t->SetAccess("protected"); } else { t->SetAccess(wxT("public")); } t->SetSignature(func->GetSignature()); t->SetPattern(func->GetShortName() + func->GetSignature()); t->SetKind("function"); } else if(entry->Is(kEntityTypeClass)) { t->SetAccess(wxT("public")); t->SetKind("class"); } else if(entry->Is(kEntityTypeNamespace)) { t->SetAccess("public"); t->SetKind("namespace"); } t->SetFlags(TagEntry::Tag_No_Signature_Format); return t; }