private void RemoteTargetGlobalAdd(SledLuaVarGlobalType variable)
        {
            if (Collection.Count > 0)
            {
                Collection[0].ValidationBeginning();
            }

            // Add any locations
            LuaVarLocationService.AddLocations(variable);

            // Do any filtering
            variable.Visible = !LuaVariableFilterService.IsVariableFiltered(variable);

            // Figure out where to insert
            if (!LookingUp)
            {
                Collection[0].Variables.Add(variable);
            }
            else
            {
                if (ListInsert.Count > 0)
                {
                    ListInsert[0].Globals.Add(variable);
                }
                else
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Error,
                        "[SledLuaGlobalVariableService] " +
                        "Failed to add variable: {0}",
                        variable.Name);
                }
            }
        }
Esempio n. 2
0
        private static void VerifyScmpAttribute(Shared.Scmp.IScmp scmp, string attributeAsString)
        {
            var attributes =
                scmp.GetType().GetCustomAttributes(true);

            var bHasAttr =
                attributes.Cast <Attribute>().Any(
                    attr => string.Compare(
                        attr.ToString(),
                        attributeAsString,
                        true) == 0);

            if (bHasAttr)
            {
                return;
            }

            SledOutDevice.OutLine(
                SledMessageType.Warning,
                "[SledDebugService] I just packed or unpacked something " +
                "[{0}] that didn't have the right attribute [{1}]!",
                scmp.GetType().Name, attributeAsString);

            if (System.Diagnostics.Debugger.IsAttached)
            {
                System.Diagnostics.Debugger.Break();
            }
        }
Esempio n. 3
0
        private void NetPluginDataReadyEvent(object sender, byte[] buffer)
        {
            // Process any items lingering in the buffer
            ProcessScmpRecvBuffer(sender);

            LogScmp(ScmpLogType.Receive, buffer);

            try
            {
                // This shouldn't throw now that we catch the problem in Dtlib but lets at least
                // stop annoying people with the stupid crashes from not handling the exception.
                m_recvBuf.Append(buffer);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                SledOutDevice.OutLine(SledMessageType.Error, ex.Message);

                // Can't continue so force disconnect
                Disconnect();

                return;
            }

            // Process any new items in the buffer
            ProcessScmpRecvBuffer(sender);
        }
Esempio n. 4
0
        private static void CreateScmpLoggingFile()
        {
            if (!s_bScmpLoggingEnabled)
            {
                return;
            }

            lock (s_hScmpFileLock)
            {
                try
                {
                    // Find a file that doesn't exist
                    s_hScmpFile = "ScmpLog" + s_iScmpFileLogNum++ + ".log";
                    while (File.Exists(s_hScmpFile))
                    {
                        s_hScmpFile = "ScmpLog" + s_iScmpFileLogNum++ + ".log";
                    }

                    using (var stream = File.Create(s_hScmpFile))
                    {
                        stream.Flush();
                        stream.Close();
                    }
                }
                catch (Exception ex)
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Error,
                        "Failed to create SCMP logging file: {0}",
                        ex.Message);
                }
            }
        }
Esempio n. 5
0
            public static ILuaCompiler Create()
            {
                try
                {
                    if (s_luaVersionService == null)
                    {
                        s_luaVersionService = SledServiceInstance.TryGet <ISledLuaLuaVersionService>();
                    }

                    if (s_luaVersionService == null)
                    {
                        return(new Sce.Lua.Utilities.Lua51.x86.LuaCompiler());
                    }

                    switch (s_luaVersionService.CurrentLuaVersion)
                    {
                    case LuaVersion.Lua51: return(new Sce.Lua.Utilities.Lua51.x86.LuaCompiler());

                    case LuaVersion.Lua52: return(new Sce.Lua.Utilities.Lua52.x86.LuaCompiler());

                    default: throw new NullReferenceException("Unknown Lua version!");
                    }
                }
                catch (Exception ex)
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Error,
                        "{0}: Exception creating Lua compiler: {1}",
                        typeof(SledLuaCompilerServiceFactory), ex.Message);

                    return(null);
                }
            }
