Is it possible to open a file named feature.xml in the XML Editor of Eclipse? - eclipse

I have project in Eclipse that contains a file named "feature.xml". If I open the file Eclipse uses the Feature Manifest Editor. In my case this file has nothing to do with Eclipses features and I simply want to open it in the XML Editor. If I try this I get a dialog informing me of "Unsupported content type in editor."
I have tried various combinations of Content Type and File Association in the Preferences but am unable to get anywhere.
Is it possible to open a file named feature.xml in the XML Editor of Eclipse?
I am using Kepler.

No, there's a low-level bug in the XML Editor that the PDE editors are side-stepping. This causes the error message you see to appear. original bug It may have been fixed in the interim, but there would need to be a thorough review to make sure the original issues didn't resurface.

Related

XML file validation in Eclipse RCP application for different customized/different file extensions

I have some customized (different file extensions than the conventional .xml files) XML files on my Eclipse RCP application and I need Eclipse to display error markers like it does for .xml files when the format is incorrect (for example if there's no end tag for the beginning tag or if the angle brackets are missing). I can easily set this up manually in Preferences -> Validation -> XML Validator -> Settings -> Add new File Extension Rule for my custom file extensions and after setting up this preference the error markers correctly display for my custom XML files when the format is incorrect but I would like this behavior to apply even though the preferences are not set for different file extensions (something we could setup using .ini file).
When I set the File Extension Rule for my custom file extensions then Eclipse stores this following preference in org.eclipse.wst.validation.prefs node -
vals/org.eclipse.wst.xml.core.xml/groups=0107include07111contentType128org.eclipse.core.runtime.xmlT111contentType134org.eclipse.wst.xml.core.xmlsourceT111contentType134org.eclipse.wst.xml.core.xslsourceT111contentType134org.eclipse.jst.jsp.core.tldsourceT07fileext03xmlF07fileext06varselF07fileext06vardefF0107exclude05113projectNature134org.eclipse.jst.j2ee.ejb.EJBNature113projectNature130org.eclipse.jst.j2ee.EARNature04file08.projectT0104file110.classpathT0104file110.settings/T02
And I tried adding the same entry to my product's .ini file and expected the settings to be read upon the product start and the validation behavior to be applied on my Eclipse RCP product to my custom file extension XML files without explicitly setting the preferences manually.
I looked upon the internet for solutions but got nowhere close, what am I doing wrong here? Are the entries I added to my .ini file correct? How can I enable validation for my custom file extension XML files (XML files with different file extensions)?
A better solution would be to add filename extensions to the relevant Content Type, via an "extension" element in your own plugin.xml file. Then almost every feature meant for XML files will, or should, apply to your own--validators, editors, task tag scanning, etc. The Platform defines one content type for XML files, and the WTP XML plug-ins define another specifically for files that could be considered ill-formed or syntactically broken, the ones that would be unreadable by most production XML parsers. They are org.eclipse.core.runtime.xml and org.eclipse.wst.xml.core.xmlsource, respectively. The Validation framework will then automatically consider your files as candidates for the XML Validator.
https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_core_contenttype_contentTypes.html?cp=2_1_1_9

How to generate HTML with FluentMark

I use Eclipse as IDE and I installed FluentMark from the Eclipse Market Place.
Afterwards, I wrote two MarkDown files which should be converted to HTML files. (It is the documentation of a bigger project.)
My question now is: how can I convert the .md files to HTML files without leaving Eclipse?
I set Eclipse to use Pandoc as converter with the path to the executable.
The problem now is: the conversion is not done automatically and I cannot find a button to do so. Building the project or Buiding all projects doesn't help.
How can I do this task?
I am relatively new to Eclipse, so I don't know all its features (yet).
There is a very easy to miss, new toolbar item "Export as HTML".
There is also an "Export as PDF" but it requires additional tools that can not be installed from Eclipse Marketplace.
I raised an issue with FluentMark about this unintuitive use.
https://github.com/grosenberg/fluentmark/issues/39
I hope you are using FluentMark editor to edit the files.
While you are editing the files you can open 'FluentMark View' in Eclipse.
(You will have to choose 'Eclipse' -> 'Window' -> 'Show View' and select 'FluentMark View' probably from the Other option if not already listed in the options to choose.)
This will give a real time view of how the markdown files would look, upon saving the file, Eclipse should have generated a hidden html file in the same folder as your markdown file exists.
For e.g., if I am editing a README.md then after saving it and viewing in 'FluentMark View' there is a hidden html file created in same directory as .README.md.html
If this isn't working you may also try choosing other 'Show View' options like 'GFM View' (if that is already preinstalled else look for it in Marketplace).

Eclipse target definition is empty

For some mysterious reason all the target definition files (*.target) in my plugin project became empty.
I have absolutely no clue how to fix this.
With the information provided in the question it is difficult to guess the reason.
However you can try these
Open target file in Text Editor and check the content.If the size of the file is more than zero then you can see some content here.
If using any SCM tool get the older version of these files.
You can replace the file content in local history. Right click on the file go to Replace with > Local History then choose the older one and click Replace.

How do I make an editor the default editor for all unknown files in Eclipse?

I regularly open files of different types in Eclipse. For many types, Eclipse uses the system editor by default. I don't want this to happen. I want Eclipse to use the built-in Text Editor for unknown file types. However all I can find are options to set the default editor for a certain file type, but not for all unknown ones. Is there an option to do this?
I don't think you can do this in one swoop, however:
Windows > Preferences > General > Editors > File Association.
If you don't have a LOT of unknown file types, just type *.junk, *.punk, *.clunck and add Text Editor as the default editor.
Sadly you can't use *.* here.
This issue with file associations is something that has always annoyed me with Eclipse. It is specially frustrating if you are trying to use Eclipse to edit files that don't have a file extension because then you can't even set a editor.
I searched over the Eclipse bug database and found my exact issue there. It was first reported in 2003 and up until now there is no solution for it. If you follow the long comment track over the years you will see that there is no way of setting a default editor for unknown file types. From what I gathered the problem boils down to eclipse not looking at the content of file to try to determine the type. Instead it fully depends on the file extension.
Some people have made suggestions for fixes but again nothing has come out of that. If you search the bug tracker DB you will find a lot more bugs created around this.
A clean solution to this is finally implemented in Eclipse.
On the Preferences > General > Editors > File Association page, you can now define an editor selection strategy for unassociated file types.
Source: https://www.eclipse.org/eclipse/news/4.6/platform.php#text-editor-selection-strategy
There is an Eclipse plugin that overrides the default behavior of the platform and opens text file of unknown type in the plain text editor of Eclipse instead in an external editor.
https://github.com/eclipselabs/default-text-editor

How to view Java's byte code in eclipse IDE?

Sometimes, in Eclipse , i press a combination of keys which take me to the editor page that shows contents of my .class file (bytecode). I never seem to be able to remember what that key combination is.
Can someone please let me know?
Or in other words, how can one see own bytecode?
Eclipse's default class file viewer shows the source (see VonC's answer) if it has been associated with the binaries, otherwise it gives a javap-like view of the class (with an option to attach source). I'm guessing it's the latter that you are looking for.
I've never found a way to cleanly force Eclipse to show that output rather than the linked source. What you probably want is an Eclipse plug-in that provides Javap like functionality (or an interface to javap). Look for plugins stating they "disassemble" (as opposed to "decompile," like jad).
Barring a plug-in, you could probably configure an external tool to perform javap but it might not play nicely with other eclipse features.
Edit: Let me be clear about the above: If you hit F3, Eclipse does the following (generally, the actual procedure might be slightly different):
Resolves the target (if you are selecting a Java file, it will be the Java file itself; if you are selecting or your cursor is over a class name it will be the class declaration, similar for a method declaration, etc).
Searches the build path (same project first) for a Java file containing the target. If found, opens up an writable editor displaying that Java source file.
For class/method declarations, it continues searching references on your build path for a class file that contains the declaration. If it is found, then
a) If the class file has had source attached to it, open up a read-only editor of the linked Java file.
b) If the class file does not have source attached to it, then open up a read-only panel showing the disassembled (javap-like) bytecode of the compiled class file.
My guess would be that you're thinking there's a dedicated key sequence to 3.b), but I don't think there is. But again, I would love to be proven wrong here.
Using the following external tool configuration we can view java byte code in eclipse with the help of javap:
To get the above pop-up select Run option and select External Tools and select External Tools configuration...
${system_path:javap} is used to locate javap in the JDK used by the Eclipse. You can use an absolute path to javap instead.
${project_loc} returns the absolute path to the project. This is used, since I could not find a pre-define variable to use, to locate the .class file of a resource, and that's why javap runs in the project's directory instead of the directory containing the .class file.
Among the arguments passed to javap:
bin is the default output folder for Eclipse projects. Change this to build/classes or whatever is used by the project. Note, the value is relative to ${project_loc}; you can specify absolute paths instead.
${java_type_name} is used to obtain the selected class name.
You can select a Java file in the Project explorer view or Project navigator view, or even a Java type in any of the views, and then run the external tool. Note - this approach doesn't work quite well when you select a method, an inner class etc. and then run the tool, as they are not resources on their own, leading to the scenario where ${project_loc} will be empty.
Source
Dr. Garbage Tools is a suite of Eclipse Plugins released under Apache Open Source license.
Install Bytecode Visualizer using Eclipse Marketplace.
To view a bytecode:
Right click on .java file, select open with and select other you will get the following popup:
Search "Bytecode Visualizer" and select the option it opens the file as follows there you can find Bytecode option as shown:
Enhanced Class Decompiler
"Window > Preferences > General > Editors > File Associations"
Change default to your for both .class association.
"*.class" : "Class Decompiler Viewer" is selected by default.
"*.class without source" : "Class Decompiler Viewer" is selected by default.
You can use ASM 4.0 Plugin.
Installation
The Bytecode Outline plugin can be installed from the Eclipse Update Manager with the ObjectWeb Eclipse Update Site http://download.forge.objectweb.org/eclipse-update/
Alternatively, the plugin can be downloaded from the ObjectWeb Forge site, and manually installed in the Eclipse plugins directory.
Usage
To see the bytecode of the current .java or .class file:
Window -> Show View -> Other -> Java -> Bytecode
To compare the bytecode of two .java or .class files:
select two *.class or *.java files -> right click -> Compare with -> Each Other Bytecode
or
select one *.class or *.java file -> right click -> Compare with -> Another Class Bytecode
http://asm.ow2.org/eclipse/index.html
Well... if the .class is selected in the Navigator View or Package Explorer view, a simple F3 is enough to open a decompiled version of it in the editor.
As hinted at by user833970: The Bytecode Outline plugin: http://andrei.gmxhome.de/bytecode/index.html
At its base, it provides a "bytecode" view for the currently opened Java file which is what you were looking for.
However, you can also assign it to load any random .class file instead of the default .class viewer, and it surpasses it in many ways. For example, this viewer actually jumps to the right spot in the bytecode if you click on a member in the Outline view.
Download links (for dropin use) can be found at the afore-mentioned link, the update-site is http://andrei.gmxhome.de/eclipse/.
If you are really interested in the bytecode there is a eclipse plugin that lets you open and edit the bytecode of a .class file using a text editor.
https://github.com/itemis/jbc
I've tried several different solutions for this.
Bytecode Visualizer (available here: https://sourceforge.net/projects/drgarbagetools/ ) is, in my opinion, the best solution. It neatly displays the output and makes clear how it links to the source code. I've noticed a few minor misinterpretations on some of the bytecodes, but you can get the gist of it.
Unfortunately, it doesn't seem to support Neon at time of writing. It does support Mars, though.