• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Ruby Code Completion

Scheduled Pinned Locked Moved Developers' Forum
9 Posts 2 Posters 2.1k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    Soundbytes
    last edited by 11 Dec 2012, 18:41

    Hi,

    This is my first post to this Forum. I am new to Ruby and the SU api but have been programming in a couple of languages over the years (mainly C, C++, php and vba)

    Being a beginner with Ruby I thought it might be a good idea to use an IDE that supports code completion.
    I have tried out a few editors and found that RubyMine will properly autocomplete my test example:

    class Foo
      ##
      # Foo, foo foo foo bar!
      
      def bar()
        return "Hello!"
      end
    end
    
    foo = Foo.new # Komodo, RubyMine; Autocomlete works fine here. 
                  # Ironruby; couldn't get autocompletion to work at all. ;(
    
    foobar = foo.bar # Ko; Autocomlete list consists of methods plus entry "bar"
                     # Ko; typing space or "(" after "bar" brings up the calltip
                     # RM; Autocomplete List includes class names - very nice!    
                     # RM; calltip includes parameter list but no documentation. 
       
    len = foobar.length # At this point no Autocompletion in Komodo Edit!
                        # RM; Code completion still available!
    

    From what I've gathered so far it seems like only RubyMine offers sufficient code completion. Autocomplete in Komodo edit only seems to work for objects that were created using the new method but not for those that were returned from a member function.

    Question: Are there any other IDEs or Editors I should consider?
    Code completetion should at least match the results of the free Komodo Edit.

    thanksalot!

    Andreas

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 12 Dec 2012, 03:39

      Most of us use the Notepad++ editor, that uses XML files that we can tweak.

      Some of the guys here added SketchUp API classes and methods to it's Ruby autocomplete XML file.

      Sorry to say that it's is difficult to hook an IDE into a Ruby subprocess that belongs to another application.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • S Offline
        Soundbytes
        last edited by 12 Dec 2012, 14:49

        @dan rathbun said:

        Most of us use the Notepad++ editor, that uses XML files that we can tweak.

        Some of the guys here added SketchUp API classes and methods to it's Ruby autocomplete XML file. ...

        I have created a couple of api files for the scite editor in the past and since notepad++ is based on the same scite engine I was of the opinion that it has the same limitations?

        IDEs that come with inbuilt Language support will parse all the language libraries plus my own script files and add the included definitions and documentation to the autocomplete data base automatically. I am afraid I am so used to having that I am spoiled for any simpler solutions.

        @unknownuser said:

        ... Sorry to say that it's is difficult to hook an IDE into a Ruby subprocess that belongs to another application.

        At the moment I don't need to hook into the sketchup Ruby process. I'll be just happy to get the autocompletion working.
        (Of course it would be great to be able to debug Sketchup scripts from the IDE.)

        Update:
        I have now tested the autocompletion features of both Eclipse (+DLTK plugin) and Netbeans 7.01 with my code fragment and found that both of them do the job very well. I am happy that I found two free solutions that fulfill my requirements.
        My preference at the moment is with Netbeans because I find the editor a bit more accessible and also because it was much easier to install.

        Andreas

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 12 Dec 2012, 16:53

          @soundbytes said:

          I have created a couple of api files for the sciTE editor in the past and since notepad++ is based on the same sciTE engine I was of the opinion that it has the same limitations?

          Yes, both are built on Scintilla.

          sciTE is really just an example. The features of Notepad++ put it to shame. Configuration dialogs and Plugins etc. For javascript, the JSLint & JsHint syntax checking plugins are invaluable!

          But.. yes... it's autocomplete is rather dumb! It cannot add extra API defintions (yet,) and does not not yet have a plugin to add "local" defintitons from the open files.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 12 Dec 2012, 17:00

            @soundbytes said:

            Update:
            My preference at the moment is with Netbeans because I find the editor a bit more accessible and also because it was much easier to install.

            I have heard good things about both.

            But until it becomes possible to hook an IDE's debugger into SketchUp's embedded Ruby process, I don't see a point in changing.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 12 Dec 2012, 17:25

              FYI, other topics on this issue:

              Notepad++:

              • Notepad++

              • Notepad++ SU8 Ruby API Autocomplete

              • thomthom's bitbucket repo for NPP AutoComplete XML

              • [Info] Notepad++ : Tip, Tricks & Plugins

              • Notepad++ and SketchUp Bridge in SU8

              OTHER:

              • Multiplatform editor Sublime Text 2

              • Open Komodo

              • ruby dev environment (re: RDE)

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • S Offline
                Soundbytes
                last edited by 12 Dec 2012, 22:06

                @dan rathbun said:

                ... But until it becomes possible to hook an IDE's debugger into SketchUp's embedded Ruby process, I don't see a point in changing.

                I agree that a perfect Sketchup Ruby IDE should include a debugger.
                On the other hand I think that a properly implemented autocompletion would be a great advantage over the existing development environments. (especially for those not familiar with every detail of the api - like me for example).

                Here is a list of features a perfect IDE would have:

                1. High quality code completion (comparable to current solutions that exist for established languages)
                2. Calltips - these show the documentation and method parameter definitions as a tooltip.
                3. Ability to load code changes into the sketchup ruby engine through a single or at least a small number of key strokes.
                4. Debugger that lets you step through the ruby code as it is executed.

                Some of these ponts are relatively easy to achive. Some will take quite some effort and some might not be possible at all.

                1., 2. Code completion and calltips:
                It is clear now that a number of IDEs can supply that (Rubymine, Neatbeans, Eclips, maybe more.) Unfortunately we can not simply include the Sketchup Ruby Libraries because these have not been made available to the public.
                What we have got instead is the mere Api documentation. If this documentation could be transformed into a proper implementation of mockup class definitions then these could be used instead of the real Libraries to make code completion for the entire API available.
                IMO this is perfectly doable even for a beginner. It's just a lot of work to write the entire 1100 mock method definitions and to copy the relevant parts of the api docs into code documentation comments.

                3. load code changes quickly:
                Most IDEs are able to run external commands. Using the SU bridge the task can be achieved without much effort. (Netbeans can't do it out of the box. Fortunately there is a third party 'Path tools' plugin that can be (ab)used to do the trick)

                4. Debugger:
                Again I see good chances that the Ruby debugger could be made available for Sketchup script development within the Netbeans IDE.

                • The netbeans Ruby Plugin is open source. It could be used as a starting point for a dedicated Sketchp Ruby Plugin.
                • A proof of concept implementation of a sketchup ruby debugger already exists with Surdebug. I agree the thing looks quite broken. Still it might be worthwhile to find out if it can be repaired and integrated within a Netbeans plugin.

                My current roadmap covers points 1. , 2. and 3.
                I see good chances that a mockup implementstion of the Api can be done. And using the SU bridge I consider the reload functionality already as achieved.
                The debugger implementation I'm afraid is beyond my limited ressources and abilities.

                Andreas

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Dan Rathbun
                  last edited by 13 Dec 2012, 01:32

                  @soundbytes said:

                  1., 2. Code completion and calltips:

                  Please help out for ALL editors and IDEs by expanding the XML file at thomthom's BitBucket repo.

                  Since it is XML... it can then easily be filtered (with various XLST files,) into other formats for other Editors & IDEs.

                  For example, the Sublime editor uses a JSON-like object format.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dan Rathbun
                    last edited by 13 Dec 2012, 01:58

                    Somewhere in one of the SU Bridge topic threads I posted a SketchupExtension script example that works for installing the SUB files in a common install directory.

                    ADD: OK, found it here: Re: Notepad++ SU8 Ruby API Autocomplete
                    .. and the d/l link is: bridge_ext.rb

                    This very important especially if you are a developer, and have several side-by-side SketchUp installs of various versions / MR levels.

                    It lets the IDE/Editor have a single valid path to SUB.exe, no matter which SketchUp version you are testing your code on.

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    1 / 1
                    • First post
                      1/9
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement