• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/language/duchain

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • language
  • duchain
  • navigation
abstractnavigationcontext.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2007 David Nolden <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17  */
18 
19 #include "abstractnavigationcontext.h"
20 
21 #include <KLocalizedString>
22 
23 #include "abstractdeclarationnavigationcontext.h"
24 #include "abstractnavigationwidget.h"
25 #include "usesnavigationcontext.h"
26 #include "../../../interfaces/icore.h"
27 #include "../../../interfaces/idocumentcontroller.h"
28 #include "../functiondeclaration.h"
29 #include "../namespacealiasdeclaration.h"
30 #include "../types/functiontype.h"
31 #include "../types/structuretype.h"
32 #include <debug.h>
33 #include <interfaces/icontextbrowser.h>
34 #include <interfaces/idocumentationcontroller.h>
35 #include <interfaces/iplugincontroller.h>
36 
37 namespace KDevelop {
38 class AbstractNavigationContextPrivate
39 {
40 public:
41  QVector<NavigationContextPointer> m_children; //Used to keep alive all children until this is deleted
42 
43  int m_selectedLink = 0; //The link currently selected
44  NavigationAction m_selectedLinkAction; //Target of the currently selected link
45 
46  bool m_shorten = false;
47 
48  //A counter used while building the html-code to count the used links.
49  int m_linkCount = -1;
50  //Something else than -1 if the current position is represented by a line-number, not a link.
51  int m_currentLine = 0;
52  int m_currentPositionLine = 0;
53  QMap<QString, NavigationAction> m_links;
54  QMap<int, int> m_linkLines; //Holds the line for each link
55  QMap<int, NavigationAction> m_intLinks;
56  AbstractNavigationContext* m_previousContext;
57  TopDUContextPointer m_topContext;
58 
59  QString m_currentText; //Here the text is built
60 };
61 
62 void AbstractNavigationContext::setTopContext(const TopDUContextPointer& context)
63 {
64  Q_D(AbstractNavigationContext);
65 
66  d->m_topContext = context;
67 }
68 
69 TopDUContextPointer AbstractNavigationContext::topContext() const
70 {
71  Q_D(const AbstractNavigationContext);
72 
73  return d->m_topContext;
74 }
75 
76 AbstractNavigationContext::AbstractNavigationContext(const TopDUContextPointer& topContext,
77  AbstractNavigationContext* previousContext)
78  : d_ptr(new AbstractNavigationContextPrivate)
79 {
80  Q_D(AbstractNavigationContext);
81 
82  d->m_previousContext = previousContext;
83  d->m_topContext = topContext;
84 
85  qRegisterMetaType<KTextEditor::Cursor>("KTextEditor::Cursor");
86  qRegisterMetaType<IDocumentation::Ptr>("IDocumentation::Ptr");
87 }
88 
89 AbstractNavigationContext::~AbstractNavigationContext()
90 {
91 }
92 
93 void AbstractNavigationContext::makeLink(const QString& name, const DeclarationPointer& declaration,
94  NavigationAction::Type actionType)
95 {
96  NavigationAction action(declaration, actionType);
97  makeLink(name, QString(), action);
98 }
99 
100 QString AbstractNavigationContext::createLink(const QString& name, const QString&, const NavigationAction& action)
101 {
102  Q_D(AbstractNavigationContext);
103 
104  if (d->m_shorten) {
105  //Do not create links in shortened mode, it's only for viewing
106  return typeHighlight(name.toHtmlEscaped());
107  }
108 
109  // NOTE: Since the by definition in the HTML standard some uri components
110  // are case-insensitive, we define a new lowercase link-id for each
111  // link. Otherwise Qt 5 seems to mess up the casing and the link
112  // cannot be matched when it's executed.
113  QString hrefId = QStringLiteral("link_%1").arg(d->m_links.count());
114 
115  d->m_links[hrefId] = action;
116  d->m_intLinks[d->m_linkCount] = action;
117  d->m_linkLines[d->m_linkCount] = d->m_currentLine;
118  if (d->m_currentPositionLine == d->m_currentLine) {
119  d->m_currentPositionLine = -1;
120  d->m_selectedLink = d->m_linkCount;
121  }
122 
123  QString str = name.toHtmlEscaped();
124  if (d->m_linkCount == d->m_selectedLink)
125  str = QLatin1String("<font style=\"background-color:#f1f1f1;\" color=\"#880088\">") + str + QLatin1String(
126  "</font>");
127 
128  QString ret = QLatin1String("<a href=\"") + hrefId + QLatin1Char('\"') +
129  ((d->m_linkCount == d->m_selectedLink &&
130  d->m_currentPositionLine ==
131  -1) ? QStringLiteral(" name = \"currentPosition\"") : QString()) + QLatin1Char('>') + str +
132  QLatin1String("</a>");
133 
134  if (d->m_selectedLink == d->m_linkCount)
135  d->m_selectedLinkAction = action;
136 
137  ++d->m_linkCount;
138  return ret;
139 }
140 
141 void AbstractNavigationContext::makeLink(const QString& name, const QString& targetId, const NavigationAction& action)
142 {
143  modifyHtml() += createLink(name, targetId, action);
144 }
145 
146 void AbstractNavigationContext::clear()
147 {
148  Q_D(AbstractNavigationContext);
149 
150  d->m_linkCount = 0;
151  d->m_currentLine = 0;
152  d->m_currentText.clear();
153  d->m_links.clear();
154  d->m_intLinks.clear();
155  d->m_linkLines.clear();
156 }
157 
158 void AbstractNavigationContext::executeLink(const QString& link)
159 {
160  Q_D(AbstractNavigationContext);
161 
162  const auto actionIt = d->m_links.constFind(link);
163  if (actionIt == d->m_links.constEnd())
164  return;
165 
166  execute(*actionIt);
167 }
168 
169 NavigationContextPointer AbstractNavigationContext::executeKeyAction(const QString& key)
170 {
171  Q_UNUSED(key);
172  return NavigationContextPointer(this);
173 }
174 
175 NavigationContextPointer AbstractNavigationContext::execute(const NavigationAction& action)
176 {
177  Q_D(AbstractNavigationContext);
178 
179  if (action.targetContext)
180  return NavigationContextPointer(action.targetContext);
181 
182  if (action.type == NavigationAction::ExecuteKey)
183  return executeKeyAction(action.key);
184 
185  if (!action.decl && (action.type != NavigationAction::JumpToSource || action.document.isEmpty())) {
186  qCDebug(LANGUAGE) << "Navigation-action has invalid declaration";
187  return NavigationContextPointer(this);
188  }
189 
190  switch (action.type) {
191  case NavigationAction::ExecuteKey:
192  break;
193  case NavigationAction::None:
194  qCDebug(LANGUAGE) << "Tried to execute an invalid action in navigation-widget";
195  break;
196  case NavigationAction::NavigateDeclaration:
197  {
198  auto ctx = dynamic_cast<AbstractDeclarationNavigationContext*>(d->m_previousContext);
199  if (ctx && ctx->declaration() == action.decl)
200  return NavigationContextPointer(d->m_previousContext);
201  return registerChild(action.decl);
202  }
203  case NavigationAction::NavigateUses:
204  {
205  auto* browser = ICore::self()->pluginController()->extensionForPlugin<IContextBrowser>();
206  if (browser) {
207  browser->showUses(action.decl);
208  return NavigationContextPointer(this);
209  }
210  Q_FALLTHROUGH();
211  }
212  case NavigationAction::ShowUses: {
213  return registerChild(new UsesNavigationContext(action.decl.data(), this));
214  }
215  case NavigationAction::JumpToSource:
216  {
217  QUrl doc = action.document;
218  KTextEditor::Cursor cursor = action.cursor;
219  {
220  DUChainReadLocker lock(DUChain::lock());
221  if (action.decl) {
222  if (doc.isEmpty()) {
223  doc = action.decl->url().toUrl();
224  /* if(action.decl->internalContext())
225  cursor = action.decl->internalContext()->range().start() + KTextEditor::Cursor(0, 1);
226  else*/
227  cursor = action.decl->rangeInCurrentRevision().start();
228  }
229 
230  action.decl->activateSpecialization();
231  }
232  }
233 
234  //This is used to execute the slot delayed in the event-loop, so crashes are avoided
235  QMetaObject::invokeMethod(ICore::self()->documentController(), "openDocument", Qt::QueuedConnection,
236  Q_ARG(QUrl, doc), Q_ARG(KTextEditor::Cursor, cursor));
237  break;
238  }
239  case NavigationAction::ShowDocumentation: {
240  auto doc = ICore::self()->documentationController()->documentationForDeclaration(action.decl.data());
241  // This is used to execute the slot delayed in the event-loop, so crashes are avoided
242  // which can happen e.g. due to focus change events resulting in tooltip destruction and thus this object
243  QMetaObject::invokeMethod(
244  ICore::self()->documentationController(), "showDocumentation", Qt::QueuedConnection,
245  Q_ARG(IDocumentation::Ptr, doc));
246  }
247  break;
248  }
249 
250  return NavigationContextPointer(this);
251 }
252 
253 AbstractNavigationContext* AbstractNavigationContext::previousContext() const
254 {
255  Q_D(const AbstractNavigationContext);
256 
257  return d->m_previousContext;
258 }
259 
260 void AbstractNavigationContext::setPreviousContext(AbstractNavigationContext* previous)
261 {
262  Q_D(AbstractNavigationContext);
263 
264  d->m_previousContext = previous;
265 }
266 
267 NavigationContextPointer AbstractNavigationContext::registerChild(AbstractNavigationContext* context)
268 {
269  Q_D(AbstractNavigationContext);
270 
271  d->m_children << NavigationContextPointer(context);
272  return d->m_children.last();
273 }
274 
275 NavigationContextPointer AbstractNavigationContext::registerChild(const DeclarationPointer& declaration)
276 {
277  Q_D(AbstractNavigationContext);
278 
279  //We create a navigation-widget here, and steal its context.. evil ;)
280  QScopedPointer<AbstractNavigationWidget> navigationWidget(
281  declaration->context()->createNavigationWidget(declaration.data()));
282  if (navigationWidget) {
283  NavigationContextPointer ret = navigationWidget->context();
284  ret->setPreviousContext(this);
285  d->m_children << ret;
286  return ret;
287  } else {
288  return NavigationContextPointer(this);
289  }
290 }
291 
292 const int lineJump = 3;
293 
294 bool AbstractNavigationContext::down()
295 {
296  Q_D(AbstractNavigationContext);
297 
298  //Make sure link-count is valid
299  if (d->m_linkCount == -1) {
300  DUChainReadLocker lock;
301  html();
302  }
303 
304  // select first link when we enter via down
305  if (d->m_selectedLink == -1 && d->m_linkCount) {
306  d->m_selectedLink = 0;
307  d->m_currentPositionLine = -1;
308  return true;
309  }
310 
311  int fromLine = d->m_currentPositionLine;
312 
313  // try to select the next link within our lineJump distance
314  if (d->m_selectedLink >= 0 && d->m_selectedLink < d->m_linkCount) {
315  if (fromLine == -1)
316  fromLine = d->m_linkLines[d->m_selectedLink];
317 
318  for (int newSelectedLink = d->m_selectedLink + 1; newSelectedLink < d->m_linkCount; ++newSelectedLink) {
319  if (d->m_linkLines[newSelectedLink] > fromLine && d->m_linkLines[newSelectedLink] - fromLine <= lineJump) {
320  d->m_selectedLink = newSelectedLink;
321  d->m_currentPositionLine = -1;
322  return true;
323  }
324  }
325  }
326 
327  if (fromLine == d->m_currentLine - 1) // nothing to do, we are at the end of the document
328  return false;
329 
330  // scroll down by applying the lineJump
331  if (fromLine == -1)
332  fromLine = 0;
333 
334  d->m_currentPositionLine = fromLine + lineJump;
335 
336  if (d->m_currentPositionLine >= d->m_currentLine) {
337  d->m_currentPositionLine = d->m_currentLine - 1;
338  }
339  return fromLine != d->m_currentPositionLine;
340 }
341 
342 bool AbstractNavigationContext::up()
343 {
344  Q_D(AbstractNavigationContext);
345 
346  //Make sure link-count is valid
347  if (d->m_linkCount == -1) {
348  DUChainReadLocker lock;
349  html();
350  }
351 
352  // select last link when we enter via up
353  if (d->m_selectedLink == -1 && d->m_linkCount) {
354  d->m_selectedLink = d->m_linkCount - 1;
355  d->m_currentPositionLine = -1;
356  return true;
357  }
358 
359  int fromLine = d->m_currentPositionLine;
360 
361  if (d->m_selectedLink >= 0 && d->m_selectedLink < d->m_linkCount) {
362  if (fromLine == -1)
363  fromLine = d->m_linkLines[d->m_selectedLink];
364 
365  for (int newSelectedLink = d->m_selectedLink - 1; newSelectedLink >= 0; --newSelectedLink) {
366  if (d->m_linkLines[newSelectedLink] < fromLine && fromLine - d->m_linkLines[newSelectedLink] <= lineJump) {
367  d->m_selectedLink = newSelectedLink;
368  d->m_currentPositionLine = -1;
369  return true;
370  }
371  }
372  }
373 
374  if (fromLine == -1)
375  fromLine = d->m_currentLine - 1;
376 
377  d->m_currentPositionLine = fromLine - lineJump;
378  if (d->m_currentPositionLine < 0)
379  d->m_currentPositionLine = 0;
380 
381  return fromLine || d->m_currentPositionLine;
382 }
383 
384 bool AbstractNavigationContext::nextLink()
385 {
386  Q_D(AbstractNavigationContext);
387 
388  //Make sure link-count is valid
389  if (d->m_linkCount == -1) {
390  DUChainReadLocker lock;
391  html();
392  }
393 
394  if (!d->m_linkCount)
395  return false;
396 
397  d->m_currentPositionLine = -1;
398 
399  d->m_selectedLink++;
400  if (d->m_selectedLink >= d->m_linkCount) {
401  d->m_selectedLink = 0;
402  return false;
403  }
404  return true;
405 }
406 
407 bool AbstractNavigationContext::previousLink()
408 {
409  Q_D(AbstractNavigationContext);
410 
411  //Make sure link-count is valid
412  if (d->m_linkCount == -1) {
413  DUChainReadLocker lock;
414  html();
415  }
416 
417  if (!d->m_linkCount)
418  return false;
419 
420  d->m_currentPositionLine = -1;
421 
422  d->m_selectedLink--;
423  if (d->m_selectedLink < 0) {
424  d->m_selectedLink = d->m_linkCount - 1;
425  return false;
426  }
427  return true;
428 }
429 
430 int AbstractNavigationContext::linkCount() const
431 {
432  Q_D(const AbstractNavigationContext);
433 
434  return d->m_linkCount;
435 }
436 
437 void AbstractNavigationContext::resetNavigation()
438 {
439  Q_D(AbstractNavigationContext);
440 
441  d->m_currentPositionLine = -1;
442  d->m_selectedLink = -1;
443  d->m_selectedLinkAction = {};
444 }
445 
446 NavigationContextPointer AbstractNavigationContext::back()
447 {
448  Q_D(AbstractNavigationContext);
449 
450  if (d->m_previousContext)
451  return NavigationContextPointer(d->m_previousContext);
452  else
453  return NavigationContextPointer(this);
454 }
455 
456 NavigationContextPointer AbstractNavigationContext::accept()
457 {
458  Q_D(AbstractNavigationContext);
459 
460  if (d->m_selectedLink >= 0 && d->m_selectedLink < d->m_linkCount) {
461  NavigationAction action = d->m_intLinks[d->m_selectedLink];
462  return execute(action);
463  }
464  return NavigationContextPointer(this);
465 }
466 
467 NavigationContextPointer AbstractNavigationContext::accept(IndexedDeclaration decl)
468 {
469  if (decl.data()) {
470  NavigationAction action(DeclarationPointer(decl.data()), NavigationAction::NavigateDeclaration);
471  return execute(action);
472  } else {
473  return NavigationContextPointer(this);
474  }
475 }
476 
477 NavigationContextPointer AbstractNavigationContext::acceptLink(const QString& link)
478 {
479  Q_D(AbstractNavigationContext);
480 
481  const auto actionIt = d->m_links.constFind(link);
482  if (actionIt == d->m_links.constEnd()) {
483  qCDebug(LANGUAGE) << "Executed unregistered link " << link;
484  return NavigationContextPointer(this);
485  }
486 
487  return execute(*actionIt);
488 }
489 
490 NavigationAction AbstractNavigationContext::currentAction() const
491 {
492  Q_D(const AbstractNavigationContext);
493 
494  return d->m_selectedLinkAction;
495 }
496 
497 QString AbstractNavigationContext::declarationKind(const DeclarationPointer& decl)
498 {
499  const auto* function = dynamic_cast<const AbstractFunctionDeclaration*>(decl.data());
500 
501  QString kind;
502 
503  if (decl->isTypeAlias())
504  kind = i18n("Typedef");
505  else if (decl->kind() == Declaration::Type) {
506  if (decl->type<StructureType>())
507  kind = i18n("Class");
508  } else if (decl->kind() == Declaration::Instance) {
509  kind = i18n("Variable");
510  } else if (decl->kind() == Declaration::Namespace) {
511  kind = i18n("Namespace");
512  }
513 
514  if (auto* alias = dynamic_cast<NamespaceAliasDeclaration*>(decl.data())) {
515  if (alias->identifier().isEmpty())
516  kind = i18n("Namespace import");
517  else
518  kind = i18n("Namespace alias");
519  }
520 
521  if (function)
522  kind = i18n("Function");
523 
524  if (decl->isForwardDeclaration())
525  kind = i18n("Forward Declaration");
526 
527  return kind;
528 }
529 
530 QString AbstractNavigationContext::html(bool shorten)
531 {
532  Q_D(AbstractNavigationContext);
533 
534  d->m_shorten = shorten;
535  return QString();
536 }
537 
538 bool AbstractNavigationContext::alreadyComputed() const
539 {
540  Q_D(const AbstractNavigationContext);
541 
542  return !d->m_currentText.isEmpty();
543 }
544 
545 bool AbstractNavigationContext::isWidgetMaximized() const
546 {
547  return true;
548 }
549 
550 QWidget* AbstractNavigationContext::widget() const
551 {
552  return nullptr;
553 }
554 
556 static QStringList splitAndKeep(QString str, const QRegExp& regExp)
557 {
558  QStringList ret;
559  int place = regExp.indexIn(str);
560  while (place != -1) {
561  ret << str.left(place + regExp.matchedLength());
562  str.remove(0, place + regExp.matchedLength());
563  place = regExp.indexIn(str);
564  }
565  ret << str;
566  return ret;
567 }
568 
569 void AbstractNavigationContext::addHtml(const QString& html)
570 {
571  Q_D(AbstractNavigationContext);
572 
573  QRegExp newLineRegExp(QStringLiteral("<br>|<br */>|</p>"));
574  const auto lines = splitAndKeep(html, newLineRegExp);
575  for (const QString& line : lines) {
576  d->m_currentText += line;
577  if (line.indexOf(newLineRegExp) != -1) {
578  ++d->m_currentLine;
579  if (d->m_currentLine == d->m_currentPositionLine) {
580  d->m_currentText += QLatin1String(
581  "<font color=\"#880088\"> <a name = \"currentPosition\" >&lt;-&gt;</a> </font>"); // >&lt;-&gt; is <->
582  }
583  }
584  }
585 }
586 
587 QString AbstractNavigationContext::currentHtml() const
588 {
589  Q_D(const AbstractNavigationContext);
590 
591  return d->m_currentText;
592 }
593 
594 QString Colorizer::operator()(const QString& str) const
595 {
596  QString ret = QLatin1String("<font color=\"#") + m_color + QLatin1String("\">") + str + QLatin1String("</font>");
597 
598  if (m_formatting & Fixed)
599  ret = QLatin1String("<tt>") + ret + QLatin1String("</tt>");
600  if (m_formatting & Bold)
601  ret = QLatin1String("<b>") + ret + QLatin1String("</b>");
602  if (m_formatting & Italic)
603  ret = QLatin1String("<i>") + ret + QLatin1String("</i>");
604 
605  return ret;
606 }
607 
608 const Colorizer AbstractNavigationContext::typeHighlight(QStringLiteral("006000"));
609 const Colorizer AbstractNavigationContext::errorHighlight(QStringLiteral("990000"));
610 const Colorizer AbstractNavigationContext::labelHighlight(QStringLiteral("000000"));
611 const Colorizer AbstractNavigationContext::codeHighlight(QStringLiteral("005000"));
612 const Colorizer AbstractNavigationContext::propertyHighlight(QStringLiteral("009900"));
613 const Colorizer AbstractNavigationContext::navigationHighlight(QStringLiteral("000099"));
614 const Colorizer AbstractNavigationContext::importantHighlight(QStringLiteral(
615  "000000"), Colorizer::Bold | Colorizer::Italic);
616 const Colorizer AbstractNavigationContext::commentHighlight(QStringLiteral("303030"));
617 const Colorizer AbstractNavigationContext::nameHighlight(QStringLiteral("000000"), Colorizer::Bold);
618 }
KDevelop::NavigationAction::cursor
KTextEditor::Cursor cursor
Definition: navigationaction.h:75
KDevelop::NavigationAction::NavigateUses
Definition: navigationaction.h:36
KDevelop::DUChainReadLocker
Customized read locker for the definition-use chain.
Definition: duchainlock.h:114
KDevelop::NavigationAction::type
Type type
Definition: navigationaction.h:72
KDevelop::AbstractNavigationContext::addHtml
void addHtml(const QString &html)
Adds given the text to currentHtml()
Definition: abstractnavigationcontext.cpp:569
KDevelop::AbstractNavigationContext::currentHtml
QString currentHtml() const
Returns the html text being built in its current state.
Definition: abstractnavigationcontext.cpp:587
KDevelop::DUChain::lock
static DUChainLock * lock()
Retrieve the read write lock for the entire definition-use chain.
Definition: duchain.cpp:1283
KDevelop::AbstractNavigationContext::typeHighlight
static const Colorizer typeHighlight
Definition: abstractnavigationcontext.h:162
QUrl
KDevelop::AbstractNavigationContext::declarationKind
virtual QString declarationKind(const DeclarationPointer &decl)
Definition: abstractnavigationcontext.cpp:497
KDevelop::NavigationAction::ExecuteKey
Definition: navigationaction.h:39
KDevelop::AbstractNavigationContext::labelHighlight
static const Colorizer labelHighlight
Definition: abstractnavigationcontext.h:164
KDevelop::Declaration::Type
A type is declared, like a class-declaration or function-declaration, or a typedef("class MyClass {};...
Definition: declaration.h:64
KDevelop::NavigationAction::targetContext
AbstractNavigationContext * targetContext
Definition: navigationaction.h:69
KDevelop::AbstractNavigationContext::linkCount
int linkCount() const
Definition: abstractnavigationcontext.cpp:430
KDevelop::AbstractNavigationContext::nextLink
bool nextLink()
Definition: abstractnavigationcontext.cpp:384
KDevelop::Colorizer::Bold
Definition: abstractnavigationcontext.h:40
QWidget
KDevelop::Declaration::Namespace
Declaration of a namespace.
Definition: declaration.h:68
KDevelop::AbstractNavigationContext::commentHighlight
static const Colorizer commentHighlight
Definition: abstractnavigationcontext.h:169
KDevelop::AbstractNavigationContext::codeHighlight
static const Colorizer codeHighlight
Definition: abstractnavigationcontext.h:165
KDevelop::AbstractNavigationContext::alreadyComputed
bool alreadyComputed() const
Returns whether this context's string has already been computed, and is up to date.
Definition: abstractnavigationcontext.cpp:538
KDevelop::DUChainPointer< TopDUContext >
KDevelop::AbstractNavigationContext::accept
NavigationContextPointer accept()
Definition: abstractnavigationcontext.cpp:456
abstractnavigationcontext.h
KDevelop::DUContext::createNavigationWidget
virtual AbstractNavigationWidget * createNavigationWidget(Declaration *decl=nullptr, TopDUContext *topContext=nullptr, AbstractNavigationWidget::DisplayHints hints=AbstractNavigationWidget::NoHints) const
Can be specialized by languages to create a navigation/information-widget.
Definition: ducontext.cpp:1504
KDevelop::AbstractNavigationContext::back
NavigationContextPointer back()
Definition: abstractnavigationcontext.cpp:446
KDevelop::Colorizer::Fixed
Definition: abstractnavigationcontext.h:42
QExplicitlySharedDataPointer< AbstractNavigationContext >
QRegExp::matchedLength
int matchedLength() const
KDevelop::Declaration::isTypeAlias
bool isTypeAlias() const
Determine if this declaration is a type-alias (in c++ typedef).
Definition: declaration.cpp:538
KDevelop::splitAndKeep
static QStringList splitAndKeep(QString str, const QRegExp &regExp)
Splits the string by the given regular expression, but keeps the split-matches at the end of each lin...
Definition: abstractnavigationcontext.cpp:556
KDevelop::Colorizer::m_color
QString m_color
Definition: abstractnavigationcontext.h:53
KDevelop::AbstractNavigationContext::down
bool down()
Definition: abstractnavigationcontext.cpp:294
KDevelop::AbstractNavigationContext::makeLink
virtual void makeLink(const QString &name, const DeclarationPointer &declaration, NavigationAction::Type actionType)
Creates and registers a link to the given declaration, labeled by the given name.
Definition: abstractnavigationcontext.cpp:93
KDevelop::AbstractNavigationContext::execute
NavigationContextPointer execute(const NavigationAction &action)
Definition: abstractnavigationcontext.cpp:175
KDevelop::IndexedDeclaration
Represents a declaration only by its global indices.
Definition: indexeddeclaration.h:33
KDevelop::AbstractNavigationContext::executeKeyAction
virtual NavigationContextPointer executeKeyAction(const QString &key)
Override this to execute own key-actions using NavigationAction.
Definition: abstractnavigationcontext.cpp:169
KDevelop::Declaration::kind
Kind kind() const
Returns the kind of this declaration.
Definition: declaration.cpp:78
QUrl::isEmpty
bool isEmpty() const
KDevelop::NavigationAction
Definition: navigationaction.h:31
KDevelop::AbstractNavigationContext::propertyHighlight
static const Colorizer propertyHighlight
Definition: abstractnavigationcontext.h:166
KDevelop::DUChainBase::url
virtual IndexedString url() const
Definition: duchainbase.cpp:68
KDevelop::NavigationAction::Type
Type
Definition: navigationaction.h:33
QString
KDevelop::NavigationAction::None
Definition: navigationaction.h:34
KDevelop::Declaration::Instance
An instance of a type is declared("MyClass m;")
Definition: declaration.h:65
QRegExp::indexIn
int indexIn(const QString &str, int offset, CaretMode caretMode) const
KDevelop::NavigationAction::key
QString key
Definition: navigationaction.h:76
KDevelop::AbstractNavigationContext::name
virtual QString name() const =0
KDevelop::AbstractNavigationContext::clear
void clear()
Definition: abstractnavigationcontext.cpp:146
KDevelop::Declaration::type
TypePtr< T > type() const
Convenience function to return this declaration's type dynamically casted to T.
Definition: declaration.h:305
KDevelop::AbstractNavigationContext::modifyHtml
TextHandler modifyHtml()
Returns a convenience object that allows writing "modifyHtml() += "Hallo";".
Definition: abstractnavigationcontext.h:139
KDevelop::Colorizer
A helper-class for elegant colorization of html-strings .
Definition: abstractnavigationcontext.h:36
KDevelop::Declaration::context
DUContext * context() const
Access the parent context of this declaration.
Definition: declaration.cpp:279
KDevelop::AbstractNavigationContext::acceptLink
NavigationContextPointer acceptLink(const QString &link)
Definition: abstractnavigationcontext.cpp:477
KDevelop::AbstractNavigationContext::registerChild
NavigationContextPointer registerChild(const DeclarationPointer &)
Definition: abstractnavigationcontext.cpp:275
KDevelop::NavigationAction::document
QUrl document
Definition: navigationaction.h:74
KDevelop::AbstractNavigationContext::~AbstractNavigationContext
~AbstractNavigationContext() override
Definition: abstractnavigationcontext.cpp:89
QLatin1String
KDevelop::AbstractNavigationContext::navigationHighlight
static const Colorizer navigationHighlight
Definition: abstractnavigationcontext.h:167
KDevelop::NavigationContextPointer
QExplicitlySharedDataPointer< AbstractNavigationContext > NavigationContextPointer
Definition: abstractnavigationcontext.h:62
QScopedPointer
KDevelop::DUChainBase::rangeInCurrentRevision
KTextEditor::Range rangeInCurrentRevision() const
Returns the range assigned to this object, transformed into the current revision of the document.
Definition: duchainbase.cpp:157
QString::remove
QString & remove(int position, int n)
KDevelop::AbstractNavigationContext::html
virtual QString html(bool shorten=false)
Here the context can return html to be displayed.
Definition: abstractnavigationcontext.cpp:530
KDevelop::NavigationAction::NavigateDeclaration
Definition: navigationaction.h:35
KDevelop::AbstractNavigationContext::topContext
TopDUContextPointer topContext() const
Definition: abstractnavigationcontext.cpp:69
KDevelop::AbstractNavigationContext::setTopContext
void setTopContext(const TopDUContextPointer &context)
Definition: abstractnavigationcontext.cpp:62
KDevelop::IndexedDeclaration::data
Declaration * data() const
Definition: indexeddeclaration.h:47
QMap
KDevelop::AbstractNavigationContext
Definition: abstractnavigationcontext.h:64
KDevelop::AbstractNavigationContext::setPreviousContext
virtual void setPreviousContext(AbstractNavigationContext *previousContext)
Definition: abstractnavigationcontext.cpp:260
KDevelop::AbstractNavigationContext::importantHighlight
static const Colorizer importantHighlight
Definition: abstractnavigationcontext.h:168
KDevelop::AbstractNavigationContext::up
bool up()
Definition: abstractnavigationcontext.cpp:342
KDevelop::Declaration::isForwardDeclaration
virtual bool isForwardDeclaration() const
Determine whether this declaration is a forward declaration.
Definition: declaration.cpp:650
QLatin1Char
KDevelop::UsesNavigationContext
Definition: usesnavigationcontext.h:27
KDevelop::Colorizer::operator()
QString operator()(const QString &str) const
Definition: abstractnavigationcontext.cpp:594
QString::left
QString left(int n) const
KDevelop::Colorizer::Italic
Definition: abstractnavigationcontext.h:41
usesnavigationcontext.h
QMetaObject::invokeMethod
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
KDevelop::Colorizer::m_formatting
Formatting m_formatting
Definition: abstractnavigationcontext.h:54
KDevelop::TopDUContextPointer
DUChainPointer< TopDUContext > TopDUContextPointer
Definition: duchainpointer.h:199
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
QRegExp
KDevelop::AbstractNavigationContext::currentAction
NavigationAction currentAction() const
Definition: abstractnavigationcontext.cpp:490
KDevelop::Declaration::activateSpecialization
virtual void activateSpecialization()
Signalized that among multiple possible specializations, this one should be used in the UI from now o...
Definition: declaration.cpp:555
KDevelop::DUChainPointer::data
Type * data() const
Definition: duchainpointer.h:173
KDevelop::AbstractNavigationContext::executeLink
void executeLink(const QString &link)
Definition: abstractnavigationcontext.cpp:158
KDevelop::NavigationAction::ShowUses
Definition: navigationaction.h:37
KDevelop::AbstractNavigationContext::widget
virtual QWidget * widget() const
Here the context can return a widget to be displayed.
Definition: abstractnavigationcontext.cpp:550
abstractdeclarationnavigationcontext.h
KDevelop::AbstractNavigationContext::previousContext
AbstractNavigationContext * previousContext() const
Definition: abstractnavigationcontext.cpp:253
QVector
KDevelop::NavigationAction::decl
DeclarationPointer decl
Definition: navigationaction.h:71
KDevelop::NavigationAction::JumpToSource
Definition: navigationaction.h:38
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
KDevelop::AbstractNavigationContext::errorHighlight
static const Colorizer errorHighlight
Definition: abstractnavigationcontext.h:163
KDevelop::AbstractNavigationContext::resetNavigation
void resetNavigation()
Definition: abstractnavigationcontext.cpp:437
KDevelop::DeclarationPointer
DUChainPointer< Declaration > DeclarationPointer
Definition: duchainpointer.h:200
KDevelop::AbstractNavigationContext::isWidgetMaximized
virtual bool isWidgetMaximized() const
Whether the widget returned by widget() should take the maximum possible spsace.
Definition: abstractnavigationcontext.cpp:545
KDevelop::AbstractNavigationContext::AbstractNavigationContext
AbstractNavigationContext(const TopDUContextPointer &topContext=TopDUContextPointer(), AbstractNavigationContext *previousContext=nullptr)
Definition: abstractnavigationcontext.cpp:76
KDevelop::lineJump
const int lineJump
Definition: abstractnavigationcontext.cpp:292
abstractnavigationwidget.h
KDevelop::AbstractNavigationContext::nameHighlight
static const Colorizer nameHighlight
Definition: abstractnavigationcontext.h:170
KDevelop::NavigationAction::ShowDocumentation
Definition: navigationaction.h:41
KDevelop::StructureType
A type representing structure types.
Definition: structuretype.h:38
KDevelop::AbstractNavigationContext::previousLink
bool previousLink()
Definition: abstractnavigationcontext.cpp:407
QStringList
KDevelop::AbstractNavigationContext::createLink
QString createLink(const QString &name, const QString &targetId, const NavigationAction &action)
Creates a link that executes the given action and returns it.
Definition: abstractnavigationcontext.cpp:100
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Mar 3 2021 00:37:28 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/language/duchain

Skip menu "kdevplatform/language/duchain"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal