Roslynpad set a wrapper context

448 Views Asked by At

I have a problem with setting a context class to a block of code on a WPF RoslynPad RoslynCodeEditor.

I already have codehighlightning and code completion but I wan't to set a context to the code so I can call an override to a method without having to code the wrapper class.

Code Example without wrapper class

public override object VisitAnnotationConstantRest(JavaParser.AnnotationConstantRestContext context)
{
    var example = Visit(context.variableDeclarator());
}

Is it possible to set the wrapping class context of the code using roslyn host?

If I code the wrapper class it works.

Code Example with wrapper class

public class CustomClass : JavaParserBaseVisitor<object>
{
    public override object VisitAnnotationConstantRest(JavaParser.AnnotationConstantRestContext context)
    {
        var example = Visit(context.variableDeclarator());    
    }
}
1

There are 1 best solutions below

0
On

I'm not sure this is possible in Roslyn, but you may be able to do this by adding invisible/uneditable header/footer lines to the editor.

See this issue for a similar discussion, where I suggested using the following solution to make lines read only:

https://stackoverflow.com/a/14426095