public Types.CompileTargetType DetermineTargetType(DocumentInfo Doc, Parser.ParserBase Parser) { // compile target Types.CompileTargetType compileTarget = C64Studio.Types.CompileTargetType.NONE; if (Doc.Element != null) { compileTarget = Doc.Element.TargetType; } if (compileTarget == C64Studio.Types.CompileTargetType.NONE) { compileTarget = Parser.CompileTarget; } return(compileTarget); }
public string DetermineTargetFilename(DocumentInfo Doc, Parser.ParserBase Parser) { if ((String.IsNullOrEmpty(Parser.CompileTargetFile)) && ((Doc.Element == null) || (String.IsNullOrEmpty(Doc.Element.TargetFilename)))) { // default to same name.prg and cbm if (Doc.Project == null) { return(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Doc.FullPath), System.IO.Path.GetFileNameWithoutExtension(Doc.FullPath)) + ".prg"); } return(System.IO.Path.Combine(Doc.Project.Settings.BasePath, System.IO.Path.GetFileNameWithoutExtension(Doc.FullPath) + ".prg")); } if ((Doc.Element != null) && (!String.IsNullOrEmpty(Doc.Element.TargetFilename))) { return(GR.Path.Append(Doc.Project.Settings.BasePath, Doc.Element.TargetFilename)); } return(Parser.CompileTargetFile); }
public void UpdateFromMessages(Parser.ParserBase Parser, Project ParsedProject) { if (InvokeRequired) { Invoke(new UpdateFromMessagesCallback(UpdateFromMessages), new object[] { Parser, ParsedProject }); return; } m_ListProject = ParsedProject; ClearMessages(); listMessages.BeginUpdate(); SortOrder oldOrder = listMessages.Sorting; listMessages.Sorting = SortOrder.None; listMessages.ListViewItemSorter = null; foreach (var docInfo in Core.MainForm.DocumentInfos) { var compilableDoc = docInfo.CompilableDocument; compilableDoc?.RemoveAllErrorMarkings(); } foreach (System.Collections.Generic.KeyValuePair <int, Parser.ParserBase.ParseMessage> msg in Parser.Messages) { int lineIndex = msg.Key; Parser.ParserBase.ParseMessage message = msg.Value; var msgType = message.Type; if (Core.Settings.IgnoredWarnings.ContainsValue(message.Code)) { // ignore warning continue; } string documentFile = ""; int documentLine = -1; Parser.DocumentAndLineFromGlobalLine(lineIndex, out documentFile, out documentLine); if (message.AlternativeFile == null) { message.AlternativeFile = documentFile; message.AlternativeLineIndex = documentLine; } if (message.CharIndex != -1) { CompilableDocument compilableDoc = null; if (ParsedProject == null) { var sourceDocInfo = Core.MainForm.DetermineDocumentByFileName(documentFile); if (sourceDocInfo != null) { compilableDoc = sourceDocInfo.CompilableDocument; } } else { var sourceElement = ParsedProject.GetElementByFilename(documentFile); if (sourceElement != null) { if (sourceElement.Document != null) { compilableDoc = sourceElement.DocumentInfo.CompilableDocument; } } } compilableDoc?.MarkTextAsError(documentLine, message.CharIndex, message.Length); } ++documentLine; ListViewItem item = new ListViewItem(); if (msgType == C64Studio.Parser.ParserBase.ParseMessage.LineType.ERROR) { item.ImageIndex = 0; item.Text = "0"; } else if (msgType == C64Studio.Parser.ParserBase.ParseMessage.LineType.WARNING) { item.ImageIndex = 1; item.Text = "2"; } else if (msgType == C64Studio.Parser.ParserBase.ParseMessage.LineType.SEVERE_WARNING) { item.ImageIndex = 2; item.Text = "1"; } else { item.Text = "3"; } item.SubItems.Add(documentLine.ToString()); string messageCode = message.Code.ToString(); if (messageCode.Length >= 5) { item.SubItems.Add(messageCode.Substring(0, 5)); } else { item.SubItems.Add(messageCode); } if (documentFile != null) { item.SubItems.Add(documentFile.ToString()); } else { item.SubItems.Add("--"); } item.SubItems.Add(message.Message); item.Tag = message; listMessages.Items.Add(item); if (message.ChildMessages != null) { foreach (var childMessage in message.ChildMessages) { ListViewItem childItem = new ListViewItem(); if (childMessage.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.ERROR) { childItem.ImageIndex = 0; childItem.Text = "0"; } else if (childMessage.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.WARNING) { childItem.ImageIndex = 1; childItem.Text = "2"; } else if (childMessage.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.SEVERE_WARNING) { childItem.ImageIndex = 2; childItem.Text = "1"; } else { childItem.Text = "3"; } childItem.SubItems.Add(documentLine.ToString()); if (childMessage.Code.ToString().Length >= 5) { childItem.SubItems.Add(childMessage.Code.ToString().Substring(0, 5)); } else { childItem.SubItems.Add(childMessage.Code.ToString()); } childItem.SubItems.Add(documentFile.ToString()); childItem.SubItems.Add(childMessage.Message); childItem.Tag = childMessage; listMessages.Items.Add(childItem); } } } listMessages.Sorting = oldOrder; listMessages.ListViewItemSorter = new CompileResultItemComparer(listMessagesSortColumn, listMessages.Sorting); listMessages.EndUpdate(); }
public void UpdateFromMessages(Parser.ParserBase Parser, Project ParsedProject) { if (InvokeRequired) { Invoke(new UpdateFromMessagesCallback(UpdateFromMessages), new object[] { Parser, ParsedProject }); return; } m_ListProject = ParsedProject; ClearMessages(); listMessages.BeginUpdate(); SortOrder oldOrder = listMessages.Sorting; listMessages.Sorting = SortOrder.None; listMessages.ListViewItemSorter = null; foreach (var docInfos in Core.MainForm.DocumentInfos) { if ((docInfos.Type == ProjectElement.ElementType.ASM_SOURCE) && (docInfos.BaseDoc != null)) { SourceASMEx source = (SourceASMEx)docInfos.BaseDoc; source.RemoveAllErrorMarkings(); } } foreach (System.Collections.Generic.KeyValuePair <int, Parser.ParserBase.ParseMessage> msg in Parser.Messages) { int lineIndex = msg.Key; Parser.ParserBase.ParseMessage message = msg.Value; /* * if ( message.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.MESSAGE ) * { * continue; * }*/ if (Core.Settings.IgnoredWarnings.ContainsValue(message.Code)) { // ignore warning continue; } string documentFile = ""; int documentLine = -1; //Debug.Log( "a" ); Parser.DocumentAndLineFromGlobalLine(lineIndex, out documentFile, out documentLine); //Debug.Log( "b" ); if (message.AlternativeFile == null) { message.AlternativeFile = documentFile; message.AlternativeLineIndex = documentLine; } if (message.CharIndex != -1) { if (ParsedProject == null) { var sourceDocInfo = Core.MainForm.DetermineDocumentByFileName(documentFile); if ((sourceDocInfo != null) && (sourceDocInfo.BaseDoc != null) && (sourceDocInfo.Type == ProjectElement.ElementType.ASM_SOURCE)) { var sourceFile = (SourceASMEx)sourceDocInfo.BaseDoc; if (sourceFile != null) { sourceFile.MarkTextAsError(documentLine, message.CharIndex, message.Length); } } } else { var sourceElement = ParsedProject.GetElementByFilename(documentFile); if (sourceElement != null) { var sourceFile = (SourceASMEx)sourceElement.Document; if (sourceFile != null) { sourceFile.MarkTextAsError(documentLine, message.CharIndex, message.Length); } else { // TODO - have no document to mark? } } else { // TODO - have no document to mark? } } } //dh.Log( "Error in " + lineIndex ); ++documentLine; ListViewItem item = new ListViewItem(); if (message.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.ERROR) { item.ImageIndex = 0; item.Text = "0"; } else if (message.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.WARNING) { item.ImageIndex = 1; item.Text = "2"; } else if (message.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.SEVERE_WARNING) { item.ImageIndex = 2; item.Text = "1"; } else { item.Text = "3"; } item.SubItems.Add(documentLine.ToString()); string messageCode = message.Code.ToString(); if (messageCode.Length >= 5) { item.SubItems.Add(messageCode.Substring(0, 5)); } else { item.SubItems.Add(messageCode); } if (documentFile != null) { item.SubItems.Add(documentFile.ToString()); } else { item.SubItems.Add("--"); } item.SubItems.Add(message.Message); item.Tag = message; //Debug.Log( "c" ); listMessages.Items.Add(item); //Debug.Log( "d" ); if (message.ChildMessages != null) { foreach (var childMessage in message.ChildMessages) { ListViewItem childItem = new ListViewItem(); if (childMessage.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.ERROR) { childItem.ImageIndex = 0; childItem.Text = "0"; } else if (childMessage.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.WARNING) { childItem.ImageIndex = 1; childItem.Text = "2"; } else if (childMessage.Type == C64Studio.Parser.ParserBase.ParseMessage.LineType.SEVERE_WARNING) { childItem.ImageIndex = 2; childItem.Text = "1"; } else { childItem.Text = "3"; } childItem.SubItems.Add(documentLine.ToString()); childItem.SubItems.Add(childMessage.Code.ToString().Substring(0, 5)); childItem.SubItems.Add(documentFile.ToString()); childItem.SubItems.Add(childMessage.Message); childItem.Tag = childMessage; //Debug.Log( "c" ); listMessages.Items.Add(childItem); } } } //Debug.Log( "e" ); listMessages.Sorting = oldOrder; listMessages.ListViewItemSorter = new CompileResultItemComparer(listMessagesSortColumn, listMessages.Sorting); //listMessages.Sort(); //Debug.Log( "f" ); listMessages.EndUpdate(); }