Redisplaying Squiggles

SyntaxEditor for WPF Forum

Posted 9 years ago by Martin de Jong - Statistics Netherlands
Version: 10.2.0532
Avatar
Hi

My squiggles are retrieved using IParseErrorProvider in the ParseData. After getting the errors (from a cache) the squiggles are displayed. However sometimes these errors are not uptodate, so i need to trigger the display of the squiggles again. Is there a way to enforce a new display of the squiggles without drastic methods like assigning a new SyntaxLanguage or editing the file?

Comments (5)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Martin,

Can you provide more information on what you mean that they are not updatable?

If your errors come from the document's ParseData then you could first clear, and set the ParseData property again. It will trigger a refresh of them.


Actipro Software Support

Posted 9 years ago by Martin de Jong - Statistics Netherlands
Avatar
The type of files i am referring to are included files, and these don't have their own parser. These files are read as source into the main file so they don't have their own parser. Errors and other information can only be retrieved from the parsing of this mainfile. Therefore this parse info is cached, so errors can be displayed for each file, include type or main.


At the moment, in the "parse" of a include file a request is send to the main file to reparse itself. At this moment the parse data of the main file is not cached yet, only the previous version.

As you can see (if i was clear enough;)) my solution would be that a parse of a main file signals its include files that the mainfile, and each include file, has new parsedata.

For displaying errors this already works, since each include file finds its errors in the cache.

In short, whats happens now is:
include file is edited -> include "parser" sends reparse request to main (cant make squiggles for include yet, need main file) -> main file is parsed, errors are cached, error refresh request is send -> error box gets aerror from cache from current file

And change it to:
include file is edited -> include "parser" sends reparse request to main (cant make squiggles for include yet, need main file) -> main file is parsed, errors are cached, error refresh request is send, to each include file too -> error box gets aerror from cache from current file + each include redisplayes squiggles

It seems tagging is always triggered in the Parse phase.

In your opinion, what is the best solution for this problem?

Cheers,
Martin


[Modified at 02/03/2011 04:03 AM]

[Modified at 02/03/2011 04:34 AM]
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Martin,

If your squiggles need to come from a source that is outside of what is parsed in the current document, I would recommend using another separate tagger for these squiggles.

If you look at our AdornmentsSquigglesIntro QuickStart, you can see how a squiggle tagger can be created. You can have this active at the same time as other squiggle taggers too (such as one that might return this document's parse errors).

If in your custom tagger you need to tell the UI that things changed, you can call its base.OnTagsChanged method.

Hope that helps.


Actipro Software Support

Posted 9 years ago by Martin de Jong - Statistics Netherlands
Avatar
Thank you

It was easier than i thought. Combining two examples i came up with a IncludeSquiggleTagger which i added to the language. Btw, the content of the Key parameter is confusing me. I noticed in the samples e.g. "Custom" Which values are recommended?

Greetz

Martin
using System;

namespace StatNeth.Blaise.IDE.SourceEditorWPF.Language {


    public class IncludeSquiggleTagger : TaggerBase<ISquiggleTag> {

        private IEditorView view;
        private IEnumerable<ActiproSoftware.Text.Parsing.IParseError> errors = null;

        public IncludeSquiggleTagger(IEditorView view)
            : base("IncludeSquiggleTagger",
                new Ordering[] { new Ordering(TaggerKeys.Token, OrderPlacement.Before) }, view.SyntaxEditor.Document) {

            this.view = view;
            IDE.ProjectManagement.CachedParsingData.Instance.NotifyFileErrorsRefresh += new Shared.FileNameEventHandler(Instance_NotifyFileErrorsRefresh);
            ActivateTagging();

        }

        void Instance_NotifyFileErrorsRefresh(object sender, Shared.FileNameEventArgs e) {
            if (String.Compare(e.FileName, view.SyntaxEditor.Document.FileName) == 0)
                ActivateTagging();
        }

        public void ActivateTagging() {
            try {
                string fn = view.SyntaxEditor.Document.FileName;
                this.errors = from ActiproSoftware.Text.Parsing.IParseError pe in ProjectManagement.CachedParsingData.Instance.GetFileMessages(fn)
                              where BlaiseParseErrorProvider.IsValidSquiggle(pe, fn)
                              select pe;
            } catch {
                this.errors = null;
            }
            // Notify that tags changed
            this.OnTagsChanged(new TagsChangedEventArgs(new TextSnapshotRange(view.SyntaxEditor.Document.CurrentSnapshot, view.SyntaxEditor.Document.CurrentSnapshot.TextRange)));

        }


        public override IEnumerable<TagSnapshotRange<ISquiggleTag>> GetTags(NormalizedTextSnapshotRangeCollection snapshotRanges, object parameter) {
            if (this.errors != null) {
                foreach (ActiproSoftware.Text.Parsing.IParseError error in this.errors) {
                    TextRange tr = new TextRange(view.SyntaxEditor.Document.CurrentSnapshot.PositionToOffset(error.PositionRange.StartPosition),
                        view.SyntaxEditor.Document.CurrentSnapshot.PositionToOffset(error.PositionRange.LastPosition));

                    foreach (TextSnapshotRange range in snapshotRanges) {
                        if (range.IntersectsWith(tr)) {
                            SquiggleTag tag = new SquiggleTag();
                            tag.ClassificationType = error.ClassificationType;
                            // Yield the tag
                            yield return new TagSnapshotRange<ISquiggleTag>(
                                new TextSnapshotRange(view.SyntaxEditor.Document.CurrentSnapshot, tr), tag);
                        }
                    }

                }
            }
        }

    } // class
}
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Martin,

The Key is just used to identify the tagger. So you can name it whatever you want.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.