Posted 12 years ago by Leif Zars
Version: 4.0.0246
Avatar
with SourceProjectContent.LoadForCode i can add code to a "project". but how would i get the syntax errors without loading the code into a "syntaxeditor".


Thanks

Comments (10)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Each CompilationUnit has a SyntaxErrors collection. So if you are tracking which source key (filenames) you pass the SourceProjectContent, you could iterate through GetTypesForSourceKey for each source key and on the first type in that array, if any, find its parent CompilationUnit and look at its SyntaxErrors collection.

Would it help if we added a collection of source keys that are currently in use. Like maybe return an array of strings?


Actipro Software Support

Posted 12 years ago by Leif Zars
Avatar
Okay ya that will work. Is the Rootnode always the CompilationUnit? Or do i need to find the parent that is a CompilationUnit?

For some people it might help to have that collection of source keys, but not so much for me.

How could i be notified of changes to a CompilationUnit so i can pull its new error list from it. Maybe when it is reparsed or some event i could handle?

Thanks Leif
Posted 12 years ago by Leif Zars
Avatar
Also how would i get the line number from the TextRange in a SyntaxError?
Posted 12 years ago by Alex
Avatar
Can't you just compile the code and get CompilerErrors? It will give you error description as well as line number?

Alex
Posted 12 years ago by Leif Zars
Avatar
That would work and i do that for compiler errors. But the SyntaxError class has the text offset i should be able to convert that to a line number and even a column. I am betting that actipro has a method for figuring this out. Time will tell

Leif
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
It's best to use AstNode.FindAncestor and look for an ICompilationUnit (or your specific CompilationUnit class). Generally RootNode will be the compilation unit however in the future there might be merged language scenarios where that might change.

For tracking changes you can handle the SyntaxEditor.DocumentSemanticParseDataChanged events of the SyntaxEditors that are open.

The Getting Started topic in the documentation has a section on converting from offsets to document positions (line numbers), etc. so check that out.


Actipro Software Support

Posted 12 years ago by Leif Zars
Avatar
1)Okay i can use AstNode.FindAncestor.

2)Okay

3) But i don't have a SyntaxEditor a document or editorview just the DotNetProjectResolver.
Maybe as of now it isn’t possible. It would be nice so I can populate a line number. I can work with textrange but it would be nice to have a line and column for the end user to see.


Thanks Leif
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I see, ok let me add something for this to the TODO list for you.


Actipro Software Support

Posted 12 years ago by Leif Zars
Avatar
jw
What is the state of this issue?

Leif
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Sorry, no change on this item yet.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.