@@ -72,18 +72,18 @@ static string GetTemplatesDir(string snippetPath, string language)
7272
7373 internal static Dictionary < string , string > GetTemplates ( string type )
7474 {
75- string pattern = Templates . Contains ( type ) ? string . Format ( PATTERN_BLOCK , type ) : string . Format ( PATTERN_T_BLOCK , type ) ;
76- Dictionary < string , string > result = new Dictionary < string , string > ( ) ;
77- List < string > paths = Settings . CustomSnippetDirectories . Select ( it => GetTemplatesDir ( it . Path ) ) . ToList ( ) ;
75+ var pattern = Templates . Contains ( type ) ? string . Format ( PATTERN_BLOCK , type ) : string . Format ( PATTERN_T_BLOCK , type ) ;
76+ var result = new Dictionary < string , string > ( ) ;
77+ var paths = Settings . CustomSnippetDirectories . Select ( it => GetTemplatesDir ( it . Path ) ) . ToList ( ) ;
7878 paths . Add ( GetTemplatesDir ( PathHelper . SnippetDir ) ) ;
7979 paths . RemoveAll ( s => ! Directory . Exists ( s ) ) ;
80- foreach ( string path in paths )
80+ foreach ( var path in paths )
8181 {
82- foreach ( string file in Directory . GetFiles ( path , "*.fds" ) )
82+ foreach ( var file in Directory . GetFiles ( path , "*.fds" ) )
8383 {
84- string content = GetFileContent ( file ) ;
85- string marker = "#pcc:" + type ;
86- int startIndex = content . IndexOf ( marker , StringComparison . Ordinal ) ;
84+ var content = GetFileContent ( file ) ;
85+ var marker = "#pcc:" + type ;
86+ var startIndex = content . IndexOf ( marker , StringComparison . Ordinal ) ;
8787 if ( startIndex != - 1 )
8888 {
8989 startIndex += marker . Length ;
@@ -101,7 +101,7 @@ internal static Dictionary<string, string> GetTemplates(string type)
101101 static string GetFileContent ( string file )
102102 {
103103 string content ;
104- using ( StreamReader reader = new StreamReader ( File . OpenRead ( file ) ) )
104+ using ( var reader = new StreamReader ( File . OpenRead ( file ) ) )
105105 {
106106 content = reader . ReadToEnd ( ) ;
107107 reader . Close ( ) ;
@@ -112,13 +112,13 @@ static string GetFileContent(string file)
112112 internal static KeyValuePair < string , string > GetVarNameToQualifiedName ( ASResult expr )
113113 {
114114 string type = null ;
115- string varname = string . Empty ;
116- string word = string . Empty ;
117- MemberModel member = expr . Member ;
115+ var varname = string . Empty ;
116+ var word = string . Empty ;
117+ var member = expr . Member ;
118118 if ( member != null && member . Type != null ) type = member . Type ;
119119 else
120120 {
121- ClassModel cType = expr . Type ;
121+ var cType = expr . Type ;
122122 if ( cType != null && cType . Name != null ) type = cType . QualifiedName ;
123123 }
124124 if ( member != null && member . Name != null ) varname = Reflector . ASGenerator . GuessVarName ( member . Name , type ) ;
@@ -133,8 +133,8 @@ internal static KeyValuePair<string, string> GetVarNameToQualifiedName(ASResult
133133 internal static string ProcessMemberTemplate ( string template , ASResult expr )
134134 {
135135 var varNameToQualifiedName = GetVarNameToQualifiedName ( expr ) ;
136- string name = varNameToQualifiedName . Key . ToLower ( ) ;
137- string type = varNameToQualifiedName . Value ;
136+ var name = varNameToQualifiedName . Key . ToLower ( ) ;
137+ var type = varNameToQualifiedName . Value ;
138138 template = ASCompletion . Completion . TemplateUtils . ReplaceTemplateVariable ( template , "Name" , name ) ;
139139 if ( ASContext . Context is Context && Settings != null && Settings . DisableTypeDeclaration ) type = null ;
140140 if ( ! string . IsNullOrEmpty ( type ) ) type = MemberModel . FormatType ( Reflector . ASGenerator . GetShortType ( type ) ) ;
@@ -144,7 +144,7 @@ internal static string ProcessMemberTemplate(string template, ASResult expr)
144144
145145 internal static string ProcessCollectionTemplate ( string template , ASResult expr )
146146 {
147- string type = expr . Member != null ? expr . Member . Type : expr . Type . QualifiedName ;
147+ var type = expr . Member != null ? expr . Member . Type : expr . Type . QualifiedName ;
148148 if ( type . Contains ( "@" ) ) type = type . Replace ( "@" , ".<" ) + ">" ;
149149 type = Regex . Match ( type , "<([^]]+)>" ) . Groups [ 1 ] . Value ;
150150 type = Reflector . ASGenerator . GetShortType ( type ) ;
@@ -165,10 +165,10 @@ internal static string ProcessHashTemplate(string template, ASResult expr)
165165 {
166166 case "as2" :
167167 case "as3" :
168- string type = expr . Member != null ? expr . Member . Type : expr . Type . QualifiedName ;
168+ var type = expr . Member != null ? expr . Member . Type : expr . Type . QualifiedName ;
169169 type = Reflector . ASGenerator . GetShortType ( type ) ;
170- ContextFeatures features = ASContext . Context . Features ;
171- string objectKey = features . objectKey ;
170+ var features = ASContext . Context . Features ;
171+ var objectKey = features . objectKey ;
172172 if ( type == objectKey || type == "Dictionary" )
173173 {
174174 template = template . Replace ( PATTERN_COLLECTION_KEY_TYPE , type == objectKey ? features . stringKey : objectKey ) ;
@@ -181,13 +181,13 @@ internal static string ProcessHashTemplate(string template, ASResult expr)
181181
182182 internal static string GetDescription ( ASResult expr , string template , string pccpattern )
183183 {
184- ScintillaControl sci = PluginBase . MainForm . CurrentDocument . SciControl ;
185- int position = ScintillaControlHelper . GetDotLeftStartPosition ( sci , sci . CurrentPos - 1 ) ;
186- int exprStartPosition = ScintillaControlHelper . GetExpressionStartPosition ( sci , sci . CurrentPos , expr ) ;
187- int lineNum = sci . CurrentLine ;
188- string line = sci . GetLine ( lineNum ) ;
189- string snippet = line . Substring ( exprStartPosition - sci . PositionFromLine ( lineNum ) , position - exprStartPosition ) ;
190- string result = template . Replace ( SnippetHelper . BOUNDARY , string . Empty ) ;
184+ var sci = PluginBase . MainForm . CurrentDocument . SciControl ;
185+ var position = ScintillaControlHelper . GetDotLeftStartPosition ( sci , sci . CurrentPos - 1 ) ;
186+ var exprStartPosition = ScintillaControlHelper . GetExpressionStartPosition ( sci , sci . CurrentPos , expr ) ;
187+ var lineNum = sci . CurrentLine ;
188+ var line = sci . GetLine ( lineNum ) ;
189+ var snippet = line . Substring ( exprStartPosition - sci . PositionFromLine ( lineNum ) , position - exprStartPosition ) ;
190+ var result = template . Replace ( SnippetHelper . BOUNDARY , string . Empty ) ;
191191 result = Regex . Replace ( result , string . Format ( PATTERN_BLOCK , pccpattern ) , snippet , RegexOptions . IgnoreCase | RegexOptions . Multiline ) ;
192192 result = ProcessMemberTemplate ( result , expr ) ;
193193 result = ArgsProcessor . ProcessCodeStyleLineBreaks ( result ) ;
@@ -198,13 +198,13 @@ internal static string GetDescription(ASResult expr, string template, string pcc
198198
199199 internal static void InsertSnippetText ( ASResult expr , string template , string pccpattern )
200200 {
201- ScintillaControl sci = PluginBase . MainForm . CurrentDocument . SciControl ;
202- int position = ScintillaControlHelper . GetDotLeftStartPosition ( sci , sci . CurrentPos - 1 ) ;
201+ var sci = PluginBase . MainForm . CurrentDocument . SciControl ;
202+ var position = ScintillaControlHelper . GetDotLeftStartPosition ( sci , sci . CurrentPos - 1 ) ;
203203 sci . SetSel ( position , sci . CurrentPos ) ;
204204 sci . ReplaceSel ( string . Empty ) ;
205205 position = ScintillaControlHelper . GetExpressionStartPosition ( sci , sci . CurrentPos , expr ) ;
206206 sci . SetSel ( position , sci . CurrentPos ) ;
207- string snippet = Regex . Replace ( template , string . Format ( PATTERN_BLOCK , pccpattern ) , sci . SelText , RegexOptions . IgnoreCase | RegexOptions . Multiline ) ;
207+ var snippet = Regex . Replace ( template , string . Format ( PATTERN_BLOCK , pccpattern ) , sci . SelText , RegexOptions . IgnoreCase | RegexOptions . Multiline ) ;
208208 snippet = ProcessMemberTemplate ( snippet , expr ) ;
209209 snippet = ArgsProcessor . ProcessCodeStyleLineBreaks ( snippet ) ;
210210 sci . ReplaceSel ( string . Empty ) ;
0 commit comments