本文整理汇总了C++中ktexteditor::Document::lineLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::lineLength方法的具体用法?C++ Document::lineLength怎么用?C++ Document::lineLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::Document
的用法示例。
在下文中一共展示了Document::lineLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executed
void FunctionDeclarationCompletionItem::executed(KTextEditor::View* view, const KTextEditor::Range& word)
{
qCDebug(KDEV_PYTHON_CODECOMPLETION) << "FunctionDeclarationCompletionItem executed";
KTextEditor::Document* document = view->document();
auto resolvedDecl = Helper::resolveAliasDeclaration(declaration().data());
DUChainReadLocker lock;
auto functionDecl = Helper::functionForCalled(resolvedDecl).declaration;
lock.unlock();
if ( ! functionDecl && (! resolvedDecl || ! resolvedDecl->abstractType()
|| resolvedDecl->abstractType()->whichType() != AbstractType::TypeStructure) ) {
qCritical(KDEV_PYTHON_CODECOMPLETION) << "ERROR: could not get declaration data, not executing completion item!";
return;
}
QString suffix = "()";
KTextEditor::Range checkPrefix(word.start().line(), 0, word.start().line(), word.start().column());
KTextEditor::Range checkSuffix(word.end().line(), word.end().column(), word.end().line(), document->lineLength(word.end().line()));
if ( m_doNotCall || document->text(checkSuffix).trimmed().startsWith('(')
|| document->text(checkPrefix).trimmed().endsWith('@')
|| (functionDecl && Helper::findDecoratorByName(functionDecl, QLatin1String("property"))) )
{
// don't insert brackets if they're already there,
// the item is a decorator, or if it's an import item.
suffix.clear();
}
// place cursor behind bracktes by default
int skip = 2;
if ( functionDecl ) {
bool needsArguments = false;
int argumentCount = functionDecl->type<FunctionType>()->arguments().length();
if ( functionDecl->context()->type() == KDevelop::DUContext::Class ) {
// it's a member function, so it has the implicit self
// TODO static methods
needsArguments = argumentCount > 1;
}
else {
// it's a free function
needsArguments = argumentCount > 0;
}
if ( needsArguments ) {
// place cursor in brackets if there's parameters
skip = 1;
}
}
document->replaceText(word, declaration()->identifier().toString() + suffix);
view->setCursorPosition( Cursor(word.end().line(), word.end().column() + skip) );
}