oleg-shilo / sublime-codemap

CodeMap - is a ST3 plugin for showing the code tree representing the code structure of the active view/document
MIT License
41 stars 4 forks source link

Does not work for php #6

Closed bantya closed 2 months ago

bantya commented 7 years ago

This package does not work for php code in Sublime Dev Build 3142. For CodeMap: Toggle Visibility opens vertical column on right side but with no content inside it. The console output for this command is:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 389, in run_callback
    expr()
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 522, in <lambda>
    run_callback('on_activated', callback, lambda: callback.on_activated(v))
  File "trailing_spaces in C:\Users\MyUsername\AppData\Roaming\Sublime Text 3\Installed Packages\TrailingSpaces.sublime-package", line 421, in on_activated
  File "trailing_spaces in C:\Users\MyUsername\AppData\Roaming\Sublime Text 3\Installed Packages\TrailingSpaces.sublime-package", line 129, in match_trailing_spaces
  File "trailing_spaces in C:\Users\MyUsername\AppData\Roaming\Sublime Text 3\Installed Packages\TrailingSpaces.sublime-package", line 86, in find_trailing_spaces
  File "C:\Program Files\Sublime Text 3\sublime.py", line 641, in __getitem__
    raise IndexError()
IndexError

On closing the opened Code - Map file console outputs:

Traceback (most recent call last):
  File "code_map in C:\Users\MyUsername\AppData\Roaming\Sublime Text 3\Installed Packages\CodeMap.sublime-package", line 171, in focus_source_code
TypeError: 'int' object is not subscriptable

While, command CodeMap: Reveal in CodeMap does nothing with no console output:

Please solve this issue and make CodeMap great again!

oleg-shilo commented 7 years ago

I will have a look at improving error handling but... the extension is not supposed to work for PHP syntax. Was the issue title a mistake?

oleg-shilo commented 6 years ago

It's not reproducible. At least on Build 3143:

st3_ 6 2

I am closing this issue but if you manage to come up with the test case to reproduce it please share it and reopen the issue.

Acecool commented 6 years ago

In order for it to work with php, you will need to write a custom mapper or wait until a universal mapper is available and then simply define the rules ( or let it read the syntax file and use those rules to parse it )...

oleg-shilo commented 6 years ago

Universal mapper is now available (CodeMap v1.0.9).

The brief description of how to use it is available directly from the setting file: https://github.com/oleg-shilo/sublime-codemap/blob/master/code_map.sublime-settings.

Acecool commented 6 years ago

I've just added basic PHP Mappings to XCodeMapper - https://bitbucket.org/Acecool/acecooldev_sublimetext3 - ( You only need the GMod Lua folder if you are using Garry's Mod Lua with my AcecoolDev_Framework for Gamemodes / Addon development )... I also added support for other languages... I'll be adding multi-type per file support soon so php can support: JavaScript, HTML, CSS, SQL, PHP.... HTML will need to support JavaScript, HTML, CSS.... ASP will need to support JavaScript, HTML, CSS, SQL, ASP... Etc..

If you want to help by submitting new mappings, please let me know.. I'm still working on the class-child-functions category algorithm to ensure it'll work in all cases... Python uses indentation to show where something belongs but PHP, JavaScript etc.. can use either { }s to denote ownership / scope or none for single-line if statements, etc... So I need to set up another system so the mapper can properly configure how it is defined...

Anyway - I've added the following to php mappings - right now it is quite basic... Basically just detecting comments, php tags ( I've commented out the output entry in PreOnAddEntry callback, detecting functions and classes, and also showing requires / includes... I've commented a few definition / debugging lines out as it appears a bit messy...

I've also set OnCalcDepth to 0 so everything lines up...

For now, you can modify the XCodeMapper_PHP_User class to add your own mappings / earmarks in the OnSetupSyntax callback function... Follow the same pattern as the PHP class above it ( The User class is for you to do with what you will, you can even get rid of the default mappings by setting the class-name from class XCodeMapper_PHP_User( XCodeMapper_PHP ): to class XCodeMapper_PHP_User( XCodeMapperBase ): which will ensure the base xcodemapper is used which doesn't come with any mappings other than the Note / Task, etc... If you don't want those, get rid of the super( ) call inside of OnSetupSyntax...

Hopefully this helps :-)

Here's what it looks like: https://www.dropbox.com/s/75uomnode92geim/map_acecooldev_framework_sublime_text_unregistered__screenshot_20180109064559_6705.png?dl=0