private static CompilerError ParseError(string error)
        {
            CompilerError result = new CompilerError();
            string[] lines = error.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];

                if (error.Contains("message:"))
                {
                    string[] args = line.Split(new[] { ':' }, 2);

                    if (args[0].Trim() == "message")
                        result.Message = args[1].Trim();

                    if (args[0].Trim() == "filename")
                        result.FileName = args[1].Trim();

                    int lineNo = 0;
                    if (args[0].Trim() == "line" && int.TryParse(args[1], out lineNo))
                        result.Line = lineNo;

                    int columnNo = 0;
                    if (args[0].Trim() == "column" && int.TryParse(args[1], out columnNo))
                        result.Column = columnNo;
                }
                else
                {
                    if (i == 1 || i == 2)
                        result.Message += " " + line;

                    if (i == 3)
                    {
                        string[] lineCol = line.Split(',');

                        int lineNo = 0;
                        if (int.TryParse(lineCol[0].Replace("on line", string.Empty).Trim(), out lineNo))
                            result.Line = lineNo;

                        int columnNo = 0;
                        if (int.TryParse(lineCol[0].Replace("column", string.Empty).Trim(':').Trim(), out columnNo))
                            result.Column = columnNo;

                        result.Message = result.Message.Trim();
                    }

                }
            }

            return result;
        }
        private CompilerError ParseError(string error)
        {
            string message = error.Replace("ERROR:", string.Empty).Replace("Error:", string.Empty);
            int line = 0, column = 0;

            Match match = Regex.Match(message, @"^(\d{1,})[:](\d{1,})");
            if (match.Success)
            {
                int.TryParse(match.Groups[1].Value, out line);
                int.TryParse(match.Groups[2].Value, out column);
            }

            CompilerError result = new CompilerError()
            {
                Message = "CoffeeScript: " + message,
                FileName = Document.FilePath,
                Line = line,
                Column = column
            };

            return result;
        }
        private ErrorTask CreateTask(CompilerError error, string message = null)
        {
            ErrorTask task = new ErrorTask()
            {
                Line = error.Line - 1,
                Column = error.Column - 1,
                ErrorCategory = Settings.LintResultLocation,
                Category = TaskCategory.Html,
                Document = error.FileName,
                Priority = TaskPriority.Low,
                Text = message ?? error.Message,
            };

            task.AddHierarchyItem();

            task.Navigate += task_Navigate;
            return task;
        }
        private CompilerError ParseError(string error)
        {
            string message = error.Replace("ERROR:", string.Empty).Replace("Error:", string.Empty);
            int index = message.IndexOf(':');
            int line = 0;

            if (index > -1)
            {
                int start = message.LastIndexOf(' ', index);
                if (start > -1)
                {
                    int length = index - start - 1;
                    string part = message.Substring(start + 1, length);
                    int.TryParse(part, out line);
                }
            }

            CompilerError result = new CompilerError()
            {
                Message = "CoffeeScript: " + message,
                FileName = Document.FilePath,
                Line = line,
            };

            return result;
        }
        private bool WriteFile(string content, string fileName, bool fileExist, bool fileWritten)
        {
            try
            {
                if (fileExist || (!fileExist && CanWriteToDisk(content)))
                {
                    using (StreamWriter writer = new StreamWriter(fileName, false, new UTF8Encoding(true)))
                    {
                        writer.Write(content);
                        fileWritten = true;
                    }
                }
            }
            catch (Exception ex)
            {
                var error = new CompilerError
                {
                    FileName = Document.FilePath,
                    Column = 0,
                    Line = 0,
                    Message = "Could not write to " + Path.GetFileName(fileName)
                };

                CreateTask(error);

                Logger.Log(ex);
            }

            return fileWritten;
        }
        protected void CreateTask(CompilerError error)
        {
            ErrorTask task = new ErrorTask()
            {
                Line = error.Line,
                Column = error.Column,
                ErrorCategory = TaskErrorCategory.Error,
                Category = TaskCategory.Html,
                Document = error.FileName,
                Priority = TaskPriority.Low,
                Text = error.Message,
            };

            task.AddHierarchyItem();

            task.Navigate += task_Navigate;
            _provider.Tasks.Add(task);
        }
        private ErrorTask CreateTask(CompilerError error)
        {
            ErrorTask task = new ErrorTask()
            {
                Line = error.Line,
                Column = error.Column,
                ErrorCategory = GetOutputLocation(),
                Category = TaskCategory.Html,
                Document = error.FileName,
                Priority = TaskPriority.Low,
                Text = error.Message,
            };

            task.AddHierarchyItem();

            task.Navigate += task_Navigate;
            return task;
        }