| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** Copyright (C) 2016 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: https://www.qt.io/licensing/
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +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.
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +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.
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-18 07:55:01 +01:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-14 13:54:31 +01:00
										 |  |  | #include "cpptools_global.h"
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | #include "cppmodelmanager.h"
 | 
					
						
							|  |  |  | #include "searchsymbols.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-25 16:16:11 +01:00
										 |  |  | #include "stringtable.h"
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-29 09:11:27 +01:00
										 |  |  | #include <cplusplus/CppDocument.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QHash>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <functional>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | namespace CppTools { | 
					
						
							| 
									
										
										
										
											2014-03-14 13:54:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | namespace Internal { | 
					
						
							| 
									
										
										
										
											2014-03-14 13:54:31 +01:00
										 |  |  | class CppToolsPlugin; | 
					
						
							| 
									
										
										
										
											2017-12-29 09:11:27 +01:00
										 |  |  | } // namespace Internal
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class CppLocatorData : public QObject | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-14 13:54:31 +01:00
										 |  |  |     // Only one instance, created by the CppToolsPlugin.
 | 
					
						
							|  |  |  |     CppLocatorData(); | 
					
						
							|  |  |  |     friend class Internal::CppToolsPlugin; | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-14 13:54:31 +01:00
										 |  |  | public: | 
					
						
							|  |  |  |     void filterAllFiles(IndexItem::Visitor func) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         flushPendingDocument(true); | 
					
						
							|  |  |  |         QMutexLocker locker(&m_pendingDocumentsMutex); | 
					
						
							|  |  |  |         QHash<QString, IndexItem::Ptr> infosByFile = m_infosByFile; | 
					
						
							|  |  |  |         locker.unlock(); | 
					
						
							|  |  |  |         for (auto i = infosByFile.constBegin(), ei = infosByFile.constEnd(); i != ei; ++i) | 
					
						
							|  |  |  |             if (i.value()->visitAllChildren(func) == IndexItem::Break) | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public slots: | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  |     void onDocumentUpdated(const CPlusPlus::Document::Ptr &document); | 
					
						
							|  |  |  |     void onAboutToRemoveFiles(const QStringList &files); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2014-03-14 13:54:31 +01:00
										 |  |  |     void flushPendingDocument(bool force) const; | 
					
						
							| 
									
										
										
										
											2014-04-14 16:52:01 +02:00
										 |  |  |     QList<IndexItem::Ptr> allIndexItems(const QHash<QString, QList<IndexItem::Ptr>> &items) const; | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-14 13:54:31 +01:00
										 |  |  |     QString findOrInsertFilePath(const QString &path) const | 
					
						
							|  |  |  |     { return m_strings->insert(path); } | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2017-12-29 09:11:27 +01:00
										 |  |  |     Internal::StringTable *m_strings = nullptr; // Used to avoid QString duplication
 | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-14 13:54:31 +01:00
										 |  |  |     mutable SearchSymbols m_search; | 
					
						
							|  |  |  |     mutable QHash<QString, IndexItem::Ptr> m_infosByFile; | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     mutable QMutex m_pendingDocumentsMutex; | 
					
						
							| 
									
										
										
										
											2014-03-14 13:54:31 +01:00
										 |  |  |     mutable QVector<CPlusPlus::Document::Ptr> m_pendingDocuments; | 
					
						
							| 
									
										
										
										
											2013-08-23 15:07:19 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-29 09:11:27 +01:00
										 |  |  | } // namespace CppTools
 |