@@ -32,17 +32,17 @@ public class PluginMain : IPlugin
3232
3333 #region Required Properties
3434
35- public int Api { get { return 1 ; } }
35+ public int Api => 1 ;
3636
37- public string Name { get { return "PostfixCodeCompletion" ; } }
37+ public string Name => "PostfixCodeCompletion" ;
3838
39- public string Guid { get { return "21d9ab3e-93e4-4460-9298-c62f87eed7ba" ; } }
39+ public string Guid => "21d9ab3e-93e4-4460-9298-c62f87eed7ba" ;
4040
41- public string Help { get { return "" ; } }
41+ public string Help => string . Empty ;
4242
43- public string Author { get { return "SlavaRa" ; } }
43+ public string Author => "SlavaRa" ;
4444
45- public string Description { get { return "Postfix code completion helps reduce backward caret jumps as you write code" ; } }
45+ public string Description => "Postfix code completion helps reduce backward caret jumps as you write code" ;
4646
4747 public object Settings { get ; private set ; }
4848
@@ -149,13 +149,13 @@ void AddEventHandlers()
149149 /// </summary>
150150 void SaveSettings ( ) => ObjectSerializer . Serialize ( settingFilename , Settings ) ;
151151
152- static void UpdateCompletionList ( )
152+ void UpdateCompletionList ( )
153153 {
154154 var expr = GetPostfixCompletionExpr ( ) ;
155155 UpdateCompletionList ( expr ) ;
156156 }
157157
158- static void UpdateCompletionList ( ASResult expr )
158+ void UpdateCompletionList ( ASResult expr )
159159 {
160160 if ( expr == null || expr . IsNull ( ) ) return ;
161161 var target = GetPostfixCompletionTarget ( expr ) ;
@@ -171,7 +171,7 @@ static void UpdateCompletionList(ASResult expr)
171171 hc . GetPositionType ( OnFunctionTypeResult ) ;
172172 }
173173
174- static void UpdateCompletionList ( MemberModel target , ASResult expr )
174+ void UpdateCompletionList ( MemberModel target , ASResult expr )
175175 {
176176 if ( target == null || ! TemplateUtils . GetHasTemplates ( ) ) return ;
177177 var items = GetPostfixCompletionItems ( target , expr ) ;
@@ -248,32 +248,32 @@ static MemberModel GetPostfixCompletionTarget(ASResult expr)
248248 return null ;
249249 }
250250
251- static List < ICompletionListItem > GetPostfixCompletionItems ( MemberModel target , ASResult expr )
251+ List < ICompletionListItem > GetPostfixCompletionItems ( MemberModel target , ASResult expr )
252252 {
253253 var result = new List < ICompletionListItem > ( ) ;
254254 if ( expr . Member != null ) result . AddRange ( GetCompletionItems ( expr . Member . Type , target , expr ) ) ;
255255 else if ( expr . Type != null ) result . AddRange ( GetCompletionItems ( expr . Type . Type , target , expr ) ) ;
256- result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_MEMBER , expr ) ) ;
257- if ( IsNullable ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_NULLABLE , expr ) ) ;
258- if ( IsCollection ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_COLLECTION , expr ) ) ;
259- if ( IsHash ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_HASH , expr ) ) ;
256+ result . AddRange ( GetCompletionItems ( TemplateUtils . PatternMember , expr ) ) ;
257+ if ( IsNullable ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PatternNullable , expr ) ) ;
258+ if ( IsCollection ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PatternCollection , expr ) ) ;
259+ if ( IsHash ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PatternHash , expr ) ) ;
260260 if ( PluginBase . MainForm . CurrentDocument . SciControl . ConfigurationLanguage . ToLower ( ) == "haxe" )
261261 {
262262 var type = ! string . IsNullOrEmpty ( expr . Type ? . Type ) && expr . Type . Type != ASContext . Context . Features . voidKey ? expr . Type : null ;
263263 if ( type != null )
264264 {
265- if ( IsCollection ( type ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_COLLECTION , expr ) ) ;
266- if ( IsHash ( type ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_HASH , expr ) ) ;
265+ if ( IsCollection ( type ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PatternCollection , expr ) ) ;
266+ if ( IsHash ( type ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PatternHash , expr ) ) ;
267267 }
268268 }
269- if ( IsBoolean ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_BOOL , expr ) ) ;
270- if ( IsNumber ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_NUMBER , expr ) ) ;
271- if ( IsString ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_STRING , expr ) ) ;
272- if ( IsType ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PATTERN_TYPE , expr ) ) ;
269+ if ( IsBoolean ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PatternBool , expr ) ) ;
270+ if ( IsNumber ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PatternNumber , expr ) ) ;
271+ if ( IsString ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PatternString , expr ) ) ;
272+ if ( IsType ( target ) ) result . AddRange ( GetCompletionItems ( TemplateUtils . PatternType , expr ) ) ;
273273 return result . Distinct ( ) . ToList ( ) ;
274274 }
275275
276- static bool IsNullable ( MemberModel target ) => ! IsNumber ( target ) && target . Type != ASContext . Context . Features . booleanKey ;
276+ bool IsNullable ( MemberModel target ) => ! IsNumber ( target ) && target . Type != ASContext . Context . Features . booleanKey ;
277277
278278 static bool IsCollection ( MemberModel target )
279279 {
@@ -326,20 +326,13 @@ static bool IsHash(MemberModel target)
326326
327327 static bool IsBoolean ( MemberModel target ) => target . Type == ASContext . Context . Features . booleanKey ;
328328
329- static bool IsNumber ( MemberModel target )
329+ bool IsNumber ( MemberModel target )
330330 {
331331 var type = target is ClassModel ? ( ( ClassModel ) target ) . QualifiedName : target . Type ;
332332 if ( type == ASContext . Context . Features . numberKey ) return true ;
333- switch ( PluginBase . MainForm . CurrentDocument . SciControl . ConfigurationLanguage )
334- {
335- case "as2" :
336- case "as3" :
337- return type == "int" || type == "uint" ;
338- case "haxe" :
339- return type == "Int" || type == "UInt" ;
340- default :
341- return false ;
342- }
333+ var language = PluginBase . MainForm . CurrentDocument . SciControl . ConfigurationLanguage . ToLower ( ) ;
334+ var features = ( ( Settings ) Settings ) . LanguageFeatures . First ( it => it . Language == language ) ;
335+ return features != null && features . Numeric . Contains ( type ) ;
343336 }
344337
345338 static bool IsString ( MemberModel target ) => target . Type == ASContext . Context . Features . stringKey ;
@@ -383,10 +376,10 @@ static IEnumerable<ICompletionListItem> GetCompletionItems(Dictionary<string, st
383376 var template = pathToTemplate . Value ;
384377 switch ( pattern )
385378 {
386- case TemplateUtils . PATTERN_COLLECTION :
379+ case TemplateUtils . PatternCollection :
387380 template = TemplateUtils . ProcessCollectionTemplate ( template , expr ) ;
388381 break ;
389- case TemplateUtils . PATTERN_HASH :
382+ case TemplateUtils . PatternHash :
390383 template = TemplateUtils . ProcessHashTemplate ( template , expr ) ;
391384 break ;
392385 }
@@ -426,7 +419,7 @@ static Process CreateHaxeProcess(string args)
426419
427420 #region Event Handlers
428421
429- static void OnCharAdded ( ScintillaControl sender , int value )
422+ void OnCharAdded ( ScintillaControl sender , int value )
430423 {
431424 try
432425 {
@@ -451,14 +444,14 @@ static void OnCharAdded(ScintillaControl sender, int value)
451444 }
452445 }
453446
454- static void OnCompletionListVisibleChanged ( object o , EventArgs args )
447+ void OnCompletionListVisibleChanged ( object o , EventArgs args )
455448 {
456449 var list = Reflector . CompletionList . CompletionList ;
457450 if ( list . Visible ) UpdateCompletionList ( ) ;
458451 else list . SelectedValueChanged -= OnCompletionListSelectedValueChanged ;
459452 }
460453
461- static void OnCompletionListSelectedValueChanged ( object sender , EventArgs args )
454+ void OnCompletionListSelectedValueChanged ( object sender , EventArgs args )
462455 {
463456 var list = Reflector . CompletionList . CompletionList ;
464457 list . SelectedValueChanged -= OnCompletionListSelectedValueChanged ;
@@ -517,7 +510,7 @@ static void OnHaxeContextFallbackNeeded(bool notSupported)
517510 completionModeHandler = new CompilerCompletionHandler ( CreateHaxeProcess ( string . Empty ) ) ;
518511 }
519512
520- static void OnFunctionTypeResult ( HaxeComplete hc , HaxeCompleteResult result , HaxeCompleteStatus status )
513+ void OnFunctionTypeResult ( HaxeComplete hc , HaxeCompleteResult result , HaxeCompleteStatus status )
521514 {
522515 switch ( status )
523516 {
@@ -549,7 +542,7 @@ static void OnFunctionTypeResult(HaxeComplete hc, HaxeCompleteResult result, Hax
549542 #endregion
550543 }
551544
552- class PostfixCompletionItem : ICompletionListItem
545+ internal class PostfixCompletionItem : ICompletionListItem
553546 {
554547 readonly string template ;
555548 readonly ASResult expr ;
@@ -561,12 +554,12 @@ public PostfixCompletionItem(string label, string template, ASResult expr)
561554 this . expr = expr ;
562555 }
563556
564- public string Label { get ; set ; }
557+ public string Label { get ; }
565558
566559 string pattern ;
567560 public virtual string Pattern
568561 {
569- get { return pattern ?? TemplateUtils . PATTERN_MEMBER ; }
562+ get { return pattern ?? TemplateUtils . PatternMember ; }
570563 set { pattern = value ; }
571564 }
572565
@@ -587,15 +580,9 @@ public Bitmap Icon
587580 }
588581
589582 string description ;
590- public string Description
591- {
592- get
593- {
594- return description ?? ( description = TemplateUtils . GetDescription ( expr , template , Pattern ) ) ;
595- }
596- }
583+ public string Description => description ?? ( description = TemplateUtils . GetDescription ( expr , template , Pattern ) ) ;
597584
598- public new string ToString ( ) { return Description ; }
585+ public new string ToString ( ) => Description ;
599586
600587 /// <summary>
601588 /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
@@ -618,9 +605,6 @@ public override bool Equals(object obj)
618605 /// A hash code for the current <see cref="T:System.Object"/>.
619606 /// </returns>
620607 /// <filterpriority>2</filterpriority>
621- public override int GetHashCode ( )
622- {
623- return Label . GetHashCode ( ) ^ expr . GetHashCode ( ) ;
624- }
608+ public override int GetHashCode ( ) => Label . GetHashCode ( ) ^ expr . GetHashCode ( ) ;
625609 }
626610}
0 commit comments