本文整理汇总了C++中SourceLocation::offset方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceLocation::offset方法的具体用法?C++ SourceLocation::offset怎么用?C++ SourceLocation::offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceLocation
的用法示例。
在下文中一共展示了SourceLocation::offset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool operator==(const SourceLocation &a, const SourceLocation &b)
{
return a.line() == b.line()
&& a.column() == b.column()
&& a.offset() == b.offset()
&& a.fileName() == b.fileName()
;
}
示例2: PrintTo
void PrintTo(const SourceLocation &sourceLocation, std::ostream *os)
{
*os << sourceLocation.filePath().constData()
<< ", line: " << sourceLocation.line()
<< ", column: "<< sourceLocation.column()
<< ", offset: "<< sourceLocation.offset();
}
示例3: hasDotAt
bool CodeCompleter::hasDotAt(uint line, uint column) const
{
const UnsavedFile &unsavedFile = translationUnit.unsavedFile();
const SourceLocation location = translationUnit.sourceLocationAtWithoutReparsing(line, column);
return unsavedFile.hasCharacterAt(location.offset(), '.');
}
示例4: assert
unsigned
SourceManager::getCol(const LREntry &range, const SourceLocation &loc, unsigned line)
{
if (!line) {
if ((line = getLine(range, loc)) == 0)
return 0;
}
SourceFile *file = range.getFile();
// Cached and returned lines are + 1, but the line cache starts at 0.
line = line - 1;
assert(line < file->lineCache()->length());
uint32_t pos = loc.offset() - range.id;
uint32_t line_start = file->lineCache()->at(line);
#if !defined(NDEBUG)
uint32_t line_end = (line < file->lineCache()->length() - 1)
? file->lineCache()->at(line + 1)
: file->length() + 1;
assert(pos >= line_start && pos < line_end);
#endif
return pos - line_start + 1;
}
示例5: PrintTo
void PrintTo(const SourceLocation &sourceLocation, std::ostream *os)
{
auto filePath = sourceLocation.filePath();
if (filePath.hasContent())
*os << filePath.constData() << ", ";
*os << "line: " << sourceLocation.line()
<< ", column: "<< sourceLocation.column()
<< ", offset: "<< sourceLocation.offset();
}
示例6: getLine
FullSourceRef
SourceManager::fullSourceRef(const LREntry &range, const SourceLocation &loc)
{
FullSourceRef ref;
ref.file = range.getFile();
ref.line = getLine(range, loc);
ref.col = getCol(range, loc, ref.line);
ref.offset = loc.offset() - range.id;
return ref;
}
示例7: while
void
SourceManager::getTokenHistory(const SourceLocation &aLoc, TokenHistory *history)
{
SourceLocation loc = aLoc;
while (loc.isSet()) {
size_t loc_index;
if (!findLocation(loc, &loc_index))
return;
const LREntry &range = locations_[loc_index];
if (loc.isInMacro()) {
history->macros.append(FullMacroRef(range.getMacro(), loc.offset() - range.id));
} else {
history->files.append(fullSourceRef(range, loc));
}
loc = range.getParent();
}
}
示例8: completeWithArrowInsteadOfDot
ClangCodeCompleteResults CodeCompleter::completeWithArrowInsteadOfDot(uint line, uint column)
{
ClangCodeCompleteResults results;
const SourceLocation location = translationUnit.sourceLocationAtWithoutReparsing(line, column - 1);
const bool replaced = translationUnit.unsavedFile().replaceAt(location.offset(),
1,
Utf8StringLiteral("->"));
if (replaced) {
results = complete(line,
column + 1,
translationUnit.cxUnsavedFiles(),
translationUnit.unsavedFilesCount());
if (results.hasResults())
neededCorrection_ = CompletionCorrection::DotToArrowCorrection;
}
return results;
}