Example #1
0
        private void HighlightRuntimeException(int functionId, ArchAngel.Common.Generator.DebugPos debugPos, string errDescription)
        {
            //string funcName = (string)dataGridViewErrors[ColFile.Index, e.RowIndex].Value;
            int line = debugPos.Line;

            treeFiles.SelectedNode = treeFiles.FindNodeByDataKey("File_" + functionId);

            syntaxEditorFilename.Document.SpanIndicatorLayers.Clear();
            syntaxEditor1.Document.SpanIndicatorLayers.Clear();

            ActiproSoftware.SyntaxEditor.SyntaxEditor editor;
            //if (codeFunction == "Filename")
            //{
            //editor = syntaxEditorFilename;
            //highlighter1.SetHighlightColor(syntaxEditorFilename, DevComponents.DotNetBar.Validator.eHighlightColor.Red);
            ////editor.Document.Lines[0].BackColor = Color.Salmon;
            //}
            //else if (codeFunction == "Body")
            //{
            editor = syntaxEditor1;
            highlighter1.SetHighlightColor(syntaxEditorFilename, DevComponents.DotNetBar.Validator.eHighlightColor.None);
            //    //editor.Document.Lines[0].BackColor = Color.White;
            //}
            //else
            //    throw new NotImplementedException("Function type not handled yet: " + codeFunction);

            int startOffset = editor.Document.Lines[line].TextRange.StartOffset;// +column;
            ActiproSoftware.SyntaxEditor.DefaultWordBreakFinder wbf = new ActiproSoftware.SyntaxEditor.DefaultWordBreakFinder();
            int endOffset = editor.Document.Lines[line].TextRange.EndOffset;// wbf.FindCurrentWordEnd(editor.Document, startOffset);

            if (endOffset < startOffset)
            {
                //MessageBox.Show("endOffset < startOffset");
                return;
            }
            ActiproSoftware.SyntaxEditor.HighlightingStyle highlightingStyle = new ActiproSoftware.SyntaxEditor.HighlightingStyle("Test", null, Color.Empty, Color.Red);
            ActiproSoftware.SyntaxEditor.HighlightingStyleSpanIndicator highlightSpan = new ActiproSoftware.SyntaxEditor.HighlightingStyleSpanIndicator("Test", highlightingStyle);
            highlightSpan.Tag = errDescription;

            this.AddSpanIndicator(
                editor,
                ActiproSoftware.SyntaxEditor.SpanIndicatorLayer.SyntaxErrorKey,
                ActiproSoftware.SyntaxEditor.SpanIndicatorLayer.SyntaxErrorDisplayPriority,
                highlightSpan, new ActiproSoftware.SyntaxEditor.TextRange(startOffset, endOffset));

            editor.SelectedView.GoToLine(line);
            editor.Caret.Offset = startOffset;
            editor.SelectedView.ScrollToCaret();

            if (superTabControl1.SelectedTab != superTabItemScript)
                superTabControl1.SelectedTab = superTabItemScript;

            string description = string.Format("{0}\nLine: {1}", errDescription, line);
            MessageBox.Show(this, description, "Runtime error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            //if (superTabControl1.SelectedTab != superTabItemScript)
            //    superTabControl1.SelectedTab = superTabItemScript;
        }
Example #2
0
        private void dataGridViewErrors_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (BusyPopulatingErrors)
                return;

            string functionId = (string)dataGridViewErrors[ColFunctionId.Index, e.RowIndex].Value;
            string funcName = (string)dataGridViewErrors[ColFile.Index, e.RowIndex].Value;
            int line = (int)dataGridViewErrors[ColLine.Index, e.RowIndex].Value - 1;
            int column = (int)dataGridViewErrors[ColColumn.Index, e.RowIndex].Value - 1;
            string codeFunction = (string)dataGridViewErrors[ColCodeFunction.Index, e.RowIndex].Value;
            string errDescription = (string)dataGridViewErrors[ColDescription.Index, e.RowIndex].Value;

            if (line < 0)
            {
                MessageBox.Show("Error before beginning");
                return;
            }
            treeFiles.SelectedNode = treeFiles.FindNodeByDataKey(functionId);

            syntaxEditorFilename.Document.SpanIndicatorLayers.Clear();
            syntaxEditor1.Document.SpanIndicatorLayers.Clear();

            ActiproSoftware.SyntaxEditor.SyntaxEditor editor;
            if (codeFunction == "Filename")
            {
                editor = syntaxEditorFilename;
                highlighter1.SetHighlightColor(syntaxEditorFilename, DevComponents.DotNetBar.Validator.eHighlightColor.Red);
                //editor.Document.Lines[0].BackColor = Color.Salmon;
            }
            else if (codeFunction == "Body")
            {
                editor = syntaxEditor1;
                highlighter1.SetHighlightColor(syntaxEditorFilename, DevComponents.DotNetBar.Validator.eHighlightColor.None);
                //editor.Document.Lines[0].BackColor = Color.White;
            }
            else
                throw new NotImplementedException("Function type not handled yet: " + codeFunction);

            int startOffset = editor.Document.Lines[line].TextRange.StartOffset + column;
            // Account for \r\n instead of \n
            //startOffset -= line;
            //int endOffset = syntaxEditor1.Document.findc startOffset + 3;
            ActiproSoftware.SyntaxEditor.DefaultWordBreakFinder wbf = new ActiproSoftware.SyntaxEditor.DefaultWordBreakFinder();
            int endOffset = wbf.FindCurrentWordEnd(editor.Document, startOffset);

            if (endOffset < startOffset)
            {
                MessageBox.Show("endOffset < startOffset");
                return;
            }
            //editor.Document.SpanIndicatorLayers.Clear();

            //this.AddSpanIndicator(
            //    syntaxEditor1,
            //    ActiproSoftware.SyntaxEditor.SpanIndicatorLayer.SyntaxErrorKey,
            //    ActiproSoftware.SyntaxEditor.SpanIndicatorLayer.SyntaxErrorDisplayPriority,
            //    new ActiproSoftware.SyntaxEditor.WaveLineSpanIndicator(Color.Red), new ActiproSoftware.SyntaxEditor.TextRange(startOffset, endOffset));

            ActiproSoftware.SyntaxEditor.HighlightingStyle highlightingStyle = new ActiproSoftware.SyntaxEditor.HighlightingStyle("Test", null, Color.Empty, Color.Red);
            ActiproSoftware.SyntaxEditor.HighlightingStyleSpanIndicator highlightSpan = new ActiproSoftware.SyntaxEditor.HighlightingStyleSpanIndicator("Test", highlightingStyle);
            highlightSpan.Tag = errDescription;

            this.AddSpanIndicator(
                editor,
                ActiproSoftware.SyntaxEditor.SpanIndicatorLayer.SyntaxErrorKey,
                ActiproSoftware.SyntaxEditor.SpanIndicatorLayer.SyntaxErrorDisplayPriority,
                highlightSpan, new ActiproSoftware.SyntaxEditor.TextRange(startOffset, endOffset));

            editor.SelectedView.GoToLine(line);
            editor.Caret.Offset = startOffset;
            editor.SelectedView.ScrollToCaret();
        }