The [+] and [-] was an implementation error (the first time I do anything in XUL and javascript). Now it works ok, I haven't tried your code yet, but with the signs problem solved it should work better. Give it a try and let me know.
I checked out your patch, seems to be working pretty fine. Still I added some comments to remember where the changes were introduced in case we need to make specific changes anytime.
If everything goes allright this extension is becoming more useful everytime :)
Now I can see my own extension methods :)
I recently installed this extension and found it worked well, until I came across an omission for perl searches. Perl allows functions to be started in any column and then I know of two forms they can take. There may be other forms as well.
As a result I have made a couple of changes to my local copy os sourcetree, and thought it would be useful to others as well. Both changes are required to the _soureTree.prototype:
1. The functions regular expression needs to be updated to:
case 'Perl':
// Two forms of function declarations for perl:
// 1. sub function_name() {}
// 2. my $var = sub {}
function_tag = /^\s*sub\s+([a-zA-Z0-9\$_\-\&]*)|^\s*my\s+([a-zA-Z0-9\$_\-]*)\s+\=\s+sub/;
class_support = false;
break;
2. The above regular expression returns a value in either found_function[1 or 2]. So the perl side needs to be treated as a special case - like SQL, as:
parent = -1;
if (found_function){
func_id++;
I have SCC (using CVS) setup and functioning properly. Under "normal" conditions SCC functions work well.
I have the Source Tree addon installed and when I click the Source tab on the right Pane and then select "Existing File(s)..." from the "Add Item to Toolbox" pulldown, all the SCC functions stop working. I click an SCC button or select an SCC function from the content menu and nothing happens.
The current work around for this is to select the "Change Lists" tab and then select the SCC function needed. Kind of a pain because when you want to go back to the Source Tree view you have to do all the selecting all over again. Not very productive.
======================
This Source Tree extension is not a maintained by the Komodo team. My
suggestion is to uninstall the source tree extension if it's creating problems with regular Komodo usage. You may wish to contact the author of the extension (Iván Campaña) to inform them that this is the case, at a guess the extension is probably unintentionally overwriting parts of the Komodo functionality, which is causing this breakage.
======================
It's more likely that the problem lies in the lack of a namespace for my extension, I tried some time ago to add one, but I had some troubles getting everything to work ok, I've been busy lately, but I will try to solve it over the weekend.
--
I observed this issue in JavaScript. Consider this code:
someSimpleFunction : function(arg1, arg2, arg3)
{
// some code here
// some more code here
// much more code here
}
Such a function is not listed in the object hierarchy. Where this function will be listed:
someSimpleFunction : function(arg1, arg2, arg3) {
// some code here
// some more code here
// much more code here
}
Just by moving the { to the same line as the function name, it gets listed in the source tree.
Is this genuine? If so is this known? And if there is a fix for this already, what is it?
This is great, I've been hoping for C/C++ support. I hope the developer adds it to an official release, but I suggest you make a decent diff against the latest version (GIMP has a good tutorial if you haven't done it before).
I have a tiny request to the original author: could you make it user-configurable whether the source tree appears on the left or right pane? I personally prefer it on the left, but the latest version seems to be hardcoded to come up on the right.
edit:
Never mind the first part. I created the regexps for C and C++ support. Here's a little preview. Note that parent's version wasn't flexible enough: for example you can't always expect functions and methods to return primitive types (int, float etc). Then again, my version might give false positives and makes some assumptions (mostly that class and function definitions / declarations must begin on the first column - but not methods). Namespaces are also parsed now as classes. Here's the diff against the latest version (0.6.8):
It's a great, handy extension, but could use some further development. For example, discarding comment blocks and multi-line parsing (right now the entire parsed file is chopped into lines, but it's possible that relevant syntactic tokens are spread across many lines).
I just installed Komodo 5 and found it wasn't compatible.
So, I bumped the max version values to 5.* in the install.rdf file, zipped it as sourcetree.xpi and installed again. It's tested and working. I did notice I needed to click refresh on the sourcetree tab to refresh the tree when changing files though.
Ivan,
Are there plans for the release of a Komodo 5 version of this extension? Source Tree is probably THE most useful extension for Komodo Edit. I performed the hack mentioned by davidwhthomas, but it would awesome to have an officially updated version. Thanks for the hard work.
Sorry for the lack of an update after so much time, I didn't even knew there was a new version of Komodo Edit (have not been working on too much code lately).
Anyway, this version is now Komodo 5 compatible, corrected the problem that prevented it from auto updating the tree when changing the file (there is a backwards compatible part that will be removed after a while, I will no longer support komodo 4 because some of the changes introduced with komodo 5) and also this version should remove the previous problems with other extensions, now it works on its own namespace, so everything is isolated.+
I also included the C++ patch and some suggestions for Perl improvement, please test since I haven't coded in C++ for centuries and Perl is not one of my best friends :P
And by the way, I introduced a small change that helps skipping single line comments, I know it would be a lot better to recognize whole blocks instead of single lines, but that would require a lot more work on the extension and maybe even getting it more complicated to maintain, the idea is just to keep it simple and easy. Anyway if someone has the time and the will to help, I will greatly appreciate it.
I have installed the XPI but the DOM and Source tabs seem to conflict as the DOM appears under the Source title and nothing appears under the DOM title in the sidebar.
Version : Komodo IDE, version 5.0.1, build 24681, platform win32-x86.
Its really a bit inconvenient to have it at the Project bar.
It rather have it back in the toolBar or at leats beeing abled to decide it.
If you browse trough files to search for a bug and following function calls .. you have to switch back and forth ... and it sucks even more because you have to open be DropDown every time instead of having a Pageframe and simple switch pages .. which seems to be a a "new" feature of V5 !? not sure just installed it yesterday .. so havent checked yet if that could be changed in some setting ...
I would *soo* love for the extension to show all of the classes/functions/variables in ALL of the opened files.
What would be even better than that would be to display a tree of all of the classes in the active project!
Seems like really natural functionality, given that any project is going to call on code from across multiple files. Only being able to see the variables/methods in the current file is a touch limiting.
I've just updated from Komodo 4 to 5.0.3. I downloaded the latest source tree, 0.7.2 and installed it.
I am on Mac OS X 10.4 and I can see that the directory has been created and that the files are all in place.
Opening the jar file (it's just a zip file!) and looking at the overlay.xul file I see very few lines and NOT ANY reference to tabs. The result is that I do not see the source tree in any panel.
...
komodo: warning: environment variable could possibly conflict with Komodo operation: 'MOZ_PIS_SESSION_PID=28035'
komodo: warning: environment variable could possibly conflict with Komodo operation: 'MOZ_PIS_MOZBINDIR=/opt/Komodo-Edit-5/bin/../lib/mozilla'
komodo: warning: environment variable could possibly conflict with Komodo operation: 'MOZ_PIS_API=2'
komodo: warning: environment variable could possibly conflict with Komodo operation: 'MOZ_PIS_USER_DIR=.komodo'
...
ERROR: extensions.sourcetree: Loading Tree[object Object]
ERROR: extensions.sourcetree: TypeError: this.source_tree is null
ERROR: extensions.sourcetree: ReferenceError: expandClasses is not defined
ERROR: extensions.sourcetree: TypeError: this.source_tree is null
ERROR: extensions.sourcetree: ReferenceError: expandClasses is not defined
ERROR: extensions.sourcetree: TypeError: this.source_tree is null
ERROR: extensions.sourcetree: ReferenceError: expandClasses is not defined
...
The Source Tree configuration is visible at Edit/Preferences/Appearence/Source Tree but the Source Tree itself is nowhere to be seen.
I have two ideas that I would love to see in sourcetree. I think they should be pretty simple to do and perhaps someone who knows more than I do can even tell me how to do them without adding support directly to sourcetree.
First: Add a way to toggle by keystroke between the sidebars (Project/Source on the left and Toolbox/Source on the right)
Second: For some reason the search box for sourcetree seems to have a fixed size (for me it is 22 characters) which prohibits me from making the sidebar that contains it smaller than that size. But the sidebar that doesn't contain sourcetree can small enough that the search box only has room for 3 characters.
Other than those two it approaches perfect for what I need.
my thanks to the developers for building and maintaining such a great tool and my thanks to the community for supporting it in whatever way you each do.
Thanks for the great plugin! Not sure this will catch everything one might need, but I've found the following additions to sourcetree.js to be handy when developing ActionScript:
When I install/enable this add-on, the Vi key binding seems to get disabled (and can't be re-enabled). For e.g., by default I should be able to use motion keys to navigate (jkhl), but instead those keys are just inserted like I was in insert mode (and hitting <esc> doesn't fix the problem)
As mentioned on the plugin page, there seems to be a bug that affects this plugin when it lives in the Toolbox panel area (right side) and coexists with other plugins (Markdown Preview offered by the HTML Toolkit, for example.
As stated here, line 37 of sourcetree.jar-overlay-right.xul should perhaps be (correcting the panel name to insertafter):
There is a new version of HTML Toolkit in the SVN trunk. It relies on split views for Markdown and Wiki preview rather than extending the Toolbox panel.
It will be released some time soon I hope (though I've been saying that for weeks) so hopefully this will correct the issue when co-installed with the Source Tree extension.
I've found that C/C++ definitions/declarations are missed if they aren't completely contained on a single
line. For example, this declaration won't be listed:
void TestFunc(
int Arg1,
char *Arg2
);
but this version will:
void TestFunc( int Arg1, char *Arg2) :
This happens on the Komodo Edit version 5.2.0, build 4075. Source Tree is 0.7.5, and I'm running on Mac OS X 10.6 (Snow Leopard).
I agree with many of the comments already posted, this is a great tool!
I've been using komodo for C++ development for awhile now and at last found time to try to make SourceTree a bit better at C++ code parsing than it is now at version 0.7.5.
Patch below adds:
* support for declarations/definitions spanning multiple lines
* and some hackish code to avoid unwanted matches exposed by such support
* limited support for subclasses -- they are listed (but theirs methods listed along with methods of parent class)
Of course there are quirks (it's impossible to correctly parse C++ code only by line-by-line regexp matching). For example, current code couldn't distinguish between class method definition and local object construction with non-empty constructor:
class ClassA { void Method(int i); void F(int i){
B obj(i); } };
class ClassA {
void Method(int i);
void F(int i) {
B obj(i);
}
};
Method list for the ClassA would include both Method and obj (and F, of course).
But overall, these changes made SourceTree quite useful with C++ code (at least for me).
case 'PHP': @@ -418,12+423,24 @@
var method_searcher = new RegExp();
method_searcher.compile(method_tag);
+ var method_ignore_matcher = new RegExp(); + method_ignore_matcher.compile(method_ignore_pre); +
var subclass_searcher = new RegExp();
subclass_searcher.compile(subclass_tag);
for(current_line=0; current_line < max_length; current_line++){
line = parts[current_line];
var found_function = function_searcher.exec(line); + // patch for C++, skip statements + if (current_language == "C++"){ + if (found_function){ + if (found_function[1] in statements){ + found_function = false; + } + } + } +
var found_class = false;
if (class_support){ @@ -477,13+494,29 @@
do{
found_method = method_searcher.exec(parts[line_start]);
- mPosition = 1; + var method_pos = 1; + var subclass_pos = 1;
// -- Javascript patch
if (current_language == "JavaScript"){ - mPosition = 2; + method_pos = 2; } else if (current_language == "PHP"){ - mPosition = 4; + method_pos = 4; + } else if (current_language == "C++"){ + method_pos = 2; + } + + // patch for C++, skip statements + if (current_language == "C++"){ + if (found_method){ + if (found_method[method_pos] in statements){ + found_method = false; + } + if (found_method[1] == null + || method_ignore_matcher.test(found_method[1])){ + found_method = false; + } + } }
A few minutes back I updated Komodod Edit to 5.2.2 and unfortunately Source Tree is not working. It is listed as an installed add-on in the Add-ons window but there is not entry in the menu (View -> Tabs and Sidebars). Also if I click on the small drop down button on the Projects or Samples tab in the left and right sidebars, respectively, Source Tree is not listed in either of those.
Source Tree entry in the preferences dialog in intact.
So appears like something has gone wrong with the overlay. Some element id changed in 5.2.2?
It would be great to see this working with latest Komodo Edit otherwise I will have to rely on the search. :(
case 'JavaScript': function_tag = /^\s*functions\s+([a-zA-Z\t\s0-9\(\)\$\,_\\"\'=#\-&]*)\s*\{*/; class_tag = /^\s*function\s+([a-zA-Z\t\s0-9\(\)\$\,_\\"\'=#\-&]*)\s*\{*/; method_tag = /^\s+(this\.|)([a-zA-Z0-9]*)(\s*=\s*|\s*:\s*)function\(.*\)\s*{/; break;Inside if(found_class)
... if (current_language == "JavaScript"){ func_id++; class_id--; this.classes_list.push(new pythonClass(func_id, obj_name, current_line + 1, parent, TYPE_FUNCTION)); } else { this.classes_list.push(new pythonClass(class_id, obj_name, current_line + 1, parent, TYPE_CLASS)); } new_class = false ...Inside if(found_method)
func_id++; if (current_language == "JavaScript"){ parentItem = this.classes_list.pop(); if(parentItem.type==TYPE_FUNCTION) { func_id--; class_id++; parentItem.id = class_id; parentItem.type = TYPE_CLASS; } this.classes_list.push(parentItem); } ...Displays correctly with
function className() { methodName: function() { ... } }and (if there are no functions between the definition and the prototype section)
function className() {} className.prototype = { this.methodName = function() { ... } }Crashes if I try and click the [+] or [-] next to the class
The [+] and [-] was an implementation error (the first time I do anything in XUL and javascript). Now it works ok, I haven't tried your code yet, but with the signs problem solved it should work better. Give it a try and let me know.
I missed a piece of code in my last post. To save time I have created a patch from the latest version.
Here is a patch for sourcetree.js (0.6.6 -> JS Classes patch)
*** sourcetree.js 2008-04-10 15:35:08.000000000 +1000 --- sourcetree.js 2008-04-14 11:13:48.000000000 +1000 *************** *** 372,378 **** break; case 'JavaScript': ! function_tag = /^\s*function\s+([a-zA-Z\t\s0-9\(\)\$\,_\\"\'=#\-&]*)\s*\{*/; ! class_support = false; ! break; case 'CSS': function_tag = /^\s*(.*)\s*{/; --- 372,379 ---- break; case 'JavaScript': ! function_tag = /^\s*functions\s+([a-zA-Z\t\s0-9\(\)\$\,_\\"\'=#\-&]*)\s*\{*/; ! class_tag = /^\s*function\s+([a-zA-Z\t\s0-9\(\)\$\,_\\"\'=#\-&]*)\s*\{*/; ! method_tag = /^\s+(this\.|)([a-zA-Z0-9]*)(\s*=\s*|\s*:\s*)function\(.*\)\s*{/; ! break; case 'CSS': function_tag = /^\s*(.*)\s*{/; *************** *** 446,450 **** } ! this.classes_list.push(new pythonClass(class_id, obj_name, current_line + 1, parent, TYPE_CLASS)); new_class = false; line_start = current_line + 1; --- 447,457 ---- } ! if (current_language == "JavaScript"){ ! func_id++; ! class_id--; ! this.classes_list.push(new pythonClass(func_id, obj_name, current_line + 1, parent, TYPE_FUNCTION)); ! } else { ! this.classes_list.push(new pythonClass(class_id, obj_name, current_line + 1, parent, TYPE_CLASS)); ! } new_class = false; line_start = current_line + 1; *************** *** 457,461 **** mPosition = 1; ! if (current_language == "PHP"){ mPosition = 4; } --- 464,470 ---- mPosition = 1; ! if (current_language == "JavaScript"){ ! mPosition = 2; ! } else if (current_language == "PHP"){ mPosition = 4; } *************** *** 464,467 **** --- 473,486 ---- if (found_method){ func_id++; + if (current_language == "JavaScript"){ + parentItem = this.classes_list.pop(); + if(parentItem.type==TYPE_FUNCTION) { + func_id--; + class_id++; + parentItem.id = class_id; + parentItem.type = TYPE_CLASS; + } + this.classes_list.push(parentItem); + } this.classes_list.push(new pythonClass(func_id, found_method[mPosition], line_start + 1, class_id, TYPE_METHOD)); }I checked out your patch, seems to be working pretty fine. Still I added some comments to remember where the changes were introduced in case we need to make specific changes anytime.
If everything goes allright this extension is becoming more useful everytime :)
Now I can see my own extension methods :)
I recently installed this extension and found it worked well, until I came across an omission for perl searches. Perl allows functions to be started in any column and then I know of two forms they can take. There may be other forms as well.
As a result I have made a couple of changes to my local copy os sourcetree, and thought it would be useful to others as well. Both changes are required to the _soureTree.prototype:
1. The functions regular expression needs to be updated to:
case 'Perl':
// Two forms of function declarations for perl:
// 1. sub function_name() {}
// 2. my $var = sub {}
function_tag = /^\s*sub\s+([a-zA-Z0-9\$_\-\&]*)|^\s*my\s+([a-zA-Z0-9\$_\-]*)\s+\=\s+sub/;
class_support = false;
break;
2. The above regular expression returns a value in either found_function[1 or 2]. So the perl side needs to be treated as a special case - like SQL, as:
parent = -1;
if (found_function){
func_id++;
switch(current_language){
case "SQL":
//obj_name = found_function[1]+" "+found_function[2]+" "+found_function[3]+" ";
obj_name = found_function[2] + " " + found_function[3].replace(/`/g,"") + "("+found_function[1]+")";
break;
case 'Perl':
if (found_function[1] != null) {
obj_name = found_function[1];
}
else {
obj_name = found_function[2];
}
break;
default:
obj_name = found_function[1];
}
Suggestion for the mentioned perl regex:
This would also match lines like this (example taken from rsnapshot):
This could be a possible solution (in perl, not sure about js):
cheers :)
Ivan,
Seems there is a SCC conflict:
I have SCC (using CVS) setup and functioning properly. Under "normal" conditions SCC functions work well.
I have the Source Tree addon installed and when I click the Source tab on the right Pane and then select "Existing File(s)..." from the "Add Item to Toolbox" pulldown, all the SCC functions stop working. I click an SCC button or select an SCC function from the content menu and nothing happens.
The current work around for this is to select the "Change Lists" tab and then select the SCC function needed. Kind of a pain because when you want to go back to the Source Tree view you have to do all the selecting all over again. Not very productive.
I submitted this as a Komodo bug (http://bugs.activestate.com/show_bug.cgi?id=78963) and got this response:
======================
This Source Tree extension is not a maintained by the Komodo team. My
suggestion is to uninstall the source tree extension if it's creating problems with regular Komodo usage. You may wish to contact the author of the extension (Iván Campaña) to inform them that this is the case, at a guess the extension is probably unintentionally overwriting parts of the Komodo functionality, which is causing this breakage.
======================
Any help you might provide would be fantastic!
Thanks,
Robert Joy
It's more likely that the problem lies in the lack of a namespace for my extension, I tried some time ago to add one, but I had some troubles getting everything to work ok, I've been busy lately, but I will try to solve it over the weekend.
--
Iván Gabriel
Following the falling stars
I observed this issue in JavaScript. Consider this code:
someSimpleFunction : function(arg1, arg2, arg3) { // some code here // some more code here // much more code here }Such a function is not listed in the object hierarchy. Where this function will be listed:
someSimpleFunction : function(arg1, arg2, arg3) { // some code here // some more code here // much more code here }Just by moving the { to the same line as the function name, it gets listed in the source tree.
Is this genuine? If so is this known? And if there is a fix for this already, what is it?
Regards,
Brahmana.
Hello friends,
I downloaded sourcetree.xpi last night from this website and added C/C++ such that it can list C/C++ classes, functions, and class members.
The following code contexts of sourcetree.js can show code newly added or adjusted. (I wish I could post the source code.)
Thanks.
Winux
winux2k AT hotmail dot com
Part 1 case 'C++': function_tag = /^(static\s+){0,1}(void\s+|int\s+|float\s+|double\s+|char\s+|long\s+|unsigned\s+|signed\s+|size_t\s+){1,7}\**\s*(\w+)\s*\(/; class_tag = /^\s*(public|protected|abstract|\s+){0,5}class\s+(\w+)/; method_tag = /^\s+(static\s+){0,1}(void|int|float|double|char|long|unsigned|signed|size_t|\s+){0,7}\**\s*(\w+)\s*\(/; break; case 'Python': function_tag = /^def\s+(.*):/; class_tag = /^class\s+(.*):/; Part 2 if (found_function){ func_id++; switch(current_language){ case "C++": obj_name = found_function[3]; break; case "SQL": Part 3 }else if(found_class){ class_id++; if (current_language == "PHP" || current_language == "Tcl" || current_language == "C++"){ obj_name = found_class[2]; Part 4 // -- Javascript patch if (current_language == "JavaScript"){ mPosition = 2; } else if (current_language == "C++"){ mPosition = 3; } else if (current_language == "PHP"){This is great, I've been hoping for C/C++ support. I hope the developer adds it to an official release, but I suggest you make a decent diff against the latest version (GIMP has a good tutorial if you haven't done it before).
I have a tiny request to the original author: could you make it user-configurable whether the source tree appears on the left or right pane? I personally prefer it on the left, but the latest version seems to be hardcoded to come up on the right.
edit:
Never mind the first part. I created the regexps for C and C++ support. Here's a little preview. Note that parent's version wasn't flexible enough: for example you can't always expect functions and methods to return primitive types (int, float etc). Then again, my version might give false positives and makes some assumptions (mostly that class and function definitions / declarations must begin on the first column - but not methods). Namespaces are also parsed now as classes. Here's the diff against the latest version (0.6.8):
--- sourcetree_orig.js 2008-05-14 20:44:00.000000000 +0300 +++ sourcetree.js 2008-11-04 22:09:26.000000000 +0200 @@ -385,6 +385,13 @@ _sourceTree.prototype = { class_support = true; subclass_support = false; switch(current_language){ + case 'C++': + function_tag = /^\w+\s+.*?([\w:]+)\s*\(.*\)/; + class_tag = /^(?:class|namespace)\s+(\w+)/; + //class_tag = /^(?!using).*?(?:class|namespace)\s+(\w+)/; // alternative + method_tag = /\w+\s+[^\(]*?([\w:]+)\s*\(.*\)/; + break; + case 'Python': function_tag = /^def\s+(.*):/; class_tag = /^class\s+(.*):/;It's a great, handy extension, but could use some further development. For example, discarding comment blocks and multi-line parsing (right now the entire parsed file is chopped into lines, but it's possible that relevant syntactic tokens are spread across many lines).
I love this extension!
I just installed Komodo 5 and found it wasn't compatible.
So, I bumped the max version values to 5.* in the install.rdf file, zipped it as sourcetree.xpi and installed again. It's tested and working. I did notice I needed to click refresh on the sourcetree tab to refresh the tree when changing files though.
You can download the version from here:
http://www.filedropper.com/sourcetree
Note: this is just the 4.x version made compatible for 5.x
DT
Ivan,
Are there plans for the release of a Komodo 5 version of this extension? Source Tree is probably THE most useful extension for Komodo Edit. I performed the hack mentioned by davidwhthomas, but it would awesome to have an officially updated version. Thanks for the hard work.
Sorry for the lack of an update after so much time, I didn't even knew there was a new version of Komodo Edit (have not been working on too much code lately).
Anyway, this version is now Komodo 5 compatible, corrected the problem that prevented it from auto updating the tree when changing the file (there is a backwards compatible part that will be removed after a while, I will no longer support komodo 4 because some of the changes introduced with komodo 5) and also this version should remove the previous problems with other extensions, now it works on its own namespace, so everything is isolated.+
I also included the C++ patch and some suggestions for Perl improvement, please test since I haven't coded in C++ for centuries and Perl is not one of my best friends :P
And by the way, I introduced a small change that helps skipping single line comments, I know it would be a lot better to recognize whole blocks instead of single lines, but that would require a lot more work on the extension and maybe even getting it more complicated to maintain, the idea is just to keep it simple and easy. Anyway if someone has the time and the will to help, I will greatly appreciate it.
--
e-van
I have installed the XPI but the DOM and Source tabs seem to conflict as the DOM appears under the Source title and nothing appears under the DOM title in the sidebar.
Version : Komodo IDE, version 5.0.1, build 24681, platform win32-x86.
This version now appears in the project tab rather than the toolbox tab is that correct?
Also - I've noticed that if I use JSDriveTree plug-in as well as SourceTree, SourceTree will no longer work. It will just remain completely blank.
Not sure at this stage whether this is just a compatibility issue with JSDriveTree - or with any plug-in destined for the project tab.
Regards
Caleb
Its really a bit inconvenient to have it at the Project bar.
It rather have it back in the toolBar or at leats beeing abled to decide it.
If you browse trough files to search for a bug and following function calls .. you have to switch back and forth ... and it sucks even more because you have to open be DropDown every time instead of having a Pageframe and simple switch pages .. which seems to be a a "new" feature of V5 !? not sure just installed it yesterday .. so havent checked yet if that could be changed in some setting ...
in sourcetree.xpi\sourcetree.jar\content\overlay.xul
changed:
34: <tabs id="right_toolbox_tabs">
38: <tabpanels id="right_toolbox_tabpanels">
On Mac OS X -if you fail (like me) to re-create the xpi file - you can also edit the jar file of the installed extension in
~/Library/Application Support/KomodoEdit/5.0/host-Macintosh/XRE/extensions/sourcetree@amautacorp.com/sourcetree.jar
using a jar file browser (I found JarInspector from www.codeland.org)
Locate the file ./content/overlay.xul and modify as described above.
I love the source tree extension!
May I make a suggestion for improving it?
I would *soo* love for the extension to show all of the classes/functions/variables in ALL of the opened files.
What would be even better than that would be to display a tree of all of the classes in the active project!
Seems like really natural functionality, given that any project is going to call on code from across multiple files. Only being able to see the variables/methods in the current file is a touch limiting.
I've just updated from Komodo 4 to 5.0.3. I downloaded the latest source tree, 0.7.2 and installed it.
I am on Mac OS X 10.4 and I can see that the directory has been created and that the files are all in place.
Opening the jar file (it's just a zip file!) and looking at the overlay.xul file I see very few lines and NOT ANY reference to tabs. The result is that I do not see the source tree in any panel.
This is my xul file:
I assume there is something wrong. ;)
Maybe the lastest xpi is broken?
running komodo -v I get the following
The Source Tree configuration is visible at Edit/Preferences/Appearence/Source Tree but the Source Tree itself is nowhere to be seen.
Any suggestions?
Thank you :-)
I have two ideas that I would love to see in sourcetree. I think they should be pretty simple to do and perhaps someone who knows more than I do can even tell me how to do them without adding support directly to sourcetree.
First: Add a way to toggle by keystroke between the sidebars (Project/Source on the left and Toolbox/Source on the right)
Second: For some reason the search box for sourcetree seems to have a fixed size (for me it is 22 characters) which prohibits me from making the sidebar that contains it smaller than that size. But the sidebar that doesn't contain sourcetree can small enough that the search box only has room for 3 characters.
Other than those two it approaches perfect for what I need.
my thanks to the developers for building and maintaining such a great tool and my thanks to the community for supporting it in whatever way you each do.
Thanks for the great plugin! Not sure this will catch everything one might need, but I've found the following additions to sourcetree.js to be handy when developing ActionScript:
case 'ActionScript': function_tag = /^\s*[\w+(\s+)]*function\s*([^\{]*)\s*\{*/; class_tag = /^\s*[\w+(\s+)]*class[ \t]+([A-Za-z0-9_]+)[ \t]*([^\\{]*)/; method_tag = /^\s*[\w+(\s+)]*function[ \t]+(set|get)[ \t]+([A-Za-z0-9_]+)/; break;If these could be added into the next version of the extension, life would be great.
When I install/enable this add-on, the Vi key binding seems to get disabled (and can't be re-enabled). For e.g., by default I should be able to use motion keys to navigate (jkhl), but instead those keys are just inserted like I was in insert mode (and hitting <esc> doesn't fix the problem)
Cheers,
-Curtis
same problem for me, seems like Vi mode is disabled when the extension is installed! would be great to have it resolved!
unpack sourcetree.jar, fix file content/loader.js and pack to jar.
i think that the problem in overloading XUL file while "vi_keybinding" load.
patch here ( add time out before load sourcetree ):
--- cut ---
20c20,30
< document.loadOverlay("chrome://sourcetree/content/overlay-right.xul", null);
---
> /*alert( 'load sourcetree XUL');*/
> var callback = {
> observe : function (subject, topic, data) {
> if (topic == 'xul-overlay-merged') {
> extensions.sourcetree.initOverlay();
> }
> }
> };
> setTimeout( function(){
> document.loadOverlay("chrome://sourcetree/content/overlay-right.xul", callback);
> },2000 );
24c34
< extensions.sourcetree.initOverlay();
---
> //extensions.sourcetree.initOverlay();
--- cut ---
I patched loader.js and now I am back to having Vi emulation *and* Source Tree which I had really been missing.
Very useful extension for me.
I would like the aplhabetical sorting do work with class' methods (PHP).
Thank you.
As mentioned on the plugin page, there seems to be a bug that affects this plugin when it lives in the Toolbox panel area (right side) and coexists with other plugins (Markdown Preview offered by the HTML Toolkit, for example.
As stated here, line 37 of sourcetree.jar-overlay-right.xul should perhaps be (correcting the panel name to insertafter):
There is a new version of HTML Toolkit in the SVN trunk. It relies on split views for Markdown and Wiki preview rather than extending the Toolbox panel.
It will be released some time soon I hope (though I've been saying that for weeks) so hopefully this will correct the issue when co-installed with the Source Tree extension.
Cheers,
Stan
I noticed that prototypes such as
String.prototype.MyNewFunction = function() { // do stuff here. console.log('new function fired'); }weren't getting matched in javascript so I added the functionality in this patch file:
*** sourcetree.js Sun Apr 12 21:07:08 2009 --- sourcetree.js Thu Aug 27 12:15:19 2009 *************** *** 338,343 **** --- 338,344 ---- language_supported = true; class_support = true; subclass_support = false; + proto_support = false; switch(current_language){ case 'Python': function_tag = /^def\s+(.*):/; *************** *** 370,375 **** --- 371,378 ---- function_tag = /^\s*functions\s+([a-zA-Z\t\s0-9\(\)\$\,_\\"\'=#\-&]*)\s*\{*/; class_tag = /^\s*function\s+([a-zA-Z\t\s0-9\(\)\$\,_\\"\'=#\-&]*)\s*\{*/; method_tag = /^\s+(this\.|)([a-zA-Z0-9]*)(\s*=\s*|\s*:\s*)function\(.*\)\s*{/; + proto_tag = /^\s*([a-zA-Z0-9\(\)\$\,_\\"\'=#\-&]+)[.]prototype[.]([a-zA-Z0-9\(\)\$\,_\\"\'=#\-&]+)[\s]*=[\s]*function[\s]*([(][a-zA-Z\t\s0-9\(\)\$\,_\\"\'=#\-&]*[)])[\s]*[{]*/; + proto_support = true; break; case 'CSS': *************** *** 418,423 **** --- 421,430 ---- var method_searcher = new RegExp(); method_searcher.compile(method_tag); + // added prototype regex. + var proto_searcher = new RegExp(); + proto_searcher.compile(proto_tag); + var subclass_searcher = new RegExp(); subclass_searcher.compile(subclass_tag); *************** *** 511,516 **** --- 518,532 ---- } } + // Javascript hack for prototype recognition + if (proto_support) { + func_id++; + found_prototype = proto_searcher.exec(parts[line_start]); + if (found_prototype) { + this.classes_list.push(new pythonClass(func_id, found_prototype[1] +'.' +found_prototype[2] +found_prototype[3], line_start + 1, parent, TYPE_FUNCTION)); + } + } + line_start++; if (line_start < max_length){will now cause
myObject.prototype.myFunctionName = function(inArgs) { ... }to display in the tree as myObject.myFunctionName(inArgs)
Let me know if there's a problem anywhere or if something should be added.
Thanks for the great tool,
Dave Smolin
I've found that C/C++ definitions/declarations are missed if they aren't completely contained on a single
line. For example, this declaration won't be listed:
void TestFunc(
int Arg1,
char *Arg2
);
but this version will:
void TestFunc( int Arg1, char *Arg2) :
This happens on the Komodo Edit version 5.2.0, build 4075. Source Tree is 0.7.5, and I'm running on Mac OS X 10.6 (Snow Leopard).
I agree with many of the comments already posted, this is a great tool!
Thanks
GaryM
I've been using komodo for C++ development for awhile now and at last found time to try to make SourceTree a bit better at C++ code parsing than it is now at version 0.7.5.
Patch below adds:
* support for declarations/definitions spanning multiple lines
* and some hackish code to avoid unwanted matches exposed by such support
* limited support for subclasses -- they are listed (but theirs methods listed along with methods of parent class)
Of course there are quirks (it's impossible to correctly parse C++ code only by line-by-line regexp matching). For example, current code couldn't distinguish between class method definition and local object construction with non-empty constructor:
void Method(int i);
void F(int i) {
B obj(i);
}
};
class ClassA { void Method(int i); void F(int i) { B obj(i); } };Method list for the
ClassAwould include bothMethodandobj(andF, of course).But overall, these changes made SourceTree quite useful with C++ code (at least for me).
Here is the patch:
--- ../../sourcetree.orig/sourcetree/content/sourcetree.js 2009-04-13 06:07:07.000000000 +0400
+++ ./content/sourcetree.js 2009-09-14 15:59:08.000000000 +0400
@@ -306,7 +306,7 @@
this.loadTree();
if (prefs.getBooleanPref('extensions.sourcetree.colapse_tree')){
- expandClasses();
+ extensions.sourcetree.expandClasses();
}
} catch (e) {
log_error(e);
@@ -328,6 +328,8 @@
var current_language = "";
var language_supported = false;
var function_tag = "", class_tag = "", method_tag = "", subclass_tag = "";
+ var statements = null;
+ var method_ignore_pre = null;
try{
current_language = view.document.language;
@@ -354,10 +356,13 @@
break;
case 'C++':
- function_tag = /^\w+\s+.*?([\w:]+)\s*\(.*\)/;
- class_tag = /^(?:class|namespace)\s+(\w+)/;
- //class_tag = /^(?!using).*?(?:class|namespace)\s+(\w+)/; // alternative
- method_tag = /\w+\s+[^\(]*?([\w:]+)\s*\(.*\)/;
+ function_tag = /^(?:[\w*&]+\s+.*?|)(\w+|\w+::~?\w+)\s*\(.*\)?/;
+ class_tag = /^(?:class|namespace|struct)\s+([\w:]+\w+)\s*[^;]*\s*$/;
+ method_tag = /^\s*([^\.\(\=]+)\s+((?:\w+:{2})?~?\w+)\s*\(.*?\)?/;
+ subclass_tag = /^\s+(?:class|namespace|struct)\s+([\w:]+\w+)\s*[^;]*\s*$/;
+ subclass_support = true;
+ statements = {'while': 1, 'catch': 1, 'operator': 1, 'for': 1, 'if': 1, 'switch': 1, 'return': 1};
+ method_ignore_pre = /^\s+$|^\s*[,:]\s*$|return|throw|typedef|define|&&|\|\|$/;
break;
case 'PHP':
@@ -418,12 +423,24 @@
var method_searcher = new RegExp();
method_searcher.compile(method_tag);
+ var method_ignore_matcher = new RegExp();
+ method_ignore_matcher.compile(method_ignore_pre);
+
var subclass_searcher = new RegExp();
subclass_searcher.compile(subclass_tag);
for(current_line=0; current_line < max_length; current_line++){
line = parts[current_line];
var found_function = function_searcher.exec(line);
+ // patch for C++, skip statements
+ if (current_language == "C++") {
+ if (found_function) {
+ if (found_function[1] in statements) {
+ found_function = false;
+ }
+ }
+ }
+
var found_class = false;
if (class_support){
@@ -477,13 +494,29 @@
do{
found_method = method_searcher.exec(parts[line_start]);
- mPosition = 1;
+ var method_pos = 1;
+ var subclass_pos = 1;
// -- Javascript patch
if (current_language == "JavaScript"){
- mPosition = 2;
+ method_pos = 2;
} else if (current_language == "PHP"){
- mPosition = 4;
+ method_pos = 4;
+ } else if (current_language == "C++"){
+ method_pos = 2;
+ }
+
+ // patch for C++, skip statements
+ if (current_language == "C++") {
+ if (found_method) {
+ if (found_method[method_pos] in statements) {
+ found_method = false;
+ }
+ if (found_method[1] == null
+ || method_ignore_matcher.test(found_method[1])) {
+ found_method = false;
+ }
+ }
}
//found_subclass = parts[line_start].match('class (.*):');
@@ -500,14 +533,14 @@
}
this.classes_list.push(parentItem);
}
- methods_list.push(new pythonClass(func_id, found_method[mPosition], line_start + 1, class_id, TYPE_METHOD));
+ methods_list.push(new pythonClass(func_id, found_method[method_pos], line_start + 1, class_id, TYPE_METHOD));
}
if (subclass_support){
func_id++;
found_subclass = subclass_searcher.exec(parts[line_start]);
if (found_subclass){
- this.classes_list.push(new pythonClass(func_id, found_subclass[mPosition], line_start + 1, class_id, TYPE_SUBCLASS));
+ this.classes_list.push(new pythonClass(func_id, found_subclass[subclass_pos], line_start + 1, class_id, TYPE_SUBCLASS));
}
}
@@ -592,8 +625,7 @@
}
}
- this.jumpToFunction = function(event)
- {
+ this.jumpToFunction = function(event){
try {
var row = getRowForEvent(event);
if (row >= 0){
diff -u -w -r ../../sourcetree.orig/sourcetree/content/sourcetree.js ./content/sourcetree.js --- ../../sourcetree.orig/sourcetree/content/sourcetree.js 2009-04-13 06:07:07.000000000 +0400 +++ ./content/sourcetree.js 2009-09-14 15:59:08.000000000 +0400 @@ -306,7 +306,7 @@ this.loadTree(); if (prefs.getBooleanPref('extensions.sourcetree.colapse_tree')){ - expandClasses(); + extensions.sourcetree.expandClasses(); } } catch (e) { log_error(e); @@ -328,6 +328,8 @@ var current_language = ""; var language_supported = false; var function_tag = "", class_tag = "", method_tag = "", subclass_tag = ""; + var statements = null; + var method_ignore_pre = null; try{ current_language = view.document.language; @@ -354,10 +356,13 @@ break; case 'C++': - function_tag = /^\w+\s+.*?([\w:]+)\s*\(.*\)/; - class_tag = /^(?:class|namespace)\s+(\w+)/; - //class_tag = /^(?!using).*?(?:class|namespace)\s+(\w+)/; // alternative - method_tag = /\w+\s+[^\(]*?([\w:]+)\s*\(.*\)/; + function_tag = /^(?:[\w*&]+\s+.*?|)(\w+|\w+::~?\w+)\s*\(.*\)?/; + class_tag = /^(?:class|namespace|struct)\s+([\w:]+\w+)\s*[^;]*\s*$/; + method_tag = /^\s*([^\.\(\=]+)\s+((?:\w+:{2})?~?\w+)\s*\(.*?\)?/; + subclass_tag = /^\s+(?:class|namespace|struct)\s+([\w:]+\w+)\s*[^;]*\s*$/; + subclass_support = true; + statements = {'while': 1, 'catch': 1, 'operator': 1, 'for': 1, 'if': 1, 'switch': 1, 'return': 1}; + method_ignore_pre = /^\s+$|^\s*[,:]\s*$|return|throw|typedef|define|&&|\|\|$/; break; case 'PHP': @@ -418,12 +423,24 @@ var method_searcher = new RegExp(); method_searcher.compile(method_tag); + var method_ignore_matcher = new RegExp(); + method_ignore_matcher.compile(method_ignore_pre); + var subclass_searcher = new RegExp(); subclass_searcher.compile(subclass_tag); for(current_line=0; current_line < max_length; current_line++){ line = parts[current_line]; var found_function = function_searcher.exec(line); + // patch for C++, skip statements + if (current_language == "C++") { + if (found_function) { + if (found_function[1] in statements) { + found_function = false; + } + } + } + var found_class = false; if (class_support){ @@ -477,13 +494,29 @@ do{ found_method = method_searcher.exec(parts[line_start]); - mPosition = 1; + var method_pos = 1; + var subclass_pos = 1; // -- Javascript patch if (current_language == "JavaScript"){ - mPosition = 2; + method_pos = 2; } else if (current_language == "PHP"){ - mPosition = 4; + method_pos = 4; + } else if (current_language == "C++"){ + method_pos = 2; + } + + // patch for C++, skip statements + if (current_language == "C++") { + if (found_method) { + if (found_method[method_pos] in statements) { + found_method = false; + } + if (found_method[1] == null + || method_ignore_matcher.test(found_method[1])) { + found_method = false; + } + } } //found_subclass = parts[line_start].match('class (.*):'); @@ -500,14 +533,14 @@ } this.classes_list.push(parentItem); } - methods_list.push(new pythonClass(func_id, found_method[mPosition], line_start + 1, class_id, TYPE_METHOD)); + methods_list.push(new pythonClass(func_id, found_method[method_pos], line_start + 1, class_id, TYPE_METHOD)); } if (subclass_support){ func_id++; found_subclass = subclass_searcher.exec(parts[line_start]); if (found_subclass){ - this.classes_list.push(new pythonClass(func_id, found_subclass[mPosition], line_start + 1, class_id, TYPE_SUBCLASS)); + this.classes_list.push(new pythonClass(func_id, found_subclass[subclass_pos], line_start + 1, class_id, TYPE_SUBCLASS)); } } @@ -592,8 +625,7 @@ } } - this.jumpToFunction = function(event) - { + this.jumpToFunction = function(event){ try { var row = getRowForEvent(event); if (row >= 0){(Also this patch makes "Source Tree colapsed by default" preference work as intended.)
Patch worked great. Thanks again
GaryM
Hi,
A few minutes back I updated Komodod Edit to 5.2.2 and unfortunately Source Tree is not working. It is listed as an installed add-on in the Add-ons window but there is not entry in the menu (View -> Tabs and Sidebars). Also if I click on the small drop down button on the Projects or Samples tab in the left and right sidebars, respectively, Source Tree is not listed in either of those.
Source Tree entry in the preferences dialog in intact.
So appears like something has gone wrong with the overlay. Some element id changed in 5.2.2?
It would be great to see this working with latest Komodo Edit otherwise I will have to rely on the search. :(
Thank you.
Regards,
Brahmana