本文整理汇总了C++中Symbol::fileNameLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Symbol::fileNameLength方法的具体用法?C++ Symbol::fileNameLength怎么用?C++ Symbol::fileNameLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symbol
的用法示例。
在下文中一共展示了Symbol::fileNameLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant OverviewModel::data(const QModelIndex &index, int role) const
{
// account for no symbol item
if (!index.parent().isValid() && index.row() == 0) {
switch (role) {
case Qt::DisplayRole:
if (rowCount() > 1)
return tr("<Select Symbol>");
else
return tr("<No Symbols>");
default:
return QVariant();
} //switch
}
switch (role) {
case Qt::DisplayRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
QString name = _overview.prettyName(symbol->name());
if (name.isEmpty())
name = QLatin1String("anonymous");
if (! symbol->isScopedSymbol() || symbol->isFunction()) {
QString type = _overview.prettyType(symbol->type());
if (! type.isEmpty()) {
if (! symbol->type()->isFunction())
name += QLatin1String(": ");
name += type;
}
}
return name;
}
case Qt::EditRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
QString name = _overview.prettyName(symbol->name());
if (name.isEmpty())
name = QLatin1String("anonymous");
return name;
}
case Qt::DecorationRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
return _icons.iconForSymbol(symbol);
} break;
case FileNameRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
return QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
}
case LineNumberRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
return symbol->line();
}
default:
return QVariant();
} // switch
}
示例2: findLinkHelper
static QSharedPointer<FunctionDeclDefLink> findLinkHelper(QSharedPointer<FunctionDeclDefLink> link, CppTools::CppRefactoringChanges changes)
{
QSharedPointer<FunctionDeclDefLink> noResult;
const Snapshot &snapshot = changes.snapshot();
// find the matching decl/def symbol
Symbol *target = 0;
CppTools::SymbolFinder finder;
if (FunctionDefinitionAST *funcDef = link->sourceDeclaration->asFunctionDefinition()) {
QList<Declaration *> nameMatch, argumentCountMatch, typeMatch;
finder.findMatchingDeclaration(LookupContext(link->sourceDocument, snapshot),
funcDef->symbol,
&typeMatch, &argumentCountMatch, &nameMatch);
if (!typeMatch.isEmpty())
target = typeMatch.first();
} else if (link->sourceDeclaration->asSimpleDeclaration()) {
target = finder.findMatchingDefinition(link->sourceFunctionDeclarator->symbol, snapshot, true);
}
if (!target) {
return noResult;
}
// parse the target file to get the linked decl/def
const QString targetFileName = QString::fromUtf8(
target->fileName(), target->fileNameLength());
CppTools::CppRefactoringFileConstPtr targetFile = changes.fileNoEditor(targetFileName);
if (!targetFile->isValid())
return noResult;
DeclarationAST *targetParent = 0;
FunctionDeclaratorAST *targetFuncDecl = 0;
DeclaratorAST *targetDeclarator = 0;
if (!findDeclOrDef(targetFile->cppDocument(), target->line(), target->column(),
&targetParent, &targetDeclarator, &targetFuncDecl))
return noResult;
// the parens are necessary for finding good places for changes
if (!targetFuncDecl->lparen_token || !targetFuncDecl->rparen_token)
return noResult;
QTC_ASSERT(targetFuncDecl->symbol, return noResult);
// if the source and target argument counts differ, something is wrong
QTC_ASSERT(targetFuncDecl->symbol->argumentCount() == link->sourceFunction->argumentCount(), return noResult);
int targetStart, targetEnd;
declDefLinkStartEnd(targetFile, targetParent, targetFuncDecl, &targetStart, &targetEnd);
QString targetInitial = targetFile->textOf(
targetFile->startOf(targetParent),
targetEnd);
targetFile->lineAndColumn(targetStart, &link->targetLine, &link->targetColumn);
link->targetInitial = targetInitial;
link->targetFile = targetFile;
link->targetFunction = targetFuncDecl->symbol;
link->targetFunctionDeclarator = targetFuncDecl;
link->targetDeclaration = targetParent;
return link;
}
示例3: handleLookupItemMatch
void CppElementEvaluator::handleLookupItemMatch(const Snapshot &snapshot,
const LookupItem &lookupItem,
const LookupContext &context,
const Scope *scope)
{
Symbol *declaration = lookupItem.declaration();
if (!declaration) {
const QString &type = Overview().prettyType(lookupItem.type(), QString());
// special case for bug QTCREATORBUG-4780
if (scope && scope->isFunction()
&& lookupItem.type().match(scope->asFunction()->returnType())) {
return;
}
m_element = QSharedPointer<CppElement>(new Unknown(type));
} else {
const FullySpecifiedType &type = declaration->type();
if (declaration->isNamespace()) {
m_element = QSharedPointer<CppElement>(new CppNamespace(declaration));
} else if (declaration->isClass()
|| declaration->isForwardClassDeclaration()
|| (declaration->isTemplate() && declaration->asTemplate()->declaration()
&& (declaration->asTemplate()->declaration()->isClass()
|| declaration->asTemplate()->declaration()->isForwardClassDeclaration()))) {
LookupContext contextToUse = context;
if (declaration->isForwardClassDeclaration())
if (Symbol *classDeclaration =
m_symbolFinder.findMatchingClassDeclaration(declaration, snapshot)) {
declaration = classDeclaration;
const QString fileName = QString::fromUtf8(declaration->fileName(),
declaration->fileNameLength());
const Document::Ptr declarationDocument = snapshot.document(fileName);
if (declarationDocument != context.thisDocument())
contextToUse = LookupContext(declarationDocument, snapshot);
}
CppClass *cppClass = new CppClass(declaration);
if (m_lookupBaseClasses)
cppClass->lookupBases(declaration, contextToUse);
if (m_lookupDerivedClasses)
cppClass->lookupDerived(declaration, snapshot);
m_element = QSharedPointer<CppElement>(cppClass);
} else if (Enum *enumDecl = declaration->asEnum()) {
m_element = QSharedPointer<CppElement>(new CppEnum(enumDecl));
} else if (EnumeratorDeclaration *enumerator = dynamic_cast<EnumeratorDeclaration *>(declaration)) {
m_element = QSharedPointer<CppElement>(new CppEnumerator(enumerator));
} else if (declaration->isTypedef()) {
m_element = QSharedPointer<CppElement>(new CppTypedef(declaration));
} else if (declaration->isFunction()
|| (type.isValid() && type->isFunctionType())
|| declaration->isTemplate()) {
m_element = QSharedPointer<CppElement>(new CppFunction(declaration));
} else if (declaration->isDeclaration() && type.isValid()) {
m_element = QSharedPointer<CppElement>(
new CppVariable(declaration, context, lookupItem.scope()));
} else {
m_element = QSharedPointer<CppElement>(new CppDeclarableElement(declaration));
}
}
}
示例4: data
QVariant OverviewModel::data(const QModelIndex &index, int role) const
{
// account for no symbol item
if (!index.parent().isValid() && index.row() == 0) {
switch (role) {
case Qt::DisplayRole:
if (rowCount() > 1)
return tr("<Select Symbol>");
else
return tr("<No Symbols>");
default:
return QVariant();
} //switch
}
switch (role) {
case Qt::DisplayRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
QString name = _overview.prettyName(symbol->name());
if (name.isEmpty())
name = QLatin1String("anonymous");
if (symbol->isObjCForwardClassDeclaration())
name = QLatin1String("@class ") + name;
if (symbol->isObjCForwardProtocolDeclaration() || symbol->isObjCProtocol())
name = QLatin1String("@protocol ") + name;
if (symbol->isObjCClass()) {
ObjCClass *clazz = symbol->asObjCClass();
if (clazz->isInterface())
name = QLatin1String("@interface ") + name;
else
name = QLatin1String("@implementation ") + name;
if (clazz->isCategory())
name += QLatin1String(" (") + _overview.prettyName(clazz->categoryName()) + QLatin1Char(')');
}
if (symbol->isObjCPropertyDeclaration())
name = QLatin1String("@property ") + name;
if (Template *t = symbol->asTemplate())
if (Symbol *templateDeclaration = t->declaration()) {
QStringList parameters;
for (unsigned i = 0; i < t->templateParameterCount(); ++i)
parameters.append(_overview.prettyName(t->templateParameterAt(i)->name()));
name += QLatin1Char('<') + parameters.join(QLatin1String(", ")) + QLatin1Char('>');
symbol = templateDeclaration;
}
if (symbol->isObjCMethod()) {
ObjCMethod *method = symbol->asObjCMethod();
if (method->isStatic())
name = QLatin1Char('+') + name;
else
name = QLatin1Char('-') + name;
} else if (! symbol->isScope() || symbol->isFunction()) {
QString type = _overview.prettyType(symbol->type());
if (Function *f = symbol->type()->asFunctionType()) {
name += type;
type = _overview.prettyType(f->returnType());
}
if (! type.isEmpty())
name += QLatin1String(": ") + type;
}
return name;
}
case Qt::EditRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
QString name = _overview.prettyName(symbol->name());
if (name.isEmpty())
name = QLatin1String("anonymous");
return name;
}
case Qt::DecorationRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
return _icons.iconForSymbol(symbol);
} break;
case FileNameRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
return QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
}
case LineNumberRole: {
Symbol *symbol = static_cast<Symbol *>(index.internalPointer());
return symbol->line();
}
default:
return QVariant();
} // switch
}