예제 #1
0
        private void BackgroundErrorTracer_DoWork(object sender, DoWorkEventArgs e)
        {
            try {
                foreach (Line line in LineCollection.lineList)
                {
                    if (line.type == "variable")
                    {
                        if (!Refactorer.CheckVariableDecleration(line.text))
                        {
                            Line errorLine = new Line();
                            errorLine.lineNumber = line.lineNumber;
                            errorLine.text       = "// variable decleration error!";
                            errorLine.type       = "variable";
                            if (!errorLines.Contains(errorLine))
                            {
                                errorLines.Add(errorLine);
                            }
                        }
                    }

                    else if (line.type == "method")
                    {
                        if (!Refactorer.CheckMethodDecleration(line.text))
                        {
                            Line errorLine = new Line();
                            errorLine.lineNumber = line.lineNumber;
                            errorLine.text       = "// method decleration error!";
                            errorLine.type       = "method";
                            if (!errorLines.Contains(errorLine))
                            {
                                errorLines.Add(errorLine);
                            }
                        }
                    }

                    else if (line.type == "class")
                    {
                        if (!Refactorer.CheckClassDecleration(line.text))
                        {
                            Line errorLine = new Line();
                            errorLine.lineNumber = line.lineNumber;
                            errorLine.text       = "// Class decleration error!";
                            errorLine.type       = "class";
                            if (!errorLines.Contains(errorLine))
                            {
                                errorLines.Add(errorLine);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #2
0
        private void NrichTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Line line = new Line();
                line.lineNumber = (NrichTextBox.Lines.Length - 1);
                line.text       = NrichTextBox.Lines[NrichTextBox.Lines.Length - 2];

                if (TokenGenerator.IsVariableDecleration(line.text))
                {
                    line.type = "variable";
                }

                else if (TokenGenerator.IsMethodDecleration(line.text))
                {
                    line.type = "method";
                }

                else if (TokenGenerator.IsClassDecleration(line.text))
                {
                    line.type = "class";
                }

                else
                {
                    line.type = "none";
                }

                lineList.Add(line);

                NrichTextBox.SelectionStart = NrichTextBox.TextLength;
            }

            if (e.KeyCode == Keys.Delete)
            {
                foreach (Line line in lineList)
                {
                    if (line.type == "variable")
                    {
                        if (!Refactorer.CheckVariableDecleration(line.text))
                        {
                            Line errorLine = new Line();
                            errorLine.lineNumber = line.lineNumber;
                            errorLine.text       = "// variable decleration error!";
                            errorLine.type       = "variable";
                            errorLines.Add(errorLine);
                        }
                    }

                    else if (line.type == "method")
                    {
                        if (!Refactorer.CheckMethodDecleration(line.text))
                        {
                            Line errorLine = new Line();
                            errorLine.lineNumber = line.lineNumber;
                            errorLine.text       = "// method decleration error!";
                            errorLine.type       = "method";
                            errorLines.Add(errorLine);
                        }
                    }

                    else if (line.type == "class")
                    {
                        if (!Refactorer.CheckClassDecleration(line.text))
                        {
                            Line errorLine = new Line();
                            errorLine.lineNumber = line.lineNumber;
                            errorLine.text       = "// Class decleration error!";
                            errorLine.type       = "class";
                            errorLines.Add(errorLine);
                        }
                    }
                }

                foreach (Line line in errorLines)
                {
                    ErrorLog.AppendText(line.lineNumber + " -> " + line.text + "\r\n");
                }
            }
        }