本文整理汇总了C++中Symbol::displayName方法的典型用法代码示例。如果您正苦于以下问题:C++ Symbol::displayName方法的具体用法?C++ Symbol::displayName怎么用?C++ Symbol::displayName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symbol
的用法示例。
在下文中一共展示了Symbol::displayName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locationToString
bool QueryJob::locationToString(Location location,
const std::function<void(LocationPiece, const String &)> &cb,
Flags<WriteFlag> writeFlags)
{
if (location.isNull())
return false;
Flags<Location::ToStringFlag> kf = locationToStringFlags();
kf &= ~Location::ShowContext;
cb(Piece_Location, location.toString(kf, &mContextCache));
if (!(writeFlags & NoContext) && !(queryFlags() & QueryMessage::NoContext))
cb(Piece_Context, location.context(kf, &mContextCache));
const bool containingFunction = queryFlags() & QueryMessage::ContainingFunction;
const bool containingFunctionLocation = queryFlags() & QueryMessage::ContainingFunctionLocation;
const bool cursorKind = queryFlags() & QueryMessage::CursorKind;
const bool displayName = queryFlags() & QueryMessage::DisplayName;
if (containingFunction || containingFunctionLocation || cursorKind || displayName || !mKindFilters.isEmpty()) {
int idx;
Symbol symbol = project()->findSymbol(location, &idx);
if (symbol.isNull()) {
error() << "Somehow can't find" << location << "in symbols";
} else {
if (!mKindFilters.filter(symbol))
return false;
if (displayName)
cb(Piece_SymbolName, symbol.displayName());
if (cursorKind)
cb(Piece_Kind, symbol.kindSpelling());
if (containingFunction || containingFunctionLocation) {
const uint32_t fileId = location.fileId();
const unsigned int line = location.line();
const unsigned int column = location.column();
auto fileMap = project()->openSymbols(location.fileId());
if (fileMap) {
while (idx > 0) {
symbol = fileMap->valueAt(--idx);
if (symbol.location.fileId() != fileId)
break;
if (symbol.isDefinition()
&& RTags::isContainer(symbol.kind)
&& comparePosition(line, column, symbol.startLine, symbol.startColumn) >= 0
&& comparePosition(line, column, symbol.endLine, symbol.endColumn) <= 0) {
if (containingFunction)
cb(Piece_ContainingFunctionName, symbol.symbolName);
if (containingFunctionLocation)
cb(Piece_ContainingFunctionLocation, symbol.location.toString(locationToStringFlags() & ~Location::ShowContext));
break;
}
}
}
}
}
}
return true;
}
示例2: write
bool QueryJob::write(const Location &location, Flags<WriteFlag> flags)
{
if (location.isNull())
return false;
if (!(flags & Unfiltered)) {
if (!filterLocation(location))
return false;
flags |= Unfiltered;
}
String out = location.key(keyFlags());
const bool containingFunction = queryFlags() & QueryMessage::ContainingFunction;
const bool cursorKind = queryFlags() & QueryMessage::CursorKind;
const bool displayName = queryFlags() & QueryMessage::DisplayName;
if (containingFunction || cursorKind || displayName || !mKindFilters.isEmpty()) {
int idx;
Symbol symbol = project()->findSymbol(location, &idx);
if (symbol.isNull()) {
error() << "Somehow can't find" << location << "in symbols";
} else {
if (!filterKind(symbol.kind))
return false;
if (displayName)
out += '\t' + symbol.displayName();
if (cursorKind)
out += '\t' + symbol.kindSpelling();
if (containingFunction) {
const uint32_t fileId = location.fileId();
const unsigned int line = location.line();
const unsigned int column = location.column();
auto fileMap = project()->openSymbols(location.fileId());
if (fileMap) {
while (idx > 0) {
symbol = fileMap->valueAt(--idx);
if (symbol.location.fileId() != fileId)
break;
if (symbol.isDefinition()
&& RTags::isContainer(symbol.kind)
&& comparePosition(line, column, symbol.startLine, symbol.startColumn) >= 0
&& comparePosition(line, column, symbol.endLine, symbol.endColumn) <= 0) {
out += "\tfunction: " + symbol.symbolName;
break;
}
}
}
}
}
}
return write(out, flags);
}