示例#1
0
        public EditorErrorTagger(ITextBuffer textBuffer)
        {
            EditorShell.Current.CompositionService.SatisfyImportsOnce(this);

            _document = REditorDocument.FromTextBuffer(textBuffer);
            _document.DocumentClosing            += OnDocumentClosing;
            _document.EditorTree.UpdateCompleted += OnTreeUpdateCompleted;
            _document.EditorTree.NodesRemoved    += OnNodesRemoved;
            _errorTags = new ErrorTagCollection(_document.EditorTree);

            _textBuffer          = _document.EditorTree.TextBuffer;
            _textBuffer.Changed += OnTextBufferChanged;

            _fireCodeMarkerUponCompletion = true;

            // Don't push syntax errors to the Error List in transient
            // documents such as in document attached to a projected buffer
            // in the R interactive window
            if (TaskList != null)
            {
                var view = _document.GetFirstView();
                if (view != null && !view.IsRepl())
                {
                    TaskList.AddTaskSource(this);
                }
            }

            TreeValidator validator = TreeValidator.EnsureFromTextBuffer(_textBuffer, _document.EditorTree);

            validator.Cleared        += OnCleared;
            ResultsQueue              = validator.ValidationResults;
            EditorShell.Current.Idle += OnIdle;

            ServiceManager.AddService <EditorErrorTagger>(this, textBuffer);
        }
        async Task UpdateTree()
        {
            //var validationResults = _treeValidator.Validate(_tree);
            //TreeValidator _treeValidator = new TreeValidator();
            //ValidationResult validationResults = new ValidationResult();
            //validationResults =  _treeValidator.Validate(_tree);
            try
            {
                TreeValidator    _treeValidator        = new TreeValidator();
                ValidationResult treevalidationResults = _treeValidator.Validate(_tree);

                if (treevalidationResults.IsValid)
                {
                    bool isUserAccept = await Application.Current.MainPage.DisplayAlert("Tree Details", "Update Tree Details", "OK", "Cancel");

                    if (isUserAccept)
                    {
                        _tree.LastModified = System.DateTime.UtcNow;
                        _treeRepository.UpdateTree(_tree);
                        NotifyPropertyChanged("TreeListFull");
                        await _navigation.PopAsync();
                    }
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Add Tree", treevalidationResults.Errors[0].ErrorMessage, "Ok");
                }
            }
            catch (Exception e)
            {
                var myerror = e.Message; // error
                                         //  Log.Fatal(e);
            };
        }
示例#3
0
        public EditorErrorTagger(ITextBuffer textBuffer, IEditorTaskList taskList, ICoreShell shell)
        {
            _taskList = taskList;
            _shell    = shell;
            _settings = _shell.GetService <IREditorSettings>();

            _document = REditorDocument.FromTextBuffer(textBuffer);
            _document.DocumentClosing            += OnDocumentClosing;
            _document.EditorTree.UpdateCompleted += OnTreeUpdateCompleted;
            _document.EditorTree.NodesRemoved    += OnNodesRemoved;
            _errorTags = new ErrorTagCollection(_document.EditorTree);

            _textBuffer          = _document.EditorTree.TextBuffer;
            _textBuffer.Changed += OnTextBufferChanged;

            _fireCodeMarkerUponCompletion = true;

            // Don't push syntax errors to the Error List in transient
            // documents such as in document attached to a projected buffer
            // in the R interactive window
            if (_taskList != null)
            {
                var view = _document.GetFirstView();
                if (view != null && !view.IsRepl())
                {
                    _taskList.AddTaskSource(this);
                }
            }

            TreeValidator validator = TreeValidator.EnsureFromTextBuffer(_textBuffer, _document.EditorTree, shell);

            validator.Cleared += OnCleared;
            ResultsQueue       = validator.ValidationResults;
            _shell.Idle       += OnIdle;
        }
