7ute / symbols-list

An alternate symbol list sidebar for Atom.io text editor
GNU General Public License v3.0
32 stars 24 forks source link

Language support ruby #44

Closed lumean closed 5 years ago

lumean commented 7 years ago

Hi, first of all many thanks for this package. I'd like to to give some improvement suggestions for the parsing of ruby.

Currently the parser seems not to recognize inheritance (<) correctly. E.g. in case of class TestClass1< Grape::Entity it just shows Entity instead of TestClass1

module Entity
module VmInfoEntity
#modules can be used to create namespaces in ruby

# e.g. the canonical name of the class below would be  Entity::VmInfoEntity::TestClass1 (<Grape::Entity)
# currently it just displays  'Entity' because of the Grape::Entity parent class
# would be fine if  just 'TestClass1' is displayed (don't think the canonical name and inheritance is needed)
  class TestClass1< Grape::Entity
    expose :show_command, documentation: {type: 'String', desc: 'generated'}
    expose :show_command2, documentation: {type: 'String', desc: 'generated'}
  end

  class TestClass2< Grape::Entity
    expose :show_command, documentation: {type: 'String', desc: 'generated'}
    expose :show_command2, documentation: {type: 'String', desc: 'generated'}
  end

  class TestVmInfoEntity< Grape::Entity

    expose :blah, documentation: {type: TestClass2, desc: 'generated'}
    expose :blah2, documentation: {type: TestClass1, desc: 'generated'}
    expose :test_methods, documentation: {type: 'String', is_array: true, desc: 'generated'}
    expose :test_case_class, documentation: {type: 'String', desc: 'generated'}
  end

  class VmInfoEntity < Grape::Entity
    expose :TestVmInfo, documentation: {type: TestVmInfoEntity, desc: 'generated'}

      # also this method is not correctly parsed somehow stopping at the &
    def my_method(*args, &block)
    end
  end

end # VmInfoEntity
end # module Entity

It is quite difficult to parse ruby code correctly based on regexes. I think a lexer/parser would be needed. Maybe instead of regexes you can get the information somehow from atoms built in symbol-view https://atom.io/packages/symbols-view the parsing seems quite complete there

lumean commented 7 years ago

I think https://atom.io/packages/symbols-tree-view is also taking the tags/parsing directly from the built-in symbol-view

7ute commented 5 years ago

Hi,

I added the support for inheritance, that will be available in the next release (https://github.com/7ute/symbols-list/commit/989a5a6481064620424a10f34e0af7d38083c706) Let me know if that can be improved.

inheritance