Skip to content

Commit 778acc1

Browse files
committed
Do not crash when no Haxe SDK is defined.
Do not set Haxe env every time a haxelib is resolved.
1 parent 55da052 commit 778acc1

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

External/Plugins/HaXeContext/Completion/CompilerCompletionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public CompilerCompletionHandler(Process haxeProcess)
1515

1616
public string GetCompletion(string[] args)
1717
{
18-
if (args == null)
18+
if (args == null || haxeProcess == null)
1919
return string.Empty;
2020
haxeProcess.StartInfo.Arguments = String.Join(" ", args);
2121
haxeProcess.Start();

External/Plugins/HaXeContext/Completion/CompletionServerCompletionHandler.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public CompletionServerCompletionHandler(Process haxeProcess, int port)
2424
{
2525
this.haxeProcess = haxeProcess;
2626
this.port = port;
27-
//haxeProcess.Start(); // deferred to first use
2827
Environment.SetEnvironmentVariable("HAXE_SERVER_PORT", "" + port);
2928
}
3029

@@ -41,9 +40,9 @@ public bool IsRunning()
4140

4241
public string GetCompletion(string[] args)
4342
{
44-
if (!IsRunning()) StartServer();
45-
if (args == null)
43+
if (args == null || haxeProcess == null)
4644
return string.Empty;
45+
if (!IsRunning()) StartServer();
4746
try
4847
{
4948
var client = new TcpClient("127.0.0.1", port);
@@ -70,7 +69,7 @@ public string GetCompletion(string[] args)
7069

7170
public void StartServer()
7271
{
73-
if (IsRunning()) return;
72+
if (haxeProcess == null || IsRunning()) return;
7473
haxeProcess.Start();
7574
if (!listening)
7675
{
@@ -90,7 +89,6 @@ void haxeProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
9089
void haxeProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
9190
{
9291
if (e.Data == null) return;
93-
//TraceManager.AddAsync(e.Data);
9492
if (Regex.IsMatch(e.Data, "Error.*--wait"))
9593
{
9694
if (!failure && FallbackNeeded != null)

External/Plugins/HaXeContext/Context.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private List<string> LookupLibrary(string lib)
162162
string hxPath = currentSDK;
163163
if (hxPath != null && Path.IsPathRooted(hxPath))
164164
{
165-
SetHaxeEnvironment(hxPath);
165+
if (hxPath != currentEnv) SetHaxeEnvironment(hxPath);
166166
haxelib = Path.Combine(hxPath, haxelib);
167167
}
168168

@@ -242,14 +242,14 @@ public void LoadMetadata()
242242
features.metadata = new Dictionary<string, string>();
243243

244244
Process process = createHaxeProcess("--help-metas");
245+
if (process == null) return;
245246
process.Start();
246247

247248
String metaList = process.StandardOutput.ReadToEnd();
248249
process.Close();
249250

250251
Regex regex = new Regex("@:([a-zA-Z]*)(?: : )(.*?)(?= @:[a-zA-Z]* :)");
251252
metaList = Regex.Replace(metaList, "\\s+", " ");
252-
metaList += "@:fake :";
253253

254254
MatchCollection matches = regex.Matches(metaList);
255255

@@ -1129,11 +1129,8 @@ private Process createHaxeProcess(string args)
11291129
// compiler path
11301130
var hxPath = currentSDK ?? "";
11311131
var process = Path.Combine(hxPath, "haxe.exe");
1132-
/*if (!File.Exists(process))
1133-
{
1134-
ErrorManager.ShowInfo(String.Format(TextHelper.GetString("Info.HaXeExeError"), "\n"));
1132+
if (!File.Exists(process))
11351133
return null;
1136-
}*/
11371134

11381135
// Run haxe compiler
11391136
Process proc = new Process();

0 commit comments

Comments
 (0)