Adding ObjectiveC Support

Discussion about CodeLite development process and patches
User avatar
Rosch
CodeLite Enthusiast
Posts: 24
Joined: Fri Nov 02, 2012 4:28 pm
Genuine User: Yes
IDE Question: C++
Location: Germany
Contact:

Adding ObjectiveC Support

Post by Rosch »

Hi Eran,

For a couple of days now I am using CodeLite and I like it! Great work! I would like to use it here inhouse as an IDE. But there is one big missing feature ObjectiveC support. We do have a large cross platform C/C++/ObjectiveC codebase and so I also will need ObjectiveC syntaxhighlighting and codecompletion in CodeLite in the same quality as the C++ support is done.

I am currently investigating the range of changes necessary to do this before I will start to implement this.
(When I got ObjectiveC support working I would like to contribute it back to CodeLite.) I am writting here in the hope to get some pointers on how to start most efficiently on this...

1. Syntax highlighting
As of now CodeLite uses wxStyledTextControl which in turn uses scintilla. Scintilla yet has no ObjC support so I need to add this here too. Plus at least some language definitions in wxWidgets itself. Right? I have seen that CodeLite itself has a bunch of own yacc and flex grammers/parsers for C++. For which purpose are they used?

2. Code Completion
CodeLite uses ctags/clang for code completion. Clang should be able to handle ObjC. Regarding ctags I have seen that codelite uses ctags 5.6. The official version of ctags is 5.8 which is already some years old. After the official release of ctags 5.8 an Objectice C parser was added to ctags (I believe in 2010) which appears to be mature. So updating ctags in codelite will be necessary. And of course Objective C semantics will be needed to get implemented in the codecompletion area of codelite itself.

Do I miss something here?

Thanks for your help,

Roland
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Adding ObjectiveC Support

Post by eranif »

Rosch wrote:As of now CodeLite uses wxStyledTextControl which in turn uses scintilla. Scintilla yet has no ObjC support so I need to add this here too. Plus at least some language definitions in wxWidgets itself. Right? I have seen that CodeLite itself has a bunch of own yacc and flex grammers/parsers for C++. For which purpose are they used?
Adding syntax highlight is an easy task

From the wiki:
http://www.codelite.org/LiteEditor/AddingNewLexer
Rosch wrote:Clang should be able to handle ObjC
clang is the way to go, as it was primary written for ObjectC (well, it was developed by Apple...)
Ignore ctags - you can enforce it within codelite for opbjective C files ( you need to add new ObjectiveCContext class which derives from ContextBase, similar to ContextCpp)
Rosch wrote:The official version of ctags is 5.8 which is already some years old
codelite is not really using ctags, it uses a libctags (a modified version of ctags which can be used as a library and not as an external executable). In addition, it contains many updates I made to ctags (better template handling, better replacements and much more)

In the ObjC context class you handle all the indentation, go to impl/decl, provide a context menu etc.

If you are interested in creating ObjC support, join our IRC channel for better communication (you can ask questions there and either me "eranif" or David "DavidGH" will be able to assist you)

codelite IRC:
#codelite @ irc.freenode.net

Eran
Make sure you have read the HOW TO POST thread
User avatar
Rosch
CodeLite Enthusiast
Posts: 24
Joined: Fri Nov 02, 2012 4:28 pm
Genuine User: Yes
IDE Question: C++
Location: Germany
Contact:

Re: Adding ObjectiveC Support

Post by Rosch »

Hi Eran,
eranif wrote: If you are interested in creating ObjC support, join our IRC channel for better communication (you can ask questions there and either me "eranif" or David "DavidGH" will be able to assist you)
Thanks for you reply. I will first take some more look at the insides of codelite and than I am sure I will pop up at the IRC channel within the next days...

Roland
User avatar
Rosch
CodeLite Enthusiast
Posts: 24
Joined: Fri Nov 02, 2012 4:28 pm
Genuine User: Yes
IDE Question: C++
Location: Germany
Contact:

Re: Adding ObjectiveC Support

Post by Rosch »

Hi Eran...

As the IRC channel seems to be orphaned at present I am writting here...
eranif wrote: Adding syntax highlight is an easy task

