Recently I did something wrong and it ruined my project's code style format, my eyes bleed with the new code style format and I neither can read or edit my code. I fixed the project settings by restoring to default, but pre-formatted code resits the new Eclipse Format and I have to fix every Java file one by one by hand...
This is how all my sources look like after the mistake
dropDat.setItemId(Integer
.parseInt(attrs
.getNamedItem(
"itemid")
.getNodeValue()));
dropDat.setMinDrop(Integer
.parseInt(attrs
.getNamedItem(
"min")
.getNodeValue()));
dropDat.setMaxDrop(Integer
.parseInt(attrs
.getNamedItem(
"max")
.getNodeValue()));
dropDat.setChance(Integer
.parseInt(attrs
.getNamedItem(
"chance")
.getNodeValue()));
The same code should look like:
dropDat.setItemId(Integer.parseInt(attrs.getNamedItem("itemid").getNodeValue()));
...
dropDat.setItemId(Integer.parseInt(attrs.getNamedItem("chance").getNodeValue()));
My whole project is destroyed (30.000+ Java files) into this annoying coding style... What should I do to automatically fix it?
Create a formatter profile here Windows > Preferences > Java > Code Style > Formatter.
Then in package explorer view right click on project then select Source > Format.
You can also create your source clean up profile here Windows > Preferences > Java > Code Style > Clean Up
Then in package explorer view right click on project then select Source > Clean up.
You have to repeat it for all projects.
If you have many many projects then try this solution
Related
Im looking to add IntelliSense support to my VS Code Extension.
Within the extension i have a few files like:
server.d.ts
client.d.ts
And files like below, with the d.ts that should provide IntelliSense behind it.
/server/script.js > server.d.ts
/client/script.js > client.d.ts
/widget/script.js > server.d.ts
/widget/widget.js > client.d.ts
I have the data for the mapping, but cant figure out what to do in the extension. Clues?
You might wanna try this extension,
https://marketplace.visualstudio.com/items?itemName=christian-kohler.path-intellisense
Is it somehow possible to change the tag-colors (not one-by-one, but for all of them... or else one-by-one would also be okay) of imported tag library tags (like e.g. jstl-tags: <c:if>, <c:forEach>, or <my:tag>, etc.)? Just to make some visual difference within a JSP-code between usual HTML-tags and all the rest.
Other than Preferences > Java > Editor > Syntax Coloring, I'm pretty sure you can't change tag colors for custom tags.
Now I'm using python to change settings files under .metadata/ in my workspace.I need find every line needed in these files beacuase I don't want any unnecessary content.
For example , if I want set tab's width be 4. I need change the file
.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs
in workspace and add a line following in it , not simply copy the settings file:
tabWidth=4
So I want to know : Can I set this value by java code in eclipse plugin? If it can, please give me related classes :-)
And, does it more complex than python's method?
In a plugin you can use:
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.ui.editors");
store.setValue("tabWidth", 4);
How programmatically associate file type with Editor?
That is what Eclipse-RCP Java code can do what is archived with the following UI interaction:
Window -> Preferences
General -> Editors -> File Associations
Add... > File type: *.json
Select *.json file type
Add... (Associated editors) > JavaScript Editor
Make it default
Ralated to Q
https://stackoverflow.com/questions/12429221/eclipse-file-associations-determine-which-editor-in-list-of-associated-editors
Eclipse: associate an editor with a content type
Get associated file extensions for an Eclipse editor
Opening a default editor, on a treeviewer selection eclipse rcp(eg: as eclipse knows that j.java files must be opened in text editor)
eclipse rcp change icon for xml configuration file
I know your questions says "programmatically" but I'll give a complete run down of the methods.
If you are writing the plugin that provides the editor, then you should simply declare the extension in your plugin.xml.
<extension
point="org.eclipse.ui.editors">
<editor
...
extensions="json"
...
If you are distributing a complete RPC application, you can edit the plugin.xml for the plugin that provides the editor or add a plugin that just refers to that editor.
But, if you have to do it programmatically, you are manipulating the internals of an RPC instance. Eclipse does not provide a public API for that but this code will do it:
// error handling is omitted for brevity
String extension = "json";
String editorId = "theplugin.editors.TheEditor";
EditorRegistry editorReg = (EditorRegistry)PlatformUI.getWorkbench().getEditorRegistry();
EditorDescriptor editor = (EditorDescriptor) editorReg.findEditor(editorId);
FileEditorMapping mapping = new FileEditorMapping(extension);
mapping.addEditor(editor);
mapping.setDefaultEditor(editor);
IFileEditorMapping[] mappings = editorReg.getFileEditorMappings();
FileEditorMapping[] newMappings = new FileEditorMapping[mappings.length+1];
for (int i = 0; i < mappings.length; i++) {
newMappings[i] = (FileEditorMapping) mappings[i];
}
newMappings[mappings.length] = mapping;
editorReg.setFileEditorMappings(newMappings);
Associating file type means associating content of ur editor with a predefined one.
This can be easily achieved via plugin.xml..
Just follow the following link:-
Eclipse help Documentation
http://help.eclipse.org/indigo/index.jsp
and search for org.eclipse.core.contenttype.contentTypes.
I'm using SpringSource Tool Suite (Eclipse) to program with Grails, and I'm also using JFreechart in the program.
In Grails you log by typing log.info("method worked"). Unfortunately JFrechart has a class called "Log" with Static methods like "info". This means that in STS I type log.info and then when I type space or ( Eclipse "assists" me by importing the JFreechart Log class and changing what I've typed to Log.info(message). Very irritating.
I reckon I could turn off the Eclipse option to "insert single proposals automatically", but I like this feature. Can I instruct Eclipse not to give me content assist from this particular JFreechart class?
You can add the JFreechart Log class to Type Filters via Window > Preferences > Java > Appearance > Type Filters:
alt text http://www.imagebanana.com/img/aairbchy/screenshot_009.png