Autocompletion placeholders for assignment, particularly of block literals

Originator:rix.rob
Number:rdar://14855686 Date Originated:28-Aug-2013 09:10 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 5
Classification:Enhancement Reproducible:Not Applicable
 
Summary:
Adding autocompletion placeholders for assignment of variables and properties a la the ones provided for parameters would be a huge improvement to the convenient assignment of block literals.

For example, NSOperation’s completionBlock is a straightforward void(^)(void) block type. I would like to have Xcode insert a placeholder for that type when I’m assigning to that property such that, on hitting return, it would expand into a block literal of that type (with the same behaviour that it has for block parameters).

Given a scope with NSOperation *operation defined for it, I would like typing this:

operation.completionBlock =

…to result in Xcode offering me a placeholder for the assigned type, in the manner of other autocompletion-provided placeholders. I could ignore it by simply continuing to type, but hitting return would accept the placeholder, and select it (as it does with the first placeholder in autocompleted messages). Hitting return again, while the placeholder is selected, would replace the placeholder with a block literal of that type. (For non-block types, the placeholder would presumably be replaced with its contents, as with other placeholders, including autocompletion-provided ones and snippet-provided ones.)

(I’m not so stuck on the details of this interaction, but it would seem to be consistent with the autocompletion of method invocations, function calls, and their parameters, which is appealing.)


Illustrating this further (using | to indicate the caret, and |…| to indicate selection):

1.`operation.completionBlock = |` — User has typed the beginning of an assignment expression, and Xcode offers autocompletion of the type of the property or variable being assigned to.

2. `operation.completionBlock = |<#^(void)block#>|` — User has accepted the suggested autocompletion, inserting the placeholder. Xcode has selected the inserted placeholder.

3. `operation.completionBlock = ^{
    |<#code#>|
}` — User has pressed return to expand the placeholder into a block literal. Xcode has inserted the literal, including inserting and selecting the placeholder for the body of the block literal. (This is how Xcode behaves when inserting a block literal as the parameter of e.g. `[operation setCompletionBlock:|<#^(void)block#>]`.)

4. `operation.completionBlock = ^{
    NSLog(@"Thanks, Xcode!");
}` — User writes their code, and rejoices.


I would like the same functionality to apply to any assignment using the = operator, including variables and properties of any scope, type, storage, etc.


Steps to Reproduce:
N/A

Expected Results:
N/A

Actual Results:
N/A

Regression:
N/A

Notes:
Thank you! You are wonderful people.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!