When in code fragment editing mode,outlining nodes disappeared ,is a bug?

SyntaxEditor for Windows Forms Forum

Posted 9 months ago by hehui - manager, foxtable
Version: 22.1.0
Platform: .NET 5.0
Environment: Windows 10 (64-bit)
Avatar

After set the optional header and footer text for a document, use the ITextDocument.SetHeaderAndFooterText method,I find that outlining nodes disappeared,why?

Comments (8)

Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you run our WinForms SyntaxEditor Code Fragments QuickStart, you can see the "if" block is getting outlined ok.

A common mistake when using header/footer text is in languages like Visual Basic where the language requires line terminator characters between statements, and the developer forgets to include a line terminator at the end of the header text.  When that happens, the header text runs right into the fragment (document) text without a line terminator and that can sometimes lead to syntax errors in the final full parsed document text that consists of header + fragment (document) + footer.  Check to see if that is what's causing your problem.  

If you still can't figure it out after that, please provide more detail on your scenario.  Thanks!


Actipro Software Support

Posted 9 months ago by hehui - manager, foxtable
Avatar

Thank you for your help.

Now my question is:

how to display a outlining node on the left of an if statement?

visual studio can do this well。

Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you are using the latest version 22.1 of our .NET Languages Add-on, you should see the 'if' statement outlined in that QuickStart.  Block statement outlining (inside methods) was added as a feature to the add-on in v22.1.  If you are on v21.1 or earlier, then that is why you aren't seeing 'if' statements outlined.


Actipro Software Support

Posted 9 months ago by hehui - manager, foxtable
Avatar

Thank you for your help.

Today, I have update to version 22.1,and then I found:

If I use c# , outlining node will appear on the left of if statement. but If I use visual basic, the problem still exists.

Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I'm sorry but the code-level constructs outlining feature in the add-on is only available for the C# language right now, not Visual Basic.  Visual Basic will do code outlining for namespaces, types, and members though.


Actipro Software Support

Posted 9 months ago by hehui - manager, foxtable
Avatar

End users are not all professional programmers,Visual Basic is more suitable for them,Can you add this code-level constructs outlining feature to visual basic? Or tell me a way to realize it myself.

Answer - Posted 9 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We will log it as a suggestion.  All code outlining is done in the VBOutliningSource class, which gets created by the VBOutliner language service. 

To customize it, you'd have to make a class that inherits VBOutliningSource and overrides the AddNodesRecursive method to handle other statement AST node types.  Then you'd have to unregister the existing VBOutliner language service from the syntax language.  Next, make a new IOutliner language service that creates your custom VBOutliningSource, and register that as a language service on the syntax language.

The JavascriptOutliner example in the CodeOutliningRangeBased QuickStart is a good example of an outliner, but our VBOutliner.GetOutliningSource is implemented like this:

public IOutliningSource GetOutliningSource(ITextSnapshot snapshot) {
	if (snapshot != null) {
		ICodeDocument document = snapshot.Document as ICodeDocument;
		if (document != null) {
			// Get the parse data
			var parseData = document.ParseData as IDotNetParseData;
			if (parseData != null) {
				// Create an outlining source based on the parse data
				VBOutliningSource source = new VBOutliningSource(parseData.Snapshot);
				source.AddNodesFromParseData(parseData);

				// Translate the data to the desired snapshot, which could be slightly newer than the parsed source
				source.TranslateTo(snapshot);

				return source;
			}
		}
	}
	return null;
}

You'd want a similar method but replace VBOutliningSource with your custom class.


Actipro Software Support

Posted 9 months ago by hehui - manager, foxtable
Avatar
 
Thank you very much
The latest build of this product (v22.1.3) 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.