Best way to implement compiler directives

SyntaxEditor for WPF Forum

Posted 3 years ago by Martin de Jong - Statistics Netherlands
Version: 14.2
Avatar

We are using a Mergable Lexer which interacts with a Antlr lexer.

In our language we define a conditional define by a token like {$define MyDef} e.g.

We looking for a simular behaviour as in VS, where not active text is "dimmed".

What is the best way to implement this?

 

Ty

Martin

Comments (6)

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Martin,

You could use a classification tagger to achieve that sort of thing.  The key thing is knowing where those ranges are.  If you have that info available from your parse data results, you then would know when to apply the tagged ranges.  You'd have to do something like in the "Adornments - Squiggles Intro" where requests are made for tags on the fly and we return them.  That's where you'd put your logic to see if you are in one of the dimmed ranges and then return a classification type that covers that range.


Actipro Software Support

Posted 3 years ago by Martin de Jong - Statistics Netherlands
Avatar

Which solution i think of, there seems a problem with the order of execution. Till now the parsing is done after the tagging of ranges. As last i tried an indicatorTagger, which seems to work fine. In a ICodeDocument provider and a ITextView provider mode.

I tried an adornmentManager too.

But it seems both are executed before the parse, which results in outdated indicators.

Does it matter or should i it matter which Ordering is specified?

We are not up to date with our version of Actipro, can the problem be there?

 

Any thoughts are welcome?

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Martin,

If I understand correctly, you have a classification tagger that looks at your parse data to determine which ranges should be dimmed out.  The problem is that it runs before the parsing updates complete, right?  Could you possibly store which ranges had the dimming and then when the document parse data updates (there is an event that fires when that happens), determine if any ranges changed.  If so, tell your tagger to invalidate those particular ranges.  Maybe try that? 

The Ordering is just for comparing to other taggers.  Parsing is async and completes at random times depending on how large of a parse it's doing.

The above should be the same in your version.


Actipro Software Support

Posted 3 years ago by Martin de Jong - Statistics Netherlands
Avatar

I was caching the ranging of dimming areas using the snapshotversion. After disabling this test on the snapshotversion it works much better. (That is progress;)) It 's a pity i didn't find this earlier:)

I will investigate this further, maybe the Document.snapshot is updated after parser and the taggers did there work, before UI in fact is updated?

Posted 3 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Martin,

Taggers get used mainly when displaying view lines.  The view will call all known classification taggers as it builds a line to get the resolved highlighting styles for the classification types over its text range.  Generally if you make an edit, the document text buffer is updated immediately, then a parse request is made, then the view "arrange" is invalidated.  The parse request is processed and its snapshot parsed at some async time later, which could be very fast for a small document snapshot or up to a second or more for a huge document snapshot.  Parsing happens in a worker thread.  Back on the main UI thread, the dispatcher is telling the view to re-arrange itself (due to the arrange invalidation) and as part of that, the view lines are built and displayed.  This all generally happens before the parsing completes.  I hope that explains the process.


Actipro Software Support

Posted 3 years ago by Martin de Jong - Statistics Netherlands
Avatar

Thank you for your information.

I switched to using a AdornmentManagerBase<IEditorView>. It listens to parse change (directlt and indirectly) and triggers the OnViewTextAreaLayout (in the UIThread).

The OnViewTextAreaLayout looks at all the e.View.VisibleViewLines to sync each line;

This construction seems to work:)

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

Add Comment

Please log in to a validated account to post comments.