Esempio n. 1
0
        public override void Run()
        {
            IViewContent content = WorkbenchSingleton.Workbench.ActiveViewContent;

            if (content != null && content.PrimaryFileName != null && content is IEditable)
            {
                IParser p = ParserFactory.CreateParser(SupportedLanguage.CSharp, ((IEditable)content).CreateSnapshot().CreateReader());
                p.Parse();
                if (p.Errors.Count > 0)
                {
                    MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Convert.CorrectSourceCodeErrors}\n" + p.Errors.ErrorOutput);
                    return;
                }

                VBNetOutputVisitor vbv = new VBNetOutputVisitor();

                List <ISpecial> specials = p.Lexer.SpecialTracker.CurrentSpecials;
                PreprocessingDirective.CSharpToVB(specials);
                IAstVisitor v = new CSharpToVBNetConvertVisitor(ParserService.CurrentProjectContent,
                                                                ParserService.GetParseInformation(content.PrimaryFileName));
                v.VisitCompilationUnit(p.CompilationUnit, null);
                using (SpecialNodesInserter.Install(specials, vbv)) {
                    vbv.VisitCompilationUnit(p.CompilationUnit, null);
                }

                FileService.NewFile("Generated.vb", vbv.Text);
            }
        }
Esempio n. 2
0
		public override void Run()
		{
			IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
			
			if (window != null && window.ViewContent is IEditable) {
				
				IParser p = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(((IEditable)window.ViewContent).Text));
				p.Parse();
				if (p.Errors.Count > 0) {
					MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Convert.CorrectSourceCodeErrors}\n" + p.Errors.ErrorOutput);
					return;
				}
				
				VBNetOutputVisitor vbv = new VBNetOutputVisitor();
				
				List<ISpecial> specials = p.Lexer.SpecialTracker.CurrentSpecials;
				PreprocessingDirective.CSharpToVB(specials);
				new CSharpToVBNetConvertVisitor().VisitCompilationUnit(p.CompilationUnit, null);
				using (SpecialNodesInserter.Install(specials, vbv)) {
					vbv.VisitCompilationUnit(p.CompilationUnit, null);
				}
				
				FileService.NewFile("Generated.VB", "VBNET", vbv.Text);
			}
		}
Esempio n. 3
0
        public override void Run()
        {
            IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;

            if (window != null && window.ViewContent is IEditable)
            {
                IParser p = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(((IEditable)window.ViewContent).Text));
                p.Parse();
                if (p.Errors.Count > 0)
                {
                    MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Convert.CorrectSourceCodeErrors}\n" + p.Errors.ErrorOutput);
                    return;
                }

                VBNetOutputVisitor vbv = new VBNetOutputVisitor();

                List <ISpecial> specials = p.Lexer.SpecialTracker.CurrentSpecials;
                PreprocessingDirective.CSharpToVB(specials);
                new CSharpToVBNetConvertVisitor().VisitCompilationUnit(p.CompilationUnit, null);
                using (SpecialNodesInserter.Install(specials, vbv)) {
                    vbv.VisitCompilationUnit(p.CompilationUnit, null);
                }

                FileService.NewFile("Generated.VB", "VBNET", vbv.Text);
            }
        }
		public override void Run()
		{
			IViewContent content = WorkbenchSingleton.Workbench.ActiveViewContent;
			
			if (content != null && content.PrimaryFileName != null && content is IEditable) {
				
				IParser p = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(((IEditable)content).Text));
				p.Parse();
				if (p.Errors.Count > 0) {
					MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Convert.CorrectSourceCodeErrors}\n" + p.Errors.ErrorOutput);
					return;
				}
				
				VBNetOutputVisitor vbv = new VBNetOutputVisitor();
				
				List<ISpecial> specials = p.Lexer.SpecialTracker.CurrentSpecials;
				PreprocessingDirective.CSharpToVB(specials);
				IAstVisitor v = new CSharpToVBNetConvertVisitor(ParserService.CurrentProjectContent,
				                                                ParserService.GetParseInformation(content.PrimaryFileName));
				v.VisitCompilationUnit(p.CompilationUnit, null);
				using (SpecialNodesInserter.Install(specials, vbv)) {
					vbv.VisitCompilationUnit(p.CompilationUnit, null);
				}
				
				FileService.NewFile("Generated.vb", vbv.Text);
			}
		}
