Posted 17 years ago by Kelly Leahy - Software Architect, Milliman
Avatar
I have my own AST node class that I'm going to use for my language, since it will be easier for me to share it between my "interactive" and "noninterative" parsers (I'm writing a parser that I'll use to compile my language and will share some code with the parser used to syntax/semantic check my language in the editor).

Because of this, I'd like to not provide the IAstNode interface on my AST objects. I realize that this means I'll have to write my own code to build the outlining tree, perform error and warning highlighting, etc. I don't mind writing this code myself, but I'd like to know where is the best place for me to do the outlining?

Previously, that code was always in my UpdateOutliningParser method of the ICompilationUnit, but since I don't want to provide IAstNode (and by association ICompilationUnit), is there another place I can put that code? Alternatively, can you break some of the ICompilationUnit declarations out from the ICompilationUnit interface so that I can use it without having IAstNode?

Any ideas???

Kelly Leahy Software Architect Milliman, USA

Comments (3)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Just put your outlining code in your language's PerformAutomaticOutlining method:
public override TextRange PerformAutomaticOutlining(Document document, TextRange parseTextRange) {
    // Code here
}
Once there create a CollapsibleNodeOutliningParser. Normally if you used our AST model, you could just call the one overload of the UpdateOutlining that takes your root compilation unit and be done with it.

But since you are now using the IAstNode interface, you can use the Add method to add each node on its own (via the overload that takes a CollapsibleNodeOutliningParserData). Then after doing that, call the simpler UpdateOutlining overload and voila, you should have instant outlining.


Actipro Software Support

Posted 17 years ago by Kelly Leahy - Software Architect, Milliman
Avatar
That looks like it will work just find for me. I'm not using IAstNode so I'll just be using ICollapsibleNode as appropriate and walk the tree myself to build the collapsible sections in code. It should be very easy.

Now, another question, for Error highlighting, is there an alternate way I can get that automatically (or somewhat automatically), or do I need to add my own error layer, and add indicators to it myself? I'm already doing that for warnings (different highlighting and different List`1 object), so it's not that big a deal if I have to do it again, but I'm just wondering what your thoughts are on it.

For instance, is there an indicator layer already there that I can access by a specific key and add my errors to? If that's the case, I can do the rest very easily in my post-processing for semantic parse (in the UI thread, of course).

Can you think of any other features I'm losing by not providing IAstNode and ICompilationUnit (other than the obvious ability to search the tree and stuff, which I'm providing in my IAstNode`1 interface)?

Thanks,

Kelly Leahy Software Architect Milliman, USA

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Kelly,

The only way to get them automatically added is if your syntaxEditor.Document.SemanticParseData is a ICompilationUnit, which has the SyntaxErrors collection populated. Otherwise, you'd have to build the span indicator layer yourself.

We use the constant string SpanIndicatorLayer.SyntaxErrorKey as the key for where to put syntax errors. But it will be up to you to maintain it meaning you might need to create the layer if it doesn't already exist.

The AST nodes are mostly used for syntax checking, IntelliPrompt-related stuff, and outlining so I don't think you'll be losing out on much if you already have your own code for the IntelliPrompt part and can reuse our outlining model as described in the previous post.


Actipro Software Support

The latest build of this product (v24.1.0) 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.