Pydev, auto code format all files in an eclipse project - pydev

Please suggest a way to auto format all py files in an eclipse project using pydev auto code format. We're using the pydev code formatter to make our code consistent and would really like to get all files standardized.
Since we've enabled code formatting in pydev, every time a py file is touched by pydev, it gets changed at many places only due to code formatting cleanup. We'd like to do it across the project in one sweep.
Thanks

You can apply code-formatting to all the files within a project/folder.
To do that, right-click a project/folder and select pydev > source format python files.

Related

Exclude *.pyd files from go to definition (with ctrl+click)

I have a small problem with my Eclipse IDE PyDev plugin - when I'm developing a program using Python with libraries in *.pyd format, I can't go to definition, because It's binary format. But there are corresponding *.pyi files with source code. How to "force" PyDev to use *.pyi files instead of *.pyd files for Go To Definition?

Recovery of Qt4 Designer Integration with PyDev for Eclipse neon.2

My Eclipse Neon.2 crashed recently and now the integration of PyQt, in particular the integration with Qt4 Designer seems to have become corrupted. It was the case that I could open a *.ui file from Neon.2 to Qt Designer, make some changes & then run (from Neon.2) a *.py file which accesses the variables created in Qt4D. Now python fails on any new variables I add in Qt4D, but is ok with those created before the crash. I suspect the PyDev integration in my Neon.2 has been corrupted such that the auto pyuic4 does not get run. Question. How do I get out of this mess, eg re-install PyDev in Eclipse (or some other way perhaps)?
Well, PyDev didn't actually do anything automatic in this regard (i.e.: by default it doesn't translate .ui files to .py files with pyiuc4).
The way to do that automatically would be creating a custom builder (right click a project > properties > builders > new > program) and then configure it to run some program which would check if it was a .ui file changed and call pyuic4 on it.
Eclipse external tool for Qt .ui to .py with pyuic has something you could probably use.
Not sure how it worked before for you though... maybe some co-worker had it configured for you or your project already had those settings saved?
Well this does what I wanted:
qtcreator_file = "test1.ui" # Enter file here.
Ui_Dialog, QtBaseClass = uic.loadUiType(qtcreator_file)
My guess is it basically runs something like pyuic4 this avoiding running ones self after having made changes is QtDesigner.

Laravel auto formatting for Netbeans

I'm using Laravel on Netbeans but any time that I use auto format (alt shift f) it messes up my code formatting. I know that I can edit each setting individually in Netbeans but that could take hours and never be complete. Is there an easy way for Netbeans to adapt to my files, or is there a settings file somewhere that I can import into Netbeans?
The only one I could find is this:
http://forumsarchive.laravel.io/viewtopic.php?id=13032
But it doesnt work. It messes up my blade templates and my routes file gets formatted differently.
Thanks!
For Laravel on PHPStorm I'm using php-cs-fixer plugin. For me, It's perfect toool for formatting.
Here you can find this plugin for Netbeans.
Also, you can install php-cs-fixer on your machine and run it from console. Git repository of php-cs-fixer.

How to format all Java files in an Eclipse project at one time?

I have an old Eclipse project and the code is not well formatted. I'd like to format all the .java files according to the settings in Eclipse. I don't want to edit every individual file with Ctrl+Shift+F. Is there a way to format all my files? Perhaps an Eclipse plugin?
Right click on the project root and select Source -> Format. This should work for at least version 3.8.1. and above.
If the above does not work, you're probably using an older Eclipse-version. In such case you can select your Source Folders by clicking on them while holding down CTRL, then select Source -> Format from the right-click -menu. Works with package-folders and class files also, in case you don't want to format the entire project.
I also had the Java Perspective ON and this was still not working. My eclipse was only formatting css and Html files, but not JAVA ones.
Then, I located this answer that explains this:
You must add Java Facet to the project to allow Java classes to be detected by Eclipse formatter
Then, you should check on PROJECT-PROPERTIES-PROJECT FACETS and activate the Java facet for the project:
And by right-clicking on top of the PACKAGE-EXPLORER you will find the SOURCE - FORMAT option, and it will format Java files too.
Be careful, check it´s package explorer, not Project Explorer (click
Window-Show View-PackageExplorer)
This is the purpose of
Source ->Clean Up...
selecting the appropriate options.
In older versions of Eclipse (Indigo) it works from Package Explorer (not Navigator). Right click the package you wish to format then choose Source -> Format. It will format all classes in that package and its sub-packages.
In Eclipse Mars.1 Release (4.5.1) version and above, just press
Right click on the code typing area
Src > Source > Format.
If you want to format individual java / xml file just do Ctrl+Shift+f

How can I format an entire source tree in Eclipse 3.4 (Ganymede)?

The obvious thing to do would be to:
Right-click on the folder that you wish to format.
Source > Format
Expected results:
- All java code in the directory and subdirectories are formatted (using the project specific formatting settings)
Actual results:
- None of the java is formatted.
While we're at it, how can we do a batch clean up operation in Eclipse?
From editor, I Right-click > Source > Clean Up, but I can only do one file at a time.
I faced the same issue. I had to switch to packaged Explorer to use the formatter. Under Navigator it does not work. Hope this help.
As mentioned in this thread, this (format all Java source files within a folder) should work since eclipse3.0.
Do you see some kind of error message in the "errors view" ?
I did exactly as you suggested you would like to do, and it did exactly what you suggested was expected. I selected Source | Format for a directory in my src tree and it reformatted all the units within.
EDIT: ...with 3.4.1 Ganymede.
If your code isn't checked out from source control or isn't writable, doing a group operation like this won't check them out or make them writable.
I have the same problem using SpringSource Tool Suite 2.5.1
I am using the package explorer
The project is in a SVN repository that is checked out
In the progress dialog I can see that only the XML files are modified
When I press Ctrl+Shift+F into a file, it gets reformatted (therefore is writable) but when after a reverse I do a right-click Source > Format on its folder nothing happens
I know it's been 2 years but I was wondering if #LES2 has found a workaround to correct this
EDIT :
Okay, despite I was really in the package explorer as written before, my java code was interpreted only as text files. I re-ran the full repository check-out of my project and a package-tree (squares for packages instead of folders) appeared giving me the ability to mass-format even Java files.