Esempio n. 5
0
		void TestProgram(string program)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.VBNet, new StringReader(program));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(StripWhitespace(program), StripWhitespace(outputVisitor.Text));
		}
		public void TestProgram(string input, string expectedOutput)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(input));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			parser.CompilationUnit.AcceptVisitor(new CSharpToVBNetConvertVisitor(), null);
			VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(expectedOutput, outputVisitor.Text);
		}
Esempio n. 7
0
		void TestProgram(string program)
		{
			VBParser parser = ParserFactory.CreateParser(new StringReader(program));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
			outputVisitor.Options.OutputByValModifier = true;
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(StripWhitespace(program), StripWhitespace(outputVisitor.Text));
		}
Esempio n. 8
0
        void TestProgram(string program)
        {
            IParser parser = ParserFactory.CreateParser(SupportedLanguage.VBNet, new StringReader(program));

            parser.Parse();
            Assert.AreEqual("", parser.Errors.ErrorOutput);
            VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();

            outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
            Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
            Assert.AreEqual(StripWhitespace(program), StripWhitespace(outputVisitor.Text));
        }
Esempio n. 9
0
        void TestProgram(string program)
        {
            VBParser parser = ParserFactory.CreateParser(new StringReader(program));

            parser.Parse();
            Assert.AreEqual("", parser.Errors.ErrorOutput);
            VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();

            outputVisitor.Options.OutputByValModifier = true;
            outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
            Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
            Assert.AreEqual(StripWhitespace(program), StripWhitespace(outputVisitor.Text));
        }
Esempio n. 10
0
        public void TestProgram(string input, string expectedOutput)
        {
            IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(input));

            parser.Parse();
            Assert.AreEqual("", parser.Errors.ErrorOutput);
            parser.CompilationUnit.AcceptVisitor(new CSharpToVBNetConvertVisitor(), null);
            VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();

            outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
            Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
            Assert.AreEqual(expectedOutput, outputVisitor.Text);
        }
		void TestProgramCS2VB(string programCS, string programVB)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(programCS));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
			using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(),
			                                    outputVisitor)) {
				outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			}
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(programVB.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", ""));
			parser.Dispose();
		}
		public void TestProgram(string input, string expectedOutput)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(input));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			parser.CompilationUnit.AcceptVisitor(new CSharpConstructsConvertVisitor(), null);
			parser.CompilationUnit.AcceptVisitor(new ToVBNetConvertVisitor(), null);
			VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
			outputVisitor.Options.IndentationChar = ' ';
			outputVisitor.Options.IndentSize = 2;
			outputVisitor.Options.OutputByValModifier = true;
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(expectedOutput, outputVisitor.Text);
		}
Esempio n. 13
0
        void TestProgramCS2VB(string programCS, string programVB)
        {
            IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(programCS));

            parser.Parse();
            Assert.AreEqual("", parser.Errors.ErrorOutput);
            VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();

            using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(),
                                                outputVisitor)) {
                outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
            }
            Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
            Assert.AreEqual(programVB.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", ""));
            parser.Dispose();
        }
        public void TestProgram(string input, string expectedOutput)
        {
            IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(input));

            parser.Parse();
            Assert.AreEqual("", parser.Errors.ErrorOutput);
            parser.CompilationUnit.AcceptVisitor(new CSharpConstructsConvertVisitor(), null);
            parser.CompilationUnit.AcceptVisitor(new ToVBNetConvertVisitor(), null);
            VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();

            outputVisitor.Options.IndentationChar     = ' ';
            outputVisitor.Options.IndentSize          = 2;
            outputVisitor.Options.OutputByValModifier = true;
            outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
            Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
            Assert.AreEqual(expectedOutput, outputVisitor.Text);
        }
