Changeset View
Changeset View
Standalone View
Standalone View
pythonparsejob.cpp
Show All 13 Lines | |||||
14 | * GNU General Public License for more details. * | 14 | * GNU General Public License for more details. * | ||
15 | * * | 15 | * * | ||
16 | * You should have received a copy of the GNU General Public License * | 16 | * You should have received a copy of the GNU General Public License * | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||
18 | ***************************************************************************** | 18 | ***************************************************************************** | ||
19 | */ | 19 | */ | ||
20 | #include "pythonparsejob.h" | 20 | #include "pythonparsejob.h" | ||
21 | 21 | | |||
22 | #include "pythondebug.h" | ||||
22 | #include "pythonhighlighting.h" | 23 | #include "pythonhighlighting.h" | ||
23 | #include "pythoneditorintegrator.h" | 24 | #include "pythoneditorintegrator.h" | ||
24 | #include "dumpchain.h" | 25 | #include "dumpchain.h" | ||
25 | #include "parsesession.h" | 26 | #include "parsesession.h" | ||
26 | #include "pythonlanguagesupport.h" | 27 | #include "pythonlanguagesupport.h" | ||
27 | #include "declarationbuilder.h" | 28 | #include "declarationbuilder.h" | ||
28 | #include "usebuilder.h" | 29 | #include "usebuilder.h" | ||
29 | #include "kshell.h" | 30 | #include "kshell.h" | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
97 | 98 | | |||
98 | 99 | | |||
99 | void ParseJob::run(ThreadWeaver::JobPointer /*self*/, ThreadWeaver::Thread* /*thread*/) | 100 | void ParseJob::run(ThreadWeaver::JobPointer /*self*/, ThreadWeaver::Thread* /*thread*/) | ||
100 | { | 101 | { | ||
101 | if ( abortRequested() || ICore::self()->shuttingDown() ) { | 102 | if ( abortRequested() || ICore::self()->shuttingDown() ) { | ||
102 | return abortJob(); | 103 | return abortJob(); | ||
103 | } | 104 | } | ||
104 | 105 | | |||
105 | qDebug() << " ====> PARSING ====> parsing file " << document().toUrl() << "; has priority" << parsePriority(); | 106 | qCDebug(KDEV_PYTHON) << " ====> PARSING ====> parsing file " << document().toUrl() << "; has priority" << parsePriority(); | ||
106 | 107 | | |||
107 | { | 108 | { | ||
108 | QMutexLocker l(&Helper::projectPathLock); | 109 | QMutexLocker l(&Helper::projectPathLock); | ||
109 | Helper::projectSearchPaths.clear(); | 110 | Helper::projectSearchPaths.clear(); | ||
110 | foreach (IProject* project, ICore::self()->projectController()->projects() ) { | 111 | foreach (IProject* project, ICore::self()->projectController()->projects() ) { | ||
111 | Helper::projectSearchPaths.append(QUrl::fromLocalFile(project->path().path())); | 112 | Helper::projectSearchPaths.append(QUrl::fromLocalFile(project->path().path())); | ||
112 | } | 113 | } | ||
113 | } | 114 | } | ||
114 | 115 | | |||
115 | // lock the URL so no other parse job can run on this document | 116 | // lock the URL so no other parse job can run on this document | ||
116 | QReadLocker parselock(languageSupport()->parseLock()); | 117 | QReadLocker parselock(languageSupport()->parseLock()); | ||
117 | UrlParseLock urlLock(document()); | 118 | UrlParseLock urlLock(document()); | ||
118 | 119 | | |||
119 | readContents(); | 120 | readContents(); | ||
120 | 121 | | |||
121 | if ( !(minimumFeatures() & TopDUContext::ForceUpdate || minimumFeatures() & Rescheduled) ) { | 122 | if ( !(minimumFeatures() & TopDUContext::ForceUpdate || minimumFeatures() & Rescheduled) ) { | ||
122 | DUChainReadLocker lock(DUChain::lock()); | 123 | DUChainReadLocker lock(DUChain::lock()); | ||
123 | static const IndexedString langString("python"); | 124 | static const IndexedString langString("python"); | ||
124 | foreach(const ParsingEnvironmentFilePointer &file, DUChain::self()->allEnvironmentFiles(document())) { | 125 | foreach(const ParsingEnvironmentFilePointer &file, DUChain::self()->allEnvironmentFiles(document())) { | ||
125 | if ( file->language() != langString ) { | 126 | if ( file->language() != langString ) { | ||
126 | continue; | 127 | continue; | ||
127 | } | 128 | } | ||
128 | if ( ! file->needsUpdate() && file->featuresSatisfied(minimumFeatures()) && file->topContext() ) { | 129 | if ( ! file->needsUpdate() && file->featuresSatisfied(minimumFeatures()) && file->topContext() ) { | ||
129 | qDebug() << " ====> NOOP ====> Already up to date:" << document().str(); | 130 | qCDebug(KDEV_PYTHON) << " ====> NOOP ====> Already up to date:" << document().str(); | ||
130 | setDuChain(file->topContext()); | 131 | setDuChain(file->topContext()); | ||
131 | if ( ICore::self()->languageController()->backgroundParser()->trackerForUrl(document()) ) { | 132 | if ( ICore::self()->languageController()->backgroundParser()->trackerForUrl(document()) ) { | ||
132 | lock.unlock(); | 133 | lock.unlock(); | ||
133 | highlightDUChain(); | 134 | highlightDUChain(); | ||
134 | } | 135 | } | ||
135 | return; | 136 | return; | ||
136 | } | 137 | } | ||
137 | break; | 138 | break; | ||
Show All 37 Lines | 163 | { | |||
175 | 176 | | |||
176 | // gather uses of variables and functions on the document | 177 | // gather uses of variables and functions on the document | ||
177 | UseBuilder usebuilder(editor.data(), builder.missingModules()); | 178 | UseBuilder usebuilder(editor.data(), builder.missingModules()); | ||
178 | usebuilder.setCurrentlyParsedDocument(document()); | 179 | usebuilder.setCurrentlyParsedDocument(document()); | ||
179 | usebuilder.buildUses(m_ast.data()); | 180 | usebuilder.buildUses(m_ast.data()); | ||
180 | 181 | | |||
181 | // check whether any unresolved imports were encountered | 182 | // check whether any unresolved imports were encountered | ||
182 | bool needsReparse = ! builder.unresolvedImports().isEmpty(); | 183 | bool needsReparse = ! builder.unresolvedImports().isEmpty(); | ||
183 | qDebug() << "Document needs update because of unresolved identifiers: " << needsReparse; | 184 | qCDebug(KDEV_PYTHON) << "Document needs update because of unresolved identifiers: " << needsReparse; | ||
184 | if ( needsReparse ) { | 185 | if ( needsReparse ) { | ||
185 | // check whether one of the imports is queued for parsing, this is to avoid deadlocks | 186 | // check whether one of the imports is queued for parsing, this is to avoid deadlocks | ||
186 | // it's also ok if the duchain is now available (and thus has been parsed before already) | 187 | // it's also ok if the duchain is now available (and thus has been parsed before already) | ||
187 | bool dependencyInQueue = false; | 188 | bool dependencyInQueue = false; | ||
188 | DUChainWriteLocker lock; | 189 | DUChainWriteLocker lock; | ||
189 | foreach ( const IndexedString& url, builder.unresolvedImports() ) { | 190 | foreach ( const IndexedString& url, builder.unresolvedImports() ) { | ||
190 | dependencyInQueue = KDevelop::ICore::self()->languageController()->backgroundParser()->isQueued(url); | 191 | dependencyInQueue = KDevelop::ICore::self()->languageController()->backgroundParser()->isQueued(url); | ||
191 | dependencyInQueue = dependencyInQueue || DUChain::self()->chainForDocument(url); | 192 | dependencyInQueue = dependencyInQueue || DUChain::self()->chainForDocument(url); | ||
Show All 15 Lines | |||||
207 | { | 208 | { | ||
208 | DUChainWriteLocker lock(DUChain::lock()); | 209 | DUChainWriteLocker lock(DUChain::lock()); | ||
209 | m_duContext->setFeatures(minimumFeatures()); | 210 | m_duContext->setFeatures(minimumFeatures()); | ||
210 | ParsingEnvironmentFilePointer parsingEnvironmentFile = m_duContext->parsingEnvironmentFile(); | 211 | ParsingEnvironmentFilePointer parsingEnvironmentFile = m_duContext->parsingEnvironmentFile(); | ||
211 | parsingEnvironmentFile->setModificationRevision(contents().modification); | 212 | parsingEnvironmentFile->setModificationRevision(contents().modification); | ||
212 | DUChain::self()->updateContextEnvironment(m_duContext, parsingEnvironmentFile.data()); | 213 | DUChain::self()->updateContextEnvironment(m_duContext, parsingEnvironmentFile.data()); | ||
213 | } | 214 | } | ||
214 | 215 | | |||
215 | qDebug() << "---- Parsing Succeeded ----"; | 216 | qCDebug(KDEV_PYTHON) << "---- Parsing Succeeded ----"; | ||
216 | 217 | | |||
217 | if ( abortRequested() ) { | 218 | if ( abortRequested() ) { | ||
218 | return abortJob(); | 219 | return abortJob(); | ||
219 | } | 220 | } | ||
220 | 221 | | |||
221 | // start the code highlighter if parsing was successful. | 222 | // start the code highlighter if parsing was successful. | ||
222 | highlightDUChain(); | 223 | highlightDUChain(); | ||
223 | } | 224 | } | ||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |