protected virtual void OnLuaVariableFilterServiceFiltering(object sender, SledLuaVariableFilterService.FilteringEventArgs e)
        {
            if (e.NodeType != NodeType)
            {
                return;
            }

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

            var objects = new List <TType>();

            foreach (var list in Collection)
            {
                SledDomUtil.GatherAllAs(list.DomNode, objects);
            }

            foreach (var luaVar in objects)
            {
                e.LuaVarsToFilter.Add(luaVar);
            }

            Editor.View = null;
        }
Пример #2
0
        private void SetupCompileAttribute(SledProjectFilesFileType file)
        {
            if (file == null)
            {
                return;
            }

            // Look for a SledLuaCompileAttributeType attribute in file.Attributes
            var iface = SledDomUtil.GetFirstAs <SledLuaCompileAttributeType, SledAttributeBaseType>(file.Attributes);

            // Files' attribute is already set up
            if (iface != null)
            {
                return;
            }

            var domNode = new DomNode(SledLuaSchema.SledLuaCompileAttributeType.Type);

            // Create new attribute
            var attr = domNode.As <SledLuaCompileAttributeType>();

            // Default values
            attr.Name    = m_luaLanguagePlugin.LanguageName;
            attr.Compile = true;

            // Add new attribute to file
            file.Attributes.Add(attr);
        }
        protected virtual IList <string> OnGetMouseHoverOverTokenValues(SledDocumentHoverOverTokenArgs args)
        {
            if (!DebugService.IsConnected)
            {
                return(null);
            }

            var szFullToken = SledLuaUtil.GetFullHoverOvenToken(args);

            if (string.IsNullOrEmpty(szFullToken))
            {
                return(null);
            }

            var variables =
                (from list in Collection
                 let luaVar = SledDomUtil.FindFirstInWhere(list.DomNode, (TType variable) => string.Compare(variable.Name, szFullToken, StringComparison.Ordinal) == 0)
                              where luaVar != null
                              select luaVar).ToList();

            return
                (!variables.Any()
                    ? null
                    : variables.Select(variable => string.Format("{0}: {1}", PopupPrefix, SledUtil.MakeXmlSafe(variable.Value))).ToList());
        }
Пример #4
0
        /// <summary>
        /// Open the project file and remove any duplicates
        /// </summary>
        /// <param name="szAbsPath"></param>
        public static void CleanupProjectFileDuplicates(string szAbsPath)
        {
            if (!File.Exists(szAbsPath))
            {
                return;
            }

            if (SledUtil.IsFileReadOnly(szAbsPath))
            {
                return;
            }

            try
            {
                var schemaLoader = SledServiceInstance.TryGet <SledSharedSchemaLoader>();
                if (schemaLoader == null)
                {
                    return;
                }

                var uri    = new Uri(szAbsPath);
                var reader = new SledSpfReader(schemaLoader);

                var root = reader.Read(uri, false);
                if (root == null)
                {
                    return;
                }

                var lstProjFiles = new List <SledProjectFilesFileType>();

                // Gather up all project files in the project
                SledDomUtil.GatherAllAs(root, lstProjFiles);

                if (lstProjFiles.Count <= 1)
                {
                    return;
                }

                var uniquePaths   = new Dictionary <string, SledProjectFilesFileType>(StringComparer.CurrentCultureIgnoreCase);
                var lstDuplicates = new List <SledProjectFilesFileType>();

                foreach (var projFile in lstProjFiles)
                {
                    if (uniquePaths.ContainsKey(projFile.Path))
                    {
                        lstDuplicates.Add(projFile);
                    }
                    else
                    {
                        uniquePaths.Add(projFile.Path, projFile);
                    }
                }

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

                foreach (var projFile in lstDuplicates)
                {
                    projFile.DomNode.RemoveFromParent();
                }

                var writer = new SledSpfWriter(schemaLoader.TypeCollection);

                // Write changes back to disk
                writer.Write(root, uri, false);
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    SledUtil.TransSub(Localization.SledProjectFilesErrorRemovingDuplicates, ex.Message, szAbsPath));
            }
        }
Пример #5
0
        /// <summary>
        /// Try and obtain project information from a project file on disk
        /// </summary>
        /// <param name="absPath"></param>
        /// <param name="name"></param>
        /// <param name="projectDir"></param>
        /// <param name="assetDir"></param>
        /// <param name="guid"></param>
        /// <param name="files"></param>
        /// <returns></returns>
        public static bool TryGetProjectDetails(
            string absPath,
            out string name,
            out string projectDir,
            out string assetDir,
            out Guid guid,
            out List <string> files)
        {
            name       = null;
            projectDir = null;
            assetDir   = null;
            guid       = Guid.Empty;
            files      = null;

            try
            {
                // ATF 3's DOM makes this so much easier now!

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

                if (schemaLoader == null)
                {
                    return(false);
                }

                var uri    = new Uri(absPath);
                var reader =
                    new SledSpfReader(schemaLoader);

                var root = reader.Read(uri, false);
                if (root == null)
                {
                    return(false);
                }

                var project =
                    root.As <SledProjectFilesType>();

                project.Uri = uri;

                // Pull out project details
                name       = project.Name;
                guid       = project.Guid;
                assetDir   = project.AssetDirectory;
                projectDir = Path.GetDirectoryName(absPath);

                var lstProjFiles =
                    new List <SledProjectFilesFileType>();

                SledDomUtil.GatherAllAs(root, lstProjFiles);

                var assetDirTemp = assetDir;
                files =
                    (from projFile in lstProjFiles
                     let absFilePath =
                         SledUtil.GetAbsolutePath(
                             projFile.Path,
                             assetDirTemp)
                         select absFilePath).ToList();

                return(true);
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "Exception encountered obtaining project " +
                    "details. Project file: \"{0}\". Exception: {1}",
                    absPath, ex.Message);

                return(false);
            }
        }