Commit 06da2419 authored by Kevin Funk's avatar Kevin Funk

Streamline ClangCodeCompletionContext

Get closer to the base-class implementation. Initialize base-class
members properly
parent 5e88cb95
......@@ -226,11 +226,12 @@ QByteArray concatenate(const QStringList& contents)
}
ClangCodeCompletionContext::ClangCodeCompletionContext(const ParseSession& session,
ClangCodeCompletionContext::ClangCodeCompletionContext(const DUContextPointer& context,
const ParseSession& session,
const SimpleCursor& position,
const QStringList& contents
)
: CodeCompletionContext({}, QString(), {}, 0)
: CodeCompletionContext(context, QString(), CursorInRevision::castFromSimpleCursor(position), 0)
, m_results(nullptr, clang_disposeCodeCompleteResults)
, m_completionHelper(session.unit(), position, ClangString(clang_getFileName(session.file())).c_str())
{
......@@ -252,8 +253,7 @@ ClangCodeCompletionContext::~ClangCodeCompletionContext()
{
}
QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(const TopDUContext* const top,
const CursorInRevision& position)
QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(bool& abort, bool fullCompletion)
{
QList<CompletionTreeItemPointer> items;
QList<CompletionTreeItemPointer> macros;
......@@ -261,7 +261,7 @@ QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(con
QSet<Declaration*> handled;
DUContext* ctx = top->findContextAt(position);
DUContext* ctx = m_duContext->findContextAt(m_position);
for (uint i = 0; i < m_results->NumResults; ++i) {
auto result = m_results->Results[i];
......@@ -351,7 +351,7 @@ QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(con
qid.push(id);
Declaration* found = 0;
foreach(Declaration* dec, ctx->findDeclarations(qid, position)) {
foreach(Declaration* dec, ctx->findDeclarations(qid, m_position)) {
if (!handled.contains(dec)) {
found = dec;
handled.insert(dec);
......
......@@ -34,19 +34,13 @@ class ParseSession;
class ClangCodeCompletionContext : public KDevelop::CodeCompletionContext
{
public:
ClangCodeCompletionContext(const ParseSession& session,
ClangCodeCompletionContext(const KDevelop::DUContextPointer& context,
const ParseSession& session,
const KDevelop::SimpleCursor& position,
const QStringList& contents);
~ClangCodeCompletionContext();
QList<KDevelop::CompletionTreeItemPointer> completionItems(const KDevelop::TopDUContext* const top,
const KDevelop::CursorInRevision& position);
QList< KDevelop::CompletionTreeItemPointer > completionItems(bool& /*abort*/, bool /*fullCompletion*/ = true) override
{
// not used, see above
return {};
}
virtual QList<KDevelop::CompletionTreeItemPointer> completionItems(bool& abort, bool fullCompletion = true) override;
QList<KDevelop::CompletionTreeElementPointer> ungroupedElements() override;
......
......@@ -70,17 +70,18 @@ public slots:
return;
}
ClangCodeCompletionContext completionContext( session, position, contents );
ClangCodeCompletionContext completionContext(DUContextPointer(top), session, position, contents);
if (aborting()) {
failed();
return;
}
bool abort = false;
// NOTE: cursor might be wrong here, but shouldn't matter much I hope...
// when the document changed significantly, then the cache is off anyways and we don't get anything sensible
// the position here is just a "optimization" to only search up to that position
const auto& items = completionContext.completionItems(top, CursorInRevision::castFromSimpleCursor(position));
const auto& items = completionContext.completionItems(abort);
if (aborting()) {
failed();
......
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