-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate with beautysh to provide auto-formatting #117
Comments
- reusing code from egradle to have cancel and process tools - avoided to use commons lang here because only 2 methods were used. Used instead own simple implementations
- wrote a simple test for builder (fails currently)
Hello Francesco, first of all: I think adding a save action is a very good idea! About your problem with tabs:Bash editor uses default text editor settings which can be set to use always spaces:
About help in developmentI appreciate your hep. Please look at https://github.com/de-jcup/eclipse-bash-editor/wiki/Contribution for some wanted settings to keep things easier. There is a branch called feature-117. Please checkout.
|
Hi @de-jcup , |
Hello @f18m, I updated https://github.com/de-jcup/eclipse-bash-editor/wiki/Contribution and give more information about initializing, developing bash editor and also about necessary usage of gradle. Please read the new information. In a nutshell: For development you need a Eclipse RCP edition. Full build is only possible by Eclipse. Gradle does only build and test eclipse independent parts. |
Hi @de-jcup , I downloaded Eclipse for RCP and RAP developers version 2018-12, I did implement the ExternalToolCommandArrayBuilder (in a dummy way for now - just to get the test passed). I did run the gradle wrapper with build and eclipse tasks (both successful). I tried to go in the launch configuration page, "Plug-ins" tab and use "launch with: plugins selected below only" and click "Add required plug-ins" but that did not solve the issue. [ UPDATE: apparently this must be some kind of version conflict inside Eclipse included packages because it's totally unrelated to BashEditor plugin: I get these errors also when I create the "Hello World" Eclipse plugin from scratch - and these errors do not seem to impact on the plugin functionalities so I'm going to just ignore them for now! ] If I click "continue" when launching the Eclipse application I then have problems when I try to view the Bash Editor preferences page: This is the real blocking problem for me now. I understand that, as written in the wiki page, the gradle build system will not build the src/main/java-eclipse folder where that preference page is actually located. However it's unclear to me what it means that "Currently the build is done in oldschool way which means the Eclipse RCP tools are used to build the plugin site." Maybe you have some hints to share... Thanks |
Hello @f18m , I think this is an JDK 11 issue. I updated contribution wiki page and added link to video at youtube: https://youtu.be/9_AQouAvehY At the video I checked out the project complete fresh from github and used a clean workspace and also a clean Eclipse RCP 2018-12 (linux). I started eclipse with Open JDK 10, launching was done with JDK11. Doing this I got same warnings as you, but I was able to start the bash editor plugin without problems. Maybe the video gives you all information you need. I did not called the So my suggestion: Get a JDK 10 and copy it to a location to your system. Then change the eclipse startup and define in eclipse.ini to use JDK 10 as JVM, for details look at https://wiki.eclipse.org I opened a bug at https://bugs.eclipse.org/bugs/show_bug.cgi?id=543198 because every developer using JDK 11 will have such problems. |
Hi, I installed the "java-11-openjdk-amd64" package (I'm on Ubuntu 18.04.1 LTS), switched Eclipse to use that (editing eclipse.ini) and imported the project in a clean workspace just as you did and now it works! The Bash Editor preference page is displayed just fine. Thanks for the help, I now think can proceed with actual implementation of the feature :) |
Hi @de-jcup
I did a very simple implementation that tokenize the given string and detects the special placeholder $filename.
Done (no hint for now - I can look into that later)
I'm thinking how to exactly do this: for example, another Eclipse extension that does something similar is CppStyle (allows to run clang-format on every save) and it's implementing this save action as: i.e. creating a derived class from AbstractSaveHandler. what do you think is the most correct way? Thanks |
Hi @de-jcup
Actually I tried using the CppStyle approach but the AbstractSaveHandler implementation I added was never being called (I added also an extension hook in plugin.xml but still did not work). I did a very simple proof of concept implementation (needs a lot of cleanup) in my forked repo... |
Hello @f18m , I would always override editor method. This is the first place any other developer would look into and its a central point. I would do following:
Hope it helps. |
ok I moved the code to the performSave() method
ok, done
ok, done
ok, done but I have spent some time trying to restore correctly the caret position to the position it had before reloading contents... I managed to do it even if the way I did it is not perhaps the best one / most clean way to do it. |
PS: I pushed all my changes to my fork: https://github.com/f18m/eclipse-bash-editor |
@f18m : I just merged you last PR #125 and tested out with using I tried out with I thinks its mostly done now. If you like I would do some final steps:
instead
Would this be okay for you or do you want to do more by yourself? |
Hi Albert, Looking forward for the next release then!! :) |
Hi Francesco, |
I found the problem:
Tried out:
seems to works always. Of course there should be a better solution. Maybe a) temp files or b) force reload , ... |
- when (at least on linux) timestamp does not change (seconds) refreshLocal() does not work. So introducted TimeStampChangedEnforcer and test - added own preference page for bash editor save actions - added preference keywords - refactored perform save method, is done inside job and cancelable now - beautysh.py added as default command, per default disabled - changed some texts
Hi @de-jcup ,
wow, such a low timestamp precision looks really like a strong assumption from Eclipse developers...
I tried latest branch feature-117...
|
Just another feedback on the new preference page: looks nice! In addition it probably makes sense to:
(I can try to help with these if you think they make sense) |
Another thing: beautysh by default will use spaces for Bash files (which make more sense than TABs) but I see that in the file BashSourceViewerConfiguration.java the text viewer is using the
to understand whether using spaces or TABs... maybe it makes sense to add a checkbox for BashEditor to allow it to override the generic setting of Eclipse about TABs / spaces? (PyDev extension has such kind of settings under PyDev->Editor->Tabs which explicits mention that PyDev ignores the "insert spaces for tabs" in the general settings page and will instead apply the Python-specific settings) |
I just created #127 for your idea about overriding standard text editor preferences. If you have more ideas or want to contribute for your wanted feature please use this issue. |
The "one second" timestamp diff is the safe way when using refreshLocal approach. If you get your former approach smooth working without the delay please try to implement it. But it must work always. And please let the execution still be done in the canceable job. So a long running operation can be canceled by user and a job does also handle the coreexception and show a detail screen to user on problems. Please do the PRs as before to the feature branch |
About the preference page suggestions:
You can look into Feel free to implement the wanted behaviours if you like. But be aware: The preference page must be tested very well because doing very customized preference pages will often result in unexpected side effects (e.g. allowing now empty entries can block the preference page - so user cannot leave, or for e.g. handling of initializing of current enabling etc. |
Hi @de-jcup
well I think that this issue (bypassing refreshLocal) would be more like an optimization; I think that your current code is already doing a good job!
I worked on that a little bit, see #128
I will try to approach this now! |
Hello @f18m . Thank you. I put some review marks into PR. |
@f18m There is still an issue: When we got code which has validation errors, the formatter will also be called. We must check on isRunningExternalToolOnSave() also if the current model has got errors inside. If so the external tool should not called - because we got additional errors from external tools and may have also corrupted error markers etc. I will fix this after I got your final PR merged . |
Hi @de-jcup I cannot see the review marks in the PR...
yes, you're right - I didn't consider this aspect. I basically use Linux only :)
yes, that's another approach. Is it possible to create a "normal" SWT button in a preference page using field editors or the extra "validate" button should be a fake field editor? |
apparently it's possible without too much troubles... I just checked in this approach in my PR branch. |
- when already an error is shown do not call the external tool - block user from editing in editor while external tool is running
I haved merged your PR to remote branch + made some changes. |
no I don't have any more ongoing changes - at least for this "Save action" thing, thanks! |
Will apply the feature in next days to master and release will follow. |
Ok, then I'm closing this. |
@f18m I just released Version 1.6.0 containing the feature |
Hi @de-jcup, beautysh -f $filename --force-function-style=fnpar It works very well, thanks!! |
Hi,
I'm a user of BashEditor and I love it, thanks for creating this plugin.
However I think a useful feature is missing: what I would like to have in Eclipse/BashEditor is to have an option to run a Bash formatter every time I save the document (I'm also using CppStyle extension that allows you to run clang-format to reformat your C/C++ code everytime you click save).
I found over time that this is really the way to go to ensure consistent formatting of your code.
I think a good formatter is:
https://github.com/bemeurer/beautysh
so I propose to add an option in BashEditor to run that tool every time you click save.
What do you think?
I think I could help with this development if that's not too difficult !
Thanks,
Francesco
NOTE: my use case for automatic bash formatting is the following:
I have an annoying problem when using Eclipse to write Bash code: Eclipse by default uses TABs and not spaces to format it. This means that if I copy/paste a snippet of my bash into a terminal, it won't work (TABs are recognized as line-completion triggers by the terminal). What I do is to copy/paste the code into another editor, replace TABs with spaces and then copy/paste to the terminal. This is very slow and error-prone. With auto-reformatting that problem would be automatically solved with a simple CTRL+S
The text was updated successfully, but these errors were encountered: