code-intel-extensions icon indicating copy to clipboard operation
code-intel-extensions copied to clipboard

Add Objective-C

Open chrismwendt opened this issue 6 years ago • 5 comments

This is a draft because the ctags for Objective-C are pretty wonky. They contain a lot of colons and parent scopes:

image

https://sourcegraph.com/github.com/react-native-community/react-native-webview/-/blob/ios/RNCWKWebView.m#L242

I don't intend to merge this in until that's been cleaned up or I figure out how to deal with it in basic-code-intel.

chrismwendt avatar Apr 18 '19 20:04 chrismwendt

@chrismwendt Those are not wonky, those are how people expect it. For exampe, here is Xcode:

image

It sounds like you think that the middle results in that screenshot should just read [NSString stringWithContentsOfFile:] and not distinguish between the two variants (encoding:error: and usedEncoding:error:). That is incorrect. Users do want to distinguish between them.

In fact, the symbol rows should also contain the type name (the NSString in the screenshot).

@nicksnyder Can you confirm (as another formerly-Objective-C-dev)?

sqs avatar Apr 18 '19 22:04 sqs

@sqs Is correct on both counts. The symbol names should include variable labels and the type of the message receiver (e.g. [NSString stringWithContentsOfFile:encoding:error:])

nicksnyder avatar Apr 18 '19 23:04 nicksnyder

Ah, I didn't know what Objective-C message definitions and calls looked like until I read https://blog.teamtreehouse.com/the-beginners-guide-to-objective-c-methods Here's an example:

// Defines a function `addX:toY:` that takes 2 int arguments and returns an int
- (int)addX:(int)x toY:(int)y {
    int sum = x + y;
    return sum;
}

// Calls the `addX:toY:` function
int newScore = [score addX:24 toY:points];

I see that basic-code-intel will need to find and combine the addX: and toY: pieces to form the full name addX:toY: in order to do a symbol search.

The type of the message receiver currently appears after the symbol name (see screenshot). The way this gets rendered could be made language-specific (e.g. by calling out to an extension API).

image

chrismwendt avatar Apr 19 '19 00:04 chrismwendt

Can we close this with the work @creachadair has done?

efritz avatar Jan 31 '20 21:01 efritz

I believe this is still relevant:

basic-code-intel will need to find and combine the addX: and toY: pieces to form the full name addX:toY: in order to do a symbol search

chrismwendt avatar Jan 31 '20 21:01 chrismwendt