Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/language/backgroundparser/parseprojectjob.cpp
Show All 35 Lines | |||||
36 | #include <QPointer> | 36 | #include <QPointer> | ||
37 | #include <QSet> | 37 | #include <QSet> | ||
38 | 38 | | |||
39 | using namespace KDevelop; | 39 | using namespace KDevelop; | ||
40 | 40 | | |||
41 | class KDevelop::ParseProjectJobPrivate | 41 | class KDevelop::ParseProjectJobPrivate | ||
42 | { | 42 | { | ||
43 | public: | 43 | public: | ||
44 | ParseProjectJobPrivate(IProject* project, bool forceUpdate) | 44 | ParseProjectJobPrivate(IProject* project, bool forceUpdate, bool forceAll) | ||
45 | : forceUpdate(forceUpdate) | 45 | : forceUpdate(forceUpdate) | ||
46 | , forceAll(forceAll) | ||||
46 | , project(project) | 47 | , project(project) | ||
47 | { | 48 | { | ||
48 | } | 49 | } | ||
49 | 50 | | |||
50 | int updated = 0; | 51 | int updated = 0; | ||
51 | bool forceUpdate; | 52 | bool forceUpdate; | ||
53 | bool forceAll; | ||||
52 | KDevelop::IProject* project; | 54 | KDevelop::IProject* project; | ||
53 | QSet<IndexedString> filesToParse; | 55 | QSet<IndexedString> filesToParse; | ||
54 | }; | 56 | }; | ||
55 | 57 | | |||
56 | bool ParseProjectJob::doKill() { | 58 | bool ParseProjectJob::doKill() { | ||
57 | qCDebug(LANGUAGE) << "stopping project parse job"; | 59 | qCDebug(LANGUAGE) << "stopping project parse job"; | ||
58 | deleteLater(); | 60 | deleteLater(); | ||
59 | return true; | 61 | return true; | ||
60 | } | 62 | } | ||
61 | 63 | | |||
62 | ParseProjectJob::~ParseProjectJob() { | 64 | ParseProjectJob::~ParseProjectJob() { | ||
63 | ICore::self()->languageController()->backgroundParser()->revertAllRequests(this); | 65 | ICore::self()->languageController()->backgroundParser()->revertAllRequests(this); | ||
64 | 66 | | |||
65 | if(ICore::self()->runController()->currentJobs().contains(this)) | 67 | if(ICore::self()->runController()->currentJobs().contains(this)) | ||
66 | ICore::self()->runController()->unregisterJob(this); | 68 | ICore::self()->runController()->unregisterJob(this); | ||
67 | } | 69 | } | ||
68 | 70 | | |||
69 | ParseProjectJob::ParseProjectJob(IProject* project, bool forceUpdate) | 71 | ParseProjectJob::ParseProjectJob(IProject* project, bool forceUpdate, bool forceAll) | ||
70 | : d(new ParseProjectJobPrivate(project, forceUpdate)) | 72 | : d(new ParseProjectJobPrivate(project, forceUpdate, forceAll)) | ||
71 | { | 73 | { | ||
72 | connect(project, &IProject::destroyed, this, &ParseProjectJob::deleteNow); | 74 | connect(project, &IProject::destroyed, this, &ParseProjectJob::deleteNow); | ||
73 | 75 | | |||
74 | if (!ICore::self()->projectController()->parseAllProjectSources()) { | 76 | if (forceAll || ICore::self()->projectController()->parseAllProjectSources()) { | ||
77 | d->filesToParse = project->fileSet(); | ||||
78 | } else { | ||||
75 | // In case we don't want to parse the whole project, still add all currently open files that belong to the project to the background-parser | 79 | // In case we don't want to parse the whole project, still add all currently open files that belong to the project to the background-parser | ||
76 | foreach (auto document, ICore::self()->documentController()->openDocuments()) { | 80 | foreach (auto document, ICore::self()->documentController()->openDocuments()) { | ||
77 | const auto path = IndexedString(document->url()); | 81 | const auto path = IndexedString(document->url()); | ||
78 | if (project->fileSet().contains(path)) { | 82 | if (project->fileSet().contains(path)) { | ||
79 | d->filesToParse.insert(path); | 83 | d->filesToParse.insert(path); | ||
80 | } | 84 | } | ||
81 | } | 85 | } | ||
82 | } else { | | |||
83 | d->filesToParse = project->fileSet(); | | |||
84 | } | 86 | } | ||
85 | 87 | | |||
86 | setCapabilities(Killable); | 88 | setCapabilities(Killable); | ||
87 | 89 | | |||
88 | setObjectName(i18np("Process 1 file in %2","Process %1 files in %2", d->filesToParse.size(), d->project->name())); | 90 | setObjectName(i18np("Process 1 file in %2","Process %1 files in %2", d->filesToParse.size(), d->project->name())); | ||
89 | } | 91 | } | ||
90 | 92 | | |||
91 | void ParseProjectJob::deleteNow() { | 93 | void ParseProjectJob::deleteNow() { | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 113 | void ParseProjectJob::start() { | |||
142 | foreach (auto document, ICore::self()->documentController()->openDocuments()) { | 144 | foreach (auto document, ICore::self()->documentController()->openDocuments()) { | ||
143 | const auto path = IndexedString(document->url()); | 145 | const auto path = IndexedString(document->url()); | ||
144 | if (d->filesToParse.contains(path)) { | 146 | if (d->filesToParse.contains(path)) { | ||
145 | ICore::self()->languageController()->backgroundParser()->addDocument(path, TopDUContext::AllDeclarationsContextsAndUses, 10, this ); | 147 | ICore::self()->languageController()->backgroundParser()->addDocument(path, TopDUContext::AllDeclarationsContextsAndUses, 10, this ); | ||
146 | d->filesToParse.remove(path); | 148 | d->filesToParse.remove(path); | ||
147 | } | 149 | } | ||
148 | } | 150 | } | ||
149 | 151 | | |||
150 | if (!ICore::self()->projectController()->parseAllProjectSources()) { | 152 | if (!d->forceAll && !ICore::self()->projectController()->parseAllProjectSources()) { | ||
151 | return; | 153 | return; | ||
152 | } | 154 | } | ||
153 | 155 | | |||
154 | // prevent UI-lockup by processing events after some files | 156 | // prevent UI-lockup by processing events after some files | ||
155 | // esp. noticeable when dealing with huge projects | 157 | // esp. noticeable when dealing with huge projects | ||
156 | const int processAfter = 1000; | 158 | const int processAfter = 1000; | ||
157 | int processed = 0; | 159 | int processed = 0; | ||
158 | // guard against reentrancy issues, see also bug 345480 | 160 | // guard against reentrancy issues, see also bug 345480 | ||
Show All 14 Lines |