Exemplo n.º 1
0
        private void run(string file)
        {
            _fochild.richTextBox3.Text = "";
            _fochild.richTextBox4.Text = "";
            // _fochild.richTextBox2.Text = "";
            _fochild.Errortext.Text = "";
            if (Getextension(_textEditor).Equals("Java"))
            {//run the project
                var p      = new ImplementPMD();
                var xml    = p.RunPMD(Path.GetDirectoryName(file), Path.GetFileName(file));
                var xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xml);
                GenerateFeedbackOutput(_fochild.richTextBox3, xmlDoc);
                _compilingJava = new Compiling(file);
                var s = _compilingJava.CompilingJavaCode();

                if (s.Equals(""))
                {
                    //  var p = new ImplementPMD(file);
                    //  var xml =  p.RunPMD(Path.GetDirectoryName(file), Path.GetFileName(file));
                    //  var xmlDoc = new XmlDocument();
                    //  xmlDoc.LoadXml(xml);
                    //  GenerateFeedbackOutput(_fochild.richTextBox3,xmlDoc);
                    var style = new JavaCompilingToolMurtada.StyleChecker.ImplementStyleChecker(file);
                    // _fochild.richTextBox2.Text = style.StyleJavaCodeFeedback();
                    _fochild.richTextBox4.Text = _runJava.RunJavaProject(file);
                }
                else
                {
                    //   MessageBox.Show(s);
                    //  _fochild.Errortext.Text = s;
                    var bugs = new ErrorDetector(s, Path.GetFileName(file));
                    var res  = bugs.GetResult();

                    //   MessageBox.Show("Errors:: " + s1);
                    var errorLines = new int[res.GetLength(0)];
                    for (var i = 0; i < res.GetLength(0); i += 1)
                    {
                        errorLines[i] = Convert.ToInt32(res[i, 0]) - 1;
                    }
                    SetLines(errorLines);
                    var totalErrorCount = res.Length / 3;
                    _textEditor.PaintLine += fastColoredTextBox1_PaintLine;
                    const float bigFont      = 12.0f;
                    var         richTextBox  = _fochild.Errortext;
                    var         fontOriginal = richTextBox.Font.Size;
                    richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, bigFont, FontStyle.Underline);
                    richTextBox.AppendText("Total Errors found: " + totalErrorCount + "\n\n");
                    richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, fontOriginal, FontStyle.Regular);
                    for (var errorIndex = 0; errorIndex < totalErrorCount; errorIndex++)
                    {
                        var errorLine      = Convert.ToInt32(res[errorIndex, 0]);
                        var errorSomething = res[errorIndex, 1];
                        var error          = res[errorIndex, 2];

                        richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, bigFont, FontStyle.Bold);
                        richTextBox.AppendText("Error ");
                        richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, bigFont, FontStyle.Regular);
                        richTextBox.AppendText((errorIndex + 1) + "\n\n");
                        richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily, fontOriginal, FontStyle.Regular);

                        richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Bold);
                        richTextBox.AppendText("In file: ");
                        richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Regular);
                        richTextBox.AppendText(file + "\n");


                        richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Bold);
                        richTextBox.AppendText("On line nr: ");
                        richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Regular);
                        richTextBox.AppendText(errorLine + "\n");

                        richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Bold);
                        richTextBox.AppendText("Details:\n");
                        richTextBox.SelectionFont = new Font(richTextBox.Font, FontStyle.Regular);

                        int asd = error.IndexOf("error:");
                        richTextBox.AppendText(error.Substring(asd + 7) + "\n");
                        richTextBox.AppendText("\n");
                    }
                }
                if (s.Equals(""))
                {
                    //  var p = new ImplementPMD(file);
                    //  var xml =  p.RunPMD(Path.GetDirectoryName(file), Path.GetFileName(file));
                    //  var xmlDoc = new XmlDocument();
                    //  xmlDoc.LoadXml(xml);
                    //  GenerateFeedbackOutput(_fochild.richTextBox3,xmlDoc);
                    var style = new JavaCompilingToolMurtada.StyleChecker.ImplementStyleChecker(file);
                    // _fochild.richTextBox2.Text = style.StyleJavaCodeFeedback();
                    _fochild.richTextBox4.Text = _runJava.RunJavaProject(file);
                }
                else
                {
                    var bugs = new ErrorDetector(s, Path.GetFileName(file));
                    var res  = bugs.GetResult();

                    //   MessageBox.Show("Errors:: " + s1);
                    var errorLines = new int[res.GetLength(0)];
                    for (var i = 0; i < res.GetLength(0); i += 1)
                    {
                        errorLines[i] = Convert.ToInt32(res[i, 0]) - 1;
                    }
                    SetLines(errorLines);
                    _textEditor.PaintLine += fastColoredTextBox1_PaintLine;
                    fillInErrorTextBox(res, file);
                }
            }
            else
            {
                _textEditor = GetEditor();

                JavaCompilingToolMurtada.CSharpRunner.CSharpRunner cs = new JavaCompilingToolMurtada.CSharpRunner.CSharpRunner(_textEditor.Text);
                _fochild.richTextBox4.Text = cs.Compile(_textEditor.Text);
            }
        }