forked from qt-creator/qt-creator
QmlJS: Allow forced rescan on already known paths
Qml files used by Quick tests are not necessarily added to the project file and therefore not fully handled by the QmlJS code model / snapshot. When adding qml files to a directory that is handled by the code model these folders are not scanned again - we need to enforce such a scan on AutoTest plugin's side. Task-number: QTCREATORBUG-17805 Change-Id: Ie3d071a9aa03297d618648b06d52fb298c856d25 Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
@@ -990,7 +990,7 @@ struct ScanItem {
|
|||||||
void ModelManagerInterface::importScan(QFutureInterface<void> &future,
|
void ModelManagerInterface::importScan(QFutureInterface<void> &future,
|
||||||
ModelManagerInterface::WorkingCopy workingCopy,
|
ModelManagerInterface::WorkingCopy workingCopy,
|
||||||
PathsAndLanguages paths, ModelManagerInterface *modelManager,
|
PathsAndLanguages paths, ModelManagerInterface *modelManager,
|
||||||
bool emitDocChangedOnDisk, bool libOnly)
|
bool emitDocChangedOnDisk, bool libOnly, bool forceRescan)
|
||||||
{
|
{
|
||||||
// paths we have scanned for files and added to the files list
|
// paths we have scanned for files and added to the files list
|
||||||
QSet<QString> scannedPaths;
|
QSet<QString> scannedPaths;
|
||||||
@@ -1008,7 +1008,7 @@ void ModelManagerInterface::importScan(QFutureInterface<void> &future,
|
|||||||
for (int i = 0; i < paths.size(); ++i) {
|
for (int i = 0; i < paths.size(); ++i) {
|
||||||
PathAndLanguage pAndL = paths.at(i);
|
PathAndLanguage pAndL = paths.at(i);
|
||||||
QString cPath = QDir::cleanPath(pAndL.path().toString());
|
QString cPath = QDir::cleanPath(pAndL.path().toString());
|
||||||
if (modelManager->m_scannedPaths.contains(cPath))
|
if (!forceRescan && modelManager->m_scannedPaths.contains(cPath))
|
||||||
continue;
|
continue;
|
||||||
pathsToScan.append(ScanItem(cPath, 0, pAndL.language()));
|
pathsToScan.append(ScanItem(cPath, 0, pAndL.language()));
|
||||||
modelManager->m_scannedPaths.insert(cPath);
|
modelManager->m_scannedPaths.insert(cPath);
|
||||||
@@ -1024,13 +1024,15 @@ void ModelManagerInterface::importScan(QFutureInterface<void> &future,
|
|||||||
ScanItem toScan = pathsToScan.last();
|
ScanItem toScan = pathsToScan.last();
|
||||||
pathsToScan.pop_back();
|
pathsToScan.pop_back();
|
||||||
int pathBudget = (1 << (maxScanDepth + 2 - toScan.depth));
|
int pathBudget = (1 << (maxScanDepth + 2 - toScan.depth));
|
||||||
if (!scannedPaths.contains(toScan.path)) {
|
if (forceRescan || !scannedPaths.contains(toScan.path)) {
|
||||||
QStringList importedFiles;
|
QStringList importedFiles;
|
||||||
if (!findNewQmlLibraryInPath(toScan.path, snapshot, modelManager, &importedFiles,
|
if (forceRescan ||
|
||||||
|
(!findNewQmlLibraryInPath(toScan.path, snapshot, modelManager, &importedFiles,
|
||||||
&scannedPaths, &newLibraries, true)
|
&scannedPaths, &newLibraries, true)
|
||||||
&& !libOnly && snapshot.documentsInDirectory(toScan.path).isEmpty())
|
&& !libOnly && snapshot.documentsInDirectory(toScan.path).isEmpty())) {
|
||||||
importedFiles += filesInDirectoryForLanguages(toScan.path,
|
importedFiles += filesInDirectoryForLanguages(toScan.path,
|
||||||
toScan.language.companionLanguages());
|
toScan.language.companionLanguages());
|
||||||
|
}
|
||||||
workDone += 1;
|
workDone += 1;
|
||||||
future.setProgressValue(progressRange * workDone / totalWork);
|
future.setProgressValue(progressRange * workDone / totalWork);
|
||||||
if (!importedFiles.isEmpty()) {
|
if (!importedFiles.isEmpty()) {
|
||||||
@@ -1101,7 +1103,7 @@ void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
|
|||||||
if (pathToScan.length() > 1) {
|
if (pathToScan.length() > 1) {
|
||||||
QFuture<void> result = Utils::runAsync(&ModelManagerInterface::importScan,
|
QFuture<void> result = Utils::runAsync(&ModelManagerInterface::importScan,
|
||||||
workingCopyInternal(), pathToScan,
|
workingCopyInternal(), pathToScan,
|
||||||
this, true, true);
|
this, true, true, false);
|
||||||
cleanupFutures();
|
cleanupFutures();
|
||||||
m_futures.append(result);
|
m_futures.append(result);
|
||||||
|
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ public:
|
|||||||
WorkingCopy workingCopyInternal,
|
WorkingCopy workingCopyInternal,
|
||||||
PathsAndLanguages paths,
|
PathsAndLanguages paths,
|
||||||
ModelManagerInterface *modelManager,
|
ModelManagerInterface *modelManager,
|
||||||
bool emitDocChangedOnDisk, bool libOnly = true);
|
bool emitDocChangedOnDisk, bool libOnly = true, bool forceRescan = false);
|
||||||
|
|
||||||
virtual void resetCodeModel();
|
virtual void resetCodeModel();
|
||||||
void removeProjectInfo(ProjectExplorer::Project *project);
|
void removeProjectInfo(ProjectExplorer::Project *project);
|
||||||
|
|||||||
@@ -134,10 +134,8 @@ static QList<QmlJS::Document::Ptr> scanDirectoryForQuickTestQmlFiles(const QStri
|
|||||||
QFutureInterface<void> future;
|
QFutureInterface<void> future;
|
||||||
QmlJS::PathsAndLanguages paths;
|
QmlJS::PathsAndLanguages paths;
|
||||||
paths.maybeInsert(Utils::FileName::fromString(srcDir), QmlJS::Dialect::Qml);
|
paths.maybeInsert(Utils::FileName::fromString(srcDir), QmlJS::Dialect::Qml);
|
||||||
const bool emitDocumentChanges = false;
|
|
||||||
const bool onlyTheLib = false;
|
|
||||||
QmlJS::ModelManagerInterface::importScan(future, qmlJsMM->workingCopy(), paths, qmlJsMM,
|
QmlJS::ModelManagerInterface::importScan(future, qmlJsMM->workingCopy(), paths, qmlJsMM,
|
||||||
emitDocumentChanges, onlyTheLib);
|
false /*emitDocumentChanges*/, false /*onlyTheLib*/, true /*forceRescan*/ );
|
||||||
|
|
||||||
const QmlJS::Snapshot snapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot();
|
const QmlJS::Snapshot snapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot();
|
||||||
QDirIterator it(srcDir, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
QDirIterator it(srcDir, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||||
|
|||||||
Reference in New Issue
Block a user