Esempio n. 6
0
        public static SledLuaVarLookUpType FromCustomValues(SledLuaVarScopeType scope, SledLuaVarLookUpContextType context, IList <SledLuaVarNameTypePairType> namesAndTypes)
        {
            try
            {
                var lookUp =
                    new DomNode(SledLuaSchema.SledLuaVarLookUpType.Type)
                    .As <SledLuaVarLookUpType>();

                lookUp.Scope   = scope;
                lookUp.Context = context;

                foreach (var nameAndType in namesAndTypes)
                {
                    lookUp.NamesAndTypes.Add((SledLuaVarNameTypePairType)nameAndType.Clone());
                }

                lookUp.Index      = 0;
                lookUp.StackLevel = 0;

                return(lookUp);
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLineDebug(
                    SledMessageType.Error,
                    "{0}: Exception in FromCustomValues: {1}",
                    typeof(SledLuaVarLookUpType), ex.Message);

                return(null);
            }
        }
Esempio n. 7
0
        private string GetUriRelPath(IResource resource)
        {
            if (resource == null)
            {
                return(string.Empty);
            }

            try
            {
                return
                    (SledUtil.GetRelativePath(
                         resource.Uri.LocalPath,
                         m_projectService.AssetDirectory));
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "Exception getting relative " +
                    "path for Uri \"{0}\": {1}",
                    resource.Uri, ex.Message);

                return(resource.Uri.LocalPath);
            }
        }
Esempio n. 8
0
        private void SubFormFindAndReplaceEvent(object sender, SledFindAndReplaceEventArgs e)
        {
            // Run find or replace event
            ((SledFindAndReplaceService)m_findAndReplaceService.Get).Run(e);

            var bMakeSound = true;

            // Check result
            switch (e.Result)
            {
            // Do nothing
            case SledFindAndReplaceResult.Success:
                bMakeSound = false;
                break;

            // No results were found
            case SledFindAndReplaceResult.NothingFound:
                SledOutDevice.OutLine(SledMessageType.Info, Localization.SledFindAndReplaceErrorNothingFound);
                break;

            // No documents to search in
            case SledFindAndReplaceResult.NothingToSearch:
                SledOutDevice.OutLine(SledMessageType.Info, Localization.SledFindAndReplaceErrorNoDocsToSearch);
                break;

            default: NotifyMissingResultProperty(this); break;
            }

            // Beep if not successful
            if (bMakeSound)
            {
                // Beep like VS does
                System.Media.SystemSounds.Exclamation.Play();
            }
        }
Esempio n. 9
0
        private void UpdateRemoteTargetComboBox()
        {
            try
            {
                // Add all targets to combo box
                m_remoteTargetComboBox.Items.Clear();
                foreach (var target in m_lstTargets)
                {
                    m_remoteTargetComboBox.Items.Add(target);
                }

                // Select the proper target
                var selTarget = SelectedTarget;
                if (selTarget != null)
                {
                    m_remoteTargetComboBox.SelectedItem = selTarget;
                }
                else if (m_remoteTargetComboBox.Items.Count > 0)
                {
                    m_remoteTargetComboBox.SelectedItem = m_remoteTargetComboBox.Items[0];
                }
                else
                {
                    m_remoteTargetComboBox.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    SledUtil.TransSub(Localization.SledRemoteTargetErrorUpdatingComboBox, ex.Message));
            }
        }
Esempio n. 10
0
        private static ISledLuaVarBaseType FindInsertion(ISledLuaVarBaseType adder, ISledLuaVarBaseType addee)
        {
            try
            {
                var adderPiecesCount = adder.TargetHierarchy.Count + 1;

                var pieces = new List <string>();
                {
                    pieces.AddRange(addee.TargetHierarchy.Select(kv => kv.Name));
                    pieces.Add(addee.DisplayName);
                }

                // Do we even need to try and find this item?
                return
                    (pieces.Count <= (adderPiecesCount + 1)
                        ? adder
                        : FindInsertionHelper(adder, adderPiecesCount, pieces));
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "[SledLuaVarWatchList] Exception finding insertion " +
                    "point with adder \"{0}\" and addee \"{1}\": {2}",
                    adder.Name, addee.Name, ex.Message);

                return(null);
            }
        }
