示例#1
0
        public static XSourceEntity FindElementInFile(XFile file, XPETypeSymbol petype, XSymbol element)
        {
            var walker = new SourceWalker(file, false);

            walker.Parse(false);
            var           entities = walker.EntityList;
            XSourceEntity result   = null;

            if (petype.IsFunctionsClass)
            {
                foreach (var entity in entities)
                {
                    if (entity.Prototype == element.Prototype)
                    {
                        result = entity;
                        break;
                    }
                }
            }
            else
            {
                foreach (var entity in entities)
                {
                    if (entity.FullName == element.FullName)
                    {
                        result = entity;
                        break;
                    }
                }
            }
            return(result);
        }
示例#2
0
        private void BuildModelDoWork(object sender, DoWorkEventArgs e)
        {
            if (disableEntityParsing)
            {
                return;
            }
            System.Diagnostics.Trace.WriteLine("-->> XSharpClassifier.BuildModelDoWork()");
            // Note this runs in the background
            // parse for positional keywords that change the colors
            // and get a reference to the tokenstream
            // do we need to create a new tree
            // this happens the first time in the buffer only
            var          snapshot = _buffer.CurrentSnapshot;
            ITokenStream tokens   = null;
            ParseResult  info;

            {
                Debug("Starting parse at {0}, version {1}", DateTime.Now, snapshot.Version.ToString());
                var lines = new List <String>();
                foreach (var line in snapshot.Lines)
                {
                    lines.Add(line.GetText());
                }

                info = _sourceWalker.Parse(lines, false);
                lock (gate)
                {
                    _info = info;
                }
                Debug("Ending parse at {0}, version {1}", DateTime.Now, snapshot.Version.ToString());
            }
            tokens = _tokens;
            if (info != null && tokens != null)
            {
                Debug("Starting model build  at {0}, version {1}", DateTime.Now, snapshot.Version.ToString());
                _sourceWalker.BuildModel(info);
                var regionTags = BuildRegionTags(info, snapshot, xsharpRegionStart, xsharpRegionStop);
                lock (gate)
                {
                    _parserRegions = regionTags.ToArray();
                }
                DoRepaintRegions();
                Debug("Ending model build  at {0}, version {1}", DateTime.Now, snapshot.Version.ToString());
            }
            System.Diagnostics.Trace.WriteLine("<<-- XSharpClassifier.BuildModelDoWork()");
        }