示例#4
0
        async Task AddTree(string _fk)
        {
            TreeValidator _treeValidator = new TreeValidator();

            _tree.PLOTID = _fk;
            ValidationResult validationResults = _treeValidator.Validate(_tree);

            if (validationResults.IsValid)
            {
                bool isUserAccept = await Application.Current.MainPage.DisplayAlert("Add Tree", "Do you want to save tree details?", "OK", "Cancel");

                if (isUserAccept)
                {
                    _tree.Created      = System.DateTime.UtcNow;
                    _tree.LastModified = _tree.Created;
                    _treeRepository.InsertTree(_tree, _fk);
                    await _navigation.PopAsync();

//                    await _navigation.PushAsync(new TreeListPage(_fk));
                }
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Add Tree", validationResults.Errors[0].ErrorMessage, "Ok");
            }
        }
示例#5
0
        private async Task GoBack()
        {
            // display Alert for confirmation
            if (IsChanged)
            {
                TreeValidator _validator     = new TreeValidator();
                TreeValidator _fullvalidator = new TreeValidator(true);

                ValidationResult validationResults     = _validator.Validate(_tree);
                ValidationResult fullvalidationResults = _fullvalidator.Validate(_tree);

                ParseValidater _parser = new ParseValidater();
                (_tree.ERRORCOUNT, _tree.ERRORMSG) = _parser.Parse(fullvalidationResults);

                if (validationResults.IsValid)
                {
                    _ = AddTree(_fk);
                    Shell.Current.Navigating -= Current_Navigating;
                    //       await Shell.Current.GoToAsync("..", true);
                    await _navigation.PopAsync(true);
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Update Tree", validationResults.Errors[0].ErrorMessage, "Ok");
                }
            }
            else
            {
                Shell.Current.Navigating -= Current_Navigating;
                //      await Shell.Current.GoToAsync("..", true);
                await _navigation.PopAsync(true);
            }
        }
示例#6
0
        public ITagger <T> CreateTagger <T>(ITextBuffer textBuffer) where T : ITag
        {
            var document = textBuffer.GetEditorDocument <IREditorDocument>();

            if (document != null && TreeValidator.IsSyntaxCheckEnabled(textBuffer.ToEditorBuffer(), _shell.GetService <IREditorSettings>(), out var unused))
            {
                return(textBuffer.Properties.GetOrCreateSingletonProperty(() => new EditorErrorTagger(textBuffer, _taskList, _shell.Services)) as ITagger <T>);
            }
            return(null);
        }
示例#7
0
        public REditorDocument(IEditorBuffer editorBuffer, IServiceContainer services, IExpressionTermFilter termFilter = null)
        {
            EditorBuffer = editorBuffer;
            _services    = services;

            EditorBuffer.Services.AddService(this);
            EditorBuffer.Closing += OnBufferClosing;

            var tree = new EditorTree(EditorBuffer, services, termFilter);

            tree.Build();
            EditorTree = tree;

            TreeValidator.FromEditorBuffer(EditorTree, services);
        }
        public ITagger <T> CreateTagger <T>(ITextBuffer textBuffer) where T : ITag
        {
            IREditorDocument  document = REditorDocument.TryFromTextBuffer(textBuffer);
            EditorErrorTagger tagger   = null;

            if (document != null && TreeValidator.IsSyntaxCheckEnabled(textBuffer))
            {
                tagger = ServiceManager.GetService <EditorErrorTagger>(textBuffer);
                if (tagger == null)
                {
                    tagger = new EditorErrorTagger(textBuffer);
                }
            }

            return(tagger as ITagger <T>);
        }
        private async Task <bool> TrySave()
        {
            TreeValidator    _validator        = new TreeValidator();
            ValidationResult validationResults = _validator.Validate(_tree);

            if (validationResults.IsValid)
            {
                _ = UpdateTree();
                return(true);
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Update Tree", validationResults.Errors[0].ErrorMessage, "Ok");

                return(false);
            }
        }
示例#10
0
        public REditorDocument(IEditorBuffer editorBuffer, IServiceContainer services, bool isRepl)
        {
            EditorBuffer = editorBuffer;
            IsRepl       = isRepl;

            _services = services;

            EditorBuffer.Services.AddService(this);
            EditorBuffer.Closing += OnBufferClosing;

            var tree = new EditorTree(EditorBuffer, services);

            tree.Build();
            EditorTree = tree;

            _validator = new TreeValidator(EditorTree, services);
        }
