@@ -20,7 +20,11 @@ namespace HaXeContext
20
20
internal class HaxeComplete
21
21
{
22
22
static readonly Regex reArg =
23
- new Regex ( "^(-cp)\\ s*([^\" '].*)$" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
23
+ new Regex ( "^(-cp|-resource)\\ s*([^\" '].*)$" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
24
+ static readonly Regex reMacro =
25
+ new Regex ( "^(--macro)\\ s*([^\" '].*)$" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
26
+ static readonly Regex reQuote =
27
+ new Regex ( "([^\" ])\" " , RegexOptions . Compiled ) ;
24
28
25
29
static readonly Regex rePosition =
26
30
new Regex ( "(?<path>.*?):(?<line>[0-9]*): (?<range>characters|lines) (?<start>[0-9]*)-(?<end>[0-9]*)" ,
@@ -105,7 +109,9 @@ string[] BuildHxmlArgs()
105
109
// Build Haxe command
106
110
var paths = ProjectManager . PluginMain . Settings . GlobalClasspaths . ToArray ( ) ;
107
111
var hxmlArgs = new List < String > ( hxproj . BuildHXML ( paths , "Nothing__" , true ) ) ;
112
+ RemoveComments ( hxmlArgs ) ;
108
113
QuotePath ( hxmlArgs ) ;
114
+ EscapeMacros ( hxmlArgs ) ;
109
115
110
116
// Get the current class edited (ensure completion even if class not reference in the project)
111
117
var package = ASContext . Context . CurrentModel . Package ;
@@ -131,6 +137,38 @@ string[] BuildHxmlArgs()
131
137
return hxmlArgs . ToArray ( ) ;
132
138
}
133
139
140
+ private void RemoveComments ( List < string > hxmlArgs )
141
+ {
142
+ for ( int i = 0 ; i < hxmlArgs . Count ; i ++ )
143
+ {
144
+ string arg = hxmlArgs [ i ] ;
145
+ if ( ! string . IsNullOrEmpty ( arg ) )
146
+ {
147
+ if ( arg . StartsWith ( "#" ) ) // commented line
148
+ hxmlArgs [ i ] = "" ;
149
+ }
150
+ }
151
+ }
152
+
153
+ private void EscapeMacros ( List < string > hxmlArgs )
154
+ {
155
+ for ( int i = 0 ; i < hxmlArgs . Count ; i ++ )
156
+ {
157
+ string arg = hxmlArgs [ i ] ;
158
+ if ( ! string . IsNullOrEmpty ( arg ) )
159
+ {
160
+ Match m = reMacro . Match ( arg ) ;
161
+ if ( m . Success )
162
+ hxmlArgs [ i ] = m . Groups [ 1 ] . Value + " " + EscapeQuotes ( m . Groups [ 2 ] . Value . Trim ( ) ) ;
163
+ }
164
+ }
165
+ }
166
+
167
+ private string EscapeQuotes ( string expr )
168
+ {
169
+ return reQuote . Replace ( expr , "$1\\ \" " ) ;
170
+ }
171
+
134
172
void QuotePath ( List < string > hxmlArgs )
135
173
{
136
174
for ( int i = 0 ; i < hxmlArgs . Count ; i ++ )
@@ -141,8 +179,6 @@ void QuotePath(List<string> hxmlArgs)
141
179
Match m = reArg . Match ( arg ) ;
142
180
if ( m . Success )
143
181
hxmlArgs [ i ] = m . Groups [ 1 ] . Value + " \" " + m . Groups [ 2 ] . Value . Trim ( ) + "\" " ;
144
- else if ( arg . StartsWith ( "#" ) ) // commented line
145
- hxmlArgs [ i ] = "" ;
146
182
}
147
183
}
148
184
}
0 commit comments