Thread: [Pydev-code] code folding
Brought to you by:
fabioz
From: Paul <pau...@af...> - 2012-10-11 11:53:34
|
Hi List, I see from this (http://sourceforge.net/tracker/index.php?func=detail&aid=1841410&group_id=85796&atid=577332), that PyDev still doesn't support code folding on custom tags. Not sure if this is the latest word on it or if I'm missing something, but from my searching on the net and the mailing list archives, I can find nothing more on it, and it seems at least a few people would like to see this feature. I've had a stab at it myself, trying both hacking the PyDev plug-in, and scripting it with the jython scripting support, but so far no luck. I'm afraid I'm new to Eclipse plug-in dev, and am having some troubles. I was wondering if there was any further info on this, anybody already involved in PyDev work that would add this (as it seems like it would be fairly quick to add for someone who knew the internals of PyDev), or if not, anybody who could help me get pointed in the right direction? For hacking the plug-in, I grabbed the code off github, unzipped the zip (I didn't want to clone the repo yet, as I just wanted to poke around quickly for now, and don't already have git installed), loaded it into Eclipse, but can't seem to run it. Something about the build path being incomplete and not being able to find java.lang.Object. I'm sure this is really simple, but I'm not very experienced with Java or Eclipse dev, so I'm just not quite sure how to set it up correctly. For the scripting approach, I've gotten further. I have hooked up an IDocumentLister in the 'onSetDocument' event to listen for changes to the document, but from looking at the plug-in code, it looks like I may actually want an IModelListener hooked up instead. I can't seem to get that part working, tho. Once I have the correct listener, I'm thinking I can check the document to get access to the comments, look for a custom comment, and add the mark to the listener (simple, right?). Either approach should do, and both seem to have their advantages, although the scripting approach may be easier for me to get working. Any comments as to which is preferable? Anybody able and willing to help me out? Thanks all Paul |
From: Fabio Z. <fa...@es...> - 2012-10-11 12:10:43
|
Hi Paul, For this situation I think doing it in the code directly (and not in scripting) would be a better choice, as you'll be able to edit the preferences and the current code isn't really meant to be extended for what you want in scripting. The first thing would be the code there compiling properly. Make sure you have downloaded the java SDK (preferably Java 5, but could be a later version too) and the latest Eclipse 3.8 SDK and try following the instructions from: http://www.pydev.org/developers.html After that, the related classes would be: org.python.pydev.editor.codefolding.CodeFoldingSetter: It'd be mainly configuring org.python.pydev.editor.codefolding.CodeFoldingSetter.getMarks(IDocument, SimpleNode) to return more folding entries. org.python.pydev.editor.codefolding.CodeFoldingSetterTest: Please do a test-case for your situation so that it keeps working after the initial implementation is done :) org.python.pydev.editor.codefolding.PyDevCodeFoldingPrefPage: add the related preferences for the option you want to add. Note that you may run an Eclipse with your own code changes doing a run configuration: menu: run > run configurations > eclipse application (right-click for new eclipse application) > run. Cheers, Fabio On Thu, Oct 11, 2012 at 8:32 AM, Paul <pau...@af...> wrote: > Hi List, > > I see from this > (http://sourceforge.net/tracker/index.php?func=detail&aid=1841410&group_id=85796&atid=577332), > that PyDev still doesn't support code folding on custom tags. Not sure > if this is the latest word on it or if I'm missing something, but from > my searching on the net and the mailing list archives, I can find > nothing more on it, and it seems at least a few people would like to > see this feature. > > I've had a stab at it myself, trying both hacking the PyDev plug-in, > and scripting it with the jython scripting support, but so far no luck. > I'm afraid I'm new to Eclipse plug-in dev, and am having some troubles. > > I was wondering if there was any further info on this, anybody already > involved in PyDev work that would add this (as it seems like it would > be fairly quick to add for someone who knew the internals of PyDev), or > if not, anybody who could help me get pointed in the right direction? > > For hacking the plug-in, I grabbed the code off github, unzipped the > zip (I didn't want to clone the repo yet, as I just wanted to poke > around quickly for now, and don't already have git installed), loaded it > into Eclipse, but can't seem to run it. Something about the build path > being incomplete and not being able to find java.lang.Object. I'm sure > this is really simple, but I'm not very experienced with Java or Eclipse > dev, so I'm just not quite sure how to set it up correctly. > > For the scripting approach, I've gotten further. I have hooked up an > IDocumentLister in the 'onSetDocument' event to listen for changes to > the document, but from looking at the plug-in code, it looks like I may > actually want an IModelListener hooked up instead. I can't seem to get > that part working, tho. Once I have the correct listener, I'm thinking > I can check the document to get access to the comments, look for a > custom comment, and add the mark to the listener (simple, right?). > > Either approach should do, and both seem to have their advantages, > although the scripting approach may be easier for me to get working. Any > comments as to which is preferable? > > Anybody able and willing to help me out? > > Thanks all > > Paul > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > pydev-code mailing list > pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-code |
From: Paul <pau...@af...> - 2012-10-12 15:40:58
|
Hi Fabio, Thanks for the reply. I've got started already, but there are some things that I'm not clear on. See comments inline. > For this situation I think doing it in the code directly (and not in > scripting) would be a better choice, as you'll be able to edit the > preferences and the current code isn't really meant to be extended for > what you want in scripting. Ah, so? Pity, scripting would have been easier, I think, but I will experiment with the plug-in code. Probably a better solution in the long run. > The first thing would be the code there compiling properly. Make sure > you have downloaded the java SDK (preferably Java 5, but could be a > later version too) and the latest Eclipse 3.8 SDK and try following > the instructions from: http://www.pydev.org/developers.html Ok, I have java version 1.6.0_21, which is java 6 AFAIU. I also have Eclipse Juno, version 4.2.0. The instructions at the given link have a few things I don't understand. Firstly, they talk about changing the compliance level from 1.4 to 5.0. I don't have a 5.0 in Eclipse, only 1.3 through 1.7, and it's currently on 1.6, so I can only assume this is correct. The numbering must have changed, and I assume 1.6 is java 6 and the 5.0 was java 5, so this should be fine. Secondly, they talk about forking the code at github, then creating your own branch. I'm not really familiar with git, or github, so I'm not sure if I should be doing the fork on github or what, but for now I've "git-clone"d the github code to my machine and made a feature branch (with git checkout -b), so if I work on that local copy I should be able to submit a patch later, right? There's stuff in the guide about creating a pull request on github, but I don't have a public IP, so I think I'll need to mail patches. Then the developers guide talks of having a dependancy on Aptana, but only if building the code, not if just running the changes in Eclipse. As I understand it, I will just be making changes, and then running it in a new Eclipse from inside Eclipse, so I won't need Aptana? It also talks of making changes to org.python.pydev.core/tests/org.python.pydev.core/TestDependent.OS.properties, which I assume would be org.python.pydev.core/tests/org.python.pydev.core/TestDependent.windows.properties for me. I see a lot of stuff in there, including things like IronPython. Do I need all of that installed? There are things there I don't even know, like PIL. And the google app engine? Surely I don't need all of that to make the simple changes I am contemplating? Is that stuff only needed for running the tests? Lastly, the guide talks about reading the instructions at /plugins/org.python.pydev.build/build_cmd.txt, but that seems to do a lot of git stuff and I'm not sure quite what that relates to. I'm hoping I don't need that stuff just to test and submit a patch. > After that, the related classes would be: > > org.python.pydev.editor.codefolding.CodeFoldingSetter: It'd be mainly > configuring > org.python.pydev.editor.codefolding.CodeFoldingSetter.getMarks(IDocument, > SimpleNode) to return more folding entries. > > org.python.pydev.editor.codefolding.CodeFoldingSetterTest: Please do a > test-case for your situation so that it keeps working after the > initial implementation is done :) > > org.python.pydev.editor.codefolding.PyDevCodeFoldingPrefPage: add the > related preferences for the option you want to add. Thanks, I've started poking around, and I think I can make a stab at it, although I may be mailing with a few more issues as I progress, I'm sure :) > > Note that you may run an Eclipse with your own code changes doing a > run configuration: > > menu: run > run configurations > eclipse application (right-click for > new eclipse application) > run. What am I trying to run? I tried to right-click on the org.python.pydev project (in the package explorer), and under the "Run As" submenu of the context menu was "Eclipse Application", but this complains about errors in com.aptana.interactive_console, org.python.pydev.django_templates and org.python.pydev.mylyn. I have tried clicking "Proceed", and sure enough a new Eclipse opens with my changes, so I'm assuming that despite the errors I'm on the right track and can safely ignore the errors to proceed. Sorry if I sound terribly noobish, but I've not had much exposure to either java or Eclipse before (and only fairly recently to python). I think I've got things chugging along enough to make the changes I need, and hopefully submit a patch at the end. Again, many thanks for the help. Paul |
From: Andornaut <and...@gm...> - 2012-10-12 16:40:06
|
Thought I'd tackle a few of the lower hanging fruit =-) > Firstly, they talk about changing the compliance level from 1.4 to 5.0. > I don't have a 5.0 in Eclipse, only 1.3 through 1.7, and it's currently > on 1.6, so I can only assume this is correct. The numbering must have > changed, and I assume 1.6 is java 6 and the 5.0 was java 5, so this > should be fine. I assume that it's referring to the Java version, not eclipse. So, Java 1.5 (5.0) > Secondly, they talk about forking the code at github, then creating > your own branch. I'm not really familiar with git, or github, so I'm > not sure if I should be doing the fork on github or what, but for now > I've "git-clone"d the github code to my machine and made a feature > branch (with git checkout -b), so if I work on that local copy I should > be able to submit a patch later, right? This link explains this process: https://help.github.com/articles/fork-a-repo > There's stuff in the guide about creating a pull request on github, but I don't have a public IP, so I think I'll need to mail patches. A static IP is not a requirement. > Then the developers guide talks of having a dependancy on Aptana, but > only if building the code, not if just running the changes in Eclipse. > As I understand it, I will just be making changes, and then running it > in a new Eclipse from inside Eclipse, so I won't need Aptana? Before you can "run" your changes, you will need to "build" (compile) the code. Therefore, you will need to meet all of the "build" dependencies. HTH On Fri, Oct 12, 2012 at 11:13 AM, Paul <pau...@af...> wrote: > Hi Fabio, > > Thanks for the reply. I've got started already, but there are some > things that I'm not clear on. See comments inline. > >> For this situation I think doing it in the code directly (and not in >> scripting) would be a better choice, as you'll be able to edit the >> preferences and the current code isn't really meant to be extended for >> what you want in scripting. > Ah, so? Pity, scripting would have been easier, I think, but I will > experiment with the plug-in code. Probably a better solution in the > long run. > >> The first thing would be the code there compiling properly. Make sure >> you have downloaded the java SDK (preferably Java 5, but could be a >> later version too) and the latest Eclipse 3.8 SDK and try following >> the instructions from: http://www.pydev.org/developers.html > Ok, I have java version 1.6.0_21, which is java 6 AFAIU. I also have > Eclipse Juno, version 4.2.0. The instructions at the given link have a > few things I don't understand. > > Firstly, they talk about changing the compliance level from 1.4 to 5.0. > I don't have a 5.0 in Eclipse, only 1.3 through 1.7, and it's currently > on 1.6, so I can only assume this is correct. The numbering must have > changed, and I assume 1.6 is java 6 and the 5.0 was java 5, so this > should be fine. > > Secondly, they talk about forking the code at github, then creating > your own branch. I'm not really familiar with git, or github, so I'm > not sure if I should be doing the fork on github or what, but for now > I've "git-clone"d the github code to my machine and made a feature > branch (with git checkout -b), so if I work on that local copy I should > be able to submit a patch later, right? There's stuff in the guide about > creating a pull request on github, but I don't have a public IP, so I > think I'll need to mail patches. > > Then the developers guide talks of having a dependancy on Aptana, but > only if building the code, not if just running the changes in Eclipse. > As I understand it, I will just be making changes, and then running it > in a new Eclipse from inside Eclipse, so I won't need Aptana? > > It also talks of making changes to > org.python.pydev.core/tests/org.python.pydev.core/TestDependent.OS.properties, > which I assume would be > org.python.pydev.core/tests/org.python.pydev.core/TestDependent.windows.properties > for me. I see a lot of stuff in there, including things like > IronPython. Do I need all of that installed? There are things there I > don't even know, like PIL. And the google app engine? Surely I don't > need all of that to make the simple changes I am contemplating? Is > that stuff only needed for running the tests? > > Lastly, the guide talks about reading the instructions > at /plugins/org.python.pydev.build/build_cmd.txt, but that seems to do > a lot of git stuff and I'm not sure quite what that relates to. I'm > hoping I don't need that stuff just to test and submit a patch. > >> After that, the related classes would be: >> >> org.python.pydev.editor.codefolding.CodeFoldingSetter: It'd be mainly >> configuring >> org.python.pydev.editor.codefolding.CodeFoldingSetter.getMarks(IDocument, >> SimpleNode) to return more folding entries. >> >> org.python.pydev.editor.codefolding.CodeFoldingSetterTest: Please do a >> test-case for your situation so that it keeps working after the >> initial implementation is done :) >> >> org.python.pydev.editor.codefolding.PyDevCodeFoldingPrefPage: add the >> related preferences for the option you want to add. > Thanks, I've started poking around, and I think I can make a stab at > it, although I may be mailing with a few more issues as I progress, I'm > sure :) >> >> Note that you may run an Eclipse with your own code changes doing a >> run configuration: >> >> menu: run > run configurations > eclipse application (right-click for >> new eclipse application) > run. > What am I trying to run? I tried to right-click on the org.python.pydev > project (in the package explorer), and under the "Run As" submenu of > the context menu was "Eclipse Application", but this complains about > errors in com.aptana.interactive_console, > org.python.pydev.django_templates and org.python.pydev.mylyn. I have > tried clicking "Proceed", and sure enough a new Eclipse opens with my > changes, so I'm assuming that despite the errors I'm on the right track > and can safely ignore the errors to proceed. > > Sorry if I sound terribly noobish, but I've not had much exposure to > either java or Eclipse before (and only fairly recently to python). I > think I've got things chugging along enough to make the changes I need, > and hopefully submit a patch at the end. > > Again, many thanks for the help. > > Paul > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > pydev-code mailing list > pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-code |
From: Paul <pau...@af...> - 2012-10-20 20:44:58
|
Hi All, Sorry for long time no reply, has been a busy week. I appear to be mostly set, I'm managing to make changes and test them, so everything seems to be configured correctly. > This link explains this process: > > https://help.github.com/articles/fork-a-repo Thanks Andornaut, I must still look at this. In the mean time I'm progressing on my own branch, so it hopefully won't be too difficult to merge the changes back in or post a patch. > Before you can "run" your changes, you will need to "build" (compile) > the code. Therefore, you will need to meet all of the "build" > dependencies. Luckily this is not the case. Or rather, AFAIU, the only project I am changing is org.python.pydev, so only that one needs to be built each time (and, apart from my changes, it does build), it's the other projects that have missing deps, but as I'm not changing them, I don't need to build them. So far everything seems to work, I can make changes, run as "Eclipse Application", and see a new Eclipse with my changes, so I can test. I must still have a look at the test suite and see how to add one. I'm leaving that for last :) mostly because I'm not familiar enough with anything to have clear ideas of how I intend to implement it. I'm happy to report some success so far. I've got code folding working for some hard coded tags, and have finally managed to get somewhere on figuring out the whole preferences page stuff. I'm still busy putting custom tag preferences together, then I need to expand the folding code to allow multiple tags instead of just one, then it's on to the test cases. I have found some other stuff that looks weird, but I don't think it's due to what I'm doing, but I still need to verify that it exists in the current code folding. A few hurdles, and much learning still to do. Probably going to take more time than it should, but at least I feel I have a solid start. Many thanks for the help so far Paul |