Commit 88e3e82f authored by Kevin Funk's avatar Kevin Funk

Move navigationwidget.h to duchain/

Also add simple Clang-specific subclass for
AbstractIncludeNavigationContext (mostly copied over from oldcpp)
parent 5383c616
......@@ -6,7 +6,6 @@ include_directories(
add_library(kdevclangcodecompletion OBJECT
model.cpp
context.cpp
navigationwidget.cpp
completionhelper.cpp
)
set_target_properties(kdevclangcodecompletion PROPERTIES
......
......@@ -21,8 +21,6 @@
#include "context.h"
#include "navigationwidget.h"
#include <language/duchain/duchainlock.h>
#include <language/duchain/ducontext.h>
#include <language/duchain/topducontext.h>
......@@ -37,6 +35,7 @@
#include "../duchain/parsesession.h"
#include "../duchain/clangtypes.h"
#include "../duchain/cursorkindtraits.h"
#include "../duchain/navigationwidget.h"
#include "../debug.h"
......
......@@ -10,6 +10,7 @@ kde4_add_library(kdevclangduchain SHARED
clanghelpers.cpp
unknowndeclarationproblem.cpp
missingincludepathproblem.cpp
navigationwidget.cpp
todoextractor.cpp
$<TARGET_OBJECTS:kdevclangutil>
......
/*
* This file is part of KDevelop
* Copyright 2014 Milian Wolff <mail@milianw.de>
* Copyright 2014 Kevin Funk <kfunk@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -22,11 +23,11 @@
#include "navigationwidget.h"
#include <language/duchain/navigation/abstractdeclarationnavigationcontext.h>
#include <language/duchain/navigation/abstractincludenavigationcontext.h>
#include <language/util/includeitem.h>
using namespace KDevelop;
namespace {
class DeclarationNavigationContext : public AbstractDeclarationNavigationContext
{
public:
......@@ -36,14 +37,48 @@ public:
}
};
class IncludeNavigationContext : public KDevelop::AbstractIncludeNavigationContext
{
public:
IncludeNavigationContext(const KDevelop::IncludeItem& item, KDevelop::TopDUContextPointer topContext);
protected:
virtual bool filterDeclaration(KDevelop::Declaration* decl);
};
IncludeNavigationContext::IncludeNavigationContext(const IncludeItem& item, KDevelop::TopDUContextPointer topContext)
: AbstractIncludeNavigationContext(item, topContext, StandardParsingEnvironment)
{}
bool IncludeNavigationContext::filterDeclaration(Declaration* decl)
{
QString declId = decl->identifier().identifier().str();
//filter out forward-declarations and macro-expansions without a range
//And filter out declarations with reserved identifiers
return !decl->qualifiedIdentifier().toString().isEmpty() && !decl->range().isEmpty() && !decl->isForwardDeclaration()
&& !(declId.startsWith("__") || (declId.startsWith("_") && declId.length() > 1 && declId[1].isUpper()) );
}
ClangNavigationWidget::ClangNavigationWidget(const DeclarationPointer& declaration)
: AbstractNavigationWidget()
{
initBrowser(400);
initBrowser(400);
//The first context is registered so it is kept alive by the shared-pointer mechanism
m_startContext = NavigationContextPointer(new DeclarationNavigationContext(declaration));
setContext( m_startContext );
//The first context is registered so it is kept alive by the shared-pointer mechanism
m_startContext = NavigationContextPointer(new DeclarationNavigationContext(declaration));
setContext( m_startContext );
}
ClangNavigationWidget::ClangNavigationWidget(const IncludeItem& includeItem, KDevelop::TopDUContextPointer topContext,
const QString& htmlPrefix, const QString& htmlSuffix)
{
m_topContext = topContext;
initBrowser(200);
//The first context is registered so it is kept alive by the shared-pointer mechanism
m_startContext = NavigationContextPointer(new IncludeNavigationContext(includeItem, m_topContext));
m_startContext->setPrefixSuffix( htmlPrefix, htmlSuffix );
setContext( m_startContext );
}
/*
* This file is part of KDevelop
* Copyright 2014 Milian Wolff <mail@milianw.de>
* Copyright 2014 Kevin Funk <kfunk@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -22,12 +23,21 @@
#ifndef NAVIGATIONWIDGET_H
#define NAVIGATIONWIDGET_H
#include "duchainexport.h"
#include <language/duchain/navigation/abstractnavigationwidget.h>
class ClangNavigationWidget : public KDevelop::AbstractNavigationWidget
namespace KDevelop
{
class IncludeItem;
}
class KDEVCLANGDUCHAIN_EXPORT ClangNavigationWidget : public KDevelop::AbstractNavigationWidget
{
public:
ClangNavigationWidget(const KDevelop::DeclarationPointer& declaration);
ClangNavigationWidget(const KDevelop::IncludeItem& includeItem, KDevelop::TopDUContextPointer topContext,
const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString());
virtual ~ClangNavigationWidget() = default;
};
......
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