Eclipse > Javascript > Code highlighting not working with Object Notation

人盡茶涼 提交于 2019-12-11 03:21:19

问题


I am using Eclipse Helios* with PDT, and when I am editing JavaScript files with the default JavaScript Editor (JSDT), code highlighting (Mark Occurrences) is not working for JSON-style (or Object Literal if you will) declarations.

*) Question also valid for Eclipse Indigo with webtools and JSDT 3.7.2

Example:

Foo = {};
Foo.Bar = Foo.Bar || {};

Foo.Bar = { 
    bar: function(str) { 
        alert(str) 
    }, 
    baz: function(str) {
        this.bar(str); // This bar *is* highlighted though
    } 
};

Foo.Bar.baz('text');

No Bar, bar or baz is highlighted. For now, I humbly edit the JavaScript part of projects in Notepad++ because it just highlights every occurrence of whatever is currently selected.

Is there a common practice for Eclipse JavaScript developers to get code highlighting work correctly, using the popular Object Literal notation? An option or update I missed?

-update-

I have found that code highlighting depends on the code being properly outlined. Altough commonly used, Object Literal outlining still seems rare in javascript editors.

The Spket Javascript Editor does partial Object Literal outlining, and the Aptana Javascript Editor does full Object Literal outlining. But both loses other important functionality. A quest for the editor with the least loss of functionality is currently in progress in this question.


回答1:


I have a partial answer to my own question.

The Spket JavaScript editor plugin for Eclipse does exactly what I want. Here is the Eclipse repository. Excellent code highlighting. I really don't know why the default JS editor has problems with this.

Two problems with this plugin are: 1) Not free/libre. You can use it for non-commercial purposes. 2) Less advanced code coloring.

I hope someone can improve on this and find a free/libre/open solution.



来源:https://stackoverflow.com/questions/6006421/eclipse-javascript-code-highlighting-not-working-with-object-notation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!