Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#100 Ruby Syntax

None
pending
nobody
Filetypes (68)
Unknown
3
2014-08-16
2007-11-28
Daniel
No

In the 'Symbol' tab (strange name), while editing Ruby programs, it lists classes and methods. The representation is incorrect.
Examples:

Ruby code:

class RootLevelClass
  class EmbeddedClass1
  end
end

module RootLevelModule
  def module_method
  end
  class EmbeddedClass2
    class EmbeddedSubClass < RootLevelClass::EmbeddedClass1
      CLASS_CONSTANT_1='We\'re constants'
      Class_Constant_2=:because_we_start_with_a_capital_letter
      i="am just a variable, don't mind me"
      def self.class_method_1
      end
      def EmbeddedSubClass.class_method_2
      end
      def instance_method_1
      end
    end
    def EmbeddedSubClass.class_method_3
    end
  end
end

obj=RootLevelModule::EmbeddedClass2::EmbeddedSubClass.new
def obj.instance_method_2
end

class RootLevelModule::EmbeddedClass3
end

produces:

  • Classes
    • RootLevelClass
    • RootLevelClass.EmbeddedClass1
    • RootLevelModule.EmbeddedClass2
    • RootLevelModule.EmbeddedClass2.EmbeddedSubClass
  • Methods
    • RootLevelModule.EmbeddedClass2.EmbeddedSubClass.instance_method_1
    • RootLevelModule.module_method

This is incorrect syntax.
Correct result:

  • Modules
    • RootLevelModule
  • Classes
    • RootLevelClass
    • RootLevelClass::EmbeddedClass1
    • RootLevelModule::EmbeddedClass2
    • RootLevelModule::EmbeddedClass2::EmbeddedSubClass
    • RootLevelModule::EmbeddedClass3
  • Methods
    • RootLevelModule.module_method
    • RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class_method_1
    • RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class_method_2
    • RootLevelModule::EmbeddedClass2::EmbeddedSubClass#instance_method_1
    • RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class_method_3
    • obj.instance_method_2

That is the ideal result, but I understand if you don't feel like implementing all of them in a hurry. I would be glad to help if I can. Unfortunately, I don't know C, which Geany appears to be written in. Thanks for a nice program.

