Beispiel #1
0
        }        // CanParse

        public override ParsedDocument Parse(ProjectDom dom, string fileName, string content)
        {
            ParsedDocument doc = new ParsedDocument(fileName);

            doc.Flags |= ParsedDocumentFlags.NonSerializable;
            Project p = (null == dom || null == dom.Project)?
                        IdeApp.Workspace.GetProjectContainingFile(fileName):
                        dom.Project;
            ProjectInformation pi = ProjectInformationManager.Instance.Get(p);
            CompilationUnit    cu;

            doc.CompilationUnit = cu = new CompilationUnit(fileName);
            IType   tmp;
            IMember member;

            string[] contentLines = content.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            DomType  globals      = new DomType(cu, ClassType.Unknown, GettextCatalog.GetString("(Global Scope)"), new DomLocation(1, 1), string.Empty, new DomRegion(1, int.MaxValue), new List <IMember> ());

            lock (pi) {
                // Add containers to type list
                foreach (LanguageItem li in pi.Containers())
                {
                    if (null == li.Parent && FilePath.Equals(li.File, fileName))
                    {
                        tmp = LanguageItemToIMember(pi, li, contentLines) as IType;
                        if (null != tmp)
                        {
                            cu.Add(tmp);
                        }
                    }
                }

                // Add global category for unscoped symbols
                foreach (LanguageItem li in pi.InstanceMembers())
                {
                    if (null == li.Parent && FilePath.Equals(li.File, fileName))
                    {
                        member = LanguageItemToIMember(pi, li, contentLines);
                        if (null != member)
                        {
                            globals.Add(member);
                        }
                    }
                }
            }

            cu.Add(globals);

            return(doc);
        }
        public override ParsedDocument Parse(bool storeAst, string fileName, TextReader reader, Project project = null)
        {
            var doc = new DefaultParsedDocument(fileName);

            doc.Flags |= ParsedDocumentFlags.NonSerializable;
            ProjectInformation pi = ProjectInformationManager.Instance.Get(project);

            string content = reader.ReadToEnd();

            string[] contentLines = content.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            var globals = new DefaultUnresolvedTypeDefinition("", GettextCatalog.GetString("(Global Scope)"));

            lock (pi) {
                // Add containers to type list
                foreach (LanguageItem li in pi.Containers())
                {
                    if (null == li.Parent && FilePath.Equals(li.File, fileName))
                    {
                        var tmp = AddLanguageItem(pi, globals, li, contentLines) as IUnresolvedTypeDefinition;
                        if (null != tmp)
                        {
                            doc.TopLevelTypeDefinitions.Add(tmp);
                        }
                    }
                }

                // Add global category for unscoped symbols
                foreach (LanguageItem li in pi.InstanceMembers())
                {
                    if (null == li.Parent && FilePath.Equals(li.File, fileName))
                    {
                        AddLanguageItem(pi, globals, li, contentLines);
                    }
                }
            }

            doc.TopLevelTypeDefinitions.Add(globals);
            return(doc);
        }
        public override System.Threading.Tasks.Task <ParsedDocument> Parse(ParseOptions options, System.Threading.CancellationToken cancellationToken)
        {
            var fileName = options.FileName;
            var project  = options.Project;
            var doc      = new DefaultParsedDocument(fileName);

            doc.Flags |= ParsedDocumentFlags.NonSerializable;
            ProjectInformation pi = ProjectInformationManager.Instance.Get(project);

            string content = options.Content.Text;

            string[] contentLines = content.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            var globals = new DefaultUnresolvedTypeDefinition("", GettextCatalog.GetString("(Global Scope)"));

            lock (pi) {
                // Add containers to type list
                foreach (LanguageItem li in pi.Containers())
                {
                    if (null == li.Parent && FilePath.Equals(li.File, fileName))
                    {
                        var tmp = AddLanguageItem(pi, globals, li, contentLines) as IUnresolvedTypeDefinition;
                        if (null != tmp) /*doc.TopLevelTypeDefinitions.Add (tmp);*/ } {
                }
            }

            // Add global category for unscoped symbols
            foreach (LanguageItem li in pi.InstanceMembers())
            {
                if (null == li.Parent && FilePath.Equals(li.File, fileName))
                {
                    AddLanguageItem(pi, globals, li, contentLines);
                }
            }
        }

        //doc.TopLevelTypeDefinitions.Add (globals);
        return(System.Threading.Tasks.Task.FromResult((ParsedDocument)doc));
    }