Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Alpha on January 03, 2012, 02:59:21 am

Title: Enable CC on file extensions
Post by: Alpha on January 03, 2012, 02:59:21 am
Is their a setting somewhere to tell the CodeCompletion plugin to run on file extensions other than the registered C/C++ ones?

I would like to add *.java files - Java is close enough to C++ that I find CC's suggestions are able to be helpful (when I already have Code::Blocks open and do not want to launch Eclipse).

(P.S. Java lexer (http://developer.berlios.de/patch/?func=detailpatch&patch_id=3246&group_id=5358) available.)
Title: Re: Enable CC on file extensions
Post by: ollydbg on January 03, 2012, 03:38:21 am
Look at Token.cpp

Code
CCFileType CCFileTypeOf(const wxString& filename)
{
    const wxString file = filename.AfterLast(wxFILE_SEP_PATH).Lower();
    const int pos = file.Find(_T('.'), true);
    wxString ext;
    if (pos != wxNOT_FOUND)
        ext = file.SubString(pos + 1, file.Len());

    if (   ext.IsEmpty()
        || ext == _T("h")
        || ext == _T("hpp")
        || ext == _T("tcc")
        || ext == _T("xpm") )
    {
        return ccftHeader;
    }
    else if (   ext == _T("cpp")
             || ext == _T("c")
             || ext == _T("cxx")
             || ext == _T("cc")
             || ext == _T("c++") )
    {
        return ccftSource;
    }
    else
        return ccftOther;
}

So, you can add the java file extension here.

The best way is that it can have a wxTextCtrl in the CC setting dialog.

PS: I'm not sure our CC's parser can correctly parse java source files.
Title: Re: Enable CC on file extensions
Post by: MortenMacFly on January 03, 2012, 08:29:02 am
The best way is that it can have a wxTextCtrl in the CC setting dialog.
That's what I played around with recently. The outcome is attached... That's how it should look like (implementation is still not complete due to a lack of time).
Title: Re: Enable CC on file extensions
Post by: ollydbg on January 03, 2012, 08:42:21 am
In your new design, I found in the new page(C/C++ parser adv), you have:

Keyword sets to additionally include:

But this I think is belong to "code completion" page, not the parser page.
Title: Re: Enable CC on file extensions
Post by: MortenMacFly on January 03, 2012, 09:12:02 am
But this I think is belong to "code completion" page, not the parser page.
True, I actually had in mind to save space... I'll change it.
Title: Re: Enable CC on file extensions
Post by: MortenMacFly on January 03, 2012, 10:49:38 am
Implemented in trunk.
Title: Re: Enable CC on file extensions
Post by: Alpha on January 03, 2012, 11:45:38 pm
PS: I'm not sure our CC's parser can correctly parse java source files.
You are right that it cannot really understand it, but for simple/quick matters in which it is not worth my time to open a different program, CC works well enough to be useful.

Implemented in trunk.
Thank you, I will be sure to try it.

A related question: is there any structure in place that I can use to create "on demand" code completion (similar to being able to select the lexer with Edit->Highlight mode)?
Title: Re: Enable CC on file extensions
Post by: Alpha on January 04, 2012, 01:59:53 am
I just realized I forgot to tag the category when I submitted the Java lexer patch.

Is there a way I can add it to the appropriate category?  (I am relatively new to BerliOS, so I am unsure if I am simply missing the button.)
Title: Re: Enable CC on file extensions
Post by: oBFusCATed on January 04, 2012, 02:03:57 am
I've set the category to Lexer, is this the correct one?
Probably only developers can change the 'advanced' settings of patches, bugs and features.
Title: Re: Enable CC on file extensions
Post by: Alpha on January 04, 2012, 02:08:11 am
I've set the category to Lexer, is this the correct one?
Yes, that is the one; thank you.  (You have saved me from being bugged at seeing something out of place :).)

Probably only developers can change the 'advanced' settings of patches, bugs and features.
OK.
Title: Re: Enable CC on file extensions
Post by: MortenMacFly on January 04, 2012, 07:18:39 am
is there any structure in place that I can use to create "on demand" code completion (similar to being able to select the lexer with Edit->Highlight mode)?
No. And I think it wouldn't really make sense. However, If you change the CC options, usually the project(s) is(are re-scanned.
Title: Re: Enable CC on file extensions
Post by: ollydbg on January 08, 2012, 06:44:59 am
But this I think is belong to "code completion" page, not the parser page.
True, I actually had in mind to save space... I'll change it.
One question:
How did you move items from one panel to another.

You just select one, then ctrl+X(cut), then ctrl+V(paste) to another panel?

As we can't not multiply select many items, so even cut/paste every items in "Keyword sets to additionally include" are quite annoying.  :)

Title: Re: Enable CC on file extensions
Post by: MortenMacFly on January 08, 2012, 07:01:01 am
As we can't not multiply select many items, so even cut/paste every items in "Keyword sets to additionally include" are quite annoying.  :)
No, sure not. You can copy/paste by container, so e.g. by wxStaticBoxSizer.