本文整理汇总了C++中phpentitybase::Ptr_t::FormatPhpDoc方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr_t::FormatPhpDoc方法的具体用法?C++ Ptr_t::FormatPhpDoc怎么用?C++ Ptr_t::FormatPhpDoc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpentitybase::Ptr_t
的用法示例。
在下文中一共展示了Ptr_t::FormatPhpDoc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
}
示例2: OnInsertDoxyBlock
void PHPCodeCompletion::OnInsertDoxyBlock(clCodeCompletionEvent& e)
{
e.Skip();
// Do we have a workspace open?
CHECK_COND_RET(PHPWorkspace::Get()->IsOpen());
// Sanity
IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor());
CHECK_PTR_RET(editor);
// Is this a PHP editor?
CHECK_COND_RET(IsPHPFile(editor));
// Get the text from the caret current position
// until the end of file
wxString unsavedBuffer = editor->GetTextRange(editor->GetCurrentPosition(), editor->GetLength());
unsavedBuffer.Trim().Trim(false);
PHPSourceFile source("<?php " + unsavedBuffer);
source.SetParseFunctionBody(false);
source.Parse();
PHPEntityBase::Ptr_t ns = source.Namespace();
if(ns) {
const PHPEntityBase::List_t& children = ns->GetChildren();
for(PHPEntityBase::List_t::const_iterator iter = children.begin(); iter != children.end(); ++iter) {
PHPEntityBase::Ptr_t match = *iter;
if(match->GetLine() == 0 && match->Is(kEntityTypeFunction)) {
e.Skip(false); // notify codelite to stop processing this event
wxString phpdoc = match->FormatPhpDoc();
phpdoc.Trim();
e.SetTooltip(phpdoc);
}
}
}
}