Author Topic: some issues and requests  (Read 42921 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
some issues and requests
« on: August 17, 2010, 12:51:39 pm »
with all the improvements currently being made on the code completion, I wonder what of the following is possible to achieve.
All tests described here are carried out on the cc branch.

Consider the following code (compile with C++Ox support) :
Code
#include <iostream>
#include <vector>
#include <memory>


class Test
{
public:
Test() : mMember() {}
void DoSomething() {}
private:
int mMember;
};

class Confuse
{
public:
Confuse() {}
void DoSomething() {}
};


int main()
{
std::vector<int> MyInts;

MyInts.push_back(2);
MyInts.push_back(4);

Test MyTest;
MyTest.DoSomething();

Test* MyPointerToTest = new Test();
MyPointerToTest->DoSomething();

// time for smart pointers
std::unique_ptr<Test> MyUniquePointer(new Test());
MyUniquePointer->DoSomething();

std::shared_ptr<Test> MySharedPointer(new Test());
MySharedPointer->DoSomething();

std::auto_ptr<Test> MyAutoPointer(new Test());
MyAutoPointer->DoSomething();

delete MyPointerToTest;
return 0;
}

Let's start with a current issue : hover over the "DoSomething" part of "MyTest.DoSomething();", right click and choose "Find declaration". CB offers you a choice, although there should be no choice, only the the Test::DoSomething() is a candidate, it however also offer the one from the class Confuse an an option. [same applies when starting from 'MyPointerToTest->DoSomething();"].

Next, hover over the "MyInts" part of "MyInts.push_back(4);", CB shows in the tooltip it is a vector, I guess it would be better to say it is a "vector<int>" ?

A similar remark applies for all the smart pointers, for example : hovering over "MyAutoPointer" tells you it is a auto_ptr, where auto_ptr<Test> would be better, right ?


And now on to the new requests.
When I type "MyAutoPointer->", the completion allows me to choose from the list of auto_ptr methods [eg. get, release, reset, ...], it would be very good if this list is extended with the list of methods of the wrapped pointer. Since smart pointers are a very good tool to write good software, it is now less nice (in CB) since you loose the completion of the original pointer.

For the other smart pointers in this example, there's nothing at all, so it would be nice, those also got supported and provide the same level of user friendliness [codecompletion wise] as auto_ptr,
that is smart pointer methods, and original pointer methods.

How feasible do the cc gurus think this is ?
Personally I think this would be a major benefit.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: some issues and requests
« Reply #1 on: August 17, 2010, 01:32:41 pm »
For the other smart pointers in this example, there's nothing at all, so it would be nice, those also got supported and provide the same level of user friendliness [codecompletion wise] as auto_ptr,
that is smart pointer methods, and original pointer methods.
-std=c++0x in gcc defines a macro (GCC_CPP_OX_EXPERIMENTAL or something like that) and probably the current parser doesn't define this macro, so the c++-0x additions to the STL are not parsed at all.

How feasible do the cc gurus think this is ?
Personally I think this would be a major benefit.
+1
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: some issues and requests
« Reply #2 on: August 18, 2010, 08:46:21 am »
How feasible do the cc gurus think this is ?
Personally I think this would be a major benefit.
+1
+1 = 2

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: some issues and requests
« Reply #3 on: August 19, 2010, 02:02:36 am »
Let's start with a current issue : hover over the "DoSomething" part of "MyTest.DoSomething();", right click and choose "Find declaration". CB offers you a choice, although there should be no choice, only the the Test::DoSomething() is a candidate, it however also offer the one from the class Confuse an an option. [same applies when starting from 'MyPointerToTest->DoSomething();"].

I'm under big work load these days, so I delayed my reply.  :D.

There are three major parts of CC
A. collect tokens
B. resolve statement
C. other improvement


The cc_branch till now has a lot of improvement in the first part A "correct tokens", we have add some functionality like:
1, one parser peer a project, this means a workplace can have several parser object and tokenstree, thus they don't intervene each other.
2, a NONE parser, which means if you open a file which does not belong to any project, then a NONE parser will be created and now, you can have the symbols tree for these files.
3, preprocessor handling can deal with #if  #ifdef like directive, and to achieve this, you need some "up-front" file list, so that these files(there are a lot of #define in them) will be parsed before other files, thus, proprocessor handling can works better.
4, function like macro handling, we have really do some kind macro expansion
5, there are some patches to support reading the "template information", but they are not complete, they can only handle some template class declared in global namespace, also if there are typedef the template class there are some parsing errors.
6, there are other patches to tokenizer and parserthread class, Yes, there a lot patches included.

About Part B: expression(statement) solving
This is most thing about your question
1, we have introduce some new match algorithm(this can avoid some recursive call and make it faster), as you can see, a match is from the parent to child. like: objA.m_aaa.m_x, if you do a cc's suggestion list here, you need to match "objA", then match "m_aaa" in the result of "match objA"....
2, about the "template issue", only template class or template function under global workspace can works.
3, about the "find declaration issue", I remember you have complaint in Is this something we can solve with the improved CC, this is still not solved. The current implementation is just do a plain text match in the tokenstree, so you get a lot of functions of other class. I have a solution in that thread, but I'm not sure it is a best way, since no one give any comments in that post.  :D
4, about the smart pointer issue, I have tried it several days, but it is complex because there are some "typedef" in the template class that make things more hard, e.g.
Code
template <typename T1>
class AAA
{
    typedef T1 T2;
    typedef T2 T3;
    T3 function();
}
This will make the match algorithm failed when dealing with "function".  :D
Also, our algorithm to split a statement is not good compare to CodeLite(it use a lex/yacc grammar). :D

About part C (UI and other improvement)
1, smart tab jump
2, auto completion for preprocessor, include files ....
3, some code format adjust after autocompletion
4, Toolbar improvement
5, symbols tree for AAA.cpp and AAA.h which are not in the same directory.
6, some auto generated code improvement
7, a Parser Test project was added, so we can find the parser error more quickly
8, realtime parse(parse while editing) and reparse issue fix, also support wxsmith change of code.
9, ..... can be seen in the SVN Log message.


Quote
Next, hover over the "MyInts" part of "MyInts.push_back(4);", CB shows in the tooltip it is a vector, I guess it would be better to say it is a "vector<int>" ?
This one, as you define the variable like this:
Code
std::vector<int> MyInts;
once a variable token "MyInts" is added to the Tokenstree, it has some other infomations like: its type string is: std::vector, its template argument list string is<int>, so I think this issue can be resolved.


Code
A similar remark applies for all the smart pointers, for example : hovering over "MyAutoPointer" tells you it is a auto_ptr, where auto_ptr<Test> would be better, right ?


And now on to the new requests.
When I type "MyAutoPointer->", the completion allows me to choose from the list of auto_ptr methods [eg. get, release, reset, ...], it would be very good if this list is extended with the list of methods of the wrapped pointer. Since smart pointers are a very good tool to write good software, it is now less nice (in CB) since you loose the completion of the original pointer.

For the other smart pointers in this example, there's nothing at all, so it would be nice, those also got supported and provide the same level of user friendliness [codecompletion wise] as auto_ptr,
that is smart pointer methods, and original pointer methods.

If I have a template class, then I found that it has a operator "->" defined, I can get the return type. As I said before, e.g.
Code
template <typename T1>
class AAA
{
    typedef T1 T2;
    typedef T2 T3;
    T3 function();
    T3 operator -> () .....
}

the return type of the operator -> is quite different of the T1(because there are a lot of typedef), so it is not easy to solve this. But logically it can. :D, it just need a lot of time.

We are fighting some bugs in the latest cc_branch, some thread safe problem of the parser can cause the crash... it is also tough :D





« Last Edit: December 09, 2010, 02:46:38 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: some issues and requests
« Reply #4 on: August 19, 2010, 03:38:01 am »
Sorry, I was busy these days to make a significant improvement, patch size has reached 95KB, so have not noticed this post.
I will carefully review your proposed that these features, and as much as possible to achieve them!

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: some issues and requests
« Reply #5 on: August 19, 2010, 03:42:02 am »
Thank ollydbg summary, your summary is really great!
 :)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: some issues and requests