Esempio n. 11
0
        private void HeartbeatTimerTick(object sender, EventArgs e)
        {
            if (!m_debugService.IsConnected)
            {
                return;
            }

            // Send heartbeat message
            m_debugService.SendScmp(new Heartbeat(m_debugService.SledPluginId));

            // Calculate time since last update
            var span = DateTime.Now.Subtract(m_lastRecvTime);

            if (span.Seconds <= TimeOutSec)
            {
                return;
            }

            // Start showing we're getting no response if audible
            if (m_bAudible)
            {
                SledOutDevice.OutLine(SledMessageType.Error, Localization.SledTargetHeartBeatNoResponse);
            }

            if (m_iLostCounter >= 2)
            {
                // Disconnect if heartbeat is allowed to control the connection
                if (m_bControlConnection)
                {
                    ((SledDebugService)m_debugService).Disconnect();
                }
            }

            m_iLostCounter++;
        }
Esempio n. 12
0
        /// <summary>
        /// Determine if a FileSystemInfo object is a directory
        /// </summary>
        /// <param name="fsi">FileSystemInfo object</param>
        /// <returns>True iff a directory</returns>
        public static bool IsDirectory(this FileSystemInfo fsi)
        {
            if (fsi == null)
            {
                return(false);
            }

            try
            {
                if (fsi is DirectoryInfo)
                {
                    return(true);
                }

                return((fsi.Attributes & FileAttributes.Directory) == FileAttributes.Directory);
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "{0}: Exception checking if item is a directory: {1}",
                    typeof(FileSystemEventArgs).Name, ex.Message);

                return(false);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Reads a DomObject from the given stream
        /// </summary>
        /// <param name="stream">Stream to read</param>
        /// <returns>Dom tree that was read</returns>
        public override DomObject Read(Stream stream)
        {
            // Read project settings
            DomObject rootProjDomObject = ReadInternal(stream);

            // Try and read temporary settings file
            DomObject rootTempDomObject = null;

            try
            {
                // Path to project file
                string szAbsProjPath = ((FileStream)stream).Name;
                // Path to hidden project temporary settings file
                string szAbsTempPath = Path.ChangeExtension(szAbsProjPath, m_extTmp);

                // Read from disk if file exists
                if (File.Exists(szAbsTempPath))
                {
                    using (FileStream file = new FileStream(szAbsTempPath, FileMode.Open, FileAccess.Read))
                    {
                        rootTempDomObject = ReadInternal(file);
                    }
                }
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(SledMessageType.Error, SledUtil.TransSub(Localization.SledSharedLoadTempSettingsFileError, new string[] { ex.Message }));
            }

            // Combine project file with temporary settings file
            Combine(rootProjDomObject, rootTempDomObject);

            return(rootProjDomObject);
        }
Esempio n. 14
0
        private void AuthenticateVersion()
        {
            var ver       = GetScmpBlob <Shared.Scmp.Version>();
            var verNumber = Shared.Scmp.ScmpExtension.ToInt32(ver);

            var appVer       = new Version(Application.ProductVersion);
            var appVerNumber = appVer.ToInt32();

            var minVerNumber = m_minVersion.ToInt32();

            // Allow a range of versions
            if ((verNumber >= minVerNumber) && (verNumber <= appVerNumber))
            {
                // Send success message
                SendScmp(new Shared.Scmp.Success(SledPluginId));
            }
            else
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    SledUtil.TransSub(
                        Localization.SledRemoteTargetErrorVersionMismatch,
                        appVer.Major, appVer.Minor,
                        m_minVersion.Major, m_minVersion.Minor,
                        ver.Major, ver.Minor));

                // Send failure message
                SendScmp(new Shared.Scmp.Failure(SledPluginId));
            }
        }
