Bug 68083 - [Help Wanted][Variant] Add support for Objective-C
Summary: [Help Wanted][Variant] Add support for Objective-C
Status: RESOLVED WONTFIX
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement with 74 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords: helpwanted
Depends on: 315539
Blocks:
  Show dependency tree
 
Reported: 2004-06-21 15:48 EDT by Andrew Carter CLA
Modified: 2020-10-25 02:13 EDT (History)
30 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Carter CLA 2004-06-21 15:48:58 EDT
CDT already works reasonably well for Objective-C (used on the Macintosh for 
Cocoa and on other platforms in GNUStep).  However, adding a few enhancements 
would make this a first-class IDE for Objective-C development.

Suggested enhancements:
* Support for objective-c keywords and syntax (primarily [object message]; 
syntax).
* Support for parsing @interface into class objects like C++.  This would 
enable the class browser and searching abilities.

I believe gdb already fully supports objective-c so debugging already works 
great under eclipse.
Comment 1 John Camelon CLA 2004-06-22 11:11:40 EDT
Setting Milestone to Future ... if there is enough interest (i.e. votes) I 
could see this happening at some point ... however there is more demand for 
VC++ right now ... 
Comment 2 Michael Larbi CLA 2005-09-16 20:02:49 EDT
I am interested in contributing to a project to fully integrate the  objective-c language in the CDT.  How do 
I get started?

