| 
									
										
										
										
											2014-08-22 08:42:04 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** Copyright (C) 2016 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: https://www.qt.io/licensing/
 | 
					
						
							| 
									
										
										
										
											2014-08-22 08:42:04 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Commercial License Usage | 
					
						
							|  |  |  | ** Licensees holding valid commercial Qt licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the commercial license agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** a written agreement between you and The Qt Company. For licensing terms | 
					
						
							|  |  |  | ** and conditions see https://www.qt.io/terms-conditions. For further
 | 
					
						
							|  |  |  | ** information use the contact form at https://www.qt.io/contact-us.
 | 
					
						
							| 
									
										
										
										
											2014-08-22 08:42:04 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** GNU General Public License Usage | 
					
						
							|  |  |  | ** Alternatively, this file may be used under the terms of the GNU | 
					
						
							|  |  |  | ** General Public License version 3 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
					
						
							|  |  |  | ** included in the packaging of this file. Please review the following | 
					
						
							|  |  |  | ** information to ensure the GNU General Public License requirements will | 
					
						
							|  |  |  | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
 | 
					
						
							| 
									
										
										
										
											2014-08-22 08:42:04 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-18 07:55:01 +01:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-15 00:12:27 +02:00
										 |  |  | #include "cppmodelmanager.h"
 | 
					
						
							| 
									
										
										
										
											2014-07-30 16:29:02 +02:00
										 |  |  | #include "cppworkingcopy.h"
 | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <cplusplus/PreprocessorEnvironment.h>
 | 
					
						
							|  |  |  | #include <cplusplus/pp-engine.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QHash>
 | 
					
						
							|  |  |  | #include <QPointer>
 | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  | #include <QSet>
 | 
					
						
							|  |  |  | #include <QStringList>
 | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-27 22:11:09 +02:00
										 |  |  | #include <functional>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-14 10:59:46 +01:00
										 |  |  | QT_BEGIN_NAMESPACE | 
					
						
							|  |  |  | class QTextCodec; | 
					
						
							|  |  |  | QT_END_NAMESPACE | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | namespace CppTools { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-26 10:57:41 +04:00
										 |  |  | // Documentation inside.
 | 
					
						
							| 
									
										
										
										
											2014-05-19 11:17:39 -04:00
										 |  |  | class CppSourceProcessor: public CPlusPlus::Client | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-05-16 15:51:04 -04:00
										 |  |  |     Q_DISABLE_COPY(CppSourceProcessor) | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-06 14:41:19 +02:00
										 |  |  | public: | 
					
						
							|  |  |  |     typedef std::function<void (const CPlusPlus::Document::Ptr &)> DocumentCallback; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-05-26 10:57:41 +04:00
										 |  |  |     static QString cleanPath(const QString &path); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-06 14:41:19 +02:00
										 |  |  |     CppSourceProcessor(const CPlusPlus::Snapshot &snapshot, DocumentCallback documentFinished); | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  |     ~CppSourceProcessor(); | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 14:48:42 +02:00
										 |  |  |     using CancelChecker = std::function<bool()>; | 
					
						
							|  |  |  |     void setCancelChecker(const CancelChecker &cancelChecker); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-30 16:29:02 +02:00
										 |  |  |     void setWorkingCopy(const CppTools::WorkingCopy &workingCopy); | 
					
						
							| 
									
										
										
										
											2016-01-13 14:12:15 +01:00
										 |  |  |     void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths); | 
					
						
							| 
									
										
										
										
											2015-02-15 23:43:26 +02:00
										 |  |  |     void setLanguageFeatures(CPlusPlus::LanguageFeatures languageFeatures); | 
					
						
							| 
									
										
										
										
											2016-08-16 13:37:49 +02:00
										 |  |  |     void setFileSizeLimitInMb(int fileSizeLimitInMb); | 
					
						
							| 
									
										
										
										
											2014-09-04 14:59:50 +02:00
										 |  |  |     void setTodo(const QSet<QString> &files); | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-16 11:25:15 +02:00
										 |  |  |     void run(const QString &fileName, const QStringList &initialIncludes = QStringList()); | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  |     void removeFromCache(const QString &fileName); | 
					
						
							|  |  |  |     void resetEnvironment(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  |     CPlusPlus::Snapshot snapshot() const { return m_snapshot; } | 
					
						
							|  |  |  |     const QSet<QString> &todo() const { return m_todo; } | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-19 16:05:29 +02:00
										 |  |  |     void setGlobalSnapshot(const CPlusPlus::Snapshot &snapshot) { m_globalSnapshot = snapshot; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2016-01-13 14:12:15 +01:00
										 |  |  |     void addFrameworkPath(const ProjectPartHeaderPath &frameworkPath); | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     CPlusPlus::Document::Ptr switchCurrentDocument(CPlusPlus::Document::Ptr doc); | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-19 09:11:59 -03:00
										 |  |  |     bool getFileContents(const QString &absoluteFilePath, QByteArray *contents, | 
					
						
							|  |  |  |                          unsigned *revision) const; | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  |     bool checkFile(const QString &absoluteFilePath) const; | 
					
						
							|  |  |  |     QString resolveFile(const QString &fileName, IncludeType type); | 
					
						
							| 
									
										
										
										
											2016-03-11 15:10:28 +01:00
										 |  |  |     QString resolveFile_helper(const QString &fileName, | 
					
						
							|  |  |  |                                ProjectPartHeaderPaths::Iterator headerPathsIt); | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void mergeEnvironment(CPlusPlus::Document::Ptr doc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  |     // Client interface
 | 
					
						
							| 
									
										
										
										
											2015-06-03 15:32:42 +02:00
										 |  |  |     void macroAdded(const CPlusPlus::Macro ¯o) override; | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  |     void passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset, | 
					
						
							| 
									
										
										
										
											2015-06-03 15:32:42 +02:00
										 |  |  |                                     unsigned line, const CPlusPlus::Macro ¯o) override; | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  |     void failedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charOffset, | 
					
						
							| 
									
										
										
										
											2015-06-03 15:32:42 +02:00
										 |  |  |                                     const CPlusPlus::ByteArrayRef &name) override; | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  |     void notifyMacroReference(unsigned bytesOffset, unsigned utf16charOffset, | 
					
						
							| 
									
										
										
										
											2015-06-03 15:32:42 +02:00
										 |  |  |                               unsigned line, const CPlusPlus::Macro ¯o) override; | 
					
						
							| 
									
										
										
										
											2014-05-16 16:09:26 -04:00
										 |  |  |     void startExpandingMacro(unsigned bytesOffset, unsigned utf16charOffset, | 
					
						
							|  |  |  |                              unsigned line, const CPlusPlus::Macro ¯o, | 
					
						
							| 
									
										
										
										
											2015-06-03 15:32:42 +02:00
										 |  |  |                              const QVector<CPlusPlus::MacroArgumentReference> &actuals) override; | 
					
						
							|  |  |  |     void stopExpandingMacro(unsigned bytesOffset, const CPlusPlus::Macro ¯o) override; | 
					
						
							|  |  |  |     void markAsIncludeGuard(const QByteArray ¯oName) override; | 
					
						
							|  |  |  |     void startSkippingBlocks(unsigned utf16charsOffset) override; | 
					
						
							|  |  |  |     void stopSkippingBlocks(unsigned utf16charsOffset) override; | 
					
						
							| 
									
										
										
										
											2014-07-16 11:25:15 +02:00
										 |  |  |     void sourceNeeded(unsigned line, const QString &fileName, IncludeType type, | 
					
						
							| 
									
										
										
										
											2015-06-03 15:32:42 +02:00
										 |  |  |                       const QStringList &initialIncludes) override; | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     CPlusPlus::Snapshot m_snapshot; | 
					
						
							| 
									
										
										
										
											2013-08-19 16:05:29 +02:00
										 |  |  |     CPlusPlus::Snapshot m_globalSnapshot; | 
					
						
							| 
									
										
										
										
											2014-06-06 14:41:19 +02:00
										 |  |  |     DocumentCallback m_documentFinished; | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  |     CPlusPlus::Environment m_env; | 
					
						
							|  |  |  |     CPlusPlus::Preprocessor m_preprocess; | 
					
						
							| 
									
										
										
										
											2016-01-13 14:12:15 +01:00
										 |  |  |     ProjectPartHeaderPaths m_headerPaths; | 
					
						
							| 
									
										
										
										
											2015-02-15 23:43:26 +02:00
										 |  |  |     CPlusPlus::LanguageFeatures m_languageFeatures; | 
					
						
							| 
									
										
										
										
											2014-07-30 16:29:02 +02:00
										 |  |  |     CppTools::WorkingCopy m_workingCopy; | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  |     QSet<QString> m_included; | 
					
						
							|  |  |  |     CPlusPlus::Document::Ptr m_currentDoc; | 
					
						
							|  |  |  |     QSet<QString> m_todo; | 
					
						
							|  |  |  |     QSet<QString> m_processed; | 
					
						
							|  |  |  |     QHash<QString, QString> m_fileNameCache; | 
					
						
							| 
									
										
										
										
											2016-08-16 13:37:49 +02:00
										 |  |  |     int m_fileSizeLimitInMb = -1; | 
					
						
							| 
									
										
										
										
											2013-11-14 10:59:46 +01:00
										 |  |  |     QTextCodec *m_defaultCodec; | 
					
						
							| 
									
										
										
										
											2013-04-23 15:04:36 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace CppTools
 |