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 | { | 59 | { | ||
58 | qCDebug(LANGUAGE) << "stopping project parse job"; | 60 | qCDebug(LANGUAGE) << "stopping project parse job"; | ||
59 | deleteLater(); | 61 | deleteLater(); | ||
60 | return true; | 62 | return true; | ||
61 | } | 63 | } | ||
62 | 64 | | |||
63 | ParseProjectJob::~ParseProjectJob() | 65 | ParseProjectJob::~ParseProjectJob() | ||
64 | { | 66 | { | ||
65 | ICore::self()->languageController()->backgroundParser()->revertAllRequests(this); | 67 | ICore::self()->languageController()->backgroundParser()->revertAllRequests(this); | ||
66 | 68 | | |||
67 | if (ICore::self()->runController()->currentJobs().contains(this)) | 69 | if (ICore::self()->runController()->currentJobs().contains(this)) | ||
68 | ICore::self()->runController()->unregisterJob(this); | 70 | ICore::self()->runController()->unregisterJob(this); | ||
69 | } | 71 | } | ||
70 | 72 | | |||
71 | ParseProjectJob::ParseProjectJob(IProject* project, bool forceUpdate) | 73 | ParseProjectJob::ParseProjectJob(IProject* project, bool forceUpdate, bool forceAll) | ||
72 | : d(new ParseProjectJobPrivate(project, forceUpdate)) | 74 | : d(new ParseProjectJobPrivate(project, forceUpdate, forceAll)) | ||
73 | { | 75 | { | ||
74 | connect(project, &IProject::destroyed, this, &ParseProjectJob::deleteNow); | 76 | connect(project, &IProject::destroyed, this, &ParseProjectJob::deleteNow); | ||
75 | 77 | | |||
76 | if (!ICore::self()->projectController()->parseAllProjectSources()) { | 78 | if (forceAll || ICore::self()->projectController()->parseAllProjectSources()) { | ||
79 | d->filesToParse = project->fileSet(); | ||||
80 | } else { | ||||
77 | // 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 | 81 | // 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 | ||
78 | foreach (auto document, ICore::self()->documentController()->openDocuments()) { | 82 | foreach (auto document, ICore::self()->documentController()->openDocuments()) { | ||
79 | const auto path = IndexedString(document->url()); | 83 | const auto path = IndexedString(document->url()); | ||
80 | if (project->fileSet().contains(path)) { | 84 | if (project->fileSet().contains(path)) { | ||
81 | d->filesToParse.insert(path); | 85 | d->filesToParse.insert(path); | ||
82 | } | 86 | } | ||
83 | } | 87 | } | ||
84 | } else { | | |||
85 | d->filesToParse = project->fileSet(); | | |||
86 | } | 88 | } | ||
87 | 89 | | |||
88 | setCapabilities(Killable); | 90 | setCapabilities(Killable); | ||
89 | 91 | | |||
90 | setObjectName(i18np("Process 1 file in %2", "Process %1 files in %2", d->filesToParse.size(), d->project->name())); | 92 | setObjectName(i18np("Process 1 file in %2", "Process %1 files in %2", d->filesToParse.size(), d->project->name())); | ||
91 | } | 93 | } | ||
92 | 94 | | |||
93 | void ParseProjectJob::deleteNow() | 95 | void ParseProjectJob::deleteNow() | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 154 | foreach (auto document, ICore::self()->documentController()->openDocuments()) { | |||
155 | if (fileIt != d->filesToParse.end()) { | 157 | if (fileIt != d->filesToParse.end()) { | ||
156 | ICore::self()->languageController()->backgroundParser()->addDocument(path, | 158 | ICore::self()->languageController()->backgroundParser()->addDocument(path, | ||
157 | TopDUContext::AllDeclarationsContextsAndUses, 10, | 159 | TopDUContext::AllDeclarationsContextsAndUses, 10, | ||
158 | this); | 160 | this); | ||
159 | d->filesToParse.erase(fileIt); | 161 | d->filesToParse.erase(fileIt); | ||
160 | } | 162 | } | ||
161 | } | 163 | } | ||
162 | 164 | | |||
163 | if (!ICore::self()->projectController()->parseAllProjectSources()) { | 165 | if (!d->forceAll && !ICore::self()->projectController()->parseAllProjectSources()) { | ||
164 | return; | 166 | return; | ||
165 | } | 167 | } | ||
166 | 168 | | |||
167 | // prevent UI-lockup by processing events after some files | 169 | // prevent UI-lockup by processing events after some files | ||
168 | // esp. noticeable when dealing with huge projects | 170 | // esp. noticeable when dealing with huge projects | ||
169 | const int processAfter = 1000; | 171 | const int processAfter = 1000; | ||
170 | int processed = 0; | 172 | int processed = 0; | ||
171 | // guard against reentrancy issues, see also bug 345480 | 173 | // guard against reentrancy issues, see also bug 345480 | ||
Show All 15 Lines |