ActiveState Community

Source Tree

Posted by icampana on 2008-02-21 16:10 | Staff Pick!
0.7.5
Iván Campaña
Sun, 2009-04-12 19:24
  • : 4.0 - 5.*
  • : 4.0 - 5.*

This simple extension for Komodo Edit adds a new tab with the list of the functions, classes and methods of the current file, double clicking an item moves you to the line of that item. Can now also filter items on the tree.

This extension tries somehow to mimic the functionality available in Komodo-IDE, even though in a very basic way, it is not intended to replace it.

Finally now it has preferences to set it to be either on the left or on the right side tabs

Has support for Python source code with one level of subclassing, SQL support (thanks to Matt Keranen), CSS support and partial Javascript method identification(thanks to Jason Hendry), Perl support (thanks to mmueller), TCL support (thanks to dgroth), Ruby support (thanks to raldred), C++ (thanks to noop) and support for PHP and Javascript, comments are welcome.

Known bugs:

  • Functions in PHP should not have spaces on front of its definition.

Error reports and code contributions, please include them in this forum:
http://community.activestate.com/forum-topic/source-tree-community-extension-issues-and-improvement

Screenshot
SourceTree Snapshot

adam | Tue, 2008-10-28 01:11

Hi,
At first, thanks for cool extension. It's really useful.
I've installed and tested it and I have a few suggestions and questions:

1. Why it's on the right pane? It's more comfortable to have all extensions as tabs on left pane. Is this configurable and where?

2. It looks like don't like the Qwin extension. Don't work when both installed and strange things happend.

3. That would be really awesome to display also vars (like in Komodo IDE).

adam | Fri, 2008-11-07 01:54

Hi,
I've discovered one more thing. It really slows down when I have lot of functions in my document (more than 20). When I have opened several files in komodo and try to switch between, it hangs up for good 3-6 seconds trying to view document with lot of functions.

icampana | Fri, 2008-11-07 11:14

I've been testing the extension against some big files(a PHP file 6153 lines of code, 200KB with at least a 100 functions) and it gets parsed in less than a second, maybe it is something with your files, remember that this extension has to parse the whole text be able to understand the functions and create the tree, if you have some more info I could try to figure out what's happening.

--

e-van

adam | Wed, 2008-11-19 02:00