Esempio n. 15
0
        private static void LogScmp(ScmpLogType type, byte[] buffer)
        {
            if (!s_bScmpLoggingEnabled)
            {
                return;
            }

            lock (s_hScmpFileLock)
            {
                try
                {
                    if (string.IsNullOrEmpty(s_hScmpFile))
                    {
                        throw new NullReferenceException("SCMP log file is null or empty!");
                    }

                    using (var stream = File.Open(s_hScmpFile, FileMode.Append, FileAccess.Write))
                    {
                        stream.WriteByte(type == ScmpLogType.Receive ? (byte)1 : (byte)0);
                        stream.Write(buffer, 0, buffer.Length);
                        stream.Flush();
                        stream.Close();
                    }
                }
                catch (Exception ex)
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Error,
                        "SCMP logging error: {0}",
                        ex.Message);
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Obtain a particular type from the MEF composition container (if it's in there)
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <returns>Type from the MEF composition container or null</returns>
        public static T Get <T>() where T : class
        {
            try
            {
                var container = SledServiceReferenceCompositionContainer.Get;
                if (container == null)
                {
                    throw new NullReferenceException("container is null");
                }

                var lazy = container.GetExport <T>();
                if (lazy == null)
                {
                    throw new NullReferenceException("lazy is null");
                }

                return(lazy.Value);
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "{0}: Type \"{1}\" does not exist in the CompositionContainer! Exception: {2}",
                    typeof(SledServiceInstance), typeof(T), ex.Message);

                return(null);
            }
        }
Esempio n. 17
0
        private void RestoreTopItem()
        {
            if (m_topItem == null)
            {
                return;
            }

            try
            {
                TreeListViewAdapter.TopItem = m_topItem;
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "Exception restoring TopItem " +
                    "on TreeListView \"{0}\": {1}",
                    TreeListView.Name, ex.Message);
            }
            finally
            {
                m_topItem     = null;
                m_topItemHash = 0;
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Obtain a particular type from the MEF composition container (if it's in there)
        /// <remarks>This method doesn't report exceptions from types that don't exist.</remarks>
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <returns>Type from the MEF composition container or null</returns>
        public static T TryGet <T>() where T : class
        {
            try
            {
                var container = SledServiceReferenceCompositionContainer.Get;
                if (container == null)
                {
                    throw new NullReferenceException("container is null");
                }

                var lazy = container.GetExport <T>();
                if (lazy == null)
                {
                    throw new NullReferenceException("lazy is null");
                }

                return(lazy.Value);
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLineDebug(
                    SledMessageType.Warning,
                    "{0}: Exception in TryGet<{1}>(): {2}",
                    typeof(SledServiceInstance), typeof(T), ex.Message);

                return(null);
            }
        }
Esempio n. 19
0
        private void SendNetVarFilterState(bool bForce)
        {
            if (!m_debugService.IsConnected)
            {
                return;
            }

            // If no variable filters are active and !bForce then return
            if (!m_globalVariableFilterState.FiltersActive &&
                !m_localVariableFilterState.FiltersActive &&
                !m_upvalueVariableFilterState.FiltersActive &&
                !m_envVarVariableFilterState.FiltersActive &&
                !bForce)
            {
                return;
            }

            SledOutDevice.OutLine(SledMessageType.Info, Localization.SledLuaSendNetVarFilterState);

            //// Send message to clear filter types/name list
            //SledTargetConnection.SendString("{filterc:c}");

            // Send all lua type filters
            SendNetVarFilterTypesInternal(m_globalVariableFilterState.NetFilterTypes, 'g');
            SendNetVarFilterTypesInternal(m_localVariableFilterState.NetFilterTypes, 'l');
            SendNetVarFilterTypesInternal(m_upvalueVariableFilterState.NetFilterTypes, 'u');
            SendNetVarFilterTypesInternal(m_envVarVariableFilterState.NetFilterTypes, 'e');

            // Send all name filters
            SendNetVarFilterNamesInternal(m_globalVariableFilterState.NetFilterNames, 'g');
            SendNetVarFilterNamesInternal(m_localVariableFilterState.NetFilterNames, 'l');
            SendNetVarFilterNamesInternal(m_upvalueVariableFilterState.NetFilterNames, 'u');
            SendNetVarFilterNamesInternal(m_envVarVariableFilterState.NetFilterNames, 'e');
        }
Esempio n. 20
0
        private bool DoSync(IEnumerable <IResource> resources)
        {
            if (!CanUseSourceControl)
            {
                return(false);
            }

            using (new ProgressBarWrapper("Syncing..."))
            {
                foreach (var resource in resources)
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Info,
                        "{0}: Syncing: {1}",
                        SourceControlText, GetUriRelPath(resource));

                    if (!SourceControlService.IsSynched(resource.Uri))
                    {
                        SourceControlService.GetLatestVersion(resource.Uri);
                    }
                }
            }

            return(true);
        }
        /// <summary>
        /// Add the files from the specified folders to the project
        /// </summary>
        /// <param name="absFolderPaths">Folders to search in</param>
        /// <param name="searchOption">Whether to recursively search or not</param>
        /// <param name="extensions">File extensions to grab</param>
        /// <param name="folder">Folder that should contain the files</param>
        public void AddFilesInFolders(IEnumerable <string> absFolderPaths, SearchOption searchOption, IEnumerable <string> extensions, SledProjectFilesFolderType folder)
        {
            foreach (var absFolderPath in absFolderPaths)
            {
                try
                {
                    var dir = new DirectoryInfo(absFolderPath);
                    if (!dir.Exists)
                    {
                        continue;
                    }

                    Func <FileInfo, bool> filePredicate =
                        fi =>
                    {
                        if (m_isHidden(fi))
                        {
                            return(false);
                        }

                        return(extensions == null || extensions.Any(ext => string.Compare(ext, fi.Extension, StringComparison.OrdinalIgnoreCase) == 0));
                    };

                    var tree = dir.GetFilesAndDirectoriesTree(searchOption, filePredicate, m_dirPredicate);
                    AddTree(m_projectService, folder, tree, null);
                }
                catch (Exception ex)
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Error,
                        "{0}: Exception finding files in directory {1}: {2}",
                        this, absFolderPaths, ex.Message);
                }
            }
        }
        void IInitializable.Initialize()
        {
            if (IsInitialized)
            {
                return;
            }

            var networkPlugins = SledServiceInstance.GetAll <ISledNetworkPlugin>();

            m_lstPlugins.Clear();

            using (new SledOutDevice.BreakBlock())
            {
                foreach (var netPlugin in networkPlugins)
                {
                    // Add plugin to list
                    m_lstPlugins.Add(netPlugin);

                    // Report the plugin was found
                    SledOutDevice.OutLine(
                        SledMessageType.Info,
                        SledUtil.TransSub(Localization.SledNetworkPluginLoaded, netPlugin.Protocol, netPlugin.Name));
                }
            }

            try
            {
                Initialized.Raise(this, EventArgs.Empty);
            }
            finally
            {
                IsInitialized = true;
            }
        }
