本文整理汇总了C++中Overview::setShowReturnTypes方法的典型用法代码示例。如果您正苦于以下问题:C++ Overview::setShowReturnTypes方法的具体用法?C++ Overview::setShowReturnTypes怎么用?C++ Overview::setShowReturnTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Overview
的用法示例。
在下文中一共展示了Overview::setShowReturnTypes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CppElement
CppDeclarableElement::CppDeclarableElement(Symbol *declaration) : CppElement()
{
m_icon = Icons().iconForSymbol(declaration);
Overview overview;
overview.setShowArgumentNames(true);
overview.setShowReturnTypes(true);
m_name = overview.prettyName(declaration->name());
if (declaration->enclosingScope()->isClass() ||
declaration->enclosingScope()->isNamespace() ||
declaration->enclosingScope()->isEnum()) {
m_qualifiedName = overview.prettyName(LookupContext::fullyQualifiedName(declaration));
setHelpIdCandidates(stripName(m_qualifiedName));
} else {
m_qualifiedName = m_name;
setHelpIdCandidates(QStringList(m_name));
}
setTooltip(overview.prettyType(declaration->type(), m_qualifiedName));
setLink(CPPEditorWidget::linkToSymbol(declaration));
setHelpMark(m_name);
}
示例2: visit
void TypePrettyPrinter::visit(Function *type)
{
if (_needsParens) {
_text.prepend(QLatin1Char('('));
if (! _name.isEmpty()) {
appendSpace();
_text.append(_name);
_name.clear();
}
_text.append(QLatin1Char(')'));
_needsParens = false;
} else if (! _name.isEmpty() && _overview->showFunctionSignatures()) {
appendSpace();
_text.append(_name);
_name.clear();
}
if (_overview->showReturnTypes()) {
const QString returnType = _overview->prettyType(type->returnType());
if (!returnType.isEmpty()) {
if (!endsWithPtrOrRef(returnType))
_text.prepend(QLatin1Char(' '));
_text.prepend(returnType);
}
}
if (_overview->showFunctionSignatures()) {
Overview argumentText;
argumentText.setShowReturnTypes(true);
argumentText.setShowArgumentNames(false);
argumentText.setShowFunctionSignatures(true);
_text += QLatin1Char('(');
for (unsigned index = 0; index < type->argumentCount(); ++index) {
if (index != 0)
_text += QLatin1String(", ");
if (Argument *arg = type->argumentAt(index)->asArgument()) {
if (index + 1 == _overview->markedArgument())
const_cast<Overview*>(_overview)->setMarkedArgumentBegin(_text.length());
const Name *name = 0;
if (_overview->showArgumentNames())
name = arg->name();
_text += argumentText(arg->type(), name);
if (_overview->showDefaultArguments()) {
if (const StringLiteral *initializer = arg->initializer()) {
_text += QLatin1String(" =");
_text += QString::fromUtf8(initializer->chars(), initializer->size());
}
}
if (index + 1 == _overview->markedArgument())
const_cast<Overview*>(_overview)->setMarkedArgumentEnd(_text.length());
}
}
if (type->isVariadic())
_text += QLatin1String("...");
_text += QLatin1Char(')');
if (type->isConst()) {
appendSpace();
_text += "const";
}
if (type->isVolatile()) {
appendSpace();
_text += "volatile";
}
}
}
示例3: visit
void TypePrettyPrinter::visit(Function *type)
{
if (_overview->showReturnTypes())
_text += _overview->prettyType(type->returnType());
if (! _ptrOperators.isEmpty()) {
_text += QLatin1Char('(');
applyPtrOperators(false);
if (! _name.isEmpty()) {
_text += _name;
_name.clear();
}
_text += QLatin1Char(')');
} else if (! _name.isEmpty() && _overview->showFunctionSignatures()) {
space();
_text += _name;
_name.clear();
}
if (_overview->showFunctionSignatures()) {
Overview argumentText;
argumentText.setShowReturnTypes(true);
argumentText.setShowArgumentNames(false);
argumentText.setShowFunctionSignatures(true);
_text += QLatin1Char('(');
for (unsigned index = 0; index < type->argumentCount(); ++index) {
if (index != 0)
_text += QLatin1String(", ");
if (Argument *arg = type->argumentAt(index)->asArgument()) {
if (index + 1 == _overview->markedArgument())
const_cast<Overview*>(_overview)->setMarkedArgumentBegin(_text.length());
Name *name = 0;
if (_overview->showArgumentNames())
name = arg->name();
_text += argumentText(arg->type(), name);
if (index + 1 == _overview->markedArgument())
const_cast<Overview*>(_overview)->setMarkedArgumentEnd(_text.length());
}
}
if (type->isVariadic())
_text += QLatin1String("...");
_text += QLatin1Char(')');
if (type->isConst() && type->isVolatile()) {
space();
_text += "const volatile";
} else if (type->isConst()) {
space();
_text += "const";
} else if (type->isVolatile()) {
space();
_text += "volatile";
}
}
}
示例4: changes
Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffset)
{
Utils::ChangeSet changes;
// parse the current source declaration
TypeOfExpression typeOfExpression; // ### just need to preprocess...
typeOfExpression.init(sourceDocument, snapshot);
QString newDeclText = linkSelection.selectedText();
for (int i = 0; i < newDeclText.size(); ++i) {
if (newDeclText.at(i).toAscii() == 0)
newDeclText[i] = QLatin1Char('\n');
}
newDeclText.append(QLatin1String("{}"));
const QString newDeclTextPreprocessed = typeOfExpression.preprocess(newDeclText);
Document::Ptr newDeclDoc = Document::create(QLatin1String("<decl>"));
newDeclDoc->setSource(newDeclTextPreprocessed.toUtf8());
newDeclDoc->parse(Document::ParseDeclaration);
newDeclDoc->check();
// extract the function symbol
if (!newDeclDoc->translationUnit()->ast())
return changes;
FunctionDefinitionAST *newDef = newDeclDoc->translationUnit()->ast()->asFunctionDefinition();
if (!newDef)
return changes;
Function *newFunction = newDef->symbol;
if (!newFunction)
return changes;
Overview overview;
overview.setShowReturnTypes(true);
overview.setShowTemplateParameters(true);
overview.setShowArgumentNames(true);
overview.setShowFunctionSignatures(true);
// abort if the name of the newly parsed function is not the expected one
DeclaratorIdAST *newDeclId = getDeclaratorId(newDef->declarator);
if (!newDeclId || !newDeclId->name || !newDeclId->name->name
|| overview(newDeclId->name->name) != nameInitial) {
return changes;
}
LookupContext sourceContext(sourceDocument, snapshot);
LookupContext targetContext(targetFile->cppDocument(), snapshot);
// sync return type
{
// set up for rewriting return type
SubstitutionEnvironment env;
env.setContext(sourceContext);
env.switchScope(sourceFunction->enclosingScope());
ClassOrNamespace *targetCoN = targetContext.lookupType(targetFunction->enclosingScope());
if (!targetCoN)
targetCoN = targetContext.globalNamespace();
UseMinimalNames q(targetCoN);
env.enter(&q);
Control *control = sourceContext.control().data();
// get return type start position and declarator info from declaration
DeclaratorAST *declarator = 0;
SpecifierAST *firstReplaceableSpecifier = 0;
TranslationUnit *targetTranslationUnit = targetFile->cppDocument()->translationUnit();
if (SimpleDeclarationAST *simple = targetDeclaration->asSimpleDeclaration()) {
declarator = simple->declarator_list->value;
firstReplaceableSpecifier = findFirstReplaceableSpecifier(
targetTranslationUnit, simple->decl_specifier_list);
} else if (FunctionDefinitionAST *def = targetDeclaration->asFunctionDefinition()) {
declarator = def->declarator;
firstReplaceableSpecifier = findFirstReplaceableSpecifier(
targetTranslationUnit, def->decl_specifier_list);
}
int returnTypeStart = 0;
if (firstReplaceableSpecifier)
returnTypeStart = targetFile->startOf(firstReplaceableSpecifier);
else
returnTypeStart = targetFile->startOf(declarator);
if (!newFunction->returnType().isEqualTo(sourceFunction->returnType())
&& !newFunction->returnType().isEqualTo(targetFunction->returnType())) {
FullySpecifiedType type = rewriteType(newFunction->returnType(), &env, control);
const QString replacement = overview(type, targetFunction->name());
changes.replace(returnTypeStart,
targetFile->startOf(targetFunctionDeclarator->lparen_token),
replacement);
}
}
// sync parameters
{
// set up for rewriting parameter types
SubstitutionEnvironment env;
env.setContext(sourceContext);
env.switchScope(sourceFunction);
ClassOrNamespace *targetCoN = targetContext.lookupType(targetFunction);
if (!targetCoN)
targetCoN = targetContext.globalNamespace();
UseMinimalNames q(targetCoN);
//.........这里部分代码省略.........