本文整理汇总了C++中cplusplus::document::Ptr::fileName方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::fileName方法的具体用法?C++ Ptr::fileName怎么用?C++ Ptr::fileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cplusplus::document::Ptr
的用法示例。
在下文中一共展示了Ptr::fileName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onParserFinished
void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr document,
CPlusPlus::Snapshot snapshot)
{
if (document.isNull())
return;
if (document->fileName() != filePath())
return; // some other document got updated
if (document->editorRevision() != revision())
return; // outdated content, wait for a new document to be parsed
if (debug) {
qDebug() << "BuiltinEditorDocumentProcessor: document parsed" << document->fileName()
<< document->editorRevision();
}
// Emit ifdefed out blocks
const auto ifdefoutBlocks = toTextEditorBlocks(document->skippedBlocks());
emit ifdefedOutBlocksUpdated(revision(), ifdefoutBlocks);
// Emit code warnings
auto codeWarnings = toTextEditorSelections(document->diagnosticMessages(), textDocument());
emit codeWarningsUpdated(revision(), codeWarnings);
emit cppDocumentUpdated(document);
m_documentSnapshot = snapshot;
const auto source = createSemanticInfoSource(false);
QTC_CHECK(source.snapshot.contains(document->fileName()));
m_semanticInfoUpdater.updateDetached(source);
}
示例2: processDocument
void CppTodoItemsScanner::processDocument(CPlusPlus::Document::Ptr doc)
{
QList<TodoItem> itemList;
CPlusPlus::TranslationUnit *translationUnit = doc->translationUnit();
for (unsigned i = 0; i < translationUnit->commentCount(); ++i) {
// Get comment source
CPlusPlus::Token token = doc->translationUnit()->commentAt(i);
QByteArray source = doc->utf8Source().mid(token.begin(), token.length()).trimmed();
if ((token.kind() == CPlusPlus::T_COMMENT) || (token.kind() == CPlusPlus::T_DOXY_COMMENT)) {
// Remove trailing "*/"
source = source.left(source.length() - 2);
}
// Process every line of the comment
// TODO: Do not create QStringList, just iterate through a string tracking line endings.
const QStringList commentLines =
QString::fromUtf8(source).split(QLatin1Char('\n'), QString::SkipEmptyParts);
unsigned lineNumber = 0;
translationUnit->getPosition(token.begin(), &lineNumber);
for (int j = 0; j < commentLines.count(); ++j) {
const QString &commentLine = commentLines.at(j);
processCommentLine(doc->fileName(), commentLine, lineNumber + j, itemList);
}
}
emit itemsFetched(doc->fileName(), itemList);
}
示例3: includesQtQuickTest
static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
const CppTools::CppModelManager *cppMM)
{
static QString expectedHeaderPrefix
= Utils::HostOsInfo::isMacHost()
? QLatin1String("QtQuickTest.framework/Headers")
: QLatin1String("QtQuickTest");
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
foreach (const CPlusPlus::Document::Include &inc, includes) {
if (inc.unresolvedFileName() == QLatin1String("QtQuickTest/quicktest.h")
&& inc.resolvedFileName().endsWith(
QString::fromLatin1("%1/quicktest.h").arg(expectedHeaderPrefix))) {
return true;
}
}
if (cppMM) {
foreach (const QString &include, cppMM->snapshot().allIncludesForDocument(doc->fileName())) {
if (include.endsWith(QString::fromLatin1("%1/quicktest.h").arg(expectedHeaderPrefix)))
return true;
}
}
return false;
}
示例4: includesQtTest
static bool includesQtTest(const CPlusPlus::Document::Ptr &doc,
const CppTools::CppModelManager *cppMM)
{
static QString expectedHeaderPrefix
= Utils::HostOsInfo::isMacHost()
? QLatin1String("QtTest.framework/Headers")
: QLatin1String("QtTest");
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
foreach (const CPlusPlus::Document::Include &inc, includes) {
// TODO this short cut works only for #include <QtTest>
// bad, as there could be much more different approaches
if (inc.unresolvedFileName() == QLatin1String("QtTest")
&& inc.resolvedFileName().endsWith(
QString::fromLatin1("%1/QtTest").arg(expectedHeaderPrefix))) {
return true;
}
}
if (cppMM) {
CPlusPlus::Snapshot snapshot = cppMM->snapshot();
const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->fileName());
foreach (const QString &include, allIncludes) {
if (include.endsWith(QString::fromLatin1("%1/qtest.h").arg(expectedHeaderPrefix))) {
return true;
}
}
}
return false;
}
示例5: quickTestName
static QString quickTestName(const CPlusPlus::Document::Ptr &doc)
{
const QList<CPlusPlus::Document::MacroUse> macros = doc->macroUses();
foreach (const CPlusPlus::Document::MacroUse ¯o, macros) {
if (!macro.isFunctionLike())
continue;
const QByteArray name = macro.macro().name();
if (QuickTestUtils::isQuickTestMacro(name)) {
CPlusPlus::Document::Block arg = macro.arguments().at(0);
return QLatin1String(CppParser::getFileContent(doc->fileName())
.mid(arg.bytesBegin(), arg.bytesEnd() - arg.bytesBegin()));
}
}
return QString();
}
示例6: includesGTest
static bool includesGTest(const CPlusPlus::Document::Ptr &doc,
const CppTools::CppModelManager *cppMM)
{
const QString gtestH = QLatin1String("gtest/gtest.h");
foreach (const CPlusPlus::Document::Include &inc, doc->resolvedIncludes()) {
if (inc.resolvedFileName().endsWith(gtestH))
return true;
}
if (cppMM) {
const CPlusPlus::Snapshot snapshot = cppMM->snapshot();
foreach (const QString &include, snapshot.allIncludesForDocument(doc->fileName())) {
if (include.endsWith(gtestH))
return true;
}
}
return false;
}
示例7: onDocumentUpdated
void CppLocatorData::onDocumentUpdated(const CPlusPlus::Document::Ptr &document)
{
QMutexLocker locker(&m_pendingDocumentsMutex);
int i = 0, ei = m_pendingDocuments.size();
for (; i < ei; ++i) {
const CPlusPlus::Document::Ptr &doc = m_pendingDocuments.at(i);
if (doc->fileName() == document->fileName()
&& doc->revision() < document->revision()) {
m_pendingDocuments[i] = document;
break;
}
}
if (i == ei)
m_pendingDocuments.append(document);
flushPendingDocument(false);
}
示例8: handleQtQuickTest
static bool handleQtQuickTest(QFutureInterface<TestParseResultPtr> futureInterface,
CPlusPlus::Document::Ptr document,
const Core::Id &id)
{
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
if (quickTestName(document).isEmpty())
return false;
const QString cppFileName = document->fileName();
QList<CppTools::ProjectPart::Ptr> ppList = modelManager->projectPart(cppFileName);
if (ppList.isEmpty()) // happens if shutting down while parsing
return false;
const QString &proFile = ppList.at(0)->projectFile;
const QString srcDir = quickTestSrcDir(modelManager, cppFileName);
if (srcDir.isEmpty())
return false;
const QList<QmlJS::Document::Ptr> qmlDocs = scanDirectoryForQuickTestQmlFiles(srcDir);
bool result = false;
foreach (const QmlJS::Document::Ptr &qmlJSDoc, qmlDocs)
result |= checkQmlDocumentForQuickTestCode(futureInterface, qmlJSDoc, id, proFile);
return result;
}
示例9: documentUpdated
void CppTodoItemsScanner::documentUpdated(CPlusPlus::Document::Ptr doc)
{
if (shouldProcessFile(doc->fileName()))
processDocument(doc);
}
示例10: onDocumentUpdated
void CppLocatorFilter::onDocumentUpdated(CPlusPlus::Document::Ptr doc)
{
m_searchList[doc->fileName()] = search(doc);
}