Esempio n. 23
0
        public object Copy()
        {
            var selectedText = Editor.Selection;

            // Since our Insert() method does not use the data object,
            // but instead requires the Windows system clipboard to be
            // set, we need to set the system clipboard ourselves
            // if StandardEditCommands does not.
            try
            {
                if (!StandardEditCommands.UseSystemClipboard)
                {
                    Clipboard.SetText(selectedText);
                }
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "{0}: Clipboard error copying text from \"{1}\": {2}",
                    this, Uri.LocalPath, ex.Message);
            }

            var data = new DataObject(selectedText);

            return(data);
        }
Esempio n. 24
0
        private void WriteToDisk()
        {
            if (!m_bDirty)
            {
                return;
            }

            try
            {
                if (m_collection == null)
                {
                    return;
                }

                if (m_collection.ProfileInfo.Count <= 0)
                {
                    return;
                }

                var schemaLoader =
                    SledServiceInstance.Get <SledSharedSchemaLoader>();

                if (schemaLoader == null)
                {
                    return;
                }

                var projDir =
                    m_projectService.Get.ProjectDirectory;

                var filePath =
                    Path.Combine(
                        projDir + Path.DirectorySeparatorChar,
                        m_collection.Name + ".xml");

                var uri = new Uri(filePath);

                using (var stream =
                           new FileStream(uri.LocalPath, FileMode.Create, FileAccess.Write))
                {
                    var writer =
                        new DomXmlWriter(schemaLoader.TypeCollection);

                    writer.Write(m_collection.DomNode, stream, uri);
                }
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "[SledLuaProfilerService] Failure to " +
                    "save profiler data to disk: {0}",
                    ex.Message);
            }
            finally
            {
                m_bDirty = false;
            }
        }
