CompletionPrefix in TextMacros don't work if OnlyAtBOL not set to YES

Number:rdar://7221040 Date Originated:14-Sep-2009 06:32 PM
Status:Duplicate/7219873 Resolved:
Product:Developer Tools Product Version:3.2
Classification:UI/Usability Reproducible:Always

When editing some source code in the Xcode IDE, using completion to insert a TextMacro (like typing "ma" to insert the "NSMutableArray * array;" as defined by the embed TextMacro objc.mutablearray) won't work if the "OnlyAtBOL" key is not set (or set to NO) for this TextMacro definition (in the xctxtmacro file)

As a consequence, only TextMacros that are defined with OnlyAtBOL=YES are working with "typing completion" (the other TextMacros can still be inserted using the "Insert Text Macro" menu item, anyway).

[Steps to Reproduce]

 - Open any ".m" file in Xcode IDE, and type some text defined as a CompletionPrefix for any TextMacro (and in the correct context)
 - For example, place the cursor inside a method definition, on the line after the open bracket "{", and type "ma". The "NSMutableArray * array;" TextMacro should be proposed but is not.
 - Or use the attached custom TextMacro file and test by typing the "bug" CompletionPrefix in any code file (see comments below and in the file)

[Expected Results]
 - The TextMacro should be proposed in the autocompletion/CodeSense menu that apears when you begin typing the CompletionPrefix of the TextMacro

[Actual Results]
 - The TextMacro is not proposed in the codesense menu

 - Was working in Xcode 3.1 and OSX 10.5.8
 - Not working any more here in Xcode 3.2 on OSX 10.6.1

A sample xctxtmacro has been attached to test this behavior.
 - Place it in "~/Library/Application Support/Developer/Shared/Xcode/Specifications"
 - relaunch Xcode, then test the TextMacro : type "bug" anywhere in a source code file and the TextMacro should appear in the completion menu.
 - comment or remove the "OnlyAtBOL=YES;" line in the xctxtmacro file and quit and relaunch Xcode again
 - The TextMacro is not proposed in the completion menu anymore


Even if you set "OnlyAtBOL" to YES in the parent entry (i.e. in the entry identified by the "BasedOn" key), it is not taken into account (inheritence of this key is probably not implemented?).

For example with the following xctxtmacro file, typing the "UIPickerViewDataSource" completion prefix still won't make it appear in the autocompletion menu, even if the TextMacro entry is 'BasedOn' the "objc.protocols3_1" entry (defined above it), which in turn defines OnlyAtBOL=YES and so should make the child entry inherit from this value (but is not).

( // Protocol implementations for Objective-C & Objective-C++ // File generated by & extract_protocols.sed (v1.5 by O.Halligon, Sept 2009) { Identifier = objc.protocols3_1; Name = "iPhone OS 3.1 Protocols implementation"; IsMenu = YES; ComputerLanguages = ( "c.objc", "c.objcpp" ); IncludeContexts = ( "xcode.lang.objc.implementation" ); ExcludeContexts = ( "xcode.lang.objc.block", "xcode.lang.string", "xcode.lang.character", "xcode.lang.comment", "xcode.lang.c.preprocessor" ); OnlyAtBOL = YES; },

// Protocol UIPickerViewDataSource
    Identifier = objc.protocols3_1.UIPickerViewDataSource;
    BasedOn = objc.protocols3_1;
    IsMenuItem = YES;
    Name = "UIPickerViewDataSource implementation (SDK 3.1)";
    CompletionPrefix = "UIPickerViewDataSource";
    OnlyAtBOL = YES;
    TextString = "

// // MARK: UIPickerViewDataSource implementation //

  • (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { // required method <#statements#> }
  • (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { // required method <#statements#> } "; },


By olivier.halligon at Sept. 17, 2009, 8:34 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!