From the wiki:
http://www.codelite.org/LiteEditor/AddingNewLexer
I wanted to start out with this, but:
On http://www.codelite.org/LiteEditor/AddingNewLexer it is written that a lexer node needs to have an Id attribute
the Id attribute needs to correspond to a given wxSTC_LEX define from wxwidgets stc.h
but well there I cannot find any id for objective C
as far as I understand it the ids are originating from scintilla

Roland


so I need to start with adding ObjC support to Scintilla and wxWidgets first?
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Adding ObjectiveC Support

Post by eranif »

From what I can see, the ObjC should be handled by the C++ lexer
So you can copy the C++ lexer definition.

You should only modify the "<Extensions>" element content

FYI:
wxStyledTextCtrl is just a bridge to scintilla http://scintilla.org - so if anything is missing it should be added to scintilla first
As the IRC channel seems to be orphaned at present I am writting here...
post your question and keep your session logged in - eventually someone will reply

Eran
Make sure you have read the HOW TO POST thread
User avatar
Rosch
CodeLite Enthusiast
Posts: 24
Joined: Fri Nov 02, 2012 4:28 pm
Genuine User: Yes
IDE Question: C++
Location: Germany
Contact:

Re: Adding ObjectiveC Support

Post by Rosch »

So...

After being blocked with other things the last days I have spent now some time on this.
Just a brief summary before I have to leave my desk for the weekend...

1. Syntax highlight
As suggested I gave the lexers xml a chance and added my stuff there. I added a new section for ObjectiveC using Id=3 (as it is done for C++ and Java) and tweaked it a little bit. Especially the keyword sections. It works quite well for files with suffix .m (as they are used for the implementations of ObjectiveC classes). ObjC declares its classes (like C++) in headerfiles where it comes to a problem now. The suffix .h is already registered as extension for C++ so the header files get syntax highlighted by the definitions for C++. Not the result I would like to have. My suggestion as a solution for this problem would be to merge the ObjectiveC syntaxhighlight style into the C++ style which is possible. I tried it and it does not seem to have a bad impact on C++ files (as far as I have checked it up to now).

So my suggestion would be to turn the "C++" Syntax highlighter into a "C/C++/ObjectiveC" highlighter. What do you think about it?

2. General integration
Also I started out integrating Objective C as a language in general which means:
- pixeled a 16x16 ObjC fileicon and added it to both icon sets.
- added .m to the fileextensionmanager
- added the icon to the bitmap loader, the file tree view, the newitem dialog and some other places
So ObjectiveC files are now clearly visible as being ObjectiveC in CodeLite.

How do you want my changes backmerged (if you want to have them)?
In one big block or is it more comfortable for you to get them in smaller packages for easier review?

Roland
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Adding ObjectiveC Support

Post by eranif »

Rosch wrote:So my suggestion would be to turn the "C++" Syntax highlighter into a "C/C++/ObjectiveC" highlighter. What do you think about it?
Good idea
Rosch wrote:How do you want my changes backmerged (if you want to have them)?
Improvements are always welcomed. Please send them as a single patch

HOW TO SUBMIT A PATCH

Eran
Make sure you have read the HOW TO POST thread
User avatar
Rosch
CodeLite Enthusiast
Posts: 24
Joined: Fri Nov 02, 2012 4:28 pm
Genuine User: Yes
IDE Question: C++
Location: Germany
Contact:

Re: Adding ObjectiveC Support

Post by Rosch »

Hi Eran,
eranif wrote:
Rosch wrote:So my suggestion would be to turn the "C++" Syntax highlighter into a "C/C++/ObjectiveC" highlighter. What do you think about it?
Good idea
Here comes the patch for doing this.
I mainly changed the lexers name to "C/C++/ObjectiveC" and added a bunch of keywords for ObjC internals (keywords0), ObjC Foundation base classnames (keywords1) and ObjC protocols (keywords3). I also made some names for the individual highlighters a little more generic.

I could not find any negative effects in highlighting C++ files with the changed lexers, yet.

And well I got a suggestion to make merging back lexers maybe a little easier:
The lexers default files in Runtime/lexers appear to be handcrafted. When CodeLite loads them and stores them to the .codelite or AppData folder it reformats them. The lexers are sorted, reindented and XML attributes get moved around. I would suggest to keep the default lexer files in SVN already in the form codelite itself saves them. This would make generating patches for the lexers and merging them back easier. The patch for the C++ lexer is already in the "CodeLite-cooked" form.

Roland
You do not have the required permissions to view the files attached to this post.
Post Reply