public ProjectItemCodeDocument(string name, CodeLanguage languageId, ProjectItem parent) : base(parent) { if(languageId == null) throw new ArgumentNullException("languageId"); this.Name = name; _codedocument = new TextDocument(); Encoding = Encoding.UTF8; _language = languageId; _codedocument.Changed += OnCodedocumentChanged; _codeSegmentService = new DocumentCodeSegmentService(this); _tokenizer = _language.CreateTokenizer(this, _codedocument); _tokenizer.FinishedSucessfully += (s, e) => { _codeSegmentService.Reset(_tokenizer.GetSegmentsSnapshot()); if(!_documentdirty) _documentTokenizerDirty = false; OnTokenizerUpdated(this, new EventArgs<ProjectItemCodeDocument>(this)); }; _ast = languageId.CreateDOMService(this); _ast.Updated += (s, e) => { if(!_documentdirty && !_documentTokenizerDirty) _documentASTDirty = false; }; DispatcherTimer tokenUpdateTimer = new DispatcherTimer(); tokenUpdateTimer.Interval = TimeSpan.FromMilliseconds(500); tokenUpdateTimer.Tick += CheckUpdateTokenRepresentation; tokenUpdateTimer.Start(); ReloadDocument(); }