This happend on Komodo Edit, version 5.0.1, build 2537, platform win32-x86. When I have opened two php files (e.g. cakephp controllers) with classes with lot of methods (more than 10 and more than 1000 lines of code) and I'm trying to switch beetwen this files cliclikng on tabs. It takes a few seconds to switch.
Maybe your extension interfere with other extension. I have such problems in past with another extensions (probably qwin, I don't remember).

Another problem is that the sourcetree extension doesn't work with JSTreedrive extension enabled (on my machine). Can anybody confirm that?

andybak | Thu, 2008-11-20 09:23

I can confirm that it doesn't work with JSTreeDrive but as other extensions also stop working when I enable this I would imagine it's the fault of JSTreeDrive

joker | Sat, 2008-11-22 09:17

Problem is that Komodo Edit no tabs "codebrowserviewbox"

You can fix it like this...

--- sourcetree.jar\content\overlay.xul 
+++ sourcetree.jar\content\overlay.xul 
@@ -32,11 +32,11 @@
     </menupopup>
 <!-- codebrowser_tab -->
     <tabs id="project_toolbox_tabs">
-        <tab id="sourcetree_tab" label="Source" insertafter="toolbox_tab"
+        <tab id="sourcetree_tab" label="Source" insertafter="project_tab"
              tooltiptext="Source Tree"/>
     </tabs>
     <tabpanels id="project_toolbox_tabpanels">
-        <tabpanel flex="1" id="sourcetreeviewbox" insertafter="codebrowserviewbox">
+        <tabpanel flex="1" id="sourcetreeviewbox" insertafter="projectviewbox">
 		<vbox flex="1" id="sourcetree-vbox">
 		    <hbox align="center" id="sourcetree-tabpanel-hbox">
 		        <toolbarbutton

qwavel | Mon, 2008-12-01 14:39

I'm having the same problem - using Komodo Edit v5.0.2 with JSTreeDrive and Source Tree.

The fix described is a bit beyond me so I'll just wait for the next release.

Glad to see it mentioned though so I know that it's not something I'm doing wrong.

nathan | Sat, 2008-11-15 12:42

The new version seems to be on the left sidebar, I personally prefer having it on the right.. any way to configure this??

aaron | Wed, 2008-11-19 11:05

I've found that it's much easier to use this extension when it's on the right sidebar. I use the left sidebar to open files and the right sidebar to view the source in the file. I understand there are conflicting views on this but if it were configurable, it'd make everybody happy.

icampana | Wed, 2008-11-19 11:10

I do want it to be configurable, but since my knowledge of XUL and its friends is pretty much basic (this is the first extension I ever do) I have to dig a little bit more, I have received some suggestions, but I'll have to test first and learn how to implement it.

I'll let everybody know when I get something sorted out
--

e-van
Following the falling stars

ctasada | Tue, 2008-11-25 10:53

Checking in the forums I found this url: http://community.activestate.com/node/2841

You only need to open the sourcetree.jar file and edit the /content/overlay.xul file.

There look for all the "project_toolbox_tabs" ids and replace them for "project_toolbox_tabs"

Restart Komodo and you're done :)

icampana | Tue, 2008-12-02 05:47

Finally now it has preferences to set it to be either on the left or on the right side tabs.

Also corrected the bug that made it fail with some extensions, please test.

--

e-van

adam | Thu, 2008-12-04 09:26

Works now wit JSTreeDrive, but still hangs for few seconds when switching open documents ;-(
Maybe it should cache once created structure?

adam | Fri, 2008-12-05 04:38

I've check it again and noticed that the slow switching is caused by class definitions. When I've got file with simple functions, it work fine, very fast, but when there is a class defined it slows. More methods in class - more time needed to refresh structure and to switch to this document.

persod | Thu, 2008-12-04 10:36

Thanks, really great extension. But now where do I find the preferences to change it to right side tab?

adam | Fri, 2008-12-05 04:27

Edit/Preferences/Appearance/Source Tree

persod | Fri, 2008-12-05 15:36

Thanks, perfect now!

ericthelin | Sun, 2009-01-11 11:21

The search box seems to be set to an exact size. This forces whichever pane that contains sourcetree to have a minimum size that is much larger than it would otherwise be. Would it be possible to change the code for input size to whatever the search box in the project and toolbox panes already use?

A second idea is to add keystroke bindings so that I can toggle between the original use of the pane and sourcetree. Or maybe there is a way that I can do this already. If so please tell me.

Btw. Sourcetree rocks!!

grbradt | Thu, 2009-01-29 14:43

Just downloaded, get nothing for .js files.

qwavel | Thu, 2009-03-05 15:14

It appears to sort functions in alphabetic order. I would prefer that they were listed in the same order that they appear in the file.

I haven't found an option to let me make this change, so I am requesting it as a new feature.

Thanks.

benw04 | Thu, 2009-03-26 17:08

> I haven't found an option to let me make this change, so I am requesting it as a new feature.

Edit -> Preferences -> Appearance -> Source Tree -> Ordering

Tick it to sort by alpha, and untick it to sort by file order.

Note that there's a bug in 0.7.2 that means functions don't appear at all if you've got sorting off; I've sent a patch to icampana that fixes that bug (amongst other things), so hopefully this will be fixed in the next release.

- Ben

ronny | Wed, 2009-03-18 00:10

Hi, downloaded this week. To get a list in my pure c file, I need to have the checkbox "order functions alphabetically" checked. Otherwise I get an empty list. I love the extension anyway, thanks a lot!

benw04 | Wed, 2009-03-25 23:42

OK, so, the lack of sorting on methods in the source tree was bugging me, so I've spent some time trying to get it running.

I reckon I've got method sorting working now (I haven't got Class sorting working, as it's a bit more complicated when method sorting is involved as well). I've also made the sort case-insensitive.

Is there somewhere I can contribute my code so other people can test it and play with it?

- Ben

benw04 | Wed, 2009-03-25 23:41

As well as the method sorting changes above, I've also made a couple of changes to the search box at the top of the sidebar panel.

It now expands with the width of the sidebar, and it's got the komodo-like styling (rounded corners with a magnifying-glass icon on the left-hand side).

Is there somewhere I can contribute my code so other people can test it and play with it?

- Ben

nathan | Thu, 2009-04-16 13:41

Error reports and code contributions, please include them in this forum:
http://community.activestate.com/forum-topic/source-tree-community-exten...

meddington | Sat, 2009-05-23 19:10

Nice plugin, I'd like to see the classes sorted too. Some of my source files have 30 or more classes, easier to locate if they are sorted :)

mike

mmitchell_riccagroup | Tue, 2009-06-23 07:09

Would it be possible to support the following JavaScript class structures. The first is a plain type of javascript class the second is one you could create with the protoptype.js framework. Komodo's built in code view recognizes the first style but not the second. This extension recognizes neither and it would be very helpful if it could.

// Supported by Komodo "code view"
// Not supported by the "source view"
var myClass = {
    
    property_1 : 'test',
    
    myFunction : function(arg1, arg2) {
        
    }    
}


// Not Supported by Komodo "code view"
// Not supported by the "source view"
var myProtoClass = Class.create({
    
    property_1 : 'test',
    
    myFunction : function(arg1, arg2) {
        
    }    
});

re
pfhat | Thu, 2009-08-27 09:54

I might be reading this wrong but technically myClass in the code above is an object, not a function. If you changed it to
function myClass(){...}
it should be recognized, and the javascript functionality should be the same as the difference between objects and functions is pretty blury in that context. I would do something like this

function MyClass(inID)
{
    this._privateID = inID;
    ....
    ....
}
MyClass.prototype.printId = function()
{
    console.log('' +this. _privateID);
};

and then something like

var myClassInstance = new MyClass('35');
myClassInstance.printId();

dimituri | Mon, 2009-07-06 06:33

Hi, loving your extension. It, along with JSTreeDrive, was the cornerstone of my decision to switch to Komodo Edit. :]

Just here to ask, if it's possible to properly support the display of CSS declarations other than these:

selector, selector {

I'm used to putting the curly bracket on the next line like so:

selector,
selector
{

And this way I get a list of green-dotted empty items in the Source panel (currently using version 0.7.5).

Thanks in advance.

thesmaw | Thu, 2009-08-20 02:48

I've come across a similar error to the one mentioned above regarding conflicts with the JSTreeDrive extension.

This error occurs when the Source Tree panel is set to the live in the right panel of Komodo. If an additional panel is needed in the right panel area (e.g. kJSLint), it conflicts with Source Tree.

I believe the problem is at line 37 of Source Tree's overlay-right.xul:

Looking in komodo.xul, there is no tabpanel with the id="toolbox_tabpanel". Rather, I've managed to get the extension playing well with others in the right panel if I change line 37 to:

veryvito | Fri, 2009-08-21 14:58

Thesmaw's post above seems to be cut off, but unless I'm mistaken, line 37 should now include id="toolboxviewbox." I did this, and it seems to work well now (saving me from more hours of frustration).

Thanks for pointing me in the right direction, thesmaw! ;)

thesmaw | Mon, 2009-08-24 01:16

Sorry, didn't realise my post got cut off.

Nice one veryvito, that's exactly what I meant!

jeremy_c | Thu, 2009-12-10 10:42

When the source browser is on the right, is it possible to have the toolbox and source view opened at the same time? I am using Komodo Edit 5.2 and to switch between the two, I have to use a drop down arrow on the right side of the pane to select which I want to view, but cannot seem to stack them one on top of the other:

[ Toolbox ]
[ enties ]
[ enties ]
[ enties ]
[ enties ]
+----------+
[ Source ]
[ enties ]
[ enties ]
[ enties ]

Jeremy

troyt | Thu, 2009-12-10 12:20

This is a limitation in the sidebar UI Komodo inherits from Mozilla. As far as I know, this is not possible.