protected override void Run()
        {
            IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;

            if (window != null && window.ViewContent is IEditable) {

                Parser p = new Parser();
                p.Parse(new Lexer(new ICSharpCode.SharpRefactory.Parser.StringReader(((IEditable)window.ViewContent).Text)));

                if (p.Errors.count > 0) {
                    Runtime.MessageService.ShowError("Correct source code errors first (only compileable C# source code would convert).");
                    return;
                }
                VBNetVisitor vbv = new VBNetVisitor();
                vbv.Visit(p.compilationUnit, null);

                Runtime.LoggingService.Info(vbv.SourceText.ToString());
                Runtime.FileService.NewFile ("Generated.VB", "VBNET", vbv.SourceText.ToString());
            }
        }
Пример #2
0
        public ICompilationUnitBase Parse(string fileName, string fileContent)
        {
            ICSharpCode.SharpRefactory.Parser.Parser p = new ICSharpCode.SharpRefactory.Parser.Parser();

            Lexer lexer = new Lexer(new StringReader(fileContent));
            p.Parse(lexer);

            CSharpVisitor visitor = new CSharpVisitor();
            visitor.Visit(p.compilationUnit, null);
            visitor.Cu.ErrorsDuringCompile = p.Errors.count > 0;
            visitor.Cu.Tag = p.compilationUnit;
            visitor.Cu.ErrorInformation = p.Errors.ErrorInformation;
            RetrieveRegions(visitor.Cu, lexer.SpecialTracker);
            foreach (IClass c in visitor.Cu.Classes)
                c.Region.FileName = fileName;
            return visitor.Cu;
        }