Esempio n. 25
0
        private void NetPluginUnHandledExceptionEvent(object sender, Exception ex)
        {
            SledOutDevice.OutLine(SledMessageType.Error, ex.Message);

            Error.Raise(this, new SledDebugServiceEventArgs(m_curTarget, new[] { ex.Message }));

            NetPluginDisconnectedEvent(sender, m_curTarget);
        }
        private void TimerTick(object sender, EventArgs e)
        {
            SledOutDevice.OutLine(SledMessageType.Info,
                                  Localization.SledTargetConnectionErrorNegotiating);

            // Timed out so disconnect
            ((SledDebugService)m_debugService).Disconnect();
        }
        private void ThreadRun()
        {
            m_threadRunning = true;

            while (m_threadRunning)
            {
                try
                {
                    Thread.Sleep(100);

                    Args arg;
                    lock (m_lock)
                    {
                        if (m_queue.Count <= 0)
                        {
                            continue;
                        }

                        arg = m_queue.Dequeue();
                    }

                    if (arg == null)
                    {
                        continue;
                    }

                    var verbosity = Verbosity;
                    var results   = arg.Function(arg.Files, verbosity, arg.UserData, m_cancel).ToList();

                    // Associate results to their project file
                    var filesAndResults = new Dictionary <SledProjectFilesFileType, List <SledLanguageParserResult> >();
                    foreach (var file in arg.Files)
                    {
                        var localFile = file;

                        var fileResults = new List <SledLanguageParserResult>(results.Where(r => r.File == localFile));
                        filesAndResults.Add(localFile, fileResults);
                    }

                    m_syncContext.Post(
                        obj =>
                    {
                        if (m_threadRunning)
                        {
                            AnnounceResults(arg.Plugin, filesAndResults, arg.UserData);
                        }
                    }, null);
                }
                catch (Exception ex)
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Error,
                        "{0}: Unhandled exception in SLED language parser thread: {1}",
                        this, ex.Message);
                }
            }
        }
        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);
        }
Esempio n. 29
0
        /// <summary>
        /// Go to a specific word on a line in a file
        /// </summary>
        /// <param name="sd">document</param>
        /// <param name="szWord">word to find</param>
        /// <param name="iLine">line in document</param>
        /// <param name="iOccurence">if the word occurs multiple times on a line then this represents which occurence</param>
        /// <param name="bUseCsi">whether to use a "current statement indicator" or not</param>
        public void GotoLineWord(ISledDocument sd, string szWord, int iLine, int iOccurence, bool bUseCsi)
        {
            if (sd == null)
            {
                return;
            }

            // Bring this files tab to the front
            m_controlHostService.Show(sd.Control);

            try
            {
                if (iOccurence < 0)
                {
                    // Selecting whole line
                    sd.Editor.SelectLine(iLine);
                }
                else
                {
                    // Selecting part of line

                    // Try and select the word "name" on the line
                    var szLine = sd.Editor.GetLineText(iLine);

                    var iBeg = -1;
                    for (var i = 0; i < iOccurence; i++)
                    {
                        iBeg = szLine.IndexOf(szWord, iBeg + 1);
                    }

                    var iEnd = iBeg + szWord.Length - 1;

                    // Select
                    sd.Editor.SelectLine(iLine, iBeg, iEnd);
                }

                // Scroll to line
                sd.Editor.CurrentLineNumber = iLine;

                if (bUseCsi)
                {
                    sd.Editor.CurrentStatement(iLine, true);
                }
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    SledUtil.TransSub(
                        Localization.SledGotoLineError1,
                        iLine, Path.GetFileName(sd.Uri.LocalPath), ex.Message));
            }

            // Now force focus to actually see the cursor on the newly selected line
            sd.Control.Focus();
        }
Esempio n. 30
0
        public void Initialize()
        {
            m_canConnect = false;

            SledOutDevice.OutLine(
                SledMessageType.Info,
                m_canConnect
                    ? "SLED usage statistics enabled!"
                    : "SLED usage statistics disabled!");
        }