News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

SmartSense/IntelliSense/CodeCompletion

Started by Aboq, January 05, 2007, 12:39:43 AM

Previous topic - Next topic

Aboq

I tried to use this feature like i know it from VisualStudio or better VisualAssist...
I only tried latest nightly build 03jan07 on windows.

It doesnt work...

typedef struct teststr_dummy {
    int test;
} teststr;

class testclass {
    public:
    int test;
};

/* ------------------------------------------------------------------------- */
BOOL InitInstance(hInstance, nCmdShow)
HANDLE  hInstance;
int     nCmdShow;
{
    teststr bla_bla; // teststr not in list in code completion
    bla_bla ---// no code completion after hitting .
    testclass bla_class; // testclass not in list in code completion
    bla_class ----// bla_class not in list in code completion | no code completion after hitting .


So how does this feature work must i refresh the symbols manually, is it only supported with depth = 1 (I Mean no . ->)

thanks for me this is a essantial feature

stahta01

Quote from: Aboq on January 05, 2007, 12:39:43 AM
I tried to use this feature like i know it from VisualStudio or better VisualAssist...
I only tried latest nightly build 03jan07 on windows.

It doesnt work...


typedef struct teststr_dummy {
    int test;
} teststr_dummy;


I think they must be named the same, I do NOT use code completion so I don't know for sure.
Tim S
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Aboq

no they shoulndt have the same name.

first is used inside the struct, second is used outside the struct definition.

Ceniza

IIRC CodeCompletion doesn't work with structs defined using a typedef... I even wonder if basic typedefs were implemented.

mann

#4
Yes this feature is essential for me as well, but if the code completion plugin can not handle typedef struct constructs it is unfortunately completely useless for us. can you estimate how long it will take until the code completion feature will work properly? it is one if not the most important feature of an IDE so it should be given highest priority,....do you agree?

thanks from hokkaido

Ceniza

Well, mandrav is the only man on earth who understands that plugin (he wrote it after all :wink:). I don't know how many time it would take a mortal to add it, and I have no idea if mandrav feels like implementing it anytime soon.

Even though there's something to clarify: CodeCompletion is able to parse structs and classes, but not those declared with a typedef.

In your example the plugin should be able to parse the class (testclass), but it should fail with the struct... and the function too. I just tested it and it's so.

Something that is not helping the plugin, 'cause it's unable to parse it, is the way you define the function: old-C style. If you change it from:
BOOL InitInstance(hInstance, nCmdShow)
HANDLE  hInstance;
int     nCmdShow;


to:
BOOL InitInstance(HANDLE hInstance, int nCmdShow)

then the plugin will be able to suggest things, and since you're also defining a class I guess you're using C++, so you should really define functions that way.

If you define structs like this:
struct NameOfTheStruct
{
  // data members
};


the plugin will be able to parse them.

Please have in mind the CodeCompletion plugin is still work in progress, even though it hasn't been touched that much for many months and it's known to lack support for a few 'constructs' (you know two now).

mandrav

  • Typedefs are supported.
  • "Typedef struct XYZ {} ABC;" is not supported. Break it in two steps if you need it (struct XYZ {}; typedef XYZ Sxyz).

  • This kind of code (what's it called? K&R?) is not supported:

    BOOL InitInstance(hInstance, nCmdShow)
    HANDLE  hInstance;
    int     nCmdShow;


  • Finally, this is WIP. Never forget that :).
Be patient!
This bug will be fixed soon...

Aboq

so i should rewrite all library header files?

please implement C parsing since C is a subset of C++

This is not my coding style, my code can be parsed (if i dont use this typedef) but major library headers wont work.

So for Linux Developers Code::Blocks might be a good thing, but i dont see why i should prefer codeblocks over visual studio.



killerbot

you have a point there, that libraries you *use* might be created like that. For the moment we focus the most on the modern language style. No promise if that old style will be supported some day, but then again no promise we will never support this. There are things with higher priorities, it hope you can accept that.

Aboq

Another Problem: Function Parameter display doesnt work right

void tester(int testparam) {
  // do something
}

void main() {
  // i enter tester( -> no parameters displayed
  // i delete ( and enter ( -> parameters are now displayed
}

killerbot

did you save first, will try out my self later on

mann

hello my friends,

ok thank you for answer. my colleagues and I have decided to stick to visual studio and use anjuta for the linux development of our project for now. but maybe we will reconsider codeblocks when version 2.0 has been released and code completion works more reliably. thank you for your work,

greetings from hokkaido

killerbot

Quote from: Aboq on January 05, 2007, 01:20:47 PM
Another Problem: Function Parameter display doesnt work right

void tester(int testparam) {
  // do something
}

void main() {
  // i enter tester( -> no parameters displayed
  // i delete ( and enter ( -> parameters are now displayed
}


I can confirm. I think I know why.
When I typed tester, after the test the CC popped up suggesting 'tester', however I kept on typing, so I typed tester, after the r was typed in the CC tooltip was still there. When I type the ( -> tooltip dismissed but the ( apparently did not trigger new CC tooltip for the arguments. When I then erase the ( and type it again, itworks. The ( in this case didn't had to clean up a previous tooltip.

Other test, instead of typing tester completely, I choose the tooltip suggestion that popped up after the 'test' (be hitting enter), so the tooltip was gone, after that enter-key I typed the ( and CC kicked in for the arguments.


@Yiannis, hope this gives you enough information to fix it ??

Alturin

#13
Quote from: mandrav on January 05, 2007, 09:04:13 AM
Typedefs are supported.


struct test_struct
{
    int first;
    int last;
    int percentage;
    char* text;
};

typedef struct test_struct MY_TEST_STRUCT;

int main()
{
    MY_TEST_STRUCT testOne;
    testOne. // hit ctrl-space, nothing happens, but code-completion DOES recognise it as a symbol (it shows up as local variable)

    return 0;
}



struct test_struct
{
    int first;
    int last;
    int percentage;
    char* text;
};

typedef struct test_struct MY_TEST_STRUCT;

int main()
{
    struct test_struct testTwo;
    test // hit ctrl-space, nothing happens, code-completion does not even recognise testTwo as a local variable

    return 0;
}



struct test_struct
{
    int first;
    int last;
    int percentage;
    char* text;
};

typedef struct test_struct test_struct;

int main()
{
    test_struct testThree;
    testThree. // hit ctrl-space, the list of available variables shows up

    return 0;
}



struct test_struct
{
    int first;
    int last;
    int percentage;
    char* text;
};

int main()
{
    test_struct testFour;
    testFour. // hit ctrl-space, the list of available variables shows up

    return 0;
}


So, I don't really see in what way typedefs are supported :(.
Apparent from test three and four it doesn't really parse the typedef, it just assumes it's there somehow?
It would be really superb to have typedef support, that is, testOne. completing properly.

TDragon

Quote from: Alturin on May 27, 2007, 09:03:55 PM
So, I don't really see in what way typedefs are supported :(.
Typedefs are certainly supported; it's C-style struct specifiers ("typedef struct test_struct blah;") that aren't. The typedef line is not recognized in any of the first three samples because of this; the last two examples work because "test_struct" is directly recognized as the previously declared struct -- which is entirely correct in C++ (except that the struct definition lacks a semicolon after the closing curly brace).
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)