Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
filesignificancecheck.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef FILESIGNIFICANCECHECK_H
5#define FILESIGNIFICANCECHECK_H
6
7#include <QtCore/qdir.h>
8#include <QtCore/qreadwritelock.h>
9#include <QtCore/qregularexpression.h>
10#include <QtCore/qstringlist.h>
11#include <QtCore/qvector.h>
12
13#include <string>
14#include <unordered_map>
15#include <vector>
16
18
19class FileSignificanceCheck
20{
21public:
22 FileSignificanceCheck() = default;
23
24 static void create()
25 {
26 m_instance = new FileSignificanceCheck;
27 }
28
29 static void destroy()
30 {
31 delete m_instance;
32 m_instance = nullptr;
33 }
34
35 static FileSignificanceCheck *the()
36 {
37 return m_instance;
38 }
39
40 void setRootDirectories(const QStringList &paths);
41 void setExclusionRegExes(const QVector<QRegularExpression> &expressions);
42
43 bool isFileSignificant(const std::string &filePath) const;
44
45private:
46 static FileSignificanceCheck *m_instance;
47 std::vector<QDir> m_rootDirs;
48 QVector<QRegularExpression> m_exclusionRegExes;
49 mutable std::unordered_map<std::string, bool> m_cache;
50 mutable QReadWriteLock m_cacheLock;
51};
52
53namespace LupdatePrivate {
54
55inline bool isFileSignificant(const std::string &filePath)
56{
57 return FileSignificanceCheck::the()->isFileSignificant(filePath);
58}
59
60} // namespace LupdatePrivate
61
62QT_END_NAMESPACE
63
64#endif // header guard
void HandleTranslationUnit(clang::ASTContext &context) override
LupdateASTConsumer(clang::ASTContext *context, Stores *stores)
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance &compiler, llvm::StringRef) override
LupdateFrontendAction(Stores *stores)
bool operator()(const clang::RawComment &LHS, const clang::RawComment &RHS)
BeforeThanCompare(const clang::SourceManager &SM)
bool operator()(const clang::RawComment *LHS, const clang::RawComment *RHS)
clang::FrontendAction * create() override
LupdateToolActionFactory(Stores *stores)
bool VisitNamedDecl(clang::NamedDecl *namedDeclaration)
void findContextForTranslationStoresFromPP(clang::NamedDecl *namedDeclaration)
LupdateVisitor(clang::ASTContext *context, Stores *stores)
bool VisitCallExpr(clang::CallExpr *callExpression)
QT_WARNING_PUSH QT_WARNING_POP QT_BEGIN_NAMESPACE QString toQt(llvm::StringRef str)
Definition cpp_clang.h:36
#define LUPDATE_CLANG_VERSION
Definition cpp_clang.h:42
#define LUPDATE_CLANG_VERSION_CHECK(major, minor, patch)
Definition cpp_clang.h:41
std::vector< std::string > getAliasFunctionDefinition()
void finalize(ReadSynchronizedRef< TranslationRelatedStore > &ast, WriteSynchronizedRef< TranslationRelatedStore > &newAst)
bool stringContainsTranslationInformation(llvm::StringRef ba)
void correctAstTranslationContext(ReadSynchronizedRef< TranslationRelatedStore > &ast, WriteSynchronizedRef< TranslationRelatedStore > &newAst, const TranslationStores &qDecl)
void collectMessages(TranslatorMessageVector &result, TranslationRelatedStore &store)
TranslatorMessage translatorMessage(const TranslationRelatedStore &store, const QString &id, bool plural, bool isID, bool isWarningOnly=false)
void loadCPP(Translator &translator, const QStringList &filenames, ConversionData &cd, bool *fail)
bool hasQuote(llvm::StringRef source)
QString cleanQuote(const std::string &token)
Definition cpp_clang.h:262
void exploreChildrenForFirstStringLiteral(clang::Stmt *stmt, QString &context)
bool trFunctionPresent(llvm::StringRef text)
QString exploreBases(clang::CXXRecordDecl *recordDecl, const clang::SourceManager &sm)
QString cleanQuote(llvm::StringRef s, QuoteCompulsary quote)
Definition cpp_clang.h:245
bool isPointWithin(const clang::SourceRange &sourceRange, const clang::SourceLocation &point, const clang::SourceManager &sm)
bool isQObjectOrQDeclareTrFunctionMacroDeclared(clang::CXXRecordDecl *recordDecl, QString &context, const clang::SourceManager &sm)
static bool capture(const QRegularExpression &exp, const QString &line, QString *i, QString *c)
bool isFileSignificant(const std::string &filePath)
QString fixedLineEndings(const QString &s)
Definition cpp_clang.h:220
QString contextForFunctionDecl(clang::FunctionDecl *func, const std::string &funcName)
QString contextForNoopMacro(clang::NamedDecl *namedDecl, const clang::SourceManager &sm)
QString lookForContext(clang::CXXRecordDecl *recordDecl, const clang::SourceManager &sm)
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcher)
Stores(TranslationStores &a, TranslationStores &qd, TranslationStores &qn)
Definition cpp_clang.h:205
WriteSynchronizedRef< TranslationRelatedStore > QDeclareTrWithContext
Definition cpp_clang.h:213
WriteSynchronizedRef< TranslationRelatedStore > QNoopTranlsationWithContext
Definition cpp_clang.h:214
TranslationStores Preprocessor
Definition cpp_clang.h:211
WriteSynchronizedRef< TranslationRelatedStore > AST
Definition cpp_clang.h:212
clang::SourceLocation sourceLocation
Definition cpp_clang.h:67
bool isValid(bool printwarning=false)
Definition cpp_clang.h:69
clang::SourceLocation callLocation(const clang::SourceManager &sourceManager)
Definition cpp_clang.h:163
void printStore() const
Definition cpp_clang.h:179
QHash< QString, QString > lupdateAllMagicMetaData
Definition cpp_clang.h:62