1010using HaXeContext ;
1111using PluginCore ;
1212using PluginCore . Helpers ;
13- using ScintillaNet ;
1413
1514namespace PostfixCodeCompletion . Helpers
1615{
@@ -19,15 +18,15 @@ static class TemplateUtils
1918 public const string PATTERN_BLOCK = @"\$\([^\)]*{0}.*?\)" ;
2019 public const string PATTERN_T_BLOCK = @"[^\$]*?\$\({0}\)" ;
2120 internal const string POSTFIX_GENERATORS = "PostfixGenerators" ;
22- internal const string PATTERN_MEMBER = "Member " ;
23- internal const string PATTERN_NULLABLE = "Nullable " ;
24- internal const string PATTERN_COLLECTION = "Collection " ;
21+ internal const string PATTERN_MEMBER = "PCCMember " ;
22+ internal const string PATTERN_NULLABLE = "PCCNullable " ;
23+ internal const string PATTERN_COLLECTION = "PCCCollection " ;
2524 internal const string PATTERN_COLLECTION_KEY_TYPE = "$(CollectionKeyType)" ;
2625 internal const string PATTERN_COLLECTION_ITEM_TYPE = "$(CollectionItemType)" ;
27- internal const string PATTERN_HASH = "Hash " ;
28- internal const string PATTERN_BOOL = "Boolean " ;
29- internal const string PATTERN_NUMBER = "Number " ;
30- internal const string PATTERN_STRING = "String " ;
26+ internal const string PATTERN_HASH = "PCCHash " ;
27+ internal const string PATTERN_BOOL = "PCCBoolean " ;
28+ internal const string PATTERN_NUMBER = "PCCNumber " ;
29+ internal const string PATTERN_STRING = "PCCString " ;
3130 internal const string PATTERN_TYPE = "PCCType" ;
3231 public static Settings Settings { get ; set ; }
3332
@@ -115,7 +114,11 @@ internal static KeyValuePair<string, string> GetVarNameToQualifiedName(ASResult
115114 {
116115 string type = null ;
117116 var varname = string . Empty ;
118- var word = string . Empty ;
117+ var sci = PluginBase . MainForm . CurrentDocument . SciControl ;
118+ var lineNum = sci . CurrentLine ;
119+ var line = sci . GetLine ( lineNum ) ;
120+ var returnType = Reflector . ASGenerator . GetStatementReturnType ( sci , line , sci . PositionFromLine ( lineNum ) ) ;
121+ var word = returnType ? . Word ;
119122 var member = expr . Member ;
120123 if ( member != null && member . Type != null ) type = member . Type ;
121124 else
@@ -128,7 +131,7 @@ internal static KeyValuePair<string, string> GetVarNameToQualifiedName(ASResult
128131 if ( ! string . IsNullOrEmpty ( word ) && ( string . IsNullOrEmpty ( type ) || Regex . IsMatch ( type , "(<[^]]+>)" ) ) ) word = null ;
129132 if ( ! string . IsNullOrEmpty ( type ) && type == ASContext . Context . Features . voidKey ) type = null ;
130133 if ( string . IsNullOrEmpty ( varname ) ) varname = Reflector . ASGenerator . GuessVarName ( word , type ) ;
131- if ( ! string . IsNullOrEmpty ( varname ) && varname == word && varname . Length == 1 ) varname = varname + " 1";
134+ if ( ! string . IsNullOrEmpty ( varname ) && varname == word ) varname = $ " { varname } 1";
132135 return new KeyValuePair < string , string > ( varname , type ) ;
133136 }
134137
@@ -147,7 +150,7 @@ internal static string ProcessMemberTemplate(string template, ASResult expr)
147150 internal static string ProcessCollectionTemplate ( string template , ASResult expr )
148151 {
149152 var type = expr . Member != null ? expr . Member . Type : expr . Type . QualifiedName ;
150- if ( type . Contains ( "@" ) ) type = type . Replace ( "@" , ".<" ) + " >";
153+ if ( type . Contains ( "@" ) ) type = $ " { type . Replace ( "@" , ".<" ) } >";
151154 type = Regex . Match ( type , "<([^]]+)>" ) . Groups [ 1 ] . Value ;
152155 type = Reflector . ASGenerator . GetShortType ( type ) ;
153156 switch ( PluginBase . MainForm . CurrentDocument . SciControl . ConfigurationLanguage )
0 commit comments