Changeset View
Changeset View
Standalone View
Standalone View
plugins/problemreporter/problemreporterplugin.cpp
Show All 38 Lines | |||||
39 | #include <interfaces/ilanguagecontroller.h> | 39 | #include <interfaces/ilanguagecontroller.h> | ||
40 | #include <language/duchain/duchainlock.h> | 40 | #include <language/duchain/duchainlock.h> | ||
41 | #include <language/duchain/duchain.h> | 41 | #include <language/duchain/duchain.h> | ||
42 | #include <util/kdevstringhandler.h> | 42 | #include <util/kdevstringhandler.h> | ||
43 | 43 | | |||
44 | #include "problemhighlighter.h" | 44 | #include "problemhighlighter.h" | ||
45 | #include "problemtreeview.h" | 45 | #include "problemtreeview.h" | ||
46 | #include "problemreportermodel.h" | 46 | #include "problemreportermodel.h" | ||
47 | #include "language/assistant/staticassistantsmanager.h" | ||||
47 | #include <interfaces/context.h> | 48 | #include <interfaces/context.h> | ||
48 | #include <language/interfaces/editorcontext.h> | 49 | #include <language/interfaces/editorcontext.h> | ||
49 | #include <language/duchain/duchainutils.h> | 50 | #include <language/duchain/duchainutils.h> | ||
50 | #include <interfaces/contextmenuextension.h> | 51 | #include <interfaces/contextmenuextension.h> | ||
51 | #include <interfaces/iassistant.h> | 52 | #include <interfaces/iassistant.h> | ||
52 | #include <QAction> | 53 | #include <QAction> | ||
53 | 54 | | |||
54 | #include "shell/problemmodelset.h" | 55 | #include "shell/problemmodelset.h" | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 120 | { | |||
123 | IndexedString url(doc->url()); | 124 | IndexedString url(doc->url()); | ||
124 | delete m_highlighters.take(url); | 125 | delete m_highlighters.take(url); | ||
125 | } | 126 | } | ||
126 | 127 | | |||
127 | void ProblemReporterPlugin::textDocumentCreated(KDevelop::IDocument* document) | 128 | void ProblemReporterPlugin::textDocumentCreated(KDevelop::IDocument* document) | ||
128 | { | 129 | { | ||
129 | Q_ASSERT(document->textDocument()); | 130 | Q_ASSERT(document->textDocument()); | ||
130 | m_highlighters.insert(IndexedString(document->url()), new ProblemHighlighter(document->textDocument())); | 131 | m_highlighters.insert(IndexedString(document->url()), new ProblemHighlighter(document->textDocument())); | ||
131 | DUChainReadLocker lock(DUChain::lock()); | | |||
132 | DUChain::self()->updateContextForUrl(IndexedString(document->url()), | 132 | DUChain::self()->updateContextForUrl(IndexedString(document->url()), | ||
133 | KDevelop::TopDUContext::AllDeclarationsContextsAndUses, this); | 133 | KDevelop::TopDUContext::AllDeclarationsContextsAndUses, this); | ||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | void ProblemReporterPlugin::updateReady(const IndexedString& url, const KDevelop::ReferencedTopDUContext&) | 136 | void ProblemReporterPlugin::updateReady(const IndexedString& url, const KDevelop::ReferencedTopDUContext& top) | ||
137 | { | 137 | { | ||
138 | { | ||||
139 | DUChainWriteLocker lock(DUChain::lock(), 300); | ||||
140 | if ( !lock.locked() ) { | ||||
141 | return; | ||||
142 | } | ||||
143 | ICore::self()->languageController()->staticAssistantsManager()->notifyAssistants(url, top); | ||||
144 | auto assistantProblems = ICore::self()->languageController()->staticAssistantsManager()->problemsForContext(top); | ||||
145 | Q_FOREACH ( const auto p, assistantProblems ) { | ||||
146 | qDebug() << "adding problem:" << p << "assistant:" << p->solutionAssistant().data() << p->solutionAssistant()->actions().size(); | ||||
147 | top->addProblem(p); | ||||
148 | } | ||||
149 | } | ||||
150 | | ||||
138 | m_model->problemsUpdated(url); | 151 | m_model->problemsUpdated(url); | ||
139 | ProblemHighlighter* ph = m_highlighters.value(url); | 152 | ProblemHighlighter* ph = m_highlighters.value(url); | ||
140 | if (ph) { | 153 | if (ph) { | ||
141 | QVector<IProblem::Ptr> allProblems = m_model->problems(url, false); | 154 | auto allProblems = m_model->problems(url, false); | ||
142 | ph->setProblems(allProblems); | 155 | ph->setProblems(allProblems); | ||
143 | } | 156 | } | ||
144 | } | 157 | } | ||
145 | 158 | | |||
146 | KDevelop::ContextMenuExtension ProblemReporterPlugin::contextMenuExtension(KDevelop::Context* context) | 159 | KDevelop::ContextMenuExtension ProblemReporterPlugin::contextMenuExtension(KDevelop::Context* context) | ||
147 | { | 160 | { | ||
148 | KDevelop::ContextMenuExtension extension; | 161 | KDevelop::ContextMenuExtension extension; | ||
149 | 162 | | |||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |