private static IEnumerable <SledSyntaxCheckerEntry> CheckString(string value, SledSyntaxCheckerVerbosity verbosity, object userData)
        {
            var errors = new List <SledSyntaxCheckerEntry>();

            try
            {
                using (var syntaxChecker = SledLuaSyntaxCheckerFactory.Create())
                {
                    try
                    {
                        var success = syntaxChecker.CheckBuffer(value);
                        if (!success)
                        {
                            var errorString = syntaxChecker.Error;
                            if (!string.IsNullOrEmpty(errorString))
                            {
                                var plugin = ((SledLuaSyntaxCheckerService)userData).m_luaLanguagePlugin;

                                // Fix up error string
                                var colon = errorString.IndexOf(':');
                                if (colon != -1)
                                {
                                    colon = errorString.IndexOf(':', colon + 1);
                                    if (colon != -1)
                                    {
                                        errorString = errorString.Substring(colon + 1).Trim();
                                    }
                                }

                                var errorEntry = new SledSyntaxCheckerEntry(plugin, null, 1, errorString);
                                errors.Add(errorEntry);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (verbosity > SledSyntaxCheckerVerbosity.None)
                        {
                            SledOutDevice.OutLine(
                                SledMessageType.Error,
                                "{0}: Exception syntax checking string \"{1}\": {2}",
                                typeof(SledLuaSyntaxCheckerService), value, ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "{0}: Exception creating syntax checker: {1}",
                    typeof(SledLuaSyntaxCheckerService), ex.Message);
            }

            return(errors);
        }
            public void WorkCallback()
            {
                if (m_shouldCancel.Value)
                {
                    return;
                }

                try
                {
                    using (var syntaxChecker = SledLuaSyntaxCheckerFactory.Create())
                    {
                        try
                        {
                            if (m_shouldCancel.Value)
                            {
                                return;
                            }

                            var success = syntaxChecker.CheckFile(new Uri(m_file.AbsolutePath));
                            if (success)
                            {
                                return;
                            }

                            // Grab error from actual syntax checker
                            var errorString = syntaxChecker.Error;
                            if (string.IsNullOrEmpty(errorString))
                            {
                                return;
                            }

                            var plugin = ((SledLuaSyntaxCheckerService)m_userData).m_luaLanguagePlugin;
                            var errors = (List <SledSyntaxCheckerEntry>)Errors;

                            var line = -1;

                            // Try and find the file name in the string. The full path
                            // can become truncated so looking for it may be faulty.
                            var iPos = errorString.IndexOf(m_file.Name, StringComparison.Ordinal);
                            if (iPos != -1)
                            {
                                // Now look for the first colon following the file name
                                var iColon = errorString.IndexOf(':', iPos + m_file.Name.Length);
                                if (iColon != -1)
                                {
                                    // Strip down to line number & error
                                    errorString = errorString.Remove(0, iColon + 1);

                                    // Find next colon to get line number from error
                                    iColon = errorString.IndexOf(':');
                                    if (iColon != -1)
                                    {
                                        int iLine;
                                        if (int.TryParse(errorString.Substring(0, iColon), out iLine))
                                        {
                                            line = iLine;
                                        }

                                        errorString = errorString.Substring(iColon + 1).Trim();
                                    }
                                }
                            }

                            errors.Add(new SledSyntaxCheckerEntry(plugin, m_file, line, errorString));

                            if (m_verbosity > SledSyntaxCheckerVerbosity.Overall)
                            {
                                SledOutDevice.OutLine(
                                    SledMessageType.Info,
                                    "[Lua] Syntax error in {0} on line {1}: {2}",
                                    m_file.Name, line, errorString);
                            }
                        }
                        catch (Exception ex)
                        {
                            if (m_verbosity > SledSyntaxCheckerVerbosity.None)
                            {
                                SledOutDevice.OutLine(
                                    SledMessageType.Error,
                                    "{0}: Exception syntax checking \"{1}\": {2}",
                                    this, m_file.AbsolutePath, ex.Message);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Error,
                        "{0}: Exception creating Lua syntax checker: {1}",
                        this, ex.Message);
                }
            }