Check for undeclared variables for custom language

SyntaxEditor for WPF Forum

Posted 2 years ago by ks techno
Version: 22.1.1

Hi we have an existing application using SyntaxEditor and a custom language. 
Is there a way to check and prompt if user enter an undeclared variable, similar to VS error IDE1007: The name 'xxx' does not exist in the current context.


Comments (1)

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


That kind of thing could be done in a parsing phase.  Please see the Parsing documentation topics for more information on how to configure a parser for your custom syntax language.  If configured properly, parsers can run in a worker thread so that they don't impact editing performance on the main UI thread.  They can scan the document's tokens and do things like build up an AST, report syntax errors, etc. 

The error you describe is generally more of a compiler error.  If you have a compiler for your language, you could invoke it as part of your syntax language parser service's logic and return its errors.  If your IParseData that is returned by the parser implements IParseErrorProvider and you've registered a ParserErrorTagger provider language service, you can get those errors to show as squiggles.  See the end of this documentation topic for some related info.  Combine that with a SquiggleTagQuickInfoProvider language service, and that will show quick info tips for the errors as well.

Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.