private CompletionDataList GetMembersOfItem(string itemFullName)
        {
            CProject project = Document.Project as CProject;

            if (project == null)
            {
                return(null);
            }

            ProjectInformation info = ProjectInformationManager.Instance.Get(project);
            CompletionDataList list = new CompletionDataList();

            LanguageItem container = null;

            string currentFileName = Document.FileName;
            bool   in_project      = false;

            foreach (LanguageItem li in info.Containers())
            {
                if (itemFullName == li.FullName)
                {
                    container  = li;
                    in_project = true;
                }
            }

            if (!in_project && info.IncludedFiles.ContainsKey(currentFileName))
            {
                foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFileName])
                {
                    foreach (LanguageItem li in fi.Containers())
                    {
                        if (itemFullName == li.FullName)
                        {
                            container = li;
                        }
                    }
                }
            }

            if (container == null)
            {
                return(null);
            }

            if (in_project)
            {
                AddItemsWithParent(list, info.AllItems(), container);
            }
            else
            {
                foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFileName])
                {
                    AddItemsWithParent(list, fi.AllItems(), container);
                }
            }

            return(list);
        }
Ejemplo n.º 2
0
        private LanguageItem GetLanguageItemAt(DocumentLocation location)
        {
            CProject project = Document.Project as CProject;
            string   token   = GetTokenAt(location);

            if (project != null && !string.IsNullOrEmpty(token))
            {
                ProjectInformation info = ProjectInformationManager.Instance.Get(project);
                return(info.AllItems().FirstOrDefault(i => i.Name.Equals(token, StringComparison.Ordinal)));
            }

            return(null);
        }
        private CompletionDataProvider GetMembersOfItem(string itemFullName)
        {
            CProject project = Document.Project as CProject;

            if (project == null)
            {
                return(null);
            }

            ProjectInformation     info     = ProjectInformationManager.Instance.Get(project);
            CompletionDataProvider provider = new CompletionDataProvider();

            LanguageItem container = null;

            string currentFileName = Document.FileName;
            bool   in_project      = false;

            foreach (LanguageItem li in info.Containers())
            {
                if (itemFullName == li.FullName)
                {
                    container  = li;
                    in_project = true;
                }
            }

            if (!in_project && info.IncludedFiles.ContainsKey(currentFileName))
            {
                foreach (FileInformation fi in info.IncludedFiles[currentFileName])
                {
                    foreach (LanguageItem li in fi.Containers())
                    {
                        if (itemFullName == li.FullName)
                        {
                            container = li;
                        }
                    }
                }
            }

            if (container == null)
            {
                return(null);
            }

            if (in_project)
            {
                foreach (LanguageItem li in info.AllItems())
                {
                    if (li.Parent != null && li.Parent.Equals(container))
                    {
                        provider.AddCompletionData(new CompletionData(li));
                    }
                }
            }
            else
            {
                foreach (FileInformation fi in info.IncludedFiles[currentFileName])
                {
                    foreach (LanguageItem li in fi.AllItems())
                    {
                        if (li.Parent != null && li.Parent.Equals(container))
                        {
                            provider.AddCompletionData(new CompletionData(li));
                        }
                    }
                }
            }

            return(provider);
        }