[cfe-commits] r90757 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaCodeComplete.cpp test/Index/complete-at-exprstmt.m
Douglas Gregor
dgregor at apple.com
Mon Dec 7 18:30:58 PST 2009
On Dec 7, 2009, at 8:35 AM, Chris Lattner wrote:
> On Dec 7, 2009, at 1:51 AM, Douglas Gregor wrote:
>> URL: http://llvm.org/viewvc/llvm-project?rev=90757&view=rev
>> Log:
>> Code completion for Objective-C @ keywords that are statements or expressions
>
> Spiffy.
>
>> +static void AddObjCExpressionResults(unsigned Rank, ResultBuilder &Results) {
>> + typedef CodeCompleteConsumer::Result Result;
>> + CodeCompletionString *Pattern = 0;
>> +
>> + // @encode ( type-name )
>> + Pattern = new CodeCompletionString;
>> + Pattern->AddTypedTextChunk("encode");
>> + Pattern->AddChunk(CodeCompletionString::CK_LeftParen);
>> + Pattern->AddPlaceholderChunk("type-name");
>> + Pattern->AddChunk(CodeCompletionString::CK_RightParen);
>> + Results.MaybeAddResult(Result(Pattern, Rank));
>
> Would it make sense to make a Builder for these? It seems that it would be a lot
> cleaner to be able to do something like:
>
> Results.MaybeAdd(ResultBuilder(Rank).addText("encode")
> .addLeftParen().addPlaceholder("type-name").addRightParen());
>
> or something.
Yes, a builder would be helpful. I think I'd make it a CodeCompletionString builder, because that's really where the action is.
> Also, does Result or MaybeAddResult take ownership of the Pattern string? This isn't obvious from the API.
Yes, it does. It should take an std::auto_ptr or llvm::OwningPtr.
Thanks!
- Doug
More information about the cfe-commits
mailing list