[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

Chris Lattner clattner at apple.com
Mon Dec 7 08:35:59 PST 2009


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.

Also, does Result or MaybeAddResult take ownership of the Pattern string? This isn't obvious from the API.

-Chris





More information about the cfe-commits mailing list