示例#11
0
        public REditorDocument(ITextBuffer textBuffer, ICoreShell shell)
        {
            _shell = shell;
            _textDocumentFactoryService = _shell.ExportProvider.GetExportedValue <ITextDocumentFactoryService>();
            _textDocumentFactoryService.TextDocumentDisposed += OnTextDocumentDisposed;

            this.TextBuffer = textBuffer;
            IsClosed        = false;

            ServiceManager.AddService(this, TextBuffer, shell);

            _editorTree = new EditorTree(textBuffer, shell);
            if (REditorSettings.SyntaxCheckInRepl)
            {
                _validator = new TreeValidator(EditorTree, shell);
            }

            _editorTree.Build();
        }
示例#12
0
        public REditorDocument(ITextBuffer textBuffer)
        {
            _textDocumentFactoryService = EditorShell.Current.ExportProvider.GetExportedValue <ITextDocumentFactoryService>();
            _textDocumentFactoryService.TextDocumentDisposed += OnTextDocumentDisposed;

            this.TextBuffer = textBuffer;
            IsClosed        = false;

            ServiceManager.AddService <REditorDocument>(this, TextBuffer);

            _editorTree = new EditorTree(textBuffer);
            if (REditorSettings.SyntaxCheckInRepl)
            {
                _validator = new TreeValidator(this.EditorTree);
            }

            _editorTree.Build();
            RCompletionEngine.Initialize();
        }
示例#13
0
        public REditorDocument(ITextBuffer textBuffer, ICoreShell shell)
        {
            _shell = shell;
            _textDocumentFactoryService = _shell.ExportProvider.GetExportedValue <ITextDocumentFactoryService>();
            _textDocumentFactoryService.TextDocumentDisposed += OnTextDocumentDisposed;

            TextBuffer = textBuffer;
            IsClosed   = false;

            ServiceManager.AddService(this, TextBuffer, shell);
            var clh = ServiceManager.GetService <IContainedLanguageHost>(textBuffer);

            _editorTree = new EditorTree(textBuffer, shell, new ExpressionTermFilter(clh));
            if (REditorSettings.SyntaxCheckInRepl)
            {
                _validator = new TreeValidator(EditorTree, shell);
            }

            _editorTree.Build();
        }
示例#14
0
        public REditorDocument(ITextBuffer textBuffer)
        {
            EditorShell.Current.CompositionService.SatisfyImportsOnce(this);

            this.TextBuffer = textBuffer;

            IsClosed = false;
            TextDocumentFactoryService.TextDocumentDisposed += OnTextDocumentDisposed;

            ServiceManager.AddService <REditorDocument>(this, TextBuffer);

            _editorTree = new EditorTree(textBuffer);
            if (REditorSettings.SyntaxCheckInRepl)
            {
                _validator = new TreeValidator(this.EditorTree);
            }

            _editorTree.Build();

            RCompletionEngine.Initialize();
        }
示例#15
0
        public EditorErrorTagger(ITextBuffer textBuffer, IEditorTaskList taskList, IServiceContainer services)
        {
            _taskList = taskList;

            _settings = services.GetService <IREditorSettings>();
            _idleTime = services.GetService <IIdleTimeService>();

            _document          = textBuffer.GetEditorDocument <IREditorDocument>();
            _document.Closing += OnDocumentClosing;
            _document.EditorTree.UpdateCompleted += OnTreeUpdateCompleted;
            _document.EditorTree.NodesRemoved    += OnNodesRemoved;
            _errorTags = new ErrorTagCollection(_document.EditorTree);

            _textBuffer          = _document.EditorTree.TextBuffer();
            _textBuffer.Changed += OnTextBufferChanged;

            _fireCodeMarkerUponCompletion = true;

            // Don't push syntax errors to the Error List in transient
            // documents such as in document attached to a projected buffer
            // in the R interactive window
            if (_taskList != null)
            {
                var view = _document.PrimaryView;
                if (view != null && !view.IsRepl())
                {
                    _taskList.AddTaskSource(this);
                }
            }

            var validator = TreeValidator.FromEditorBuffer(_document.EditorTree, services);

            validator.Cleared += OnCleared;

            ResultsQueue    = validator.ValidationResults;
            _idleTime.Idle += OnIdle;
        }