| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2013-01-28 17:12:19 +01:00
										 |  |  | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Contact: http://www.qt-project.org/legal
 | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** This file is part of Qt Creator. | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** 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 | 
					
						
							|  |  |  | ** a written agreement between you and Digia.  For licensing terms and | 
					
						
							|  |  |  | ** conditions see http://qt.digia.com/licensing.  For further information
 | 
					
						
							|  |  |  | ** use the contact form at http://qt.digia.com/contact-us.
 | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							|  |  |  | ** General Public License version 2.1 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
					
						
							|  |  |  | ** packaging of this file.  Please review the following information to | 
					
						
							|  |  |  | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
					
						
							|  |  |  | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** In addition, as a special exception, Digia gives you certain additional | 
					
						
							|  |  |  | ** rights.  These rights are described in the Digia Qt LGPL Exception | 
					
						
							| 
									
										
										
										
											2010-12-17 16:01:08 +01:00
										 |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-15 13:49:00 +01:00
										 |  |  | #include "qmljsmodelmanager.h"
 | 
					
						
							| 
									
										
										
										
											2010-11-11 10:05:05 +01:00
										 |  |  | #include "qmljstoolsconstants.h"
 | 
					
						
							| 
									
										
										
										
											2010-11-10 15:07:53 +01:00
										 |  |  | #include "qmljsplugindumper.h"
 | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  | #include "qmljsfindexportedcpptypes.h"
 | 
					
						
							| 
									
										
										
										
											2012-04-13 11:57:34 +02:00
										 |  |  | #include "qmljssemanticinfo.h"
 | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  | #include "qmljsbundleprovider.h"
 | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <coreplugin/icore.h>
 | 
					
						
							|  |  |  | #include <coreplugin/progressmanager/progressmanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-05-30 12:56:24 +02:00
										 |  |  | #include <coreplugin/messagemanager.h>
 | 
					
						
							| 
									
										
										
										
											2012-03-14 10:25:55 +01:00
										 |  |  | #include <cpptools/ModelManagerInterface.h>
 | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  | #include <qmljs/qmljsbind.h>
 | 
					
						
							| 
									
										
										
										
											2010-11-11 10:05:05 +01:00
										 |  |  | #include <texteditor/basetexteditor.h>
 | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  | #include <projectexplorer/buildconfiguration.h>
 | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  | #include <projectexplorer/project.h>
 | 
					
						
							| 
									
										
										
										
											2010-09-27 15:51:49 +02:00
										 |  |  | #include <projectexplorer/projectexplorer.h>
 | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  | #include <projectexplorer/session.h>
 | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  | #include <projectexplorer/target.h>
 | 
					
						
							|  |  |  | #include <qtsupport/qtkitinformation.h>
 | 
					
						
							|  |  |  | #include <qtsupport/qmldumptool.h>
 | 
					
						
							|  |  |  | #include <qtsupport/qtsupportconstants.h>
 | 
					
						
							| 
									
										
										
										
											2012-08-23 15:53:58 +02:00
										 |  |  | #include <utils/hostosinfo.h>
 | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  | #include <extensionsystem/pluginmanager.h>
 | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QDir>
 | 
					
						
							|  |  |  | #include <QFile>
 | 
					
						
							|  |  |  | #include <QFileInfo>
 | 
					
						
							| 
									
										
										
										
											2012-02-09 09:35:03 +01:00
										 |  |  | #include <utils/runextensions.h>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QTextStream>
 | 
					
						
							|  |  |  | #include <QTimer>
 | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  | #include <QRegExp>
 | 
					
						
							| 
									
										
										
										
											2009-10-01 16:38:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2010-03-01 13:01:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-25 14:18:53 +01:00
										 |  |  | using namespace QmlJS; | 
					
						
							| 
									
										
										
										
											2010-11-11 10:05:05 +01:00
										 |  |  | using namespace QmlJSTools; | 
					
						
							|  |  |  | using namespace QmlJSTools::Internal; | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | ModelManagerInterface::ProjectInfo QmlJSTools::defaultProjectInfoForProject( | 
					
						
							|  |  |  |         ProjectExplorer::Project *project) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ModelManagerInterface::ProjectInfo projectInfo(project); | 
					
						
							|  |  |  |     ProjectExplorer::Target *activeTarget = 0; | 
					
						
							|  |  |  |     if (project) { | 
					
						
							|  |  |  |         Core::MimeDatabase *db = Core::ICore::mimeDatabase(); | 
					
						
							|  |  |  |         QList<Core::MimeGlobPattern> globs; | 
					
						
							|  |  |  |         QList<Core::MimeType> mimeTypes = db->mimeTypes(); | 
					
						
							|  |  |  |         foreach (const Core::MimeType &mimeType, mimeTypes) | 
					
						
							|  |  |  |             if (mimeType.type() == QLatin1String(Constants::QML_MIMETYPE) | 
					
						
							|  |  |  |                     || mimeType.subClassesOf().contains(QLatin1String(Constants::QML_MIMETYPE))) | 
					
						
							|  |  |  |                 globs << mimeType.globPatterns(); | 
					
						
							|  |  |  |         if (globs.isEmpty()) | 
					
						
							|  |  |  |             globs << Core::MimeGlobPattern(QRegExp(QLatin1String(".*\\.(?:qbs|qml|qmltypes|qmlproject)$"))); | 
					
						
							|  |  |  |         foreach (const QString &filePath | 
					
						
							|  |  |  |                  , project->files(ProjectExplorer::Project::ExcludeGeneratedFiles)) | 
					
						
							|  |  |  |             foreach (const Core::MimeGlobPattern &glob, globs) | 
					
						
							|  |  |  |                 if (glob.regExp().exactMatch(filePath)) | 
					
						
							|  |  |  |                     projectInfo.sourceFiles << filePath; | 
					
						
							|  |  |  |         activeTarget = project->activeTarget(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ProjectExplorer::Kit *activeKit = activeTarget ? activeTarget->kit() : | 
					
						
							|  |  |  |                                            ProjectExplorer::KitManager::instance()->defaultKit(); | 
					
						
							|  |  |  |     QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(activeKit); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool preferDebugDump = false; | 
					
						
							|  |  |  |     bool setPreferDump = false; | 
					
						
							|  |  |  |     projectInfo.tryQmlDump = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (activeTarget) { | 
					
						
							|  |  |  |         if (ProjectExplorer::BuildConfiguration *bc = activeTarget->activeBuildConfiguration()) { | 
					
						
							|  |  |  |             preferDebugDump = bc->buildType() == ProjectExplorer::BuildConfiguration::Debug; | 
					
						
							|  |  |  |             setPreferDump = true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!setPreferDump && qtVersion) | 
					
						
							|  |  |  |         preferDebugDump = (qtVersion->defaultBuildConfig() & QtSupport::BaseQtVersion::DebugBuild); | 
					
						
							|  |  |  |     if (qtVersion && qtVersion->isValid()) { | 
					
						
							|  |  |  |         projectInfo.tryQmlDump = project && ( | 
					
						
							|  |  |  |                     qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT) | 
					
						
							|  |  |  |                     || qtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)); | 
					
						
							|  |  |  |         projectInfo.qtQmlPath = qtVersion->qmakeProperty("QT_INSTALL_QML"); | 
					
						
							|  |  |  |         projectInfo.qtImportsPath = qtVersion->qmakeProperty("QT_INSTALL_IMPORTS"); | 
					
						
							|  |  |  |         projectInfo.qtVersionString = qtVersion->qtVersionString(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (projectInfo.tryQmlDump) { | 
					
						
							|  |  |  |         ProjectExplorer::ToolChain *toolChain = | 
					
						
							|  |  |  |                 ProjectExplorer::ToolChainKitInformation::toolChain(activeKit); | 
					
						
							|  |  |  |         QtSupport::QmlDumpTool::pathAndEnvironment(project, qtVersion, | 
					
						
							|  |  |  |                                                    toolChain, | 
					
						
							|  |  |  |                                                    preferDebugDump, &projectInfo.qmlDumpPath, | 
					
						
							|  |  |  |                                                    &projectInfo.qmlDumpEnvironment); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         projectInfo.qmlDumpPath.clear(); | 
					
						
							|  |  |  |         projectInfo.qmlDumpEnvironment.clear(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     setupProjectInfoQmlBundles(projectInfo); | 
					
						
							|  |  |  |     return projectInfo; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlJSTools::setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ProjectExplorer::Target *activeTarget = 0; | 
					
						
							|  |  |  |     if (projectInfo.project) { | 
					
						
							|  |  |  |         activeTarget = projectInfo.project->activeTarget(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     ProjectExplorer::Kit *activeKit = activeTarget | 
					
						
							|  |  |  |             ? activeTarget->kit() : ProjectExplorer::KitManager::instance()->defaultKit(); | 
					
						
							|  |  |  |     QHash<QString, QString> replacements; | 
					
						
							|  |  |  |     replacements.insert(QLatin1String("$(QT_INSTALL_IMPORTS)"), projectInfo.qtImportsPath); | 
					
						
							|  |  |  |     replacements.insert(QLatin1String("$(QT_INSTALL_QML)"), projectInfo.qtQmlPath); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<IBundleProvider *> bundleProviders = | 
					
						
							|  |  |  |             ExtensionSystem::PluginManager::getObjects<IBundleProvider>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach (IBundleProvider *bp, bundleProviders) { | 
					
						
							|  |  |  |         if (bp) | 
					
						
							|  |  |  |             bp->mergeBundlesForKit(activeKit, projectInfo.activeBundle, replacements); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     projectInfo.extendedBundle = projectInfo.activeBundle; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (projectInfo.project) { | 
					
						
							|  |  |  |         QSet<ProjectExplorer::Kit *> currentKits; | 
					
						
							|  |  |  |         foreach (const ProjectExplorer::Target *t, projectInfo.project->targets()) | 
					
						
							|  |  |  |             if (t->kit()) | 
					
						
							|  |  |  |                 currentKits.insert(t->kit()); | 
					
						
							|  |  |  |         currentKits.remove(activeKit); | 
					
						
							|  |  |  |         foreach (ProjectExplorer::Kit *kit, currentKits) { | 
					
						
							|  |  |  |             foreach (IBundleProvider *bp, bundleProviders) | 
					
						
							|  |  |  |                 if (bp) | 
					
						
							|  |  |  |                     bp->mergeBundlesForKit(kit, projectInfo.extendedBundle, replacements); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-16 16:34:33 +01:00
										 |  |  | static QStringList environmentImportPaths(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-06 12:11:12 +01:00
										 |  |  | static void mergeSuffixes(QStringList &l1, const QStringList &l2) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!l2.isEmpty()) | 
					
						
							|  |  |  |         l1 = l2; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-09 10:55:11 +02:00
										 |  |  | QmlJS::Document::Language QmlJSTools::languageOfFile(const QString &fileName) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |     QStringList jsSuffixes(QLatin1String("js")); | 
					
						
							|  |  |  |     QStringList qmlSuffixes(QLatin1String("qml")); | 
					
						
							| 
									
										
										
										
											2012-12-06 12:11:12 +01:00
										 |  |  |     QStringList qmlProjectSuffixes(QLatin1String("qmlproject")); | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |     QStringList jsonSuffixes(QLatin1String("json")); | 
					
						
							| 
									
										
										
										
											2012-12-06 12:11:12 +01:00
										 |  |  |     QStringList qbsSuffixes(QLatin1String("qbs")); | 
					
						
							| 
									
										
										
										
											2011-09-09 10:55:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (Core::ICore::instance()) { | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |         Core::MimeDatabase *db = Core::ICore::mimeDatabase(); | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |         Core::MimeType jsSourceTy = db->findByType(QLatin1String(Constants::JS_MIMETYPE)); | 
					
						
							| 
									
										
										
										
											2012-12-06 12:11:12 +01:00
										 |  |  |         mergeSuffixes(jsSuffixes, jsSourceTy.suffixes()); | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |         Core::MimeType qmlSourceTy = db->findByType(QLatin1String(Constants::QML_MIMETYPE)); | 
					
						
							| 
									
										
										
										
											2012-12-06 12:11:12 +01:00
										 |  |  |         mergeSuffixes(qmlSuffixes, qmlSourceTy.suffixes()); | 
					
						
							|  |  |  |         Core::MimeType qbsSourceTy = db->findByType(QLatin1String(Constants::QBS_MIMETYPE)); | 
					
						
							|  |  |  |         mergeSuffixes(qbsSuffixes, qbsSourceTy.suffixes()); | 
					
						
							|  |  |  |         Core::MimeType qmlProjectSourceTy = db->findByType(QLatin1String(Constants::QMLPROJECT_MIMETYPE)); | 
					
						
							|  |  |  |         mergeSuffixes(qbsSuffixes, qmlProjectSourceTy.suffixes()); | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |         Core::MimeType jsonSourceTy = db->findByType(QLatin1String(Constants::JSON_MIMETYPE)); | 
					
						
							| 
									
										
										
										
											2012-12-06 12:11:12 +01:00
										 |  |  |         mergeSuffixes(jsonSuffixes, jsonSourceTy.suffixes()); | 
					
						
							| 
									
										
										
										
											2011-09-09 10:55:11 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const QFileInfo info(fileName); | 
					
						
							|  |  |  |     const QString fileSuffix = info.suffix(); | 
					
						
							|  |  |  |     if (jsSuffixes.contains(fileSuffix)) | 
					
						
							|  |  |  |         return QmlJS::Document::JavaScriptLanguage; | 
					
						
							| 
									
										
										
										
											2012-12-06 12:11:12 +01:00
										 |  |  |     if (qbsSuffixes.contains(fileSuffix)) | 
					
						
							|  |  |  |         return QmlJS::Document::QmlQbsLanguage; | 
					
						
							|  |  |  |     if (qmlSuffixes.contains(fileSuffix) || qmlProjectSuffixes.contains(fileSuffix)) | 
					
						
							| 
									
										
										
										
											2011-09-09 10:55:11 +02:00
										 |  |  |         return QmlJS::Document::QmlLanguage; | 
					
						
							| 
									
										
										
										
											2011-10-05 12:09:14 +02:00
										 |  |  |     if (jsonSuffixes.contains(fileSuffix)) | 
					
						
							|  |  |  |         return QmlJS::Document::JsonLanguage; | 
					
						
							| 
									
										
										
										
											2011-09-09 10:55:11 +02:00
										 |  |  |     return QmlJS::Document::UnknownLanguage; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QStringList QmlJSTools::qmlAndJsGlobPatterns() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QStringList pattern; | 
					
						
							|  |  |  |     if (Core::ICore::instance()) { | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |         Core::MimeDatabase *db = Core::ICore::mimeDatabase(); | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |         Core::MimeType jsSourceTy = db->findByType(QLatin1String(Constants::JS_MIMETYPE)); | 
					
						
							|  |  |  |         Core::MimeType qmlSourceTy = db->findByType(QLatin1String(Constants::QML_MIMETYPE)); | 
					
						
							| 
									
										
										
										
											2011-09-09 10:55:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         QStringList pattern; | 
					
						
							|  |  |  |         foreach (const Core::MimeGlobPattern &glob, jsSourceTy.globPatterns()) | 
					
						
							|  |  |  |             pattern << glob.regExp().pattern(); | 
					
						
							|  |  |  |         foreach (const Core::MimeGlobPattern &glob, qmlSourceTy.globPatterns()) | 
					
						
							|  |  |  |             pattern << glob.regExp().pattern(); | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |         pattern << QLatin1String("*.qml") << QLatin1String("*.js"); | 
					
						
							| 
									
										
										
										
											2011-09-09 10:55:11 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     return pattern; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-15 13:49:00 +01:00
										 |  |  | ModelManager::ModelManager(QObject *parent): | 
					
						
							|  |  |  |         ModelManagerInterface(parent), | 
					
						
							| 
									
										
										
										
											2010-11-10 15:07:53 +01:00
										 |  |  |         m_pluginDumper(new PluginDumper(this)) | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     m_synchronizer.setCancelOnWait(true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  |     m_updateCppQmlTypesTimer = new QTimer(this); | 
					
						
							|  |  |  |     m_updateCppQmlTypesTimer->setInterval(1000); | 
					
						
							|  |  |  |     m_updateCppQmlTypesTimer->setSingleShot(true); | 
					
						
							| 
									
										
										
										
											2011-01-06 10:01:45 +01:00
										 |  |  |     connect(m_updateCppQmlTypesTimer, SIGNAL(timeout()), SLOT(startCppQmlTypeUpdate())); | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-18 16:15:23 +01:00
										 |  |  |     qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr"); | 
					
						
							| 
									
										
										
										
											2010-03-18 15:43:33 +01:00
										 |  |  |     qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo"); | 
					
						
							| 
									
										
										
										
											2012-04-13 11:57:34 +02:00
										 |  |  |     qRegisterMetaType<QmlJSTools::SemanticInfo>("QmlJSTools::SemanticInfo"); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-01 13:01:05 +01:00
										 |  |  |     loadQmlTypeDescriptions(); | 
					
						
							| 
									
										
										
										
											2010-03-16 16:34:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_defaultImportPaths << environmentImportPaths(); | 
					
						
							| 
									
										
										
										
											2010-12-09 09:41:43 +01:00
										 |  |  |     updateImportPaths(); | 
					
						
							| 
									
										
										
										
											2010-03-01 13:01:05 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-20 11:25:38 +02:00
										 |  |  | ModelManager::~ModelManager() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_cppQmlTypesUpdater.cancel(); | 
					
						
							|  |  |  |     m_cppQmlTypesUpdater.waitForFinished(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  | void ModelManager::delayedInitialization() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     CPlusPlus::CppModelManagerInterface *cppModelManager = | 
					
						
							|  |  |  |             CPlusPlus::CppModelManagerInterface::instance(); | 
					
						
							|  |  |  |     if (cppModelManager) { | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  |         // It's important to have a direct connection here so we can prevent
 | 
					
						
							|  |  |  |         // the source and AST of the cpp document being cleaned away.
 | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  |         connect(cppModelManager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)), | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  |                 this, SLOT(maybeQueueCppQmlTypeUpdate(CPlusPlus::Document::Ptr)), Qt::DirectConnection); | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-08-26 13:31:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ProjectExplorer::SessionManager *sessionManager = ProjectExplorer::ProjectExplorerPlugin::instance()->session(); | 
					
						
							| 
									
										
										
										
											2012-01-31 13:31:27 +01:00
										 |  |  |     connect(sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)), | 
					
						
							|  |  |  |             this, SLOT(removeProjectInfo(ProjectExplorer::Project*))); | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-01 13:01:05 +01:00
										 |  |  | void ModelManager::loadQmlTypeDescriptions() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-11-10 16:21:05 +01:00
										 |  |  |     if (Core::ICore::instance()) { | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |         loadQmlTypeDescriptions(Core::ICore::resourcePath()); | 
					
						
							|  |  |  |         loadQmlTypeDescriptions(Core::ICore::userResourcePath()); | 
					
						
							| 
									
										
										
										
											2010-11-10 16:21:05 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-09-08 10:11:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ModelManager::loadQmlTypeDescriptions(const QString &resourcePath) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-03-01 13:01:05 +01:00
										 |  |  |     const QDir typeFileDir(resourcePath + QLatin1String("/qml-type-descriptions")); | 
					
						
							| 
									
										
										
										
											2011-02-08 13:22:34 +01:00
										 |  |  |     const QStringList qmlTypesExtensions = QStringList() << QLatin1String("*.qmltypes"); | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  |     QFileInfoList qmlTypesFiles = typeFileDir.entryInfoList( | 
					
						
							| 
									
										
										
										
											2011-02-08 13:22:34 +01:00
										 |  |  |                 qmlTypesExtensions, | 
					
						
							|  |  |  |                 QDir::Files, | 
					
						
							|  |  |  |                 QDir::Name); | 
					
						
							| 
									
										
										
										
											2010-03-01 13:01:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-30 12:56:24 +02:00
										 |  |  |     QStringList errors; | 
					
						
							|  |  |  |     QStringList warnings; | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // filter out the actual Qt builtins
 | 
					
						
							|  |  |  |     for (int i = 0; i < qmlTypesFiles.size(); ++i) { | 
					
						
							|  |  |  |         if (qmlTypesFiles.at(i).baseName() == QLatin1String("builtins")) { | 
					
						
							|  |  |  |             QFileInfoList list; | 
					
						
							|  |  |  |             list.append(qmlTypesFiles.at(i)); | 
					
						
							| 
									
										
										
										
											2011-08-08 12:47:49 +02:00
										 |  |  |             CppQmlTypesLoader::defaultQtObjects = | 
					
						
							|  |  |  |                     CppQmlTypesLoader::loadQmlTypes(list, &errors, &warnings); | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  |             qmlTypesFiles.removeAt(i); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // load the fallbacks for libraries
 | 
					
						
							| 
									
										
										
										
											2011-08-08 12:47:49 +02:00
										 |  |  |     CppQmlTypesLoader::defaultLibraryObjects.unite( | 
					
						
							|  |  |  |                 CppQmlTypesLoader::loadQmlTypes(qmlTypesFiles, &errors, &warnings)); | 
					
						
							| 
									
										
										
										
											2011-05-30 12:56:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Core::MessageManager *messageManager = Core::MessageManager::instance(); | 
					
						
							|  |  |  |     foreach (const QString &error, errors) | 
					
						
							| 
									
										
										
										
											2013-03-12 16:58:28 +01:00
										 |  |  |         messageManager->printToOutputPane(error, Core::MessageManager::Flash); | 
					
						
							| 
									
										
										
										
											2011-05-30 12:56:24 +02:00
										 |  |  |     foreach (const QString &warning, warnings) | 
					
						
							| 
									
										
										
										
											2013-03-12 16:58:28 +01:00
										 |  |  |         messageManager->printToOutputPane(warning, Core::MessageManager::Flash); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-24 14:05:34 +02:00
										 |  |  | ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     WorkingCopy workingCopy; | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |     if (!Core::ICore::instance()) | 
					
						
							| 
									
										
										
										
											2010-11-10 16:21:05 +01:00
										 |  |  |         return workingCopy; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |     foreach (Core::IEditor *editor, Core::ICore::editorManager()->openedEditors()) { | 
					
						
							| 
									
										
										
										
											2012-02-14 16:43:51 +01:00
										 |  |  |         const QString key = editor->document()->fileName(); | 
					
						
							| 
									
										
										
										
											2010-09-24 14:05:34 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor)) { | 
					
						
							| 
									
										
										
										
											2010-11-11 10:05:05 +01:00
										 |  |  |             if (textEditor->context().contains(ProjectExplorer::Constants::LANG_QMLJS)) { | 
					
						
							| 
									
										
										
											
												Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
  # skip ast (excluding paste, astpath, and canv'ast'imer)
  next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
  s = File.read(file)
  next if s.include?('qlalr')
  orig = s.dup
  s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
    res = $&
    if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
      res
    else
      res.gsub!('} else', 'else')
      res.gsub!(/\n +} *\n/m, "\n")
      res.gsub(/ *{$/, '')
    end
  }
  s.gsub!(/ *$/, '')
  File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
											
										 
											2013-01-08 03:32:53 +02:00
										 |  |  |                 if (TextEditor::BaseTextEditorWidget *ed = qobject_cast<TextEditor::BaseTextEditorWidget *>(textEditor->widget())) | 
					
						
							| 
									
										
										
										
											2010-11-11 10:05:05 +01:00
										 |  |  |                     workingCopy.insert(key, ed->toPlainText(), ed->document()->revision()); | 
					
						
							| 
									
										
										
										
											2010-09-24 14:05:34 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return workingCopy; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-30 09:19:56 +02:00
										 |  |  | Snapshot ModelManager::snapshot() const | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-04 17:54:38 +02:00
										 |  |  |     QMutexLocker locker(&m_mutex); | 
					
						
							| 
									
										
										
										
											2011-08-30 09:19:56 +02:00
										 |  |  |     return _validSnapshot; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-09-04 17:54:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-30 09:19:56 +02:00
										 |  |  | Snapshot ModelManager::newestSnapshot() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMutexLocker locker(&m_mutex); | 
					
						
							|  |  |  |     return _newestSnapshot; | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-16 13:08:59 +02:00
										 |  |  | void ModelManager::updateSourceFiles(const QStringList &files, | 
					
						
							|  |  |  |                                      bool emitDocumentOnDiskChanged) | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-04-16 13:08:59 +02:00
										 |  |  |     refreshSourceFiles(files, emitDocumentOnDiskChanged); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-16 13:08:59 +02:00
										 |  |  | QFuture<void> ModelManager::refreshSourceFiles(const QStringList &sourceFiles, | 
					
						
							|  |  |  |                                                bool emitDocumentOnDiskChanged) | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
											
												Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
  # skip ast (excluding paste, astpath, and canv'ast'imer)
  next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
  s = File.read(file)
  next if s.include?('qlalr')
  orig = s.dup
  s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
    res = $&
    if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
      res
    else
      res.gsub!('} else', 'else')
      res.gsub!(/\n +} *\n/m, "\n")
      res.gsub(/ *{$/, '')
    end
  }
  s.gsub!(/ *$/, '')
  File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
											
										 
											2013-01-08 03:32:53 +02:00
										 |  |  |     if (sourceFiles.isEmpty()) | 
					
						
							| 
									
										
										
										
											2009-09-21 18:27:15 +02:00
										 |  |  |         return QFuture<void>(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-15 13:49:00 +01:00
										 |  |  |     QFuture<void> result = QtConcurrent::run(&ModelManager::parse, | 
					
						
							| 
									
										
										
										
											2010-09-24 14:05:34 +02:00
										 |  |  |                                               workingCopy(), sourceFiles, | 
					
						
							| 
									
										
										
										
											2010-04-16 13:08:59 +02:00
										 |  |  |                                               this, | 
					
						
							|  |  |  |                                               emitDocumentOnDiskChanged); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 18:27:15 +02:00
										 |  |  |     if (m_synchronizer.futures().size() > 10) { | 
					
						
							|  |  |  |         QList<QFuture<void> > futures = m_synchronizer.futures(); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 18:27:15 +02:00
										 |  |  |         m_synchronizer.clearFutures(); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-19 15:42:14 +02:00
										 |  |  |         foreach (const QFuture<void> &future, futures) { | 
					
						
							| 
									
										
										
										
											2009-09-21 18:27:15 +02:00
										 |  |  |             if (! (future.isFinished() || future.isCanceled())) | 
					
						
							|  |  |  |                 m_synchronizer.addFuture(future); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-09-21 18:27:15 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 18:27:15 +02:00
										 |  |  |     m_synchronizer.addFuture(result); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-21 18:27:15 +02:00
										 |  |  |     if (sourceFiles.count() > 1) { | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |         Core::ICore::progressManager()->addTask(result, tr("Indexing"), | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |                         QLatin1String(Constants::TASK_INDEX)); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-09-21 18:27:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return result; | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-16 12:42:12 +02:00
										 |  |  | void ModelManager::fileChangedOnDisk(const QString &path) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QtConcurrent::run(&ModelManager::parse, | 
					
						
							| 
									
										
										
										
											2010-09-24 14:05:34 +02:00
										 |  |  |                       workingCopy(), QStringList() << path, | 
					
						
							| 
									
										
										
										
											2010-04-16 12:42:12 +02:00
										 |  |  |                       this, true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-18 13:40:35 +02:00
										 |  |  | void ModelManager::removeFiles(const QStringList &files) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     emit aboutToRemoveFiles(files); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMutexLocker locker(&m_mutex); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-16 14:11:30 +02:00
										 |  |  |     foreach (const QString &file, files) { | 
					
						
							|  |  |  |         _validSnapshot.remove(file); | 
					
						
							|  |  |  |         _newestSnapshot.remove(file); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-05-18 13:40:35 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  | QList<ModelManager::ProjectInfo> ModelManager::projectInfos() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMutexLocker locker(&m_mutex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return m_projects.values(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ModelManager::ProjectInfo ModelManager::projectInfo(ProjectExplorer::Project *project) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMutexLocker locker(&m_mutex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return m_projects.value(project, ProjectInfo(project)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ModelManager::updateProjectInfo(const ProjectInfo &pinfo) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (! pinfo.isValid()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-09 14:29:43 +01:00
										 |  |  |     Snapshot snapshot; | 
					
						
							|  |  |  |     ProjectInfo oldInfo; | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         QMutexLocker locker(&m_mutex); | 
					
						
							| 
									
										
										
										
											2010-11-09 14:29:43 +01:00
										 |  |  |         oldInfo = m_projects.value(pinfo.project); | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  |         m_projects.insert(pinfo.project, pinfo); | 
					
						
							| 
									
										
										
										
											2011-08-16 14:11:30 +02:00
										 |  |  |         snapshot = _validSnapshot; | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-11-24 09:30:46 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  |     if (oldInfo.qmlDumpPath != pinfo.qmlDumpPath | 
					
						
							|  |  |  |             || oldInfo.qmlDumpEnvironment != pinfo.qmlDumpEnvironment) { | 
					
						
							|  |  |  |         m_pluginDumper->scheduleRedumpPlugins(); | 
					
						
							|  |  |  |         m_pluginDumper->scheduleMaybeRedumpBuiltins(pinfo); | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  |     updateImportPaths(); | 
					
						
							| 
									
										
										
										
											2010-11-09 14:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // remove files that are no longer in the project and have been deleted
 | 
					
						
							|  |  |  |     QStringList deletedFiles; | 
					
						
							|  |  |  |     foreach (const QString &oldFile, oldInfo.sourceFiles) { | 
					
						
							|  |  |  |         if (snapshot.document(oldFile) | 
					
						
							|  |  |  |                 && !pinfo.sourceFiles.contains(oldFile) | 
					
						
							|  |  |  |                 && !QFile::exists(oldFile)) { | 
					
						
							|  |  |  |             deletedFiles += oldFile; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     removeFiles(deletedFiles); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // parse any files not yet in the snapshot
 | 
					
						
							|  |  |  |     QStringList newFiles; | 
					
						
							|  |  |  |     foreach (const QString &file, pinfo.sourceFiles) { | 
					
						
							|  |  |  |         if (!snapshot.document(file)) | 
					
						
							|  |  |  |             newFiles += file; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     updateSourceFiles(newFiles, false); | 
					
						
							| 
									
										
										
										
											2011-04-21 11:09:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-23 10:22:51 +01:00
										 |  |  |     // dump builtin types if the shipped definitions are probably outdated and the
 | 
					
						
							|  |  |  |     // Qt version ships qmlplugindump
 | 
					
						
							|  |  |  |     if (QtSupport::QtVersionNumber(pinfo.qtVersionString) >= QtSupport::QtVersionNumber(4, 8, 0)) | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  |         m_pluginDumper->loadBuiltinTypes(pinfo); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-21 11:09:29 +02:00
										 |  |  |     emit projectInfoUpdated(pinfo); | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-26 13:31:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void ModelManager::removeProjectInfo(ProjectExplorer::Project *project) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ProjectInfo info(project); | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  |     info.sourceFiles.clear(); | 
					
						
							| 
									
										
										
										
											2011-08-26 13:31:18 +02:00
										 |  |  |     // update with an empty project info to clear data
 | 
					
						
							|  |  |  |     updateProjectInfo(info); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QMutexLocker locker(&m_mutex); | 
					
						
							|  |  |  |         m_projects.remove(project); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  | ModelManagerInterface::ProjectInfo ModelManager::projectInfoForPath(QString path) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMutexLocker locker(&m_mutex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     foreach (const ProjectInfo &p, m_projects) | 
					
						
							|  |  |  |         if (p.sourceFiles.contains(path)) | 
					
						
							|  |  |  |             return p; | 
					
						
							|  |  |  |     return ProjectInfo(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-16 12:42:12 +02:00
										 |  |  | void ModelManager::emitDocumentChangedOnDisk(Document::Ptr doc) | 
					
						
							|  |  |  | { emit documentChangedOnDisk(doc); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-15 10:06:59 +02:00
										 |  |  | void ModelManager::updateDocument(Document::Ptr doc) | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-10-15 10:06:59 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         QMutexLocker locker(&m_mutex); | 
					
						
							| 
									
										
										
										
											2011-08-16 14:11:30 +02:00
										 |  |  |         _validSnapshot.insert(doc); | 
					
						
							|  |  |  |         _newestSnapshot.insert(doc, true); | 
					
						
							| 
									
										
										
										
											2010-10-15 10:06:59 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     emit documentUpdated(doc); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-15 10:06:59 +02:00
										 |  |  | void ModelManager::updateLibraryInfo(const QString &path, const LibraryInfo &info) | 
					
						
							| 
									
										
										
										
											2010-03-18 15:43:33 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-10-15 10:06:59 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         QMutexLocker locker(&m_mutex); | 
					
						
							| 
									
										
										
										
											2011-08-16 14:11:30 +02:00
										 |  |  |         _validSnapshot.insertLibraryInfo(path, info); | 
					
						
							|  |  |  |         _newestSnapshot.insertLibraryInfo(path, info); | 
					
						
							| 
									
										
										
										
											2010-10-15 10:06:59 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |     // only emit if we got new useful information
 | 
					
						
							|  |  |  |     if (info.isValid()) | 
					
						
							|  |  |  |         emit libraryInfoUpdated(path, info); | 
					
						
							| 
									
										
										
										
											2010-03-18 15:43:33 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  | static QStringList qmlFilesInDirectory(const QString &path) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-09 10:55:11 +02:00
										 |  |  |     const QStringList pattern = qmlAndJsGlobPatterns(); | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  |     QStringList files; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const QDir dir(path); | 
					
						
							|  |  |  |     foreach (const QFileInfo &fi, dir.entryInfoList(pattern, QDir::Files)) | 
					
						
							|  |  |  |         files += fi.absoluteFilePath(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return files; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void findNewImplicitImports(const Document::Ptr &doc, const Snapshot &snapshot, | 
					
						
							|  |  |  |                             QStringList *importedFiles, QSet<QString> *scannedPaths) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // scan files that could be implicitly imported
 | 
					
						
							|  |  |  |     // it's important we also do this for JS files, otherwise the isEmpty check will fail
 | 
					
						
							|  |  |  |     if (snapshot.documentsInDirectory(doc->path()).isEmpty()) { | 
					
						
							|  |  |  |         if (! scannedPaths->contains(doc->path())) { | 
					
						
							|  |  |  |             *importedFiles += qmlFilesInDirectory(doc->path()); | 
					
						
							|  |  |  |             scannedPaths->insert(doc->path()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void findNewFileImports(const Document::Ptr &doc, const Snapshot &snapshot, | 
					
						
							|  |  |  |                         QStringList *importedFiles, QSet<QString> *scannedPaths) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // scan files and directories that are explicitly imported
 | 
					
						
							| 
									
										
										
										
											2011-08-08 12:47:49 +02:00
										 |  |  |     foreach (const ImportInfo &import, doc->bind()->imports()) { | 
					
						
							| 
									
										
										
										
											2011-09-21 12:42:27 +02:00
										 |  |  |         const QString &importName = import.path(); | 
					
						
							| 
									
										
										
										
											2011-08-08 12:47:49 +02:00
										 |  |  |         if (import.type() == ImportInfo::FileImport) { | 
					
						
							| 
									
										
										
										
											2010-09-16 15:29:37 +02:00
										 |  |  |             if (! snapshot.document(importName)) | 
					
						
							|  |  |  |                 *importedFiles += importName; | 
					
						
							| 
									
										
										
										
											2011-08-08 12:47:49 +02:00
										 |  |  |         } else if (import.type() == ImportInfo::DirectoryImport) { | 
					
						
							| 
									
										
										
										
											2010-09-16 15:29:37 +02:00
										 |  |  |             if (snapshot.documentsInDirectory(importName).isEmpty()) { | 
					
						
							|  |  |  |                 if (! scannedPaths->contains(importName)) { | 
					
						
							|  |  |  |                     *importedFiles += qmlFilesInDirectory(importName); | 
					
						
							|  |  |  |                     scannedPaths->insert(importName); | 
					
						
							| 
									
										
										
										
											2010-09-16 09:40:19 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-10 14:49:38 +01:00
										 |  |  | static bool findNewQmlLibraryInPath(const QString &path, | 
					
						
							|  |  |  |                                     const Snapshot &snapshot, | 
					
						
							|  |  |  |                                     ModelManager *modelManager, | 
					
						
							|  |  |  |                                     QStringList *importedFiles, | 
					
						
							|  |  |  |                                     QSet<QString> *scannedPaths, | 
					
						
							|  |  |  |                                     QSet<QString> *newLibraries) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     // if we know there is a library, done
 | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |     const LibraryInfo &existingInfo = snapshot.libraryInfo(path); | 
					
						
							|  |  |  |     if (existingInfo.isValid()) | 
					
						
							| 
									
										
										
										
											2011-03-10 14:49:38 +01:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     if (newLibraries->contains(path)) | 
					
						
							|  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |     // if we looked at the path before, done
 | 
					
						
							|  |  |  |     if (existingInfo.wasScanned()) | 
					
						
							|  |  |  |         return false; | 
					
						
							| 
									
										
										
										
											2011-03-10 14:49:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const QDir dir(path); | 
					
						
							|  |  |  |     QFile qmldirFile(dir.filePath(QLatin1String("qmldir"))); | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |     if (!qmldirFile.exists()) { | 
					
						
							|  |  |  |         LibraryInfo libraryInfo(LibraryInfo::NotFound); | 
					
						
							|  |  |  |         modelManager->updateLibraryInfo(path, libraryInfo); | 
					
						
							| 
									
										
										
										
											2011-03-10 14:49:38 +01:00
										 |  |  |         return false; | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-03-10 14:49:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-23 15:53:58 +02:00
										 |  |  |     if (Utils::HostOsInfo::isWindowsHost()) { | 
					
						
							|  |  |  |         // QTCREATORBUG-3402 - be case sensitive even here?
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-03-10 14:49:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // found a new library!
 | 
					
						
							|  |  |  |     qmldirFile.open(QFile::ReadOnly); | 
					
						
							|  |  |  |     QString qmldirData = QString::fromUtf8(qmldirFile.readAll()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QmlDirParser qmldirParser; | 
					
						
							| 
									
										
										
										
											2012-07-31 10:12:26 +02:00
										 |  |  |     qmldirParser.parse(qmldirData); | 
					
						
							| 
									
										
										
										
											2011-03-10 14:49:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const QString libraryPath = QFileInfo(qmldirFile).absolutePath(); | 
					
						
							|  |  |  |     newLibraries->insert(libraryPath); | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |     modelManager->updateLibraryInfo(libraryPath, LibraryInfo(qmldirParser)); | 
					
						
							| 
									
										
										
										
											2011-03-10 14:49:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // scan the qml files in the library
 | 
					
						
							|  |  |  |     foreach (const QmlDirParser::Component &component, qmldirParser.components()) { | 
					
						
							|  |  |  |         if (! component.fileName.isEmpty()) { | 
					
						
							|  |  |  |             const QFileInfo componentFileInfo(dir.filePath(component.fileName)); | 
					
						
							|  |  |  |             const QString path = QDir::cleanPath(componentFileInfo.absolutePath()); | 
					
						
							|  |  |  |             if (! scannedPaths->contains(path)) { | 
					
						
							|  |  |  |                 *importedFiles += qmlFilesInDirectory(path); | 
					
						
							|  |  |  |                 scannedPaths->insert(path); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  | static void findNewQmlLibrary( | 
					
						
							|  |  |  |     const QString &path, | 
					
						
							|  |  |  |     const LanguageUtils::ComponentVersion &version, | 
					
						
							|  |  |  |     const Snapshot &snapshot, | 
					
						
							|  |  |  |     ModelManager *modelManager, | 
					
						
							|  |  |  |     QStringList *importedFiles, | 
					
						
							|  |  |  |     QSet<QString> *scannedPaths, | 
					
						
							|  |  |  |     QSet<QString> *newLibraries) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |     QString libraryPath = QString::fromLatin1("%1.%2.%3").arg( | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |                 path, | 
					
						
							|  |  |  |                 QString::number(version.majorVersion()), | 
					
						
							|  |  |  |                 QString::number(version.minorVersion())); | 
					
						
							|  |  |  |     findNewQmlLibraryInPath( | 
					
						
							|  |  |  |                 libraryPath, snapshot, modelManager, | 
					
						
							|  |  |  |                 importedFiles, scannedPaths, newLibraries); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-21 22:43:22 +02:00
										 |  |  |     libraryPath = QString::fromLatin1("%1.%2").arg( | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |                 path, | 
					
						
							|  |  |  |                 QString::number(version.majorVersion())); | 
					
						
							|  |  |  |     findNewQmlLibraryInPath( | 
					
						
							|  |  |  |                 libraryPath, snapshot, modelManager, | 
					
						
							|  |  |  |                 importedFiles, scannedPaths, newLibraries); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     findNewQmlLibraryInPath( | 
					
						
							|  |  |  |                 path, snapshot, modelManager, | 
					
						
							|  |  |  |                 importedFiles, scannedPaths, newLibraries); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  | static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snapshot, | 
					
						
							|  |  |  |                            ModelManager *modelManager, | 
					
						
							| 
									
										
										
										
											2011-01-12 13:58:24 +01:00
										 |  |  |                            QStringList *importedFiles, QSet<QString> *scannedPaths, QSet<QString> *newLibraries) | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |     // scan current dir
 | 
					
						
							|  |  |  |     findNewQmlLibraryInPath(doc->path(), snapshot, modelManager, | 
					
						
							|  |  |  |                             importedFiles, scannedPaths, newLibraries); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // scan dir and lib imports
 | 
					
						
							| 
									
										
										
										
											2010-04-26 10:40:18 +02:00
										 |  |  |     const QStringList importPaths = modelManager->importPaths(); | 
					
						
							| 
									
										
										
										
											2011-08-08 12:47:49 +02:00
										 |  |  |     foreach (const ImportInfo &import, doc->bind()->imports()) { | 
					
						
							|  |  |  |         if (import.type() == ImportInfo::DirectoryImport) { | 
					
						
							| 
									
										
										
										
											2011-09-21 12:42:27 +02:00
										 |  |  |             const QString targetPath = import.path(); | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |             findNewQmlLibraryInPath(targetPath, snapshot, modelManager, | 
					
						
							|  |  |  |                                     importedFiles, scannedPaths, newLibraries); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-08 12:47:49 +02:00
										 |  |  |         if (import.type() == ImportInfo::LibraryImport) { | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |             if (!import.version().isValid()) | 
					
						
							|  |  |  |                 continue; | 
					
						
							| 
									
										
										
										
											2011-03-10 14:49:38 +01:00
										 |  |  |             foreach (const QString &importPath, importPaths) { | 
					
						
							| 
									
										
										
										
											2011-09-21 12:42:27 +02:00
										 |  |  |                 const QString targetPath = QDir(importPath).filePath(import.path()); | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |                 findNewQmlLibrary(targetPath, import.version(), snapshot, modelManager, | 
					
						
							|  |  |  |                                   importedFiles, scannedPaths, newLibraries); | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-15 13:49:00 +01:00
										 |  |  | void ModelManager::parse(QFutureInterface<void> &future, | 
					
						
							| 
									
										
										
										
											2010-09-24 14:05:34 +02:00
										 |  |  |                             WorkingCopy workingCopy, | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  |                             QStringList files, | 
					
						
							| 
									
										
										
										
											2010-04-16 12:42:12 +02:00
										 |  |  |                             ModelManager *modelManager, | 
					
						
							|  |  |  |                             bool emitDocChangedOnDisk) | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  |     int progressRange = files.size(); | 
					
						
							|  |  |  |     future.setProgressRange(0, progressRange); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // paths we have scanned for files and added to the files list
 | 
					
						
							|  |  |  |     QSet<QString> scannedPaths; | 
					
						
							| 
									
										
										
										
											2011-01-12 13:58:24 +01:00
										 |  |  |     // libraries we've found while scanning imports
 | 
					
						
							|  |  |  |     QSet<QString> newLibraries; | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 0; i < files.size(); ++i) { | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  |         future.setProgressValue(qreal(i) / files.size() * progressRange); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         const QString fileName = files.at(i); | 
					
						
							| 
									
										
										
										
											2010-02-15 14:07:35 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-09 10:55:11 +02:00
										 |  |  |         Document::Language language = languageOfFile(fileName); | 
					
						
							|  |  |  |         if (language == Document::UnknownLanguage) | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  |         QString contents; | 
					
						
							| 
									
										
										
										
											2010-01-25 14:18:53 +01:00
										 |  |  |         int documentRevision = 0; | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (workingCopy.contains(fileName)) { | 
					
						
							| 
									
										
										
										
											2010-09-24 14:05:34 +02:00
										 |  |  |             QPair<QString, int> entry = workingCopy.get(fileName); | 
					
						
							|  |  |  |             contents = entry.first; | 
					
						
							|  |  |  |             documentRevision = entry.second; | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             QFile inFile(fileName); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (inFile.open(QIODevice::ReadOnly)) { | 
					
						
							|  |  |  |                 QTextStream ins(&inFile); | 
					
						
							|  |  |  |                 contents = ins.readAll(); | 
					
						
							|  |  |  |                 inFile.close(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-03 13:47:03 +01:00
										 |  |  |         Document::MutablePtr doc = Document::create(fileName, language); | 
					
						
							| 
									
										
										
										
											2010-07-07 17:52:02 +02:00
										 |  |  |         doc->setEditorRevision(documentRevision); | 
					
						
							| 
									
										
										
										
											2009-09-04 16:51:11 +02:00
										 |  |  |         doc->setSource(contents); | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  |         doc->parse(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-27 14:51:30 +02:00
										 |  |  |         // update snapshot. requires synchronization, but significantly reduces amount of file
 | 
					
						
							|  |  |  |         // system queries for library imports because queries are cached in libraryInfo
 | 
					
						
							|  |  |  |         const Snapshot snapshot = modelManager->snapshot(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  |         // get list of referenced files not yet in snapshot or in directories already scanned
 | 
					
						
							|  |  |  |         QStringList importedFiles; | 
					
						
							|  |  |  |         findNewImplicitImports(doc, snapshot, &importedFiles, &scannedPaths); | 
					
						
							|  |  |  |         findNewFileImports(doc, snapshot, &importedFiles, &scannedPaths); | 
					
						
							| 
									
										
										
										
											2011-01-12 13:58:24 +01:00
										 |  |  |         findNewLibraryImports(doc, snapshot, modelManager, &importedFiles, &scannedPaths, &newLibraries); | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // add new files to parse list
 | 
					
						
							|  |  |  |         foreach (const QString &file, importedFiles) { | 
					
						
							|  |  |  |             if (! files.contains(file)) | 
					
						
							|  |  |  |                 files.append(file); | 
					
						
							| 
									
										
										
										
											2010-03-18 15:43:33 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-15 10:06:59 +02:00
										 |  |  |         modelManager->updateDocument(doc); | 
					
						
							| 
									
										
										
										
											2010-04-16 12:42:12 +02:00
										 |  |  |         if (emitDocChangedOnDisk) | 
					
						
							|  |  |  |             modelManager->emitDocumentChangedOnDisk(doc); | 
					
						
							| 
									
										
										
										
											2010-03-16 16:34:33 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-06 09:52:29 +02:00
										 |  |  |     future.setProgressValue(progressRange); | 
					
						
							| 
									
										
										
										
											2010-03-16 16:34:33 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-20 16:43:50 +01:00
										 |  |  | // Check whether fileMimeType is the same or extends knownMimeType
 | 
					
						
							| 
									
										
										
										
											2010-02-15 13:49:00 +01:00
										 |  |  | bool ModelManager::matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType) | 
					
						
							| 
									
										
										
										
											2010-01-20 16:43:50 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |     Core::MimeDatabase *db = Core::ICore::mimeDatabase(); | 
					
						
							| 
									
										
										
										
											2010-01-20 16:43:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const QStringList knownTypeNames = QStringList(knownMimeType.type()) + knownMimeType.aliases(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-19 15:42:14 +02:00
										 |  |  |     foreach (const QString &knownTypeName, knownTypeNames) | 
					
						
							| 
									
										
										
										
											2010-01-20 16:43:50 +01:00
										 |  |  |         if (fileMimeType.matchesType(knownTypeName)) | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // recursion to parent types of fileMimeType
 | 
					
						
							|  |  |  |     foreach (const QString &parentMimeType, fileMimeType.subClassesOf()) { | 
					
						
							|  |  |  |         if (matchesMimeType(db->findByType(parentMimeType), knownMimeType)) | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2010-03-16 16:34:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | QStringList ModelManager::importPaths() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-01-13 11:07:20 +01:00
										 |  |  |     QMutexLocker l(&m_mutex); | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  |     return m_allImportPaths; | 
					
						
							| 
									
										
										
										
											2010-03-16 16:34:33 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  | QmlLanguageBundles ModelManager::activeBundles() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMutexLocker l(&m_mutex); | 
					
						
							|  |  |  |     return m_activeBundles; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QmlLanguageBundles ModelManager::extendedBundles() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMutexLocker l(&m_mutex); | 
					
						
							|  |  |  |     return m_extendedBundles; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-16 16:34:33 +01:00
										 |  |  | static QStringList environmentImportPaths() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QStringList paths; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QByteArray envImportPath = qgetenv("QML_IMPORT_PATH"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-31 16:39:20 +02:00
										 |  |  |     foreach (const QString &path, QString::fromLatin1(envImportPath) | 
					
						
							|  |  |  |              .split(Utils::HostOsInfo::pathListSeparator(), QString::SkipEmptyParts)) { | 
					
						
							| 
									
										
										
										
											2010-03-16 16:34:33 +01:00
										 |  |  |         QString canonicalPath = QDir(path).canonicalPath(); | 
					
						
							|  |  |  |         if (!canonicalPath.isEmpty() && !paths.contains(canonicalPath)) | 
					
						
							|  |  |  |             paths.append(canonicalPath); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return paths; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2010-06-09 14:27:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  | void ModelManager::updateImportPaths() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-01-13 11:07:20 +01:00
										 |  |  |     QStringList allImportPaths; | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  |     QmlLanguageBundles activeBundles; | 
					
						
							|  |  |  |     QmlLanguageBundles extendedBundles; | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  |     QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects); | 
					
						
							|  |  |  |     while (it.hasNext()) { | 
					
						
							|  |  |  |         it.next(); | 
					
						
							| 
									
										
										
										
											2011-01-20 11:03:23 +01:00
										 |  |  |         foreach (const QString &path, it.value().importPaths) { | 
					
						
							|  |  |  |             const QString canonicalPath = QFileInfo(path).canonicalFilePath(); | 
					
						
							|  |  |  |             if (!canonicalPath.isEmpty()) | 
					
						
							| 
									
										
										
										
											2012-01-13 11:07:20 +01:00
										 |  |  |                 allImportPaths += canonicalPath; | 
					
						
							| 
									
										
										
										
											2011-01-20 11:03:23 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  |     it.toFront(); | 
					
						
							|  |  |  |     while (it.hasNext()) { | 
					
						
							|  |  |  |         it.next(); | 
					
						
							|  |  |  |         activeBundles.mergeLanguageBundles(it.value().activeBundle); | 
					
						
							|  |  |  |         foreach (Document::Language l, it.value().activeBundle.languages()) { | 
					
						
							|  |  |  |             foreach (const QString &path, it.value().activeBundle.bundleForLanguage(l) | 
					
						
							|  |  |  |                  .searchPaths().stringList()) { | 
					
						
							|  |  |  |                 const QString canonicalPath = QFileInfo(path).canonicalFilePath(); | 
					
						
							|  |  |  |                 if (!canonicalPath.isEmpty()) | 
					
						
							|  |  |  |                     allImportPaths += canonicalPath; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     it.toFront(); | 
					
						
							|  |  |  |     while (it.hasNext()) { | 
					
						
							|  |  |  |         it.next(); | 
					
						
							|  |  |  |         extendedBundles.mergeLanguageBundles(it.value().extendedBundle); | 
					
						
							|  |  |  |         foreach (Document::Language l, it.value().extendedBundle.languages()) { | 
					
						
							|  |  |  |             foreach (const QString &path, it.value().extendedBundle.bundleForLanguage(l) | 
					
						
							|  |  |  |                      .searchPaths().stringList()) { | 
					
						
							|  |  |  |                 const QString canonicalPath = QFileInfo(path).canonicalFilePath(); | 
					
						
							|  |  |  |                 if (!canonicalPath.isEmpty()) | 
					
						
							|  |  |  |                     allImportPaths += canonicalPath; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-01-13 11:07:20 +01:00
										 |  |  |     allImportPaths += m_defaultImportPaths; | 
					
						
							|  |  |  |     allImportPaths.removeDuplicates(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QMutexLocker l(&m_mutex); | 
					
						
							|  |  |  |         m_allImportPaths = allImportPaths; | 
					
						
							| 
									
										
										
										
											2012-12-06 17:20:58 +01:00
										 |  |  |         m_activeBundles = activeBundles; | 
					
						
							|  |  |  |         m_extendedBundles = extendedBundles; | 
					
						
							| 
									
										
										
										
											2012-01-13 11:07:20 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // check if any file in the snapshot imports something new in the new paths
 | 
					
						
							| 
									
										
										
										
											2011-08-16 14:11:30 +02:00
										 |  |  |     Snapshot snapshot = _validSnapshot; | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  |     QStringList importedFiles; | 
					
						
							|  |  |  |     QSet<QString> scannedPaths; | 
					
						
							| 
									
										
										
										
											2011-01-12 13:58:24 +01:00
										 |  |  |     QSet<QString> newLibraries; | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  |     foreach (const Document::Ptr &doc, snapshot) | 
					
						
							| 
									
										
										
										
											2011-01-12 13:58:24 +01:00
										 |  |  |         findNewLibraryImports(doc, snapshot, this, &importedFiles, &scannedPaths, &newLibraries); | 
					
						
							| 
									
										
										
										
											2010-06-22 12:54:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     updateSourceFiles(importedFiles, true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-08 13:29:21 +01:00
										 |  |  | void ModelManager::loadPluginTypes(const QString &libraryPath, const QString &importPath, | 
					
						
							|  |  |  |                                    const QString &importUri, const QString &importVersion) | 
					
						
							| 
									
										
										
										
											2010-09-15 14:13:33 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-02-08 13:29:21 +01:00
										 |  |  |     m_pluginDumper->loadPluginTypes(libraryPath, importPath, importUri, importVersion); | 
					
						
							| 
									
										
										
										
											2010-09-15 14:13:33 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  | // is called *inside a c++ parsing thread*, to allow hanging on to source and ast
 | 
					
						
							|  |  |  | void ModelManager::maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc) | 
					
						
							| 
									
										
										
										
											2011-01-06 10:01:45 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-08-24 10:55:48 +02:00
										 |  |  |     // avoid scanning documents without source code available
 | 
					
						
							|  |  |  |     doc->keepSourceAndAST(); | 
					
						
							| 
									
										
										
										
											2012-01-12 17:53:56 +01:00
										 |  |  |     if (doc->utf8Source().isEmpty()) { | 
					
						
							| 
									
										
										
										
											2011-08-24 10:55:48 +02:00
										 |  |  |         doc->releaseSourceAndAST(); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  |     // keep source and AST alive if we want to scan for register calls
 | 
					
						
							|  |  |  |     const bool scan = FindExportedCppTypes::maybeExportsTypes(doc); | 
					
						
							| 
									
										
										
										
											2011-08-24 10:55:48 +02:00
										 |  |  |     if (!scan) | 
					
						
							|  |  |  |         doc->releaseSourceAndAST(); | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // delegate actual queuing to the gui thread
 | 
					
						
							|  |  |  |     QMetaObject::invokeMethod(this, "queueCppQmlTypeUpdate", | 
					
						
							|  |  |  |                               Q_ARG(CPlusPlus::Document::Ptr, doc), Q_ARG(bool, scan)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ModelManager::queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QPair<CPlusPlus::Document::Ptr, bool> prev = m_queuedCppDocuments.value(doc->fileName()); | 
					
						
							|  |  |  |     if (prev.first && prev.second) | 
					
						
							|  |  |  |         prev.first->releaseSourceAndAST(); | 
					
						
							|  |  |  |     m_queuedCppDocuments.insert(doc->fileName(), qMakePair(doc, scan)); | 
					
						
							| 
									
										
										
										
											2011-01-06 10:01:45 +01:00
										 |  |  |     m_updateCppQmlTypesTimer->start(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ModelManager::startCppQmlTypeUpdate() | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-10-20 11:25:38 +02:00
										 |  |  |     // if a future is still running, delay
 | 
					
						
							|  |  |  |     if (m_cppQmlTypesUpdater.isRunning()) { | 
					
						
							|  |  |  |         m_updateCppQmlTypesTimer->start(); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  |     CPlusPlus::CppModelManagerInterface *cppModelManager = | 
					
						
							|  |  |  |             CPlusPlus::CppModelManagerInterface::instance(); | 
					
						
							|  |  |  |     if (!cppModelManager) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-20 11:25:38 +02:00
										 |  |  |     m_cppQmlTypesUpdater = QtConcurrent::run( | 
					
						
							|  |  |  |                 &ModelManager::updateCppQmlTypes, | 
					
						
							|  |  |  |                 this, cppModelManager->snapshot(), m_queuedCppDocuments); | 
					
						
							| 
									
										
										
										
											2011-01-06 10:01:45 +01:00
										 |  |  |     m_queuedCppDocuments.clear(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-20 11:25:38 +02:00
										 |  |  | void ModelManager::updateCppQmlTypes(QFutureInterface<void> &interface, | 
					
						
							|  |  |  |                                      ModelManager *qmlModelManager, | 
					
						
							|  |  |  |                                      CPlusPlus::Snapshot snapshot, | 
					
						
							| 
									
										
										
										
											2011-09-16 10:35:48 +02:00
										 |  |  |                                      QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > documents) | 
					
						
							| 
									
										
										
										
											2011-01-06 10:01:45 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-08-25 12:35:55 +02:00
										 |  |  |     CppDataHash newData = qmlModelManager->cppData(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  |     FindExportedCppTypes finder(snapshot); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     typedef QPair<CPlusPlus::Document::Ptr, bool> DocScanPair; | 
					
						
							|  |  |  |     foreach (const DocScanPair &pair, documents) { | 
					
						
							| 
									
										
										
										
											2011-10-20 11:25:38 +02:00
										 |  |  |         if (interface.isCanceled()) | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  |         CPlusPlus::Document::Ptr doc = pair.first; | 
					
						
							|  |  |  |         const bool scan = pair.second; | 
					
						
							|  |  |  |         const QString fileName = doc->fileName(); | 
					
						
							|  |  |  |         if (!scan) { | 
					
						
							| 
									
										
										
										
											2011-08-25 12:35:55 +02:00
										 |  |  |             newData.remove(fileName); | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  |             continue; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-25 12:35:55 +02:00
										 |  |  |         finder(doc); | 
					
						
							| 
									
										
										
										
											2011-01-06 10:01:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-25 12:35:55 +02:00
										 |  |  |         QList<LanguageUtils::FakeMetaObject::ConstPtr> exported = finder.exportedTypes(); | 
					
						
							| 
									
										
										
										
											2011-09-16 10:35:48 +02:00
										 |  |  |         QHash<QString, QString> contextProperties = finder.contextProperties(); | 
					
						
							| 
									
										
										
										
											2011-08-25 12:35:55 +02:00
										 |  |  |         if (exported.isEmpty() && contextProperties.isEmpty()) { | 
					
						
							|  |  |  |             newData.remove(fileName); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             CppData &data = newData[fileName]; | 
					
						
							|  |  |  |             data.exportedTypes = exported; | 
					
						
							|  |  |  |             data.contextProperties = contextProperties; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-08-23 12:02:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         doc->releaseSourceAndAST(); | 
					
						
							| 
									
										
										
										
											2011-01-06 10:01:45 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-25 12:35:55 +02:00
										 |  |  |     QMutexLocker locker(&qmlModelManager->m_cppDataMutex); | 
					
						
							|  |  |  |     qmlModelManager->m_cppDataHash = newData; | 
					
						
							| 
									
										
										
										
											2011-01-06 10:01:45 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-25 12:35:55 +02:00
										 |  |  | ModelManager::CppDataHash ModelManager::cppData() const | 
					
						
							| 
									
										
										
										
											2011-01-06 10:01:45 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-08-25 12:35:55 +02:00
										 |  |  |     QMutexLocker locker(&m_cppDataMutex); | 
					
						
							|  |  |  |     return m_cppDataHash; | 
					
						
							| 
									
										
										
										
											2010-12-03 10:13:15 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-04-12 09:14:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  | LibraryInfo ModelManager::builtins(const Document::Ptr &doc) const | 
					
						
							| 
									
										
										
										
											2011-04-12 09:14:31 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-06-28 12:01:56 +02:00
										 |  |  |     ProjectExplorer::SessionManager *sessionManager = ProjectExplorer::ProjectExplorerPlugin::instance()->session(); | 
					
						
							|  |  |  |     ProjectExplorer::Project *project = sessionManager->projectForFile(doc->fileName()); | 
					
						
							|  |  |  |     if (!project) | 
					
						
							|  |  |  |         return LibraryInfo(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMutexLocker locker(&m_mutex); | 
					
						
							|  |  |  |     ProjectInfo info = m_projects.value(project); | 
					
						
							|  |  |  |     if (!info.isValid()) | 
					
						
							|  |  |  |         return LibraryInfo(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-16 14:11:30 +02:00
										 |  |  |     return _validSnapshot.libraryInfo(info.qtImportsPath); | 
					
						
							| 
									
										
										
										
											2011-04-12 09:14:31 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-06-23 15:12:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-12 11:11:26 +02:00
										 |  |  | void ModelManager::joinAllThreads() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     foreach (QFuture<void> future, m_synchronizer.futures()) | 
					
						
							|  |  |  |         future.waitForFinished(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-23 15:12:03 +02:00
										 |  |  | void ModelManager::resetCodeModel() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QStringList documents; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QMutexLocker locker(&m_mutex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // find all documents currently in the code model
 | 
					
						
							| 
									
										
										
										
											2011-08-16 14:11:30 +02:00
										 |  |  |         foreach (Document::Ptr doc, _validSnapshot) | 
					
						
							| 
									
										
										
										
											2011-06-23 15:12:03 +02:00
										 |  |  |             documents.append(doc->fileName()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // reset the snapshot
 | 
					
						
							| 
									
										
										
										
											2011-08-16 14:11:30 +02:00
										 |  |  |         _validSnapshot = Snapshot(); | 
					
						
							|  |  |  |         _newestSnapshot = Snapshot(); | 
					
						
							| 
									
										
										
										
											2011-06-23 15:12:03 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // start a reparse thread
 | 
					
						
							|  |  |  |     updateSourceFiles(documents, false); | 
					
						
							|  |  |  | } |