[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdev-clang] codecompletion: Fix in-class code-completion
From:       Sergey Kalinichev <kalinichev.so.0 () gmail ! com>
Date:       2015-07-31 19:12:19
Message-ID: E1ZLFj9-00072O-6p () scm ! kde ! org
[Download RAW message or body]

Git commit 38b11c1ecf01367b2c17b1e488bb4811a32fbc82 by Sergey Kalinichev.
Committed on 31/07/2015 at 18:00.
Pushed by skalinichev into branch 'master'.

Fix in-class code-completion

E.g.:
class Class{
    Class(){ //Here m_var wasn't shown as completion item.
	}
    int m_var;};

Sadly, it's very problematic to add an unit test for it, so there is
none...

M  +7    -6    codecompletion/model.cpp
M  +1    -1    codecompletion/model.h

http://commits.kde.org/kdev-clang/38b11c1ecf01367b2c17b1e488bb4811a32fbc82

diff --git a/codecompletion/model.cpp b/codecompletion/model.cpp
index 9888156..57902d3 100644
--- a/codecompletion/model.cpp
+++ b/codecompletion/model.cpp
@@ -64,12 +64,13 @@ QSharedPointer<CodeCompletionContext> \
                createCompletionContext(const DUContextPoi
                                                               const \
                ParseSessionData::Ptr& session,
                                                               const QUrl& url,
                                                               const \
                KTextEditor::Cursor& position,
-                                                              const QString& text)
+                                                              const QString& text,
+                                                              const QString& \
followingText)  {
     if (includePathCompletionRequired(text)) {
         return QSharedPointer<IncludePathCompletionContext>::create(context, \
session, url, position, text);  } else {
-        return QSharedPointer<ClangCodeCompletionContext>::create(context, session, \
url, position, text); +        return \
QSharedPointer<ClangCodeCompletionContext>::create(context, session, url, position, \
text + followingText);  }
 }
 
@@ -84,7 +85,7 @@ public:
     virtual ~ClangCodeCompletionWorker() = default;
 
 public slots:
-    void completionRequested(const QUrl &url, const KTextEditor::Cursor& position, \
const QString& text) +    void completionRequested(const QUrl &url, const \
KTextEditor::Cursor& position, const QString& text, const QString& followingText)  {
         aborting() = false;
 
@@ -125,7 +126,7 @@ public slots:
             return;
         }
 
-        auto completionContext = ::createCompletionContext(DUContextPointer(top), \
sessionData, url, position, text); +        auto completionContext = \
::createCompletionContext(DUContextPointer(top), sessionData, url, position, text, \
followingText);  
         lock.lock();
         if (aborting()) {
@@ -183,9 +184,9 @@ CodeCompletionWorker* \
ClangCodeCompletionModel::createCompletionWorker()  void \
ClangCodeCompletionModel::completionInvokedInternal(KTextEditor::View* view, const \
                KTextEditor::Range& range,
                                                          \
CodeCompletionModel::InvocationType /*invocationType*/, const QUrl &url)  {
-    // get text before this range so we can parse this version with clang
     auto text = view->document()->text({0, 0, range.start().line(), \
                range.start().column()});
-    emit requestCompletion(url, KTextEditor::Cursor(range.start()), text);
+    auto followingText = view->document()->text({{range.start().line(), \
range.start().column()}, view->document()->documentEnd()}); +    emit \
requestCompletion(url, KTextEditor::Cursor(range.start()), text, followingText);  }
 
 #include "model.moc"
diff --git a/codecompletion/model.h b/codecompletion/model.h
index 13e33fd..4242aa3 100644
--- a/codecompletion/model.h
+++ b/codecompletion/model.h
@@ -42,7 +42,7 @@ public:
     virtual ~ClangCodeCompletionModel();
 
 signals:
-    void requestCompletion(const QUrl &url, const KTextEditor::Cursor& cursor, const \
QString& text); +    void requestCompletion(const QUrl &url, const \
KTextEditor::Cursor& cursor, const QString& text, const QString& followingText);  
 protected:
     KDevelop::CodeCompletionWorker* createCompletionWorker() override;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic