Code::Blocks Forums

User forums => Help => Topic started by: jonas thomas on June 04, 2011, 03:52:21 pm

Title: Issues with "Find Declaration of" and Code Completion.
Post by: jonas thomas on June 04, 2011, 03:52:21 pm
I've been working my way through some Ogre Tutorials http://www.ogre3d.org/tikiwiki/Intermediate+Tutorial+1&structure=Tutorials#Animation (http://www.ogre3d.org/tikiwiki/Intermediate+Tutorial+1&structure=Tutorials#Animation)
and I'm having some annoying issues with Code Completion when I try to hack up the code.

Basically
Quote
class BaseApplication : public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener, public OIS::MouseListener, OgreBites::SdkTrayListener
{
......
protected:
    Ogre::SceneManager* mSceneMgr;
......
}

Quote
class ITutorial01 : public BaseApplication
{
public:
    ITutorial01(void);
    virtual ~ITutorial01(void);
 
protected:
     virtual void createScene(void);
     virtual void createFrameListener(void);
     virtual bool nextLocation(void);
     virtual bool frameRenderingQueued(const Ogre::FrameEvent &evt);
}

class ITutorial01 : public BaseApplication
{
public:
    ITutorial01(void);
    virtual ~ITutorial01(void);
 
protected:
     virtual void createScene(void);
......

}

Quote
void ITutorial01::createScene(void)
{
    Ogre::SceneManager *Testthis;
    *Testthis->getEntity("code completion works here");
   
    // Set the default lighting.
        mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
    // Create the entity
        mEntity = mSceneMgr->createEntity("Robot", "robot.mesh");

Code completion works the pointer Testthis but doesn't work on mSceneMgr
If I try doing a find declaration of mSceneMgr it can't find it, even though it's in the project and everything compiles and runs properly.

I must be missing something obvious here..
Anyone?






Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: jonas thomas on June 04, 2011, 04:12:53 pm
I must have screwed something up here.  I found something here back in 2007 http://forums.codeblocks.org/index.php?action=printpage;topic=7241.0 (http://forums.codeblocks.org/index.php?action=printpage;topic=7241.0)
that talked about
Quote
I select the Symbols tab of the Management notebook
I right click on the Symbols item of the tree (root)
I click on re-parse now

This force the projects to be reparsed and the find items work again.

Err... Does that still apply in 2011?
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: ollydbg on June 05, 2011, 04:49:33 am
I just test a sample code below:
Code
class BaseApplication : public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener, public OIS::MouseListener, OgreBites::SdkTrayListener
{

protected:
    Ogre::SceneManager* mSceneMgr;

};

class ITutorial01 : public BaseApplication
{
public:
    ITutorial01(void);
    virtual ~ITutorial01(void);

protected:
     virtual void createScene(void);
     virtual void createFrameListener(void);
     virtual bool nextLocation(void);
     virtual bool frameRenderingQueued(const Ogre::FrameEvent &evt);
};

void ITutorial01::createScene(void)
{
    Ogre::SceneManager *Testthis;
    *Testthis->getEntity("code completion works here");


    // Set the default lighting.
        mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
    // Create the entity
        mEntity = mSceneMgr->createEntity("Robot", "robot.mesh");
}

and it works here.
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: jonas thomas on June 05, 2011, 07:16:35 am
Most curious, that's not what I get when I created a new single file project.
I created a new ogre project using the single file below and was able to build.
    Testthis
    mSceneMgr
Now code completion is not working on either one nor is find declaration.

The thing is if I type:
Ogre::
, I get code completion to work on that.
I'm using SVN 7174 Build 28 May Wx 2.8.10 (Linux Unicode) 32 bit.

Am I missing something obvious here? (It seems like there is not a lot of noise when I google this, so I'm thinking it's me.  :cry:





Code

#include <OgreCamera.h>
#include <OgreEntity.h>
#include <OgreLogManager.h>
#include <OgreRoot.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>

#include <OISEvents.h>
#include <OISInputManager.h>
#include <OISKeyboard.h>
#include <OISMouse.h>

#include <SdkTrays.h>
#include <SdkCameraMan.h>



class BaseApplication : public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener, public OIS::MouseListener, OgreBites::SdkTrayListener
{

protected:
    Ogre::SceneManager* mSceneMgr;
    Ogre::Entity *mEntity;
   
};

class ITutorial01 : public BaseApplication
{
public:
    ITutorial01(void);
    virtual ~ITutorial01(void);

protected:
     virtual void createScene(void);
     virtual void createFrameListener(void);
     virtual bool nextLocation(void);
     virtual bool frameRenderingQueued(const Ogre::FrameEvent &evt);
};

void ITutorial01::createScene(void)
{
   
    Ogre::SceneManager *Testthis;
   
    Testthis->getEntity("code completion works here");
   
    // Set the default lighting.
        mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));

    // Create the entity
        mEntity = mSceneMgr->createEntity("Robot", "robot.mesh");


}
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: ollydbg on June 06, 2011, 01:55:30 pm
Most curious, that's not what I get when I created a new single file project.
I created a new ogre project using the single file below and was able to build.
    Testthis
    mSceneMgr
Now code completion is not working on either one nor is find declaration.
Is it simple or complex to test the Ogre library???
If it is simple, I can test this file for you.  :D
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: jonas thomas on June 09, 2011, 10:19:11 pm
I appreciate the offer.  I done think there's an issue with the code, but perhaps something I've done with code::blocks that the code::completion isn't working.
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: Tutemlake on June 20, 2011, 01:26:21 pm
I will post here, since I have similar issues with the code completion feature.
I'm using codeblocks (svn 7178, unicode) on 64-bit Win 7.

Like the OP, I'm building an application using OGRE (mingw SDK 1-7-2). I've started with a similar, but even smaller codebase (http://www.ogre3d.org/tikiwiki/Ogre+Wiki+Tutorial+Framework#TinyOgre).
And I cannot seem to get the auto-completion to work! I'm always getting the "The Parser is still parsing files..." message. And when I right click on a header file (say OgreRoot.h) and then on "Open include file", I get a "Not found" message (I remember that at least this working at some point... Not sure why it's not now)
I have tried:

I just test a sample code below:
...code..
and it works here.
Can you elaborate on how you managed to make it work? Obviously, I'm missing something...
Is there a known procedure on how to make CC register the include files?
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: ollydbg on June 20, 2011, 04:15:06 pm
I have download the full Ogre mingw sdk and the tinyOgre sample.
I just create a console project, and put the source of tinyOgre there, and setting the compiler search path.
and "Find declaration of" works.

the batch parsing seems works fine:
Code
Project 'Ogre' parsing stage done (306 total parsed files, 37200 tokens in 0 minute(s), 3.781 seconds).

So, you need to give use a step by step to produce your bug.

thanks you.
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: Tutemlake on June 20, 2011, 06:37:22 pm
I've tried again now with a fresh copy of the latest nightly CB and the ogre mingw sdk.
Extracted all archives on D:\, respectively.
Started CB, created a new C++ console project on D:\ called test.
Removed main.cpp from the project.
Added the TinyOgre files to project, recursively.
Right-clicked on the project test -> Build options -> Selected test (instead of Debug) on the left panel -> Search directories -> Compiler -> Clicked the Add button -> I've put in D:\OgreSDK_mingw_v1-7-2\include\OGRE -> OK -> OK
At this point I've tried the "Find Declaration of", CC and "Open #include file" features, all of which do not work. Their respective errors are: "Not found", "The Parser is still parsing files" and "Not found".

I should note that the same occurs on the original main.cpp:
Code
#include <iostream>

using namespace std;
int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: ollydbg on June 21, 2011, 04:03:17 am
I have two include search path
D:\OgreSDK_mingw_v1-7-2\include\OGRE
and
D:\OgreSDK_mingw_v1-7-2\include\OIS (If I remember correctly)
And after that, I just save/close the project, and open it again, then everything works well.
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: MortenMacFly on June 21, 2011, 09:07:33 am
And after that, I just save/close the project, and open it again, then everything works well.
Same here. Can you tell how you setup CC in the options, please? Maybe we missed some flags in the setup to reproduce.
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: Tutemlake on June 21, 2011, 09:14:20 am
It works now!
I went to where CB stores settings and deleted it, so I got the vanilla settings, and now it works fine.

I'm gonna fiddle with the settings to see what I set wrong previously

EDIT: I've fiddled a bit, and every combination of settings in CC works fine now.
In short... I haven't a clue what borked it before! :)
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: Tutemlake on June 26, 2011, 01:16:03 pm
I think I've found a bug of some sort.

The CC works fine as long as I don't change the GCC toolchain settings! Once I change them and restart CB, CC doesn't work anymore. The funny thing is that until I restart CB, it will work fine... I just can't exit CB again, or I'll have to remove the default.conf and set everything up again, to get it to work.

I've compared the working and not working default.confs:
working:
Code
				<MASTER_PATH>
<str>
<![CDATA[D:\TDM-MinGW]]>
</str>
</MASTER_PATH>
NOTE: there are no C_COMPILER,etc. tags present here

not working (after I've changed the toolchain settings and restarted CB):
Code
				<MASTER_PATH>
<str>
<![CDATA[D:\TDM-MinGW-dw2]]>
</str>
</MASTER_PATH>
<C_COMPILER>
<str>
<![CDATA[mingw32-gcc-dw2.exe]]>
</str>
</C_COMPILER>
<CPP_COMPILER>
<str>
<![CDATA[mingw32-g++-dw2.exe]]>
</str>
</CPP_COMPILER>
<LINKER>
<str>
<![CDATA[mingw32-g++-dw2.exe]]>
</str>
</LINKER>

I've also noticed that when CC works I get this in the Code::Blocks tab:
Code
Opening D:\test_OGRE\cb2\cb2.cbp
done
Create new parser for project 'cb2'
Project 'cb2' parsing stage done!

vs. not working:
Code
Opening D:\test_OGRE\cb2\cb2.cbp
done
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: ollydbg on June 26, 2011, 04:05:38 pm
@Tutemlake (http://forums.codeblocks.org/index.php?action=profile;u=30539), I'm not sure what exactly cause this issue you said. But did you try the latest revision (rev 7255), as recently loaden has fix a bug on getting Mingw predefined macros.
Title: Re: Issues with "Find Declaration of" and Code Completion.
Post by: Tutemlake on June 27, 2011, 06:04:28 pm
I've tried the latest nightly build (7257) and after some tinkering everything seems to be working fine!

Thank you CB team! :D