Discussion

  • Daniel
    Daniel
    2007-11-28

    Logged In: YES
    user_id=1877428
    Originator: YES

    geany 0.12
    Ubuntu 7.10 Gutsy Gibbon

    Devi.webmaster@skip.this.gmail.com

     
  • Enrico Tröger
    Enrico Tröger
    2007-11-29

    Logged In: YES
    user_id=1117045
    Originator: NO

    Thanks for reporting.
    I added Module and Singletons sections in the symbol list in SVN r2078.
    What about the context separator("::" vs ".") to separate the scopes? Should we change it to "::"? The CTags parser uses also ".".

    The wrong parsing of your example code is more or less a bug of Exuberant Ctags(http://ctags.sf.net) and I would like you to file a bug report there for this issue since Geany uses the Ruby parser from CTags. The maintainer of the Ruby parser may fix this much quicker and better than me.
    Thanks.

     
  • Today the status is much better than what the original post reports, though it's still not perfect. All is as the OP's "correct result", but:

    * RootLevelModule::EmbeddedClass3 is wrongly recognized as a class named RootLevelModule (dirty patch available, may get committed);
    * RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class_method_3 appears as a method of EmbeddedClass2 rather than EmbeddedSubClass;
    * obj.instance_method_2 doesn't show the "obj" part.

    Fixing the first one is relatively easy if somewhat dirty code isn't an issue. The 2 others are more tricky and would require at least to know Ruby better than I do to fix them, because it seems not *every* dot-separated prefixes denotes a deeper scope (see class_method_1 defined as self.class_method_1 and class_method_2 defined as EmbeddedSubClass.class_method_2 that seem to be in the current scope; but class_method_3 would be in EmbeddedSubClass's scope).

     
    • labels: --> Filetypes
    • priority: 5 --> 3
     
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -2,62 +2,69 @@
     Examples:
    
     Ruby code:
    -class RootLevelClass
    -class EmbeddedClass1
    -end
    -end
    -module RootLevelModule
    -def module\_method
    -end
    -class EmbeddedClass2
    -class EmbeddedSubClass &lt; RootLevelClass::EmbeddedClass1
    -CLASS\_CONSTANT\_1='We\'re constants'
    -Class\_Constant\_2=:because\_we\_start\_with\_a\_capital\_letter
    -i="am just a variable, don't mind me"
    -def self.class\_method\_1
    -end
    -def EmbeddedSubClass.class\_method\_2
    -end
    -def instance\_method\_1
    -end
    -end
    -def EmbeddedSubClass.class\_method\_3
    -end
    -end
    -end
    -obj=RootLevelModule::EmbeddedClass2::EmbeddedSubClass.new
    -def obj.instance\_method\_2
    -end
    -class RootLevelModule::EmbeddedClass3
    -end
    +
    +    ::ruby
    +    class RootLevelClass
    +      class EmbeddedClass1
    +      end
    +    end
    +
    +    module RootLevelModule
    +      def module_method
    +      end
    +      class EmbeddedClass2
    +        class EmbeddedSubClass < RootLevelClass::EmbeddedClass1
    +          CLASS_CONSTANT_1='We\'re constants'
    +          Class_Constant_2=:because_we_start_with_a_capital_letter
    +          i="am just a variable, don't mind me"
    +          def self.class_method_1
    +          end
    +          def EmbeddedSubClass.class_method_2
    +          end
    +          def instance_method_1
    +          end
    +        end
    +        def EmbeddedSubClass.class_method_3
    +        end
    +      end
    +    end
    +
    +    obj=RootLevelModule::EmbeddedClass2::EmbeddedSubClass.new
    +    def obj.instance_method_2
    +    end
    +
    +    class RootLevelModule::EmbeddedClass3
    +    end
    
     produces:
    -Classes
    -RootLevelClass
    -RootLevelClass.EmbeddedClass1
    -RootLevelModule.EmbeddedClass2
    -RootLevelModule.EmbeddedClass2.EmbeddedSubClass
    -Methods
    -RootLevelModule.EmbeddedClass2.EmbeddedSubClass.instance\_method\_1
    -RootLevelModule.module\_method
    +
    ++ Classes
    +    - `RootLevelClass`
    +    - `RootLevelClass.EmbeddedClass1`
    +    - `RootLevelModule.EmbeddedClass2`
    +    - `RootLevelModule.EmbeddedClass2.EmbeddedSubClass`
    ++ Methods
    +    - `RootLevelModule.EmbeddedClass2.EmbeddedSubClass.instance_method_1`
    +    - `RootLevelModule.module_method`
    
     This is incorrect syntax.
     Correct result:
    -Modules
    -RootLevelModule
    -Classes
    -RootLevelClass
    -RootLevelClass::EmbeddedClass1
    -RootLevelModule::EmbeddedClass2
    -RootLevelModule::EmbeddedClass2::EmbeddedSubClass
    -RootLevelModule::EmbeddedClass3
    -Methods
    -RootLevelModule.module\_method
    -RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class\_method\_1
    -RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class\_method\_2
    -RootLevelModule::EmbeddedClass2::EmbeddedSubClass\#instance\_method\_1
    -RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class\_method\_3
    -obj.instance\_method\_2
    +
    ++ Modules
    +    - `RootLevelModule`
    ++ Classes
    +    - `RootLevelClass`
    +    - `RootLevelClass::EmbeddedClass1`
    +    - `RootLevelModule::EmbeddedClass2`
    +    - `RootLevelModule::EmbeddedClass2::EmbeddedSubClass`
    +    - `RootLevelModule::EmbeddedClass3`
    ++ Methods
    +    - `RootLevelModule.module_method`
    +    - `RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class_method_1`
    +    - `RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class_method_2`
    +    - `RootLevelModule::EmbeddedClass2::EmbeddedSubClass#instance_method_1`
    +    - `RootLevelModule::EmbeddedClass2::EmbeddedSubClass.class_method_3`
    +    - `obj.instance_method_2`
    
     That is the ideal result, but I understand if you don't feel like implementing all of them in a hurry. I would be glad to help if I can. Unfortunately, I don't know C, which Geany appears to be written in. Thanks for a nice program.
    
    • status: open --> pending
    • Found in: --> Unknown
    • Fixed in: --> None
     
  • Fixing this awaits more Ruby knowledge.