« Reply #6 on: August 27, 2010, 08:27:28 am »
Solved the first issue, test are welcome.  :D

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: some issues and requests
« Reply #7 on: August 27, 2010, 09:10:38 am »
Fix the next issue: about template variables calltip error.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: some issues and requests
« Reply #8 on: August 27, 2010, 10:26:50 am »
About the the requests: support GCC's "-std=c++0x" or "-std=gnu++0x" options.
If use the above options, will define a macro named: __GXX_EXPERIMENTAL_CXX0X__

So, We can parse shared_ptr now. :)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: some issues and requests
« Reply #9 on: August 27, 2010, 12:50:37 pm »
I can confirm it all works (vector<int>, smart pointer, goto decla/impl).
Really, a job well done. Superb !!!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: some issues and requests
« Reply #10 on: August 27, 2010, 12:53:36 pm »
Does

Code
#include <tr1/memory>
std::tr1::shared_ptr<blabla> p(...)

work?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: some issues and requests
« Reply #11 on: August 27, 2010, 01:09:45 pm »
Does

Code
#include <tr1/memory>
std::tr1::shared_ptr<blabla> p(...)

work?

GCC version?
All test based GCC 4.4.x

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: some issues and requests
« Reply #12 on: August 27, 2010, 01:17:49 pm »
Does

Code
#include <tr1/memory>
std::tr1::shared_ptr<blabla> p(...)

work?



no ,it is about operator overload,
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: some issues and requests
« Reply #13 on: August 27, 2010, 01:29:39 pm »
I was asking if you're parsing the the tr1 shared_ptr correctly, not if the operator -> works.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: some issues and requests
« Reply #14 on: August 27, 2010, 03:29:30 pm »
I can confirm it works also with the "trunk" version... I just had to apply the patch manually, but here is a patch against the trunk version r6536.
« Last Edit: August 27, 2010, 04:08:34 pm by daniloz »