Пример #1
0
        /// <summary>
        /// Rebuilds the entire database
        /// </summary>
        /// <param name="project"></param>
        private void DoRebuild(ILuaIntellisenseProject project)
        {
            DoClear();

            DoLoadStandardLibrary();

            lock (this)
            {
                // use default or user-supplied method for script registration(s)

                if (m_broker.CustomScriptRegistrationHandler != null)
                {
                    var documents = new List <ILuaIntellisenseDocument>();

                    m_broker.CustomScriptRegistrationHandler(m_stdLibs, ref m_scripts, ref documents);

                    foreach (var document in documents)
                    {
                        ParseScript(document);
                    }
                }
                else
                {
                    foreach (ILuaIntellisenseDocument document in project.AllDocuments)
                    {
                        RegisterScript(document, m_stdLibs);
                        ParseScript(document);
                    }
                }
            }
        }
Пример #2
0
        public void ProjectOpened(ILuaIntellisenseProject project)
        {
            m_project = project;

            foreach (var document in project.OpenDocuments)
                RegisterIntellipromptTipImageHandler(document);

            ProjectModified(m_project);
        }
Пример #3
0
        public void ProjectOpened(ILuaIntellisenseProject project)
        {
            m_project = project;

            foreach (var document in project.OpenDocuments)
            {
                RegisterIntellipromptTipImageHandler(document);
            }

            ProjectModified(m_project);
        }
Пример #4
0
        private static string GetReferenceText(LuatValue.IReference reference, ILuaIntellisenseProject project)
        {
            string fileContents;

            {
                var uri             = new Uri(reference.Path);
                var document        = project[uri];
                var useOpenDocument =
                    (document != null) &&
                    (!string.IsNullOrEmpty(document.Contents));

                try
                {
                    fileContents =
                        useOpenDocument
                            ? document.Contents
                            : System.IO.File.ReadAllText(uri.LocalPath);
                }
                catch (Exception ex)
                {
                    fileContents = string.Empty;
                    ex.ToString();
                }

                fileContents = fileContents.Replace("\r\n", "\n");
            }

            if (string.IsNullOrEmpty(fileContents))
            {
                return(reference.DisplayText);
            }

            int lineStart, lineEnd;

            for (lineStart = reference.TextRange.StartOffset; lineStart > 0; --lineStart)
            {
                if (fileContents[lineStart] == '\n')
                {
                    ++lineStart;
                    break;
                }
            }

            for (lineEnd = reference.TextRange.StartOffset; lineEnd < fileContents.Length; ++lineEnd)
            {
                if (fileContents[lineEnd] == '\n')
                {
                    break;
                }
            }

            return(fileContents.Substring(lineStart, lineEnd - lineStart));
        }
Пример #5
0
        public static void RegisterProject(ILuaIntellisenseProject project, LuatTable stdLibs, ref List<LuatScript> scripts, ref List<ILuaIntellisenseDocument> documents)
        {
            if (project == null)
                return;

            var allDocuments = new List<ILuaIntellisenseDocument>(project.AllDocuments);
            documents.AddRange(allDocuments);

            foreach (var document in allDocuments)
            {
                var script = CreateLuatScript(document);
                script.Table.SetMetadataIndexTable(stdLibs);
                AddSledSpecificFunctions(script.Table);
                scripts.Add(script);
            }
        }
Пример #6
0
        public void ProjectModified(ILuaIntellisenseProject project)
        {
            if (project != m_project)
                return;

            if (project == null)
            {
                Database.Clear();
                Database.LoadStandardLibrary();
            }
            else
            {
                Database.Rebuild(project);
            }

            TaskQueue.AddTask(ReparseOpenDocuments, TaskQueue.Thread.UI);
        }
Пример #7
0
        public void ProjectModified(ILuaIntellisenseProject project)
        {
            if (project != m_project)
            {
                return;
            }

            if (project == null)
            {
                Database.Clear();
                Database.LoadStandardLibrary();
            }
            else
            {
                Database.Rebuild(project);
            }

            TaskQueue.AddTask(ReparseOpenDocuments, TaskQueue.Thread.UI);
        }
Пример #8
0
        public static void RegisterProject(ILuaIntellisenseProject project, LuatTable stdLibs, ref List <LuatScript> scripts, ref List <ILuaIntellisenseDocument> documents)
        {
            if (project == null)
            {
                return;
            }

            var allDocuments = new List <ILuaIntellisenseDocument>(project.AllDocuments);

            documents.AddRange(allDocuments);

            foreach (var document in allDocuments)
            {
                var script = CreateLuatScript(document);
                script.Table.SetMetadataIndexTable(stdLibs);
                AddSledSpecificFunctions(script.Table);
                scripts.Add(script);
            }
        }
Пример #9
0
 /// <summary>
 /// Queues a reload of the entire database
 /// </summary>
 /// <param name="project"></param>
 public void Rebuild(ILuaIntellisenseProject project)
 {
     m_taskQueue.AddTask(() => DoRebuild(project), TaskQueue.Thread.Worker);
 }
Пример #10
0
        /// <summary>
        /// Rebuilds the entire database
        /// </summary>
        /// <param name="project"></param>
        private void DoRebuild(ILuaIntellisenseProject project)
        {
            DoClear();

            DoLoadStandardLibrary();

            lock (this)
            {
                // use default or user-supplied method for script registration(s)

                if (m_broker.CustomScriptRegistrationHandler != null)
                {
                    var documents = new List<ILuaIntellisenseDocument>();

                    m_broker.CustomScriptRegistrationHandler(m_stdLibs, ref m_scripts, ref documents);

                    foreach (var document in documents)
                        ParseScript(document);
                }
                else
                {
                    foreach (ILuaIntellisenseDocument document in project.AllDocuments)
                    {
                        RegisterScript(document, m_stdLibs);
                        ParseScript(document);
                    }
                }
            }
        }
Пример #11
0
        private static string GetReferenceText(LuatValue.IReference reference, ILuaIntellisenseProject project)
        {
            string fileContents;
            {
                var uri = new Uri(reference.Path);
                var document = project[uri];
                var useOpenDocument =
                    (document != null) &&
                    (!string.IsNullOrEmpty(document.Contents));

                try
                {
                    fileContents =
                        useOpenDocument
                            ? document.Contents
                            : System.IO.File.ReadAllText(uri.LocalPath);
                }
                catch (Exception ex)
                {
                    fileContents = string.Empty;
                    ex.ToString();
                }

                fileContents = fileContents.Replace("\r\n", "\n");
            }

            if (string.IsNullOrEmpty(fileContents))
                return reference.DisplayText;

            int lineStart, lineEnd;

            for (lineStart = reference.TextRange.StartOffset; lineStart > 0; --lineStart)
            {
                if (fileContents[lineStart] == '\n')
                {
                    ++lineStart;
                    break;
                }
            }

            for (lineEnd = reference.TextRange.StartOffset; lineEnd < fileContents.Length; ++lineEnd)
            {
                if (fileContents[lineEnd] == '\n')
                {
                    break;
                }
            }

            return fileContents.Substring(lineStart, lineEnd - lineStart);
        }
Пример #12
0
 /// <summary>
 /// Queues a reload of the entire database
 /// </summary>
 /// <param name="project"></param>
 public void Rebuild(ILuaIntellisenseProject project)
 {
     m_taskQueue.AddTask(() => DoRebuild(project), TaskQueue.Thread.Worker);
 }