EditorViewAdapterList _viewsCopy; //copy used in refresh loop; set to null when views are added/removed #endregion Fields #region Constructors public EditorAdapter(LanguageCompiler compiler) { _compiler = compiler; _context = new CompilerContext(_compiler); _context.Options |= CompilerOptions.CollectTokens | CompilerOptions.MatchBraces; _parsedSource = new ParsedSource(String.Empty, new TokenList(), null); _colorizerThread = new Thread(ColorizerLoop); _colorizerThread.IsBackground = true; _parserThread = new Thread(ParserLoop); _parserThread.IsBackground = true; }
//Note: we don't actually parse in current version, only scan. Will implement full parsing in the future, // to support all intellisense operations private void ParseSource(String newText) { TokenList newTokens = new TokenList(); //Explicitly catch the case when new text is empty if (newText != string.Empty) { SourceFile srcFile = new SourceFile(newText, "source"); _compiler.Scanner.Prepare(_context, srcFile); IEnumerable<Token> tokenStream = _compiler.Scanner.BeginScan(); foreach (Token _token in tokenStream) { newTokens.Add(_token); } //newTokens.AddRange(tokenStream); } //finally create new contents object and replace the existing _contents value _parsedSource = new ParsedSource(newText, newTokens, null); //notify views var views = GetViews(); foreach (var view in views) view.UpdateParsedSource(_parsedSource); }