public override void Run()
		{
			IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
			
			if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
				return;
			}
			TextEditorControl textEditorControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
			
			ParseInformation parseInformation;
			
			if (window.ViewContent.IsUntitled) {
				parseInformation = ParserService.ParseFile(textEditorControl.FileName, textEditorControl.Document.TextContent);
			} else {
				parseInformation = ParserService.GetParseInformation(textEditorControl.FileName);
			}
			
			if (parseInformation == null) {
				return;
			}
			
			ICompilationUnit cu = parseInformation.MostRecentCompilationUnit as ICompilationUnit;
			if (cu == null) {
				return;
			}
			IClass currentClass = GetCurrentClass(textEditorControl, cu, textEditorControl.FileName);
			
			if (currentClass != null) {
				ArrayList categories = new ArrayList();
				ArrayList generators = AddInTree.BuildItems("/AddIns/DefaultTextEditor/CodeGenerator", this, true);
				using (CodeGenerationForm form = new CodeGenerationForm(textEditorControl, (CodeGeneratorBase[])generators.ToArray(typeof(CodeGeneratorBase)), currentClass)) {
					form.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
				}
			}
		}
		public override void Run()
		{
			IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
			
			if (viewContent == null || !(viewContent is ITextEditorControlProvider)) {
				return;
			}
			TextEditorControl textEditorControl = ((ITextEditorControlProvider)viewContent).TextEditorControl;
			
			ParseInformation parseInformation;
			
			if (viewContent.PrimaryFile.IsUntitled) {
				parseInformation = ParserService.ParseFile(textEditorControl.FileName, textEditorControl.Document.TextContent);
			} else {
				parseInformation = ParserService.GetParseInformation(textEditorControl.FileName);
			}
			
			if (parseInformation == null) {
				return;
			}
			
			ICompilationUnit cu = parseInformation.MostRecentCompilationUnit as ICompilationUnit;
			if (cu == null) {
				return;
			}
			IClass currentClass = GetCurrentClass(textEditorControl, cu, textEditorControl.FileName);
			
			if (currentClass != null) {
				var generators = AddInTree.BuildItems<CodeGeneratorBase>("/AddIns/DefaultTextEditor/CodeGenerator", this, true);
				using (CodeGenerationForm form = new CodeGenerationForm(textEditorControl, generators.ToArray(), currentClass)) {
					form.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
				}
			}
		}
Example #3
0
        public override void Run()
        {
            IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;

            if (window == null || !(window.ViewContent is ITextEditorControlProvider))
            {
                return;
            }
            TextEditorControl textEditorControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;

            ParseInformation parseInformation;

            if (window.ViewContent.IsUntitled)
            {
                parseInformation = ParserService.ParseFile(textEditorControl.FileName, textEditorControl.Document.TextContent);
            }
            else
            {
                parseInformation = ParserService.GetParseInformation(textEditorControl.FileName);
            }

            if (parseInformation == null)
            {
                return;
            }

            ICompilationUnit cu = parseInformation.MostRecentCompilationUnit as ICompilationUnit;

            if (cu == null)
            {
                return;
            }
            IClass currentClass = GetCurrentClass(textEditorControl, cu, textEditorControl.FileName);

            if (currentClass != null)
            {
                ArrayList categories = new ArrayList();
                ArrayList generators = AddInTree.BuildItems("/AddIns/DefaultTextEditor/CodeGenerator", this, true);
                using (CodeGenerationForm form = new CodeGenerationForm(textEditorControl, (CodeGeneratorBase[])generators.ToArray(typeof(CodeGeneratorBase)), currentClass)) {
                    form.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
                }
            }
        }
Example #4
0
        public override void Run()
        {
            IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;

            if (viewContent == null || !(viewContent is ITextEditorControlProvider))
            {
                return;
            }
            TextEditorControl textEditorControl = ((ITextEditorControlProvider)viewContent).TextEditorControl;

            ParseInformation parseInformation;

            if (viewContent.PrimaryFile.IsUntitled)
            {
                parseInformation = ParserService.ParseFile(textEditorControl.FileName, textEditorControl.Document.TextContent);
            }
            else
            {
                parseInformation = ParserService.GetParseInformation(textEditorControl.FileName);
            }

            if (parseInformation == null)
            {
                return;
            }

            ICompilationUnit cu = parseInformation.MostRecentCompilationUnit as ICompilationUnit;

            if (cu == null)
            {
                return;
            }
            IClass currentClass = GetCurrentClass(textEditorControl, cu, textEditorControl.FileName);

            if (currentClass != null)
            {
                var generators = AddInTree.BuildItems <CodeGeneratorBase>("/AddIns/DefaultTextEditor/CodeGenerator", this, true);
                using (CodeGenerationForm form = new CodeGenerationForm(textEditorControl, generators.ToArray(), currentClass)) {
                    form.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
                }
            }
        }