本文整理汇总了C++中phpentitybase::Ptr_t类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr_t类的具体用法?C++ Ptr_t怎么用?C++ Ptr_t使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr_t类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoShowCompletionBox
void PHPCodeCompletion::DoShowCompletionBox(const PHPEntityBase::List_t& entries, PHPExpression::Ptr_t expr)
{
std::vector<TagEntryPtr> tags;
wxStringSet_t uniqueEntries;
// search for the old item
PHPEntityBase::List_t::const_iterator iter = entries.begin();
for(; iter != entries.end(); ++iter) {
PHPEntityBase::Ptr_t entry = *iter;
if(uniqueEntries.count(entry->GetFullName()) == 0) {
uniqueEntries.insert(entry->GetFullName());
} else {
// don't add duplicate entries
continue;
}
PHPEntityBase::Ptr_t ns = expr->GetSourceFile()->Namespace(); // the namespace at the source file
TagEntryPtr t = DoPHPEntityToTagEntry(entry);
t->SetUserData(new PHPCCUserData(entry));
tags.push_back(t);
}
if(tags.empty()) return;
std::sort(tags.begin(), tags.end(), _SAscendingSort());
m_manager->GetActiveEditor()->ShowCompletionBox(tags, expr->GetFilter(), false, this);
}
示例2: DoShowCompletionBox
void PHPCodeCompletion::DoShowCompletionBox(const PHPEntityBase::List_t& entries, PHPExpression::Ptr_t expr)
{
wxCodeCompletionBoxEntry::Vec_t ccEntries;
TagEntryPtrVector_t tags;
wxStringSet_t uniqueEntries;
// search for the old item
PHPEntityBase::List_t::const_iterator iter = entries.begin();
for(; iter != entries.end(); ++iter) {
PHPEntityBase::Ptr_t entry = *iter;
if(uniqueEntries.count(entry->GetFullName()) == 0) {
uniqueEntries.insert(entry->GetFullName());
} else {
// don't add duplicate entries
continue;
}
PHPEntityBase::Ptr_t ns = expr->GetSourceFile()->Namespace(); // the namespace at the source file
TagEntryPtr t = DoPHPEntityToTagEntry(entry);
tags.push_back(t);
}
std::sort(tags.begin(), tags.end(), _SAscendingSort());
for(size_t i = 0; i < tags.size(); ++i) {
wxCodeCompletionBoxEntry::Ptr_t ccEntry = wxCodeCompletionBox::TagToEntry(tags.at(i));
ccEntry->SetComment(tags.at(i)->GetComment());
ccEntries.push_back(ccEntry);
}
wxCodeCompletionBoxManager::Get().ShowCompletionBox(
m_manager->GetActiveEditor()->GetCtrl(), ccEntries, wxCodeCompletionBox::kRefreshOnKeyType, wxNOT_FOUND);
}
示例3: OnInsertDoxyComment
void PHPEditorContextMenu::OnInsertDoxyComment(wxCommandEvent& e)
{
IEditor* editor = m_manager->GetActiveEditor();
if(editor) {
PHPEntityBase::Ptr_t entry =
PHPCodeCompletion::Instance()->GetPHPEntityAtPos(editor, editor->GetCurrentPosition());
if(entry) {
wxStyledTextCtrl* ctrl = editor->GetCtrl();
ctrl->BeginUndoAction();
wxString comment = entry->FormatPhpDoc();
// Create the whitespace buffer
int lineStartPos = ctrl->PositionFromLine(ctrl->GetCurrentLine());
int lineEndPos = lineStartPos + ctrl->LineLength(ctrl->GetCurrentLine());
// Collect all whitespace from the begining of the line until the first non whitespace
// character we find
wxString whitespace;
for(int i = lineStartPos; lineStartPos < lineEndPos; ++i) {
if(ctrl->GetCharAt(i) == ' ' || ctrl->GetCharAt(i) == '\t') {
whitespace << (wxChar)ctrl->GetCharAt(i);
} else {
break;
}
}
// Prepare the comment block
wxArrayString lines = ::wxStringTokenize(comment, "\n", wxTOKEN_STRTOK);
for(size_t i = 0; i < lines.size(); ++i) {
lines.Item(i).Prepend(whitespace);
}
// Glue the lines back together
wxString doxyBlock = ::wxJoin(lines, '\n');
doxyBlock << "\n";
// Insert the text
ctrl->InsertText(lineStartPos, doxyBlock);
// Try to place the caret after the @brief
wxRegEx reBrief("[@\\]brief[ \t]*");
if(reBrief.IsValid() && reBrief.Matches(doxyBlock)) {
wxString match = reBrief.GetMatch(doxyBlock);
// Get the index
int where = doxyBlock.Find(match);
if(where != wxNOT_FOUND) {
where += match.length();
int caretPos = lineStartPos + where;
editor->SetCaretAt(caretPos);
// Remove the @brief as its non standard in the PHP world
editor->GetCtrl()->DeleteRange(caretPos - match.length(), match.length());
}
}
editor->GetCtrl()->EndUndoAction();
}
}
}
示例4: DoOpenEditorForEntry
void PHPCodeCompletion::DoOpenEditorForEntry(PHPEntityBase::Ptr_t entry)
{
// Open the file (make sure we use the 'OpenFile' so we will get a browsing record)
IEditor* editor = m_manager->OpenFile(entry->GetFilename().GetFullPath(), wxEmptyString, entry->GetLine());
if(editor) {
// Select the word in the editor (its a new one)
int selectFromPos = editor->GetCtrl()->PositionFromLine(entry->GetLine());
DoSelectInEditor(editor, entry->GetShortName(), selectFromPos);
}
}
示例5: GetGetters
PHPSetterGetterEntry::Vec_t PHPRefactoring::GetGetters(IEditor* editor) const
{
PHPSetterGetterEntry::Vec_t getters, candidates;
if(!editor) {
return getters;
}
// Parse until the current position
wxString text = editor->GetTextRange(0, editor->GetCurrentPosition());
PHPSourceFile sourceFile(text);
sourceFile.SetParseFunctionBody(true);
sourceFile.SetFilename(editor->GetFileName());
sourceFile.Parse();
const PHPEntityClass* scopeAtPoint = sourceFile.Class()->Cast<PHPEntityClass>();
if(!scopeAtPoint) {
return getters;
}
// filter out
const PHPEntityBase::List_t& children = scopeAtPoint->GetChildren();
PHPEntityBase::List_t::const_iterator iter = children.begin();
PHPEntityBase::List_t members, functions;
for(; iter != children.end(); ++iter) {
PHPEntityBase::Ptr_t child = *iter;
if(child->Is(kEntityTypeFunction)) {
functions.push_back(child);
} else if(child->Is(kEntityTypeVariable) && child->Cast<PHPEntityVariable>()->IsMember() &&
!child->Cast<PHPEntityVariable>()->IsConst() && !child->Cast<PHPEntityVariable>()->IsStatic()) {
// a member of a class
members.push_back(child);
}
}
if(members.empty()) {
return getters;
}
// Prepare list of candidates
PHPEntityBase::List_t::iterator membersIter = members.begin();
for(; membersIter != members.end(); ++membersIter) {
PHPSetterGetterEntry candidate(*membersIter);
// make sure we don't add setters that already exist
if(FindByName(functions, candidate.GetGetter(kSG_NameOnly))) {
continue;
}
candidates.push_back(candidate);
}
getters.swap(candidates);
return getters;
}
示例6: Class
const PHPEntityBase* PHPSourceFile::Class()
{
PHPEntityBase::Ptr_t curScope = CurrentScope();
PHPEntityBase* pScope = curScope.Get();
while(pScope) {
PHPEntityClass* cls = pScope->Cast<PHPEntityClass>();
if(cls) {
// this scope is a class
return pScope;
}
pScope = pScope->Parent();
}
return NULL;
}
示例7: BuildTree
void PHPFileLayoutTree::BuildTree(wxTreeItemId parentTreeItem, PHPEntityBase::Ptr_t entity)
{
int imgID = GetImageId(entity);
wxTreeItemId parent = AppendItem(parentTreeItem, entity->GetDisplayName(), imgID, imgID, new QItemData(entity));
// dont add the children of the function (i.e. function arguments)
if(entity->Is(kEntityTypeFunction)) return;
const PHPEntityBase::List_t& children = entity->GetChildren();
if(!children.empty()) {
PHPEntityBase::List_t::const_iterator iter = children.begin();
for(; iter != children.end(); ++iter) {
BuildTree(parent, *iter);
}
}
}
示例8: FindDefinition
PHPLocation::Ptr_t PHPCodeCompletion::FindDefinition(IEditor* editor, int pos)
{
CHECK_PHP_WORKSPACE_RET_NULL();
PHPLocation::Ptr_t loc; // Null
if(IsPHPFile(editor)) {
PHPEntityBase::Ptr_t resolved = GetPHPEntryUnderTheAtPos(editor, editor->GetCurrentPosition());
if(resolved) {
loc = new PHPLocation;
loc->filename = resolved->GetFilename().GetFullPath();
loc->linenumber = resolved->GetLine();
loc->what = resolved->GetShortName();
}
}
return loc;
}
示例9: GetMembers
void PHPCodeCompletion::GetMembers(IEditor* editor, PHPEntityBase::List_t& members, wxString& scope)
{
members.clear();
scope.clear();
if(!editor) {
return;
}
// Parse until the current position to get the current scope name
{
wxString text = editor->GetTextRange(0, editor->GetCurrentPosition());
PHPSourceFile sourceFile(text);
sourceFile.SetParseFunctionBody(true);
sourceFile.SetFilename(editor->GetFileName());
sourceFile.Parse();
const PHPEntityClass* scopeAtPoint = sourceFile.Class()->Cast<PHPEntityClass>();
if(!scopeAtPoint) {
return;
}
scope = scopeAtPoint->GetFullName();
}
// Second parse: parse the entire buffer so we are not limited by the caret position
wxString text = editor->GetTextRange(0, editor->GetLength());
PHPSourceFile sourceFile(text);
sourceFile.SetParseFunctionBody(true);
sourceFile.SetFilename(editor->GetFileName());
sourceFile.Parse();
// Locate the scope
PHPEntityBase::Ptr_t parentClass = sourceFile.Namespace()->FindChild(scope);
if(!parentClass) return;
// filter out
const PHPEntityBase::List_t& children = parentClass->GetChildren();
PHPEntityBase::List_t::const_iterator iter = children.begin();
for(; iter != children.end(); ++iter) {
PHPEntityBase::Ptr_t child = *iter;
if(child->Is(kEntityTypeVariable) && child->Cast<PHPEntityVariable>()->IsMember() &&
!child->Cast<PHPEntityVariable>()->IsConst() && !child->Cast<PHPEntityVariable>()->IsStatic()) {
// a member of a class
members.push_back(child);
}
}
}
示例10: OnFindSymbol
void PHPCodeCompletion::OnFindSymbol(clCodeCompletionEvent& e)
{
if(PHPWorkspace::Get()->IsOpen()) {
if(!CanCodeComplete(e)) return;
IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor());
if(editor) {
PHPEntityBase::Ptr_t resolved = GetPHPEntryUnderTheAtPos(editor, editor->GetCurrentPosition());
if(resolved) {
m_manager->OpenFile(resolved->GetFilename().GetFullPath(), "", resolved->GetLine());
}
}
} else {
e.Skip();
}
}
示例11: GetImageId
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
}
示例12: GetImageId
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
}
示例13: FindDefinition
PHPLocation::Ptr_t PHPCodeCompletion::FindDefinition(IEditor* editor, int pos)
{
CHECK_PHP_WORKSPACE_RET_NULL();
PHPLocation::Ptr_t loc; // Null
if(IsPHPFile(editor)) {
PHPEntityBase::Ptr_t resolved = GetPHPEntityAtPos(editor, editor->GetCurrentPosition());
if(resolved) {
if(resolved->Is(kEntityTypeFunctionAlias)) {
// use the internal function
resolved = resolved->Cast<PHPEntityFunctionAlias>()->GetFunc();
}
loc = new PHPLocation;
loc->filename = resolved->GetFilename().GetFullPath();
loc->linenumber = resolved->GetLine();
loc->what = resolved->GetShortName();
}
}
return loc;
}
示例14: OnTypeinfoTip
void PHPCodeCompletion::OnTypeinfoTip(clCodeCompletionEvent& e)
{
if(PHPWorkspace::Get()->IsOpen()) {
if(!CanCodeComplete(e)) return;
IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor());
if(editor) {
if(IsPHPFile(editor)) {
PHPEntityBase::Ptr_t entity = GetPHPEntityAtPos(editor, e.GetPosition());
if(entity) {
e.SetTooltip(entity->ToTooltip());
}
return;
}
}
} else {
e.Skip();
}
}
示例15: OnConstant
void PHPSourceFile::OnConstant(const phpLexerToken& tok)
{
// Parse constant line (possibly multiple constants)
phpLexerToken token;
PHPEntityBase::Ptr_t member;
while(NextToken(token)) {
if(token.type == ';') {
if(member) {
CurrentScope()->AddChild(member);
break;
}
} else if(token.type == ',') {
if(member) {
CurrentScope()->AddChild(member);
member.Reset(NULL);
}
} else if(token.type == kPHP_T_IDENTIFIER) {
// found the constant name
member.Reset(new PHPEntityVariable());
member->Cast<PHPEntityVariable>()->SetFlag(kVar_Const);
member->Cast<PHPEntityVariable>()->SetFlag(kVar_Member);
member->SetFullName(token.text);
member->SetLine(token.lineNumber);
member->SetFilename(m_filename.GetFullPath());
} else {
// do nothing
}
}
}