Esempio n. 15
0
		void TestProgramCS2VB(string programCS, string programVB)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(programCS));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
			List<ISpecial> specials = parser.Lexer.SpecialTracker.RetrieveSpecials();
			PreprocessingDirective.CSharpToVB(specials);
			outputVisitor.Options.IndentationChar = ' ';
			outputVisitor.Options.IndentSize = 2;
			using (SpecialNodesInserter.Install(specials, outputVisitor)) {
				outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			}
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(programVB.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", ""));
			parser.Dispose();
		}
Esempio n. 16
0
		void TestProgram(string program)
		{
			VBParser parser = ParserFactory.CreateParser(new StringReader(program));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
			outputVisitor.Options.IndentationChar = ' ';
			outputVisitor.Options.TabSize = 2;
			outputVisitor.Options.IndentSize = 2;
			using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(),
			                                    outputVisitor)) {
				outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			}
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(program.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", ""));
			parser.Dispose();
		}
Esempio n. 17
0
        void TestProgram(string program)
        {
            VBParser parser = ParserFactory.CreateParser(new StringReader(program));

            parser.Parse();
            Assert.AreEqual("", parser.Errors.ErrorOutput);
            VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();

            outputVisitor.Options.IndentationChar = ' ';
            outputVisitor.Options.TabSize         = 2;
            outputVisitor.Options.IndentSize      = 2;
            using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(),
                                                outputVisitor)) {
                outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
            }
            Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
            Assert.AreEqual(program.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", ""));
            parser.Dispose();
        }
Esempio n. 18
0
        void TestProgramCS2VB(string programCS, string programVB)
        {
            IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(programCS));

            parser.Parse();
            Assert.AreEqual("", parser.Errors.ErrorOutput);
            VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
            List <ISpecial>    specials      = parser.Lexer.SpecialTracker.RetrieveSpecials();

            PreprocessingDirective.CSharpToVB(specials);
            outputVisitor.Options.IndentationChar = ' ';
            outputVisitor.Options.IndentSize      = 2;
            using (SpecialNodesInserter.Install(specials, outputVisitor)) {
                outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
            }
            Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
            Assert.AreEqual(programVB.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", ""));
            parser.Dispose();
        }
		public void TestProgram(string input, string expectedOutput)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(input));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			var specials = parser.Lexer.SpecialTracker.RetrieveSpecials();
			PreprocessingDirective.CSharpToVB(specials);
			parser.CompilationUnit.AcceptVisitor(new CSharpConstructsConvertVisitor(), null);
			parser.CompilationUnit.AcceptVisitor(new ToVBNetConvertVisitor(), null);
			VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
			outputVisitor.Options.IndentationChar = ' ';
			outputVisitor.Options.IndentSize = 2;
			outputVisitor.Options.OutputByValModifier = true;
			using (SpecialNodesInserter.Install(specials, outputVisitor)) {
				outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			}
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(expectedOutput.Replace("\r", ""), outputVisitor.Text.Replace("\r", ""));
		}
Esempio n. 20
0
        public void TestProgram(string input, string expectedOutput)
        {
            IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(input));

            parser.Parse();
            Assert.AreEqual("", parser.Errors.ErrorOutput);
            var specials = parser.Lexer.SpecialTracker.RetrieveSpecials();

            PreprocessingDirective.CSharpToVB(specials);
            parser.CompilationUnit.AcceptVisitor(new CSharpConstructsConvertVisitor(), null);
            parser.CompilationUnit.AcceptVisitor(new ToVBNetConvertVisitor(), null);
            VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();

            outputVisitor.Options.IndentationChar     = ' ';
            outputVisitor.Options.IndentSize          = 2;
            outputVisitor.Options.OutputByValModifier = true;
            using (SpecialNodesInserter.Install(specials, outputVisitor)) {
                outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
            }
            Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
            Assert.AreEqual(expectedOutput.Replace("\r", ""), outputVisitor.Text.Replace("\r", ""));
        }