Example #1
0
        private void OutputAnalysisMessages(RawShaderNavigationResult result, NShaderSource source = null)
        {
            lock (errorListProvider)
            {
                try
                {
                    var taskProvider = source != null?source.GetTaskProvider() : null;

                    if (taskProvider != null)
                    {
                        taskProvider.Tasks.Clear();
                    }

                    errorListProvider.Tasks.Clear(); // clear previously created
                    foreach (var message in result.Messages)
                    {
                        var errorCategory = TaskErrorCategory.Message;
                        if (message.Type == "warning")
                        {
                            errorCategory = TaskErrorCategory.Warning;
                        }
                        else if (message.Type == "error")
                        {
                            errorCategory = TaskErrorCategory.Error;
                        }

                        // Make sure that we won't pass nay null to VS as it will crash it
                        var filePath    = message.Span.File ?? string.Empty;
                        var messageText = message.Text ?? string.Empty;


                        if (taskProvider != null && errorCategory == TaskErrorCategory.Error)
                        {
                            var task = source.CreateErrorTaskItem(ConvertToTextSpan(message.Span), filePath, messageText, TaskPriority.High, TaskCategory.CodeSense, MARKERTYPE.MARKER_CODESENSE_ERROR, TaskErrorCategory.Error);
                            taskProvider.Tasks.Add(task);
                        }
                        else
                        {
                            var newError = new ErrorTask()
                            {
                                ErrorCategory = errorCategory,
                                Category      = TaskCategory.BuildCompile,
                                Text          = messageText,
                                Document      = filePath,
                                Line          = Math.Max(0, message.Span.Line - 1),
                                Column        = Math.Max(0, message.Span.Column - 1),
                                // HierarchyItem = hierarchyItem // TODO Add hierarchy the file is associated to
                            };

                            // Install our navigate to source
                            newError.Navigate += NavigateToSourceError;
                            errorListProvider.Tasks.Add(newError); // add item
                        }
                    }

                    if (result.Messages.Count > 0)
                    {
                        errorListProvider.Show(); // make sure it is visible
                    }
                    else
                    {
                        errorListProvider.Refresh();
                    }

                    if (taskProvider != null)
                    {
                        taskProvider.Refresh();
                    }
                }
                catch (Exception ex)
                {
                    errorListProvider.Tasks.Add(new ErrorTask(ex.InnerException ?? ex));
                }
            }
        }
        private void OutputAnalysisMessages(RawShaderNavigationResult result, NShaderSource source = null)
        {
            lock (errorListProvider)
            {
                try
                {
                    var taskProvider = source != null ? source.GetTaskProvider() : null;
                    if (taskProvider != null)
                    {
                        taskProvider.Tasks.Clear();
                    }

                    errorListProvider.Tasks.Clear(); // clear previously created
                    foreach (var message in result.Messages)
                    {
                        var errorCategory = TaskErrorCategory.Message;
                        if (message.Type == "warning")
                        {
                            errorCategory = TaskErrorCategory.Warning;
                        }
                        else if (message.Type == "error")
                        {
                            errorCategory = TaskErrorCategory.Error;
                        }

                        // Make sure that we won't pass nay null to VS as it will crash it
                        var filePath = message.Span.File ?? string.Empty;
                        var messageText = message.Text ?? string.Empty;


                        if (taskProvider != null && errorCategory == TaskErrorCategory.Error)
                        {
                            var task = source.CreateErrorTaskItem(ConvertToTextSpan(message.Span), filePath, messageText, TaskPriority.High, TaskCategory.CodeSense, MARKERTYPE.MARKER_CODESENSE_ERROR, TaskErrorCategory.Error);
                            taskProvider.Tasks.Add(task);
                        }
                        else
                        {
                            var newError = new ErrorTask()
                            {
                                ErrorCategory = errorCategory,
                                Category = TaskCategory.BuildCompile,
                                Text = messageText,
                                Document = filePath,
                                Line = Math.Max(0, message.Span.Line - 1),
                                Column = Math.Max(0, message.Span.Column - 1),
                                // HierarchyItem = hierarchyItem // TODO Add hierarchy the file is associated to
                            };

                            // Install our navigate to source 
                            newError.Navigate += NavigateToSourceError;
                            errorListProvider.Tasks.Add(newError); // add item
                        }
                    }

                    if (result.Messages.Count > 0)
                    {
                        errorListProvider.Show(); // make sure it is visible 
                    }
                    else
                    {
                        errorListProvider.Refresh();
                    }

                    if (taskProvider != null)
                    {
                        taskProvider.Refresh();
                    }
                }
                catch (Exception ex)
                {
                    errorListProvider.Tasks.Add(new ErrorTask(ex.InnerException ?? ex));
                }
            }
        }