Flag lines not covered in config file

SyntaxEditor for Universal Windows Forum

Posted 10 months ago by Ryan
Version: 16.1.0341
Avatar

I would like to be able to flag any line that has text that does not have a pattern set for text.   I would also like to be able to collect the line numbers to store in a list.  Is this possible?

Comments (7)

Posted 10 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Ryan,

Can you provide some more detail and examples of what you're trying to do so that we can better understand the scenario?  Thanks!


Actipro Software Support

Posted 10 months ago by Ryan
Avatar

I have files that can not have any commands / patterns that are not in the config file for color coding.  Below is a simple example.   Notice the RR is not in the config pattern.  I would like to know what line or lines the happens on.

Config example:

<ExplicitPatterns>
VN VL M3 HA ZZ Z4 FP FE
</ExplicitPatterns>

File example

VL M3 FE RR VN

Posted 10 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Ryan,

If you wanted to mark squiggles under unknown commands, then the first step would be to make sure your lexer has all known commands getting tokenized.  Then use some general identifier-like syntax to tokenize other words as "Unknown".

From here, you could register an IParser service on your language that scans the snapshot's tokens and lokos for tokens with the ID/key for your Unknown tokens.  Then have your IParseData result implement IParseErrorProvider and return the errors there.  Follow the steps in Getting Started #5 QuickStart to show the squiggle lines and have quick info for them.  That would get it to show error squiggle lines for each unknown command.  Make sure you register the ambient parse request dispatcher so all this process is offloaded into a worker thread to not hold up your UI.

Then at any time you can get an ITextSnapshotReader with current editor.Document.CurrentSnapshot.GetReader(0) and use that to scan through the tokens, also looking for your Unknown tokens.  Or if you did the above, you alternatively could just look at editor.Document.ParseData for your parse data.

I hope that helps.


Actipro Software Support

Posted 9 months ago by Ryan
Avatar

Sounds like a great solution if I understood what you were saying, you lost me at IParser.  I am sure this is covered in the sample code but I have found it a little difficult with the one sample to fit all cases.  Sorting through code that may or may not be relevant to want I am looking for.  Any chance you can provide some links or example code with a very simple example to build on?

Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Ryan,

Take a look at the "Getting Started #2" QuickStart.  It shows a very basic example of an IParser implementation.  Assuming you have a lexer in place to tokenize the text text already, that sample shows how you can scan through all the tokens and look for those with a specific Key.

If the prase data object you return implements IParseErrorProvider and you register the language services we do in the "Getting Started #5" QuickStart, then it will support squiggle lines for any parse errors you report via the parse data.

I hope that helps point you to the right samples.


Actipro Software Support

Posted 9 months ago by Ryan
Avatar

That sounds like what I am looking for.   Not sure where to find the "Getting Started #2" It could be because I am using an old version 4.0.  

I have tried the below.  

At application start a call:

SemanticParserService.Start()

Then try:

        If TypeOf SyntaxEditor1.Document.SemanticParseData Is ICompilationUnit Then
            syntaxErrors = (CType(SyntaxEditor1.Document.SemanticParseData, ICompilationUnit)).SyntaxErrors
        End If

It does not fall into the if statement SyntaxEditor1.Document.SemanticParseData is equal to nothing.

[Modified 9 months ago]

Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Ryan,

Ahh, yes we have a lot more documentation and samples with the newer APIs in the most recent version.  Things weren't quite as straightforward compared to the most recent version, nor did we have as many samples in the old 4.0 version.

In the old v4.0 documentation, you'd probably want to look at the "SyntaxEditor / Language Definition Guide / Semantic Parsing / Semantic Parser Service" and follow along in that topic.  That will tell you how the service can execute in a worker thread. 

The Document.SemanticParseData property doesn't get filled in unless you set it to something, which is what you would do in a parser.

Again, all of this is easier to do and more of a streamlined process in the most recent version.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.