@@ -173,21 +173,19 @@ static void UpdateCompletionList(ASResult expr)
173173
174174 static void UpdateCompletionList ( MemberModel target , ASResult expr )
175175 {
176- if ( target == null ) return ;
177- if ( ! TemplateUtils . GetHasTemplates ( ) ) return ;
176+ if ( target == null || ! TemplateUtils . GetHasTemplates ( ) ) return ;
178177 var items = GetPostfixCompletionItems ( target , expr ) ;
179178 var allItems = Reflector . CompletionList . allItems ;
180179 if ( allItems != null )
181180 {
182181 var labels = new HashSet < string > ( ) ;
183- foreach ( var item in allItems . OfType < PostfixCompletionItem > ( ) )
182+ foreach ( var item in allItems )
184183 {
185- labels . Add ( item . Label ) ;
184+ if ( item is PostfixCompletionItem ) labels . Add ( item . Label ) ;
186185 }
187186 foreach ( var item in items )
188187 {
189- var label = item . Label ;
190- if ( ! labels . Contains ( label ) ) allItems . Add ( item ) ;
188+ if ( ! labels . Contains ( item . Label ) ) allItems . Add ( item ) ;
191189 }
192190 items = allItems ;
193191 }
@@ -243,8 +241,7 @@ static MemberModel GetPostfixCompletionTarget(ASResult expr)
243241 if ( expr == null || expr . IsNull ( ) ) return null ;
244242 var member = expr . Member ;
245243 var voidKey = ASContext . Context . Features . voidKey ;
246- if ( member != null && ! string . IsNullOrEmpty ( member . Type ) && member . Type != voidKey )
247- return member ;
244+ if ( ! string . IsNullOrEmpty ( member ? . Type ) && member . Type != voidKey ) return member ;
248245 var type = expr . Type ;
249246 if ( type != null && ! type . IsVoid ( ) && ! string . IsNullOrEmpty ( type . Type ) && type . Type != voidKey )
250247 return type ;
@@ -262,10 +259,7 @@ static List<ICompletionListItem> GetPostfixCompletionItems(MemberModel target, A
262259 if ( IsHash ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_HASH , expr ) ) ;
263260 if ( PluginBase . MainForm . CurrentDocument . SciControl . ConfigurationLanguage . ToLower ( ) == "haxe" )
264261 {
265- var type = expr . Type != null && ! string . IsNullOrEmpty ( expr . Type . Type ) &&
266- expr . Type . Type != ASContext . Context . Features . voidKey
267- ? expr . Type
268- : null ;
262+ var type = ! string . IsNullOrEmpty ( expr . Type ? . Type ) && expr . Type . Type != ASContext . Context . Features . voidKey ? expr . Type : null ;
269263 if ( type != null )
270264 {
271265 if ( IsCollection ( type ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_COLLECTION , expr ) ) ;
@@ -308,13 +302,18 @@ static bool IsHash(MemberModel target)
308302 var type = target . Type ;
309303 return type == ASContext . Context . Features . objectKey || type == "Dictionary" ;
310304 case "haxe" :
311- if ( IsIteratorOrIterable ( target ) ) return true ;
305+ Func < MemberModel , bool > isIterator = member =>
306+ {
307+ var cleanType = Reflector . ASGenerator . CleanType ( member . Type ) ;
308+ return cleanType == "Iterator" || cleanType == "Iterable" ;
309+ } ;
310+ if ( isIterator ( target ) ) return true ;
312311 if ( target is ClassModel )
313312 {
314313 var classModel = target as ClassModel ;
315314 while ( classModel != null && ! classModel . IsVoid ( ) )
316315 {
317- if ( classModel . Members . Items . Any ( IsIteratorOrIterable ) )
316+ if ( classModel . Members . Items . Any ( isIterator ) )
318317 return true ;
319318 classModel . ResolveExtends ( ) ;
320319 classModel = classModel . Extends ;
@@ -325,12 +324,6 @@ static bool IsHash(MemberModel target)
325324 }
326325 }
327326
328- static bool IsIteratorOrIterable ( MemberModel member )
329- {
330- var cleanType = Reflector . ASGenerator . CleanType ( member . Type ) ;
331- return cleanType == "Iterator" || cleanType == "Iterable" ;
332- }
333-
334327 static bool IsBoolean ( MemberModel target ) => target . Type == ASContext . Context . Features . booleanKey ;
335328
336329 static bool IsNumber ( MemberModel target )
@@ -368,10 +361,7 @@ static IEnumerable<ICompletionListItem> GetCompletionItems(string pattern, Membe
368361 return GetCompletionItems ( templates ?? new Dictionary < string , string > ( ) , pattern , expr ) ;
369362 }
370363
371- static IEnumerable < ICompletionListItem > GetCompletionItems ( string pattern , ASResult expr )
372- {
373- return GetCompletionItems ( TemplateUtils . GetTemplates ( pattern ) , pattern , expr ) ;
374- }
364+ static IEnumerable < ICompletionListItem > GetCompletionItems ( string pattern , ASResult expr ) => GetCompletionItems ( TemplateUtils . GetTemplates ( pattern ) , pattern , expr ) ;
375365
376366 static IEnumerable < ICompletionListItem > GetCompletionItems ( Dictionary < string , string > templates , string pattern , ASResult expr )
377367 {
@@ -400,10 +390,7 @@ static IEnumerable<ICompletionListItem> GetCompletionItems(Dictionary<string, st
400390 template = TemplateUtils . ProcessHashTemplate ( template , expr ) ;
401391 break ;
402392 }
403- var item = new PostfixCompletionItem ( fileName , template , expr )
404- {
405- Pattern = pattern
406- } ;
393+ var item = new PostfixCompletionItem ( fileName , template , expr ) { Pattern = pattern } ;
407394 if ( isHaxe && fileName == "code" && itemIcon != null )
408395 {
409396 item . Icon = itemIcon ;
0 commit comments