private void DisplayResult(ParseResult result) { if (result.Status != ParseResult.StatusCode.Found) { var content = new ParseMessageContent(); switch (result.Status) { case ParseResult.StatusCode.InvalidInput: content.Message = "Parser had Invalid Input."; break; case ParseResult.StatusCode.ParseFailed: content.Message = "Errors found while parsing.\nUpdate the Extension's options as needed for a succesful compilation.\nCheck the 'Struct Layout' output pane for more information."; break; case ParseResult.StatusCode.NotFound: content.Message = "No structure found at the given position.\nTry performing the query from a structure definition or initialization."; break; } content.Log = result.ParserLog; content.ShowOptions = result.Status == ParseResult.StatusCode.ParseFailed; CheckForSpecialResults(content); ParseMessageWindow.Display(content); } }
public async System.Threading.Tasks.Task ParseAtCurrentLocationAsync() { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); OutputLog.Clear(); EditorUtils.SaveActiveDocument(); DocumentLocation location = GetCurrentLocation(); if (location == null) { string msg = "Unable to retrieve current document position."; OutputLog.Error(msg); ParseMessageWindow.Display(new ParseMessageContent(msg)); } ProjectProperties properties = GetProjectData(); if (properties == null) { string msg = "Unable to retrieve the project configuration"; OutputLog.Error(msg); ParseMessageWindow.Display(new ParseMessageContent(msg)); return; } GeneralSettingsPageGrid settings = EditorUtils.GetGeneralSettings(); parser.PrintCommandLine = settings.OptionParserShowCommandLine; //TODO ~ ramonv ~ add parsing queue to avoid multiple queries at the same time LayoutWindow prewin = EditorUtils.GetLayoutWindow(false); if (prewin != null) { prewin.SetProcessing(); } ParseResult result = await parser.ParseAsync(properties, location); //Only create or focus the window if we have a valid result LayoutWindow win = EditorUtils.GetLayoutWindow(result.Status == ParseResult.StatusCode.Found); if (win != null) { win.SetResult(result); if (result.Status == ParseResult.StatusCode.Found) { EditorUtils.FocusWindow(win); } } DisplayResult(result); }
static public void OpenFile(string filename, uint line, uint column) { ThreadHelper.ThrowIfNotOnUIThread(); DTE2 applicationObject = ServiceProvider.GetService(typeof(SDTE)) as DTE2; Assumes.Present(applicationObject); Window window = null; Document doc = null; try { window = applicationObject.ItemOperations.OpenFile(filename.Replace('/', '\\')); } catch (Exception) { var content = new ParseMessageContent(); content.Message = "Unable to open file " + filename; ParseMessageWindow.Display(content); return; } if (window == null) { //sometimes it opens but it does not give a window element ( check if opened already ) Document activeDoc = GetActiveDocument(); if (activeDoc != null && Path.GetFileName(activeDoc.FullName) == Path.GetFileName(filename)) { doc = activeDoc; } } else { window.Activate(); doc = window.Document; } if (doc != null) { TextSelection sel = (TextSelection)doc.Selection; sel.MoveTo((int)line, (int)column); } }