(In reply to comment #1)
> Setting Milestone to Future ... if there is enough interest (i.e. votes) I 
> could see this happening at some point ... however there is more demand for 
> VC++ right now ... 

Comment 3 Michael Larbi CLA 2005-09-16 20:05:34 EDT
Hello, 

I am able to build Objective-C apps using CDT on Mac OS X using the Apple GCC 4.0.1 and using the 
standard make and manually writing my makefile .  Can you please shed some more light on how you 
did this?

(In reply to comment #0)
> CDT already works reasonably well for Objective-C (used on the Macintosh for 
> Cocoa and on other platforms in GNUStep).  However, adding a few enhancements 
> would make this a first-class IDE for Objective-C development.
> 
> Suggested enhancements:
> * Support for objective-c keywords and syntax (primarily [object message]; 
> syntax).
> * Support for parsing @interface into class objects like C++.  This would 
> enable the class browser and searching abilities.
> 
> I believe gdb already fully supports objective-c so debugging already works 
> great under eclipse.

Comment 4 Chris Recoskie CLA 2007-05-16 11:27:28 EDT
It's now possible to add new ILanguages to CDT and map them to content types.  You would still need new AST constructs to handle the language though, as it's got things that are not in C or C++.  You could probably look at the C99 preprocessor and parser that we contributed recently and start looking there as to how to contribute your own parser and ILanguage.  You can probably reuse our preprocessor and parts of our C grammar to create your own parser.

No one is currently looking at doing this, but we would welcome a contribution.  Looks like a great idea for a Google Summer of Code project or the like.
Comment 5 Mike Kucera CLA 2007-05-16 13:05:46 EDT
Something I would really like to do is completely decouple the preprocessor from LPG and the C99 parser (right now its dependent on the token types generated by LPG). That way it could be reused on any token stream.
Comment 6 Doug Schaefer CLA 2007-05-16 13:28:26 EDT
(In reply to comment #5)
> Something I would really like to do is completely decouple the preprocessor
> from LPG and the C99 parser (right now its dependent on the token types
> generated by LPG). That way it could be reused on any token stream.

Definitely. I'd like to be able to use it with ANTLR generated parsers too.

BTW, ANTLR v3 release party is next Tuesday. I got an invite. Too bad I'm not in San Fran :)
Comment 7 Mike Kucera CLA 2007-05-16 13:38:53 EDT
(In reply to comment #6)

> Definitely. I'd like to be able to use it with ANTLR generated parsers too.

I've opened bug #187328 for this.

Maybe the Safari and Photran people would find this useful as well.
Comment 8 Michael Richmond CLA 2007-05-17 18:46:24 EDT
(In reply to comment #1)
> Setting Milestone to Future ... if there is enough interest (i.e. votes)

Another vote for interest in extending CDT to support Objective-C.

I'm also willing to contribute to the effort. I assume the right place to start would be to extend the CDT parser to support objective-c constructs.
Comment 9 Jim CLA 2007-07-20 06:19:05 EDT
Kind of new to both Eclipse and Objective C, but if there is anything I can do to help out building Objective C into Eclipse, please let me know.
Comment 10 Doug Schaefer CLA 2007-08-21 10:56:38 EDT
Future means you commit to fix it in the Future. Inboxes can't make committments. Moving to '--'.
Comment 11 Eric Hildum CLA 2008-06-06 15:04:50 EDT
How many votes are needed to get this active?
Comment 12 Chris Recoskie CLA 2008-06-06 15:09:41 EDT
(In reply to comment #11)
> How many votes are needed to get this active?

Votes are just meant to gauge community interest.  None of the committers are currently able/willing to work on it as it doesn't intersect with their business interests.  Hence the "helpwanted" tag.  Someone from the community will have to step up and contribute.
Comment 13 Doug Schaefer CLA 2008-06-06 15:23:40 EDT
(In reply to comment #11)
> How many votes are needed to get this active?
> 

In reality, it only takes one vote, someone who is willing to actually contribute the code. All those who vote and don't contribute, I'm not sure how they're expecting it to get done. If you want to vote, vote with your time or $$$'s.
Comment 14 Leonardo CLA 2008-07-18 14:25:11 EDT
Anyone willing to work on this? I could offer some help (thou'm only beginning at Obj-C), but I can't do all by myself.
Comment 15 Michel Rondeau CLA 2008-09-30 12:44:58 EDT
Did someone made some preliminary work on this? What is the status of the work made by  Mike Kucera and Doug Schaefer in 2007? I saw that Jim has offered help. I may also do some work as well as I am pretty confortable in both Java and Objective C. We might just need a project leader to distribute workload and fix milestones. We might also need help for architecture and analysis. Is there someone that could federate people to get this done?
Comment 16 Matisse Enzer CLA 2008-09-30 13:47:32 EDT
What would be a reasonable small first step in making some progress?
Comment 17 Leonardo CLA 2008-09-30 13:55:03 EDT
(In reply to comment #16)
> What would be a reasonable small first step in making some progress?
> 

Since I had no replies, I started working something on my own. I wrote a very simple sintax highlight for the language but it does not use CDT in any way. That's, at least, a start. If it's a good start, I could post it later.
Comment 18 Doug Schaefer CLA 2008-10-01 10:52:20 EDT
I'd suggest a quick not to the cdt-dev list letting people know what your are doing and ask any questions you may have.

There has been zero work done on Objective-C support so this is all new.

There are ways to add languages to the CDT and Mike K is the expert. But he's not copied on this bug.
Comment 19 Matisse Enzer CLA 2008-10-01 12:06:44 EDT
I am curious about how much people are using ObjC outside of Apple's Cocoa framework - presumably any first attempts in Eclipse will focus on Objective-C itself, and not deal with Cocoa until later (if at all.)
Comment 20 Matthew Jimenez CLA 2008-10-01 12:24:36 EDT
(In reply to comment #19)
> I am curious about how much people are using ObjC outside of Apple's Cocoa
> framework - presumably any first attempts in Eclipse will focus on Objective-C
> itself, and not deal with Cocoa until later (if at all.)
> 

I've used Eclipse for Objective-C development under window with GNUStep (company's code base was formerly using OpenStep)
Eclipse already works well for most parts on this, except I have to use the GDB command input window quite a bit for 'print-object'
Comment 21 Roel van der Kraan CLA 2008-11-06 10:10:24 EST
(In reply to comment #19)
> I am curious about how much people are using ObjC outside of Apple's Cocoa
> framework - presumably any first attempts in Eclipse will focus on Objective-C
> itself, and not deal with Cocoa until later (if at all.)

We use ObjC quite a lot here, and we could use a good IDE that supports ObjC. Right now everyone uses their own text editor for code editing, Visual Studio for debugging and some other tools for searching the code. It's a mess.

I'm experienced in both Java and Objective C so I might be of assistance to this feature request, however: I only have limited time available. 
Comment 22 Alex Blewitt CLA 2009-01-24 17:39:59 EST
Is anyone interested in discussing this at EclipseCon in March? There's quite a lot in implementing a new language parser/indexer/complete etc. and I'd have zero time between now and then, but if we can get some conversations going and a bit of hackery in place, it would be good to see if we can add dribs and drabs in an incubator environment.
Comment 23 Alex Blewitt CLA 2009-02-14 15:06:46 EST
I've created http://code.google.com/p/objectiveclipse/ to start working on this; if anyone's interested in joining in, drop me a line.
Comment 24 Ashwani Kumar CLA 2009-04-17 16:35:31 EDT
I am interested in contributing to it . As I am new to Eclipse community. I may need some help to get it started .

Thanks
Ashwani Kumar
Comment 25 Alex Blewitt CLA 2009-04-17 17:25:31 EDT
Probably best take this off-line; but there's a getting started page (http://code.google.com/p/objectiveclipse/wiki/GettingStarted) where you can download and compile what's in SVN so far, and a minimal list of issues (http://code.google.com/p/objectiveclipse/issues/list) that need to be addressed. Even thinking up new use cases for what the plugin should do would be helpful :-)

The project page also lists the mailing lists for the project; I'd suggest you follow up questions to the objcetiveclipse-dev group (http://groups.google.com/group/objectiveclipse-dev)
Comment 26 Alex Blewitt CLA 2010-06-02 18:53:08 EDT
(In reply to comment #25)
> Probably best take this off-line; but there's a getting started page
> (http://code.google.com/p/objectiveclipse/wiki/GettingStarted) ...

The ObjectivEClipse project has been closed, through lack of interest and unable to refactor itself to work on top of CDT 7.0, due out later this month.

The only real way to integrate a new language at the parser level, based upon the CDT C parser, is to do it at the CDT level. For example, the C refactoring for 7.0 was done with the knowledge and support of the C++ plugin at the same time. Objective-C support would have to be refactored at the same time in order to not break.
Comment 27 Doug Schaefer CLA 2010-06-02 19:06:05 EDT
(In reply to comment #26)
> (In reply to comment #25)
> > Probably best take this off-line; but there's a getting started page
> > (http://code.google.com/p/objectiveclipse/wiki/GettingStarted) ...
> 
> The ObjectivEClipse project has been closed, through lack of interest and
> unable to refactor itself to work on top of CDT 7.0, due out later this month.
> 
> The only real way to integrate a new language at the parser level, based upon
> the CDT C parser, is to do it at the CDT level. For example, the C refactoring
> for 7.0 was done with the knowledge and support of the C++ plugin at the same
> time. Objective-C support would have to be refactored at the same time in order
> to not break.

Thanks Alex. I'd like to use Objective-C as an example of how to add a language to CDT. My hope is that we can restructure the APIs for CDT 8.0 to make this easier.
Comment 28 Alex Blewitt CLA 2010-06-02 19:14:48 EDT
(In reply to comment #27)
> Thanks Alex. I'd like to use Objective-C as an example of how to add a language
> to CDT. My hope is that we can restructure the APIs for CDT 8.0 to make this
> easier.

I think you'd be better off using a non-C language as an example, like C#, to demonstrate it. That would be easier to include, because then you'd be writing the parser from scratch in the first place. However, the key problem is hooking in to the parser's expression and declaration points, and the fact that the parser is all internal and friendly with the Ui:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/?root=Tools_Project

 org.eclipse.cdt.internal.core.dom;x-friends:="org.eclipse.cdt.ui",
 org.eclipse.cdt.internal.core.dom.parser;x-friends:="org.eclipse.cdt.ui",
 org.eclipse.cdt.internal.core.dom.parser.c;x-friends:="org.eclipse.cdt.ui",
 org.eclipse.cdt.internal.core.dom.parser.cpp;x-friends:="org.eclipse.cdt.ui",
 org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;x-friends:="org.eclipse.cdt.ui",

The only way that Objective-C will realistically fit in is as a peer to cpp with the same friends restrictions (and that refactorings to the base are done in a context where the dependent languages are open as well). Doing it as an external project is ultimately futile, even if CDT moves to Git in the next release.

Note that there are also other C level language features, like blocks, which are available outside of Objective-C and OSX and which really should be integrated at the C level, with some kind of option to enable/disable the use of blocks as appropriate.
Comment 29 Doug Schaefer CLA 2010-06-02 19:20:26 EDT
(In reply to comment #28)
> I think you'd be better off using a non-C language as an example, like C#, to
> demonstrate it. That would be easier to include, because then you'd be writing
> the parser from scratch in the first place.

Ah, but I would be. I have a start of a parser written in ANTLR, starting with C and hope to add Objective- to it. My first look again at IASTTranslationUnit made me realize that there are a lot of assumptions built into the DOM, like the parser technology being used, that need to be broken.
Comment 30 Doug Schaefer CLA 2010-06-02 19:22:48 EDT
BTW, I also looked at Xtext. Unfortunately they don't support semantic predicates which are necessary to parse C-like languages. There was word they would for Helios but I haven't seen confirmation of that.
Comment 31 Alex Blewitt CLA 2010-06-02 20:04:47 EDT
(In reply to comment #29)
> Ah, but I would be. I have a start of a parser written in ANTLR, starting with
> C and hope to add Objective- to it. My first look again at IASTTranslationUnit
> made me realize that there are a lot of assumptions built into the DOM, like
> the parser technology being used, that need to be broken.

There are some other self-limiting things which make it more difficult than it needs to be:

* Duplication of Ixx types across the C and CPP variants:

org/eclipse/cdt/core/dom/ast/IASTIfStatement.class
org/eclipse/cdt/core/dom/ast/IASTPreprocessorIfStatement.class
org/eclipse/cdt/core/dom/ast/cpp/ICPPASTIfStatement.class
org/eclipse/cdt/internal/core/dom/parser/c/CASTIfStatement.class
org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.class

* There being no different 'base' CDT feature; all CDT-derived projects have a 'cnature' but it's considered C if it doesn't have a 'cppnature' and C++ if it does have a 'cppnature'. It would probably make sense if there were a base cdt feature, and then vanilla c could sit on top of that (and cpp sit on top of the base feature). We could then get rid of the ParserLanguage hack:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserLanguage.java?revision=1.5&root=Tools_Project&view=markup

* Storage of the PDOM being done on hard-coded enums which are only available in the CDT is pretty self-limiting (though I don't know if this is used any more? org/eclipse/cdt/internal/core/pdom/IPDOM)

* Linkage defining a 'type' is hard-coded, instead of being picked up by an extension:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/Linkage.java?revision=1.7&root=Tools_Project&view=markup

Objective-C also has some other features (like the -frameworks extension on Apple's GCC) which affects the way that imports are parsed. I think that's tracked on a different bug.
Comment 32 Doug Schaefer CLA 2010-06-02 20:39:06 EDT
I'd like to define a minimal IAST and IBinding hierarchy that enables the indexer and source navigation features to work. Since the C and C++ DOMs have different implementations, I'm not sure why we have such a huge overlap. e.g. Why is there an IASTIfStatement? (BTW, preprocessor if is for #if, it's very different).

BTW, I've started a project at Eclipse Labs to hold this work:

http://code.google.com/a/eclipselabs.org/p/cdtantlr
Comment 33 Michael Richmond CLA 2010-06-17 20:44:54 EDT
The other alternative is to use an existing external parser such as the Objective C parser that is available in libllvm. Given that Apple will soon move to using LLVM exclusively on the OS X platform there is probably a lot of reuse that can be gained from libllvm.
Comment 34 Marc-André Laperle CLA 2020-10-25 02:13:55 EDT
I doubt this will happen in the shape of CDT parser support given the amount of work needed and the diminishing amount of expertise that would be required to review proposed changes. Otherwise, an alternative would be to use Clangd which I believe has support for Objective-C. CDT already has a feature to integrate Clangd. A more specific bug could be created if there is anything missing in the Clangd integration.