Commit 1396fac7 authored by Sergey Kalinichev's avatar Sergey Kalinichev

qmljs: Added navigation widget for IncludeItem

parent a83baa09
......@@ -23,6 +23,7 @@
#include "declarationnavigationcontext.h"
#include <language/duchain/topducontext.h>
#include <language/duchain/navigation/abstractincludenavigationcontext.h>
using namespace KDevelop;
......@@ -46,4 +47,20 @@ NavigationWidget::NavigationWidget(KDevelop::Declaration* decl,
setContext(m_startContext);
}
NavigationWidget::NavigationWidget(const KDevelop::IncludeItem& includeItem,
KDevelop::TopDUContextPointer topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints)
: AbstractNavigationWidget()
{
setDisplayHints(hints);
m_topContext = topContext;
initBrowser(200);
m_startContext = NavigationContextPointer(new KDevelop::AbstractIncludeNavigationContext(includeItem, m_topContext, StandardParsingEnvironment));
m_startContext->setPrefixSuffix(htmlPrefix, htmlSuffix);
setContext(m_startContext);
}
}
......@@ -26,6 +26,10 @@
#include "duchainexport.h"
namespace KDevelop {
class IncludeItem;
}
namespace QmlJS {
class KDEVQMLJSDUCHAIN_EXPORT NavigationWidget : public KDevelop::AbstractNavigationWidget
......@@ -36,6 +40,11 @@ public:
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints);
NavigationWidget(const KDevelop::IncludeItem& includeItem,
KDevelop::TopDUContextPointer topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints);
};
}
......
......@@ -27,6 +27,7 @@
#include <language/duchain/topducontextdata.h>
#include <language/duchain/duchainregister.h>
#include <language/duchain/duchainpointer.h>
#include <language/util/includeitem.h>
#include "navigation/navigationwidget.h"
......@@ -40,8 +41,14 @@ QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUConte
AbstractNavigationWidget::DisplayHints hints) const
{
if (!decl) {
qCDebug(KDEV_QMLJS_DUCHAIN) << "no declaration, not returning navigationwidget";
return nullptr;
const QUrl u = url().toUrl();
IncludeItem item;
item.pathNumber = -1;
item.name = u.fileName();
item.isDirectory = false;
item.basePath = u.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash);
return new NavigationWidget(item, TopDUContextPointer(topContext ? topContext : this->topContext()), htmlPrefix, htmlSuffix, hints);
}
return new NavigationWidget(decl, topContext, htmlPrefix, htmlSuffix, hints);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment