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();
        }
Ejemplo n.º 2
0
 public override AbstractFoldingStrategy CreateFoldingStrategy( DocumentCodeSegmentService segmentService)
 {
     return new FoldingStrategyAHKv1(segmentService);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new BraceFoldingStrategy.
 /// </summary>
 public FoldingStrategyAHKv1(DocumentCodeSegmentService tokenservice)
 {
     _openingBrace = Token.BlockOpen;
     _closingBrace = Token.BlockClosed;
     _tokenservice = tokenservice;
 }