How to get AST from SourceFile in a IProjectAssembly

SyntaxEditor .NET Languages Add-on for WPF Forum

Posted 12 years ago by 7Alpha7
Version: 11.2.0551

in a VS like solution / project scenario, it's not quite clear by reading the documentation how to access the AST in the existing files queued on the IProjectAssembly.SourceFiles collection.

while I can easily find how to retrieve the AST of a file currently edited in a SyntaxEditor, I cannot figure out how doing the same in a closed file. AST in a source file is usefull for a lot of purposes and actually I need to know the AST of each source file of my project, even if I am not editing them.

Since the IProjectAssembly knows how to resolve a file in Types, I imagine that somewhere there is an AST but I don't know how to access it.

Other question : what happens if a source file is modified by a i/o disk operation, while it was queued on a IProjectAssembly ? Does it knows that it has to refresh its types ? I guess not.

Comments (1)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
The IProjectAssembly.SourceFiles collection is keyed by the sourceFileKey, which is typically the path to the file indicated in QueueFile. So just use the indexer to get an ISourceFile. That will provide you the ITypeDefinition objects from that file. We don't store the full ASTs since that would take an enormous amount of memory. For queued up files not open in a document, we only store the minimum information needed to supply IntelliPrompt info, which is basically the objects defined in our Reflection namespace.

We don't monitor the file system so you'd have to set up file system watchers on your own to check for disk modifications.

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.