How can i get a function list like ICompletionSession.Items in SyntaxEditor?

SyntaxEditor for WPF Forum

Posted 1 year ago by Scarlett
Version: 22.1.4
Avatar

Hello.

I'd like to get an errors when I use undefined functions in SyntaxEditor.

But there is no error in editor. and both are InvocationExpression. So I can't distinguish what is undefine funciton.

Forexample, If I define function which name is Add by using SetHeaderAndFooterText, The editor shows like below.

Add(123) -> OK

ABC(123) -> Error

How can I get a defined function list? or How can I mark error in editor?

Thank you.

[Modified 1 year ago]

Comments (1)

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scarlett,

First, which syntax language are you using here?  If it's one of our premium add-ons, we do have syntax error reporting but we don't do any sort of compilation that would discover undefined functions. 

That being said, one way you could achieve such a feature is to:

  • Alter your IParser language service to call its normal parsing code first that generates parse data with an AST and syntax errors list.
  • Recursively examine the AST and find the various function declarations in it, building a list of their names as you go.
  • You could also build up a list of InvocationExpressions that were located as you examine the AST.
  • After you've gone through the entire AST, enumerate the list of InvocationExpressions and see if any make calls to identifiers that aren't declared function names.
  • When this situation occurs, add a new parse error to the parse data's list of syntax errors.
  • Note that you may need to make a new parse data object that returns the AST, snapshot used, and combined syntax/parse errors list.  Use the same parse data object Type that the original parser used.

At that point, SyntaxEditor should now have parse errors for unclared functions and will show the squiggle lines by them, and support quick info tips when hovering over the parse errors.

I hope that helps!


Actipro Software Support

The latest build of this product (v24.1.2) was released 3 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.