Ejemplo n.º 1
0
        public override void BeginParse()
        {
            if (_document != null)
            {
                //td: cancel
            }

            var service = (ExcessLanguageService)LanguageService;

            _document = service.CreateExcessDocument(GetText(), _id);
            _document.applyChanges(CompilerStage.Syntactical);

            //td: check saving error & SemanticalChanges
            saveCodeBehind(_document, false);

            if (_document.HasSemanticalChanges())
            {
                var doc          = _workspace.CurrentSolution.GetDocument(_id);
                var semanticRoot = doc.GetSyntaxRootAsync().Result;

                _document.Mapper.Map(_document.SyntaxRoot, semanticRoot);

                var model = doc.GetSemanticModelAsync().Result;
                _document.Model = model;
                _document.applyChanges(CompilerStage.Semantical);
            }

            saveCodeBehind(_document, true);
            base.BeginParse();
        }
Ejemplo n.º 2
0
        public override void BeginParse()
        {
            if (_document != null)
            {
                //td: cancel
            }

            ExcessLanguageService service = (ExcessLanguageService)this.LanguageService;

            _document = service.CreateExcessDocument(GetText(), _id);
            _document.applyChanges(CompilerStage.Syntactical);

            _document.SyntaxRoot = _document.SyntaxRoot.NormalizeWhitespace(elasticTrivia: true); //td: optimize
            if (!saveCodeBehind(_document.SyntaxRoot))
            {
                return; //td: error?
            }
            if (!_document.HasSemanticalChanges())
            {
                return;
            }

            var doc          = _workspace.CurrentSolution.GetDocument(_id);
            var semanticRoot = doc.GetSyntaxRootAsync().Result;

            _document.Mapper.SemanticalChange(_document.SyntaxRoot, semanticRoot);

            var model = doc.GetSemanticModelAsync().Result;

            _document.Model = model;
            _document.applyChanges(CompilerStage.Semantical);

            saveCodeBehind(_document.SyntaxRoot);

            base.BeginParse();
        }