Character sets offered in the Eclipse properties - eclipse

I've just been handed a pile of Java source that, I suspect, is in ISO-8859-8. Eclipse's menu of charsets, here on my Mac, does not include that. Or any of a wide variety of other encodings supported by the JDK.
Is there a recipe for expanding the list of encodings that show up in the menu?

You can just type it in manually. From Edit->Set Encoding..., simply type in ISO-8859-8. Only a few are listed, but it will accept any that your Java runtime accepts. After you choose it once, it should be listed in the drop-down combobox after that.
See Supported Encodings for more information on which sets are supported by Java.
If it's not the Set Encoding action you're trying to run, please give more information of what steps you're taking to get to the "menu of charsets."

Related

Supporting toggle between new file-types in eclipse or eclipse CDT

I would like to extend the source/header toggle functionality of eclipse CDT for custom file types. I work with *.cppml and *.hppml file extensions (C++ with some functional language syntax-extension), and I would like eclipse to understand that there is a source/header relationship between these two file types and toggle between them upon request.
The current CDT does not support this exactly, but it is pretty close, it needs an update to SourceHeaderPartnerFinder.
That class has a method, getPartnerFileFromFilename, which calculates the partner when you do a Header/Source toggle (Ctrl+Tab by default, or available from Navigate -> Toggle Source/Header)
That method strips off the extension of the file you started in, and then tries the partner type extensions (as derived from getPartnerContentTypes).
What needs to be done is update getPartnerFileFromFilename to create new header/source partnerships. Perhaps you could even edit the File Types property pages to allow users to explicitly define such associations.
If this feature is of value to you, raising it in CDT's Bugzilla would be a good start.

Eclipse Custom Content Assist Based on Default Java Content Assist results

I'm in the process of implementing a task tool. As a part of this I'm making an Eclipse plug-in to reflect certain code level issues.
In the Eclipse plug-in my aim is to attach some visual aids to different Java elements according to their host task's status. I've been successful in adding multi-colored markers to the vertical ruler of the default Java editor as well as the resource icons displayed by the Overview. However, I have not been able to change the icons in the Java content assist.
At first I thought that by using the extension point org.eclipse.ui.decorators and having its enablement set as org.eclipse.jdt.core.IJavaElement, the content assistant would also be affected, as this was the case with element icons in the Overview. I've tried several other enablement classes ranging all the way to ICompletionProposal.
Since this approach, a bunch of others and extending the default Java content assist, won't work. I've decided to implement my own content assist.
The idea now is to somehow take the default Java content assist's results and run some checks on the proposed elements and in case of a match change the icon displayed in the content assist, to reflect the associated task's level.
I've tried to look through the source for Eclipse's default Java editor and the Mylyn project, but I can't understand how they provide their Java content assists and how to access / redo them.
The end result I'm looking to get: LINK
The actual question
When providing a new content assist (category) for the default Java editor in Eclipse, how does one get a list of proposals that the default Java content assistant would produce for that point?
My first question and certainly a long intro, please let me know if I should edit this in any way and most importantly thanks for all the help in advance!
-J3lly
Take a look at the following extension point : org.eclipse.jdt.ui.javaCompletionProposalComputer
To implement your own Content Assist you have to write a class that implements org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer. In your case, since you want to modify the behavior of the default Java Content Assist, you should override one of the internal implementations org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer, org.eclipse.jdt.internal.ui.text.java.JavaAllCompletionProposalComputer or any other implementation depending on which Content Assist you want to modify.
Now all you have to do is override the method computeCompletionProposals which returns the list of completion proposals. The overridden method should call super.computeCompletionProposals(...) to get the default completion proposals, then you can modify them according to your needs.

How to Add Legal Syntax to Language in Eclipse

I've seen similar questions to this on StackOverflow regarding adding highlighting to a language, but what I'm concerned with is getting Eclipse (I'm guessing xtext?) to stop marking certain syntax as incorrect for a language.
Specifically, I have a wrapper from which I call PIG files that looks for certain syntax in the PIG file that would normally be illegal in PIG and substitutes a template for it. I'd like Eclipse to stop marking this syntax as incorrect and giving me ugly red x's in my folder structure because of it. Is there a simple way to do this? Or failing that, to at least disable marking of incorrect for that language in general?
Generally, error markers are created by two entities: editors and builders (compilers). If your existing editor understands the PIG format, it might display parse errors in the opened editor as you are typing. The only way to disable this feature is to re-open the file using a different editor (right-click the file, select Open with... and find an editor - e.g. plain text editor). To support syntax highlighting/error display in other parts, but not in special parts, you have to provide your own editor - that can be written using Xtext.
If the error markers are provided using a builder, then they are only refreshed on save - when it tries to understand the format, and provide an output. In this case, you only have to make sure that the templates are substituted before the file is executed (you can reorder the builder in the project preferences if needed). If you have no such builder, you could disable the PIG builder, that would prevent displaying the erroneous markers (however, it also disables displaying the correct ones as well).

how to switch/control syntax highlighting in eclipse flexibly?

I have a file with extension .xml.
But it doesn't necessarily contain XML. It may also contain HTML and JavaScript. Now I would like to either have Eclipse decide inteligently/heuristically which syntax highlighting would be appropriate or to switch it myself.
Any ideas?
Eclipse associates files with an editor. You can let eclipse decide which editor to use (e.g. defaults per file extension) or select the editor by yourself. I guess you might already know that or have at least experienced it.
Syntax highlighting isn't always set seperately but instead part of some editor (together with stuff like keyboard shortcuts). So what you are going to need is an editor that behaves the way you want it to. I do not know if there is an editor like this available but one options is writing an eclipse plug-in and implementing such an editor.
Fortunately there are great editors for each of XML, javascript, HTML, etc that are all open source. I guess you might be able to use some of their code. Ideally as a client of their API / Objects or if it won't work out just by reusing code.
short answer: not possible. use PHPStorm instead :)

Eclipse - how to add a file that has right to left strings

I am writing a Java app using Eclipse. This app read a set of Hebrew strings (that are right-to-left). Assuming I put these strings is a separate file, how do I tell the Eclipse editor that they are right-to-left text.
I tried eclipse -dir rtl but that puts all of Eclipse in RTL mode which is not the behavior I looking for.
One alternative is to carefully use StringBuilder.reverse() to manipulate the strings as needed after they are read in.
http://download.oracle.com/javase/1.5.0/docs/api/java/lang/StringBuilder.html#reverse%28%29
You could also write some simple string manipulation methods as helpers to handle whatever special needs you have.
This page, found in a quick google search, seems to have some interesting info on how Java handles and renders Hebrew: http://mindprod.com/jgloss/hebrew.html