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

List:       kde-commits
Subject:    [kdev-python/5.1] codecompletion: Completion hint: Correct default-argument index for non-static met
From:       Francis Herne <null () kde ! org>
Date:       2017-01-01 1:13:12
Message-ID: E1cNUi0-0001CI-VJ () code ! kde ! org
[Download RAW message or body]

Git commit cbcde7f0136bde15858931774fb9e44a8e217a7e by Francis Herne.
Committed on 01/01/2017 at 01:03.
Pushed by flherne into branch '5.1'.

Completion hint: Correct default-argument index for non-static methods.

BUG: 369369

>From the bug:
```
class C:
    def func1(self, arg1, arg2, arg3=None, arg4=42, arg5='default'):
        pass
c = C()
c.func1(
 # argument tooltip says void func1 (arg1, arg2, arg3, [arg4, arg5])
```

Now '(arg1, arg2, [arg3, arg4, arg5])' as expected.

Still wrong in case of calling the method directly from the class:
`C.func1(c,` <- same tooltip, but now the self argument is explicit.

This was broken before too, and would require much more intrusive
 changes to fix because we only have the function declaration currently.

Quick fix for 5.1, I'm making some larger changes for master.

M  +4    -5    codecompletion/helpers.cpp

https://commits.kde.org/kdev-python/cbcde7f0136bde15858931774fb9e44a8e217a7e

diff --git a/codecompletion/helpers.cpp b/codecompletion/helpers.cpp
index 30a42888..6a0ca057 100644
--- a/codecompletion/helpers.cpp
+++ b/codecompletion/helpers.cpp
@@ -319,10 +319,6 @@ void createArgumentList(Declaration* dec_, QString& ret, QList< QVariant >* high
         if (DUChainUtils::getArgumentContext(dec))
             parameters = DUChainUtils::getArgumentContext(dec)->localDeclarations();
 
-        uint defaultParamNum = 0;
-
-        int firstDefaultParam = parameters.count() - decl->defaultParametersSize();
-
         ret = '(';
         bool first = true;
         int num = 0;
@@ -332,7 +328,10 @@ void createArgumentList(Declaration* dec_, QString& ret, QList< QVariant >* high
             // the function is a class method, and its first argument is "self". Don't display that.
             skipFirst = true;
         }
-        
+
+        uint defaultParamNum = 0;
+        int firstDefaultParam = parameters.count() - decl->defaultParametersSize() - skipFirst;
+
         // disable highlighting when in default arguments, it doesn't make much sense then
         bool disableHighlighting = false;
         
[prev in list] [next in list] [prev in thread] [next in thread] 

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