Пример #1
0
        public void SetUpFixture()
        {
            using (TextEditorControl textEditor = new TextEditorControl()) {
                document        = textEditor.Document;
                textEditor.Text = GetTextEditorCode();

                RubyParser         parser         = new RubyParser();
                MockProjectContent projectContent = new MockProjectContent();
                MockProject        project        = new MockProject();
                project.RootNamespace  = "RootNamespace";
                projectContent.Project = project;
                ICompilationUnit compilationUnit = parser.Parse(projectContent, @"test.py", document.TextContent);

                using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
                    IDesignerHost        host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                    IEventBindingService eventBindingService = new MockEventBindingService(host);
                    Form form = (Form)host.RootComponent;
                    form.ClientSize = new Size(200, 300);

                    PropertyDescriptorCollection descriptors            = TypeDescriptor.GetProperties(form);
                    PropertyDescriptor           namePropertyDescriptor = descriptors.Find("Name", false);
                    namePropertyDescriptor.SetValue(form, "MainForm");

                    // Add picture box
                    PictureBox pictureBox = (PictureBox)host.CreateComponent(typeof(PictureBox), "pictureBox1");
                    pictureBox.Location = new Point(0, 0);
                    pictureBox.Image    = new Bitmap(10, 10);
                    pictureBox.Size     = new Size(100, 120);
                    pictureBox.TabIndex = 0;
                    form.Controls.Add(pictureBox);

                    MockTextEditorProperties properties = new MockTextEditorProperties();
                    properties.ConvertTabsToSpaces = true;
                    properties.IndentationSize     = 4;

                    DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
                    using (serializationManager.CreateSession()) {
                        RubyDesignerGenerator.Merge(host, document, compilationUnit, properties, serializationManager);
                    }
                }
            }
        }
        public void SetUpFixture()
        {
            string ruby = "class Test\r\n" +
                          "\r\n" +
                          "\tdef foo\r\n" +
                          "\tend\r\n" +
                          "end";

            DefaultProjectContent projectContent = new DefaultProjectContent();
            RubyParser            parser         = new RubyParser();

            compilationUnit = parser.Parse(projectContent, @"C:\test.rb", ruby);
            if (compilationUnit.Classes.Count > 0)
            {
                c = compilationUnit.Classes[0];
                if (c.Methods.Count > 0)
                {
                    method = c.Methods[0];
                }

                TextArea textArea = new TextArea();
                document               = new TextDocument();
                textArea.Document      = document;
                textArea.Document.Text = ruby;

                // Get folds.
                ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy(textArea);
                ParseInformation      parseInfo       = new ParseInformation(compilationUnit);
                foldingStrategy.UpdateFoldings(parseInfo);
                List <FoldingSection> folds = new List <FoldingSection>(foldingStrategy.FoldingManager.AllFoldings);

                if (folds.Count > 0)
                {
                    classFold = folds[0];
                }
                if (folds.Count > 1)
                {
                    methodFold = folds[1];
                }
            }
        }
Пример #3
0
        public void SetUpFixture()
        {
            string Ruby = "def foo\r\n" +
                          "end\r\n" +
                          "\r\n" +
                          "def bar(i)\r\n" +
                          "end";

            DefaultProjectContent projectContent = new DefaultProjectContent();
            RubyParser            parser         = new RubyParser();

            compilationUnit = parser.Parse(projectContent, @"C:\test.rb", Ruby);

            if (compilationUnit.Classes.Count > 0)
            {
                globalClass = compilationUnit.Classes[0];
                if (globalClass.Methods.Count > 1)
                {
                    fooMethod = globalClass.Methods[0];
                    barMethod = globalClass.Methods[1];
                }
            }

            // Get folds.
            ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy();
            ParseInformation      parseInfo       = new ParseInformation();

            parseInfo.SetCompilationUnit(compilationUnit);

            DocumentFactory docFactory = new DocumentFactory();
            IDocument       doc        = docFactory.CreateDocument();

            doc.TextContent = Ruby;
            List <FoldMarker> markers = foldingStrategy.GenerateFoldMarkers(doc, @"C:\Temp\test.rb", parseInfo);

            if (markers.Count > 1)
            {
                fooMethodMarker = markers[0];
                barMethodMarker = markers[1];
            }
        }
        public void SetUpFixture()
        {
            string Ruby = "class Test\r\n" +
                          "\tdef foo(sender, e)\r\n" +
                          "\tend\r\n" +
                          "end";

            DefaultProjectContent projectContent  = new DefaultProjectContent();
            RubyParser            parser          = new RubyParser();
            ICompilationUnit      compilationUnit = parser.Parse(projectContent, @"C:\test.rb", Ruby);

            if (compilationUnit.Classes.Count > 0)
            {
                IClass c = compilationUnit.Classes[0];
                method = c.Methods[0];
                if (method.Parameters.Count > 1)
                {
                    senderParameter    = method.Parameters[0];
                    eventArgsParameter = method.Parameters[1];
                }
            }
        }
Пример #5
0
        public void SetUpFixture()
        {
            DerivedRubyDesignerGenerator   generator       = new DerivedRubyDesignerGenerator();
            MockTextEditorViewContent      mockViewContent = new MockTextEditorViewContent();
            DerivedFormDesignerViewContent viewContent     = new DerivedFormDesignerViewContent(mockViewContent, new MockOpenedFile("Test.rb"));

            viewContent.DesignerCodeFileContent = GetTextEditorCode();

            // Create parse info.
            RubyParser       parser    = new RubyParser();
            ICompilationUnit unit      = parser.Parse(new MockProjectContent(), @"C:\Projects\MyProject\test.rb", GetTextEditorCode());
            ParseInformation parseInfo = new ParseInformation();

            parseInfo.SetCompilationUnit(unit);
            generator.ParseInfoToReturnFromParseFileMethod = parseInfo;

            // Attach view content to generator.
            generator.Attach(viewContent);

            // Get compatible methods for event.
            MockEventDescriptor eventDescriptor = new MockEventDescriptor("Click");

            compatibleMethods = generator.GetCompatibleMethods(eventDescriptor);
        }
        public void SetUpFixture()
        {
            string Ruby = "class Test\r\n" +
                          "\tdef initialize\r\n" +
                          "\t\tputs 'test'\r\n" +
                          "\tend\r\n" +
                          "end";

            DefaultProjectContent projectContent = new DefaultProjectContent();
            RubyParser            parser         = new RubyParser();

            compilationUnit = parser.Parse(projectContent, @"C:\test.rb", Ruby);
            if (compilationUnit.Classes.Count > 0)
            {
                c = compilationUnit.Classes[0];
                if (c.Methods.Count > 0)
                {
                    method = c.Methods[0];
                }

                // Get folds.
                ParserFoldingStrategy foldingStrategy = new ParserFoldingStrategy();
                ParseInformation      parseInfo       = new ParseInformation();
                parseInfo.SetCompilationUnit(compilationUnit);

                DocumentFactory docFactory = new DocumentFactory();
                IDocument       doc        = docFactory.CreateDocument();
                doc.TextContent = Ruby;
                List <FoldMarker> markers = foldingStrategy.GenerateFoldMarkers(doc, @"C:\Temp\test.py", parseInfo);

                if (markers.Count > 1)
                {
                    methodMarker = markers[1];
                }
            }
        }