diff --git a/language/codegen/archivetemplateloader.h b/language/codegen/archivetemplateloader.h index 872c81d4c..897c6e5f2 100644 --- a/language/codegen/archivetemplateloader.h +++ b/language/codegen/archivetemplateloader.h @@ -1,74 +1,74 @@ /* This file is part of KDevelop Copyright 2012 Miha Čančula This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEVPLATFORM_ARCHIVETEMPLATELOADER_H #define KDEVPLATFORM_ARCHIVETEMPLATELOADER_H #include class KArchiveDirectory; namespace KDevelop { class ArchiveTemplateLocation; class ArchiveTemplateLoader : public Grantlee::AbstractTemplateLoader { public: static ArchiveTemplateLoader* self(); virtual ~ArchiveTemplateLoader(); virtual bool canLoadTemplate(const QString& name) const override; virtual Grantlee::Template loadByName(const QString& name, const Grantlee::Engine* engine) const override; virtual QPair getMediaUri(const QString& fileName) const override; protected: friend class ArchiveTemplateLocation; void addLocation(ArchiveTemplateLocation* location); void removeLocation(ArchiveTemplateLocation* location); private: - Q_DISABLE_COPY(ArchiveTemplateLoader); + Q_DISABLE_COPY(ArchiveTemplateLoader) ArchiveTemplateLoader(); class ArchiveTemplateLoaderPrivate* const d; }; /** * RAII class that should be used to add KArchiveDirectory locations to the engine. * * Adds the archive @p directory to the list of places searched for templates * during the lifetime of the created ArchiveTemplateLocation class. */ class ArchiveTemplateLocation { public: explicit ArchiveTemplateLocation(const KArchiveDirectory* directory); ~ArchiveTemplateLocation(); bool hasTemplate(const QString& name) const; QString templateContents(const QString& name) const; private: const KArchiveDirectory* m_directory; }; } #endif // KDEVPLATFORM_ARCHIVETEMPLATELOADER_H diff --git a/language/duchain/problem.h b/language/duchain/problem.h index 518a5db54..3bb556766 100644 --- a/language/duchain/problem.h +++ b/language/duchain/problem.h @@ -1,247 +1,247 @@ /* This file is part of KDevelop Copyright 2007 Hamish Rodda This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEVPLATFORM_PROBLEM_H #define KDEVPLATFORM_PROBLEM_H #include #include #include "../editor/documentrange.h" #include #include "duchainbase.h" #include #include "indexedtopducontext.h" #include namespace KDevelop { class IAssistant; class Problem; using ProblemPointer = QExplicitlySharedDataPointer; /** * Represents a problem only by its index within the top-context * * Fixme: share code with the other LocalIndexed* classes */ class KDEVPLATFORMLANGUAGE_EXPORT LocalIndexedProblem { public: LocalIndexedProblem(const ProblemPointer& problem, const TopDUContext* top); explicit LocalIndexedProblem(uint index = 0) : m_index(index) {} /** * \note Duchain must be read locked */ ProblemPointer data(const TopDUContext* top) const; bool operator==(const LocalIndexedProblem& rhs) const { return m_index == rhs.m_index; } bool isValid() const { return m_index; } /** * Index of the Declaration within the top context */ uint localIndex() const { return m_index; } private: uint m_index; }; KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(ProblemData, diagnostics, LocalIndexedProblem) class KDEVPLATFORMLANGUAGE_EXPORT ProblemData : public DUChainBaseData { public: ProblemData() : source(IProblem::Unknown) , severity(IProblem::Error) { initializeAppendedLists(); } ProblemData(const ProblemData& rhs) : DUChainBaseData(rhs) , source(rhs.source) , severity(rhs.severity) , url(rhs.url) , description(rhs.description) , explanation(rhs.explanation) { initializeAppendedLists(); copyListsFrom(rhs); } ~ProblemData() { freeAppendedLists(); } IProblem::Source source; IProblem::Severity severity; IndexedString url; IndexedString description; IndexedString explanation; START_APPENDED_LISTS_BASE(ProblemData, DUChainBaseData); APPENDED_LIST_FIRST(ProblemData, LocalIndexedProblem, diagnostics); END_APPENDED_LISTS(ProblemData, diagnostics); }; /** * An object representing a problem in preprocessing, parsing, definition-use chain compilation, etc. * * You should always use ProblemPointer, because Problem may be subclassed. * The subclass would be lost while copying. * * @warning Access to problems must be serialized through DUChainLock. */ class KDEVPLATFORMLANGUAGE_EXPORT Problem : public DUChainBase, public IProblem { public: using Ptr = QExplicitlySharedDataPointer; Problem(); explicit Problem(ProblemData& data); ~Problem(); Source source() const override; void setSource(IProblem::Source source) override; /** * Returns a string version of the problem source */ QString sourceString() const override; TopDUContext* topContext() const override; KDevelop::IndexedString url() const override; /** * Location where this problem occurred * @warning Must only be called from the foreground * */ DocumentRange finalLocation() const override; void setFinalLocation(const DocumentRange& location) override; /** * Returns child diagnostics of this particular problem * * Example: * @code * void foo(unsigned int); * void foo(const char*); * int main() { foo(0); } * @endcode * * => foo(0) is ambigous. This will give us a ProblemPointer pointing to 'foo(0)'. * * Additionally, @p diagnostics may return the two locations to the ambiguous overloads, * with descriptions such as 'test.cpp:1: candidate : ...' */ void clearDiagnostics() override; QVector diagnostics() const override; void setDiagnostics(const QVector &diagnostics) override; void addDiagnostic(const IProblem::Ptr &diagnostic) override; /** * A brief description of the problem. */ QString description() const override; void setDescription(const QString& description) override; /** * A (detailed) explanation of why the problem occurred. */ QString explanation() const override; void setExplanation(const QString& explanation) override; /** * Get the severity of this problem. * This is used for example to decide for a highlighting color. * * @see setSeverity() */ Severity severity() const override; /** * Set the severity of this problem. */ void setSeverity(Severity severity) override; /** * Returns a string representation of the severity. */ QString severityString() const override; /** * If this problem can be solved, this may return an assistant for the solution. */ virtual QExplicitlySharedDataPointer solutionAssistant() const override; enum { Identity = 15 }; /** * Returns a string representation of this problem, useful for debugging. */ virtual QString toString() const; private: void rebuildDynamicData(DUContext* parent, uint ownIndex) override; - Q_DISABLE_COPY(Problem); + Q_DISABLE_COPY(Problem) DUCHAIN_DECLARE_DATA(Problem) friend class TopDUContext; friend class TopDUContextDynamicData; friend class LocalIndexedProblem; //BEGIN dynamic data TopDUContextPointer m_topContext; mutable QList m_diagnostics; uint m_indexInTopContext; //END dynamic data }; } Q_DECLARE_TYPEINFO(KDevelop::LocalIndexedProblem, Q_MOVABLE_TYPE); KDEVPLATFORMLANGUAGE_EXPORT QDebug operator<<(QDebug s, const KDevelop::Problem& problem); KDEVPLATFORMLANGUAGE_EXPORT QDebug operator<<(QDebug s, const KDevelop::ProblemPointer& problem); #endif // KDEVPLATFORM_PROBLEM_H diff --git a/serialization/repositorymanager.h b/serialization/repositorymanager.h index a9f0c9d75..5dc3fbaa8 100644 --- a/serialization/repositorymanager.h +++ b/serialization/repositorymanager.h @@ -1,90 +1,90 @@ /* Copyright 2008 David Nolden This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef REPOSITORYMANAGER_H #define REPOSITORYMANAGER_H #include "abstractitemrepository.h" #include "itemrepositoryregistry.h" namespace KDevelop { /// This class helps managing the lifetime of a global item repository, and protecting the consistency. /// Especially it helps doing thread-safe lazy repository-creation. template struct RepositoryManager : public AbstractRepositoryManager { public: ///@param shareMutex Option repository from where this repository should take the thread-safety mutex RepositoryManager(QString name, int version = 1, AbstractRepositoryManager*(*shareMutex)() = 0, ItemRepositoryRegistry& registry = globalItemRepositoryRegistry()) : m_name(name), m_version(version), m_registry(registry), m_shareMutex(shareMutex) { if(!lazy) { createRepository(); } } ~RepositoryManager() { } - Q_DISABLE_COPY(RepositoryManager); + Q_DISABLE_COPY(RepositoryManager) ItemRepositoryType* repository() const { if(!m_repository) { createRepository(); } return static_cast(m_repository); } inline ItemRepositoryType* operator->() const { return repository(); } QMutex* repositoryMutex() const override { return (*this)->mutex(); } private: void createRepository() const { if(!m_repository) { QMutexLocker lock(&m_registry.mutex()); if(!m_repository) { m_repository = new ItemRepositoryType(m_name, &m_registry, m_version, const_cast(this)); if(m_shareMutex) { (*this)->setMutex(m_shareMutex()->repositoryMutex()); } (*this)->setUnloadingEnabled(unloadingEnabled); } } } QString m_name; int m_version; ItemRepositoryRegistry& m_registry; AbstractRepositoryManager* (*m_shareMutex)(); }; } #endif // REPOSITORYMANAGER_H diff --git a/tests/json/delayedoutput.h b/tests/json/delayedoutput.h index 3134b5c56..cce92e213 100644 --- a/tests/json/delayedoutput.h +++ b/tests/json/delayedoutput.h @@ -1,55 +1,55 @@ /* This file is part of KDevelop Copyright 2012 Olivier de Gaalon This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEVPLATFORM_DELAYEDOUTPUT_H #define KDEVPLATFORM_DELAYEDOUTPUT_H #include #include #include namespace KDevelop { ///Used to invert and visually nest error output generated by nested/recursive functions ///Used in TestSuite.h, use only at your own, singleton educated risk class DelayedOutputPrivate; class KDEVPLATFORMTESTS_EXPORT DelayedOutput { public: class KDEVPLATFORMTESTS_EXPORT Delay { public: Delay(DelayedOutput* output); ~Delay(); private: DelayedOutput *m_output; }; ~DelayedOutput(); static DelayedOutput& self(); void push(const QString &output); private: DelayedOutput(); - Q_DISABLE_COPY(DelayedOutput); + Q_DISABLE_COPY(DelayedOutput) const QScopedPointer d; }; } #endif //KDEVPLATFORM_DELAYEDOUTPUT_H diff --git a/tests/json/testsuite.h b/tests/json/testsuite.h index fdffe94a6..519588868 100644 --- a/tests/json/testsuite.h +++ b/tests/json/testsuite.h @@ -1,137 +1,137 @@ /* This file is part of KDevelop Copyright 2012 Olivier de Gaalon This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEVPLATFORM_TESTSUITE_H #define KDEVPLATFORM_TESTSUITE_H #include #include "delayedoutput.h" #include #include namespace KDevelop { class DUContext; class Declaration; inline QString EXPECT_FAIL() { return QStringLiteral("EXPECT_FAIL"); } inline QString FAILED_TO_FAIL() { return QStringLiteral("\"%1\" FAILED TO FAIL AS EXPECTED: \"%2\" %3"); } inline QString EXPECTED_FAIL() { return QStringLiteral("\"%1\" FAILED (expected): %2 %3"); } inline QString FAIL() { return QStringLiteral("\"%1\" FAILED: %2 %3"); } inline QString TEST_NOT_FOUND() { return QStringLiteral("Test not found"); } template class TestSuite; KDEVPLATFORMTESTS_EXPORT TestSuite& declarationTestSuite(); KDEVPLATFORMTESTS_EXPORT TestSuite& contextTestSuite(); KDEVPLATFORMTESTS_EXPORT TestSuite& typeTestSuite(); template class KDEVPLATFORMTESTS_EXPORT TestSuite { public: typedef QString (*TestFunction)(const QVariant&, T); static TestSuite& get(); bool addTest(const QString& testName, TestFunction testFunc) { m_testFunctions.insert(testName, testFunc); return true; } bool runTests(const QVariantMap &testData, T object) { QVariantMap expectedFails = expectedFailures(testData); QVariantMap::const_iterator it; DelayedOutput::Delay delay(&DelayedOutput::self()); for (it = testData.begin(); it != testData.end(); ++it) { if (it.key() == EXPECT_FAIL()) continue; QString result = m_testFunctions.value(it.key(), &TestSuite::noSuchTest)(it.value(), object); QString expectedFailure = expectedFails.value(it.key(), QString()).toString(); //Either ("expected failure" & "no result failure") or ("no expected failure" & "result failure") if (expectedFailure.isEmpty() ^ result.isEmpty()) { DelayedOutput::self().push(result.isEmpty() ? FAILED_TO_FAIL().arg(it.key(), expectedFailure, objectInformation(object)) : FAIL().arg(it.key(), result, objectInformation(object))); return false; } if (!expectedFailure.isEmpty()) qDebug() << EXPECTED_FAIL().arg(it.key(), expectedFailure, objectInformation(object)).toUtf8().data(); } return true; } private: QVariantMap expectedFailures(const QVariantMap &testData) { if (!testData.contains(EXPECT_FAIL())) return QVariantMap(); return testData[EXPECT_FAIL()].toMap(); } static QString noSuchTest(const QVariant&, T) { return TEST_NOT_FOUND(); } static QString objectInformation(T) { return QString(); } QHash m_testFunctions; TestSuite() { } - Q_DISABLE_COPY(TestSuite); + Q_DISABLE_COPY(TestSuite) friend TestSuite& declarationTestSuite(); friend TestSuite& contextTestSuite(); friend TestSuite& typeTestSuite(); }; template inline bool runTests(const QVariantMap &data, T object) { return TestSuite::get().runTests(data, object); } ///TODO: Once we can use C++11, see whether this can be cleaned up by extern templates template<> inline TestSuite& TestSuite::get() { return declarationTestSuite(); } template<> inline TestSuite& TestSuite::get() { return contextTestSuite(); } template<> inline TestSuite& TestSuite::get() { return typeTestSuite(); } } #endif //KDEVPLATFORM_TESTSUITE_H