mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-07 12:16:04 +00:00
Adopt the comments of the AI reviewers
This commit is contained in:
parent
b1cabe9fbb
commit
96bd29c06a
|
@ -1,6 +1,7 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -61,7 +62,10 @@ namespace WelsonJS.Launcher
|
|||
.ToList();
|
||||
executables.AddRange(executableFiles);
|
||||
}
|
||||
catch (Exception) { }
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Error enumerating executables in '{installLocation}': {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(uninstallString))
|
||||
|
@ -77,7 +81,7 @@ namespace WelsonJS.Launcher
|
|||
|
||||
private static bool TryParseExecutablePath(string s, out string path)
|
||||
{
|
||||
Match match = Regex.Match(s, @"(?<=""|^)([a-zA-Z]:\\[^""\s]+\.exe)");
|
||||
Match match = Regex.Match(s, @"(?<=""|^)([a-zA-Z]:\\[^""]+\.exe)", RegexOptions.IgnoreCase);
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
|
@ -104,7 +108,10 @@ namespace WelsonJS.Launcher
|
|||
{
|
||||
executables.AddRange(Directory.GetFiles(path, "*.exe", SearchOption.TopDirectoryOnly));
|
||||
}
|
||||
catch (Exception) { }
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Error enumerating executables in '{path}': {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,19 +114,19 @@ namespace WelsonJS.Launcher
|
|||
.Where(exec => exec.IndexOf(word, 0, StringComparison.OrdinalIgnoreCase) > -1)
|
||||
.Select(exec => new CompletionItem
|
||||
{
|
||||
label = Path.GetFileName(exec),
|
||||
kind = "Text",
|
||||
documentation = "An executable file",
|
||||
insertText = exec
|
||||
Label = Path.GetFileName(exec),
|
||||
Kind = "Text",
|
||||
Documentation = "An executable file",
|
||||
InsertText = exec
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
XElement response = new XElement("suggestions",
|
||||
completionItems.Select(item => new XElement("item",
|
||||
new XElement("label", item.label),
|
||||
new XElement("kind", item.kind),
|
||||
new XElement("documentation", item.documentation),
|
||||
new XElement("insertText", item.insertText)
|
||||
new XElement("label", item.Label),
|
||||
new XElement("kind", item.Kind),
|
||||
new XElement("documentation", item.Documentation),
|
||||
new XElement("insertText", item.InsertText)
|
||||
))
|
||||
);
|
||||
|
||||
|
@ -138,8 +138,11 @@ namespace WelsonJS.Launcher
|
|||
context.Response.StatusCode = statusCode;
|
||||
context.Response.ContentType = "application/xml";
|
||||
context.Response.ContentLength64 = data.Length;
|
||||
context.Response.OutputStream.Write(data, 0, data.Length);
|
||||
context.Response.OutputStream.Close();
|
||||
using (Stream outputStream = context.Response.OutputStream)
|
||||
{
|
||||
context.Response.OutputStream.Write(data, 0, data.Length);
|
||||
context.Response.OutputStream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void ServeResource(HttpListenerContext context, byte[] data, string mimeType = "text/html")
|
||||
|
@ -157,8 +160,11 @@ namespace WelsonJS.Launcher
|
|||
context.Response.StatusCode = statusCode;
|
||||
context.Response.ContentType = mimeType;
|
||||
context.Response.ContentLength64 = data.Length;
|
||||
context.Response.OutputStream.Write(data, 0, data.Length);
|
||||
context.Response.OutputStream.Close();
|
||||
using (Stream outputStream = context.Response.OutputStream)
|
||||
{
|
||||
context.Response.OutputStream.Write(data, 0, data.Length);
|
||||
context.Response.OutputStream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] GetResource(string resourceName)
|
||||
|
@ -214,9 +220,9 @@ namespace WelsonJS.Launcher
|
|||
|
||||
public class CompletionItem
|
||||
{
|
||||
public string label { get; set; }
|
||||
public string kind { get; set; }
|
||||
public string documentation { get; set; }
|
||||
public string insertText { get; set; }
|
||||
public string Label { get; set; }
|
||||
public string Kind { get; set; }
|
||||
public string Documentation { get; set; }
|
||||
public string InsertText { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user