Beispiel #1
0
        public override void VisitNode(ITreeNode node, IHighlightingConsumer consumer)
        {
            if (!myInternalMode && myProcessKind != DaemonProcessKind.VISIBLE_DOCUMENT)
            {
                return;
            }

            if (myProcessKind == DaemonProcessKind.VISIBLE_DOCUMENT)
            {
                // TODO: Highlight identifiers
                // if (myIdentifierHighlightingEnabled)

                var info = myVisualElementHighlighter.CreateColorHighlightingInfo(node);
                if (info != null)
                {
                    consumer.AddHighlighting(info.Highlighting, info.Range);
                }
            }


            var references = node.GetReferences(myReferenceProvider);

            myResolveProblemHighlighter.CheckForResolveProblems(node, consumer, references);

            // TODO: Move to ShaderLabSyntaxHighlightingStage
            // (Not Rider's syntax highlighting though!)
            // E.g. protobuf support has a SyntaxHighlightingStage that will do this,
            // plus look for simple syntax validation errors, e.g. enums must have at
            // least one value defined, correct value for `syntax "proto3"`, etc.
            // And then a separate identifier
            if (node is IErrorElement errorElement)
            {
                var range = errorElement.GetDocumentRange();
                if (!range.IsValid())
                {
                    range = node.Parent.GetDocumentRange();
                }
                if (range.TextRange.IsEmpty)
                {
                    if (range.TextRange.EndOffset < range.Document.GetTextLength())
                    {
                        range = range.ExtendRight(1);
                    }
                    else if (range.TextRange.StartOffset > 0)
                    {
                        range = range.ExtendLeft(1);
                    }
                }
                consumer.AddHighlighting(new ShaderLabSyntaxError(errorElement.ErrorDescription, range));
            }

            base.VisitNode(node, consumer);
        }
        public override void VisitNode(ITreeNode node, IHighlightingConsumer context)
        {
            if (myProcessKind == DaemonProcessKind.VISIBLE_DOCUMENT)
            {
                if (myIdentifierHighlightingEnabled)
                {
                    var info = myVisualElementHighlighter.CreateColorHighlightingInfo(node);
                    if (info != null)
                    {
                        context.AddHighlighting(info);
                    }
                }
            }

            // TODO: Resolve problem highlighter
            // That is, highlight problems with resolve

            // TODO: Move to ShaderLabSyntaxHighlightingStage
            // (Not Rider's syntax highlighting though!)
            // E.g. protobuf support has a SyntaxHighlightingStage that will do this,
            // plus look for simple syntax validation errors, e.g. enums must have at
            // least one value defined, correct value for `syntax "proto3"`, etc.
            // And then a separate identifier
            var errorElement = node as IErrorElement;

            if (errorElement != null)
            {
                var range = errorElement.GetDocumentRange();
                if (!range.IsValid())
                {
                    range = node.Parent.GetDocumentRange();
                }
                if (range.TextRange.IsEmpty)
                {
                    if (range.TextRange.EndOffset < range.Document.GetTextLength())
                    {
                        range = range.ExtendRight(1);
                    }
                    else if (range.TextRange.StartOffset > 0)
                    {
                        range = range.ExtendLeft(1);
                    }
                }
                context.AddHighlighting(new ShaderLabSyntaxError(errorElement.ErrorDescription, range));
            }

            base.VisitNode(node, context);
        }