private static string[] LoadLibDirs(PROBEENVSRVRLib.ProbeEnvApp currentApp, ProbeAppSettings appSettings) { var list = new List <string>(); for (int i = 1, ii = currentApp.NumLibraryPath; i <= ii; i++) { try { var path = currentApp.LibraryPath[i]; if (string.IsNullOrWhiteSpace(path)) { Log.Warning("PROBE returned blank lib path in slot {0}", i); } else if (!Directory.Exists(path)) { Log.Warning("Lib directory [{0}] does not exist.", path); } else { list.Add(path); } } catch (Exception ex) { Log.Error(ex, "Exception when attempting to retrieve lib path in slot {0}", i); } } if (!string.IsNullOrEmpty(appSettings.PlatformPath)) { list.Add(appSettings.PlatformPath); } return(list.ToArray()); }
private static string[] LoadSourceFiles(ProbeAppSettings appSettings) { var sourceFiles = new List <string>(); foreach (var dir in appSettings.SourceDirs) { if (string.IsNullOrWhiteSpace(dir)) { continue; } sourceFiles.AddRange(GetAllSourceFiles_ProcessDir(dir)); } return(sourceFiles.ToArray()); }
private static void ReloadTableList(ProbeAppSettings appSettings) { try { Log.Write(LogLevel.Info, "Loading dictionary..."); var startTime = DateTime.Now; DkDict.Dict.Load(appSettings); var elapsed = DateTime.Now.Subtract(startTime); Log.Write(LogLevel.Info, "Successfully loaded dictionary (elapsed: {0})", elapsed); } catch (Exception ex) { Log.Error(ex, "Exception when reloading DK table list."); } }
public static void ReloadAsync(string appName, bool updateDefaultApp) { _ = Task.Run(() => { var appSettings = ReloadCurrentApp(appName); if (appSettings.Initialized) { ReloadTableList(appSettings); _currentApp = appSettings; AppChanged?.Invoke(null, EventArgs.Empty); if (updateDefaultApp) { _currentApp.TryUpdateDefaultCurrentApp(); } } }); }
private static string[] LoadIncludeFiles(ProbeAppSettings appSettings) { var includeFiles = new List <string>(); foreach (var dir in appSettings.IncludeDirs) { try { if (string.IsNullOrWhiteSpace(dir) || !Directory.Exists(dir)) { continue; } includeFiles.AddRange(GetAllIncludeFiles_ProcessDir(dir)); } catch (Exception ex) { Log.Error(ex, "Exception when scanning for include files in directory [{0}]", dir); } } return(includeFiles.ToArray()); }
private static CodeModel.CodeModel GetModelForActiveDoc(ProbeAppSettings appSettings) { ThreadHelper.ThrowIfNotOnUIThread(); var view = Shell.ActiveView; if (view == null) { return(null); } var store = CodeModel.FileStore.GetOrCreateForTextBuffer(view.TextBuffer); if (store == null) { return(null); } var fileName = VsTextUtil.TryGetDocumentFileName(view.TextBuffer); return(store.GetMostRecentModel(appSettings, fileName, view.TextSnapshot, "Debug Commands")); }
private static ProbeAppSettings ReloadCurrentApp(string appName = "") { Log.Write(LogLevel.Info, "Loading application settings..."); var startTime = DateTime.Now; var appSettings = new ProbeAppSettings(); PROBEENVSRVRLib.ProbeEnv env = null; PROBEENVSRVRLib.ProbeEnvApp currentApp = null; try { env = new PROBEENVSRVRLib.ProbeEnv(); if (!string.IsNullOrEmpty(appName)) { currentApp = env.FindApp(appName); } if (currentApp == null) { currentApp = env.FindApp(env.DefaultAppName); } if (currentApp == null) { Debug.WriteLine("No current app found."); appSettings.Initialized = true; } else { Debug.WriteLine("Current App: " + currentApp.Name); appSettings.AppName = currentApp.Name; appSettings.Initialized = true; appSettings.PlatformPath = (env as PROBEENVSRVRLib.IProbeEnvPlatform).Folder; appSettings.AllAppNames = LoadAppNames(env); appSettings.SourceDirs = LoadSourceDirs(currentApp); appSettings.IncludeDirs = LoadIncludeDirs(currentApp, appSettings); appSettings.LibDirs = LoadLibDirs(currentApp, appSettings); appSettings.ExeDirs = LoadExeDirs(currentApp); appSettings.ObjectDir = currentApp.ObjectPath; appSettings.TempDir = currentApp.TempPath; appSettings.ReportDir = currentApp.ListingsPath; appSettings.DataDir = currentApp.DataPath; appSettings.LogDir = currentApp.LogPath; appSettings.SourceFiles = LoadSourceFiles(appSettings); appSettings.IncludeFiles = LoadIncludeFiles(appSettings); } var elapsed = DateTime.Now.Subtract(startTime); Log.Write(LogLevel.Info, "Application settings reloaded (elapsed: {0})", elapsed); return(appSettings); } finally { if (currentApp != null) { Marshal.ReleaseComObject(currentApp); currentApp = null; } if (env != null) { Marshal.ReleaseComObject(env); env = null; } } }