Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 280021

Summary: JSDT acts oddly when function literals are not followed by a semicolon
Product: [WebTools] JSDT Reporter: Laurens Holst <laurens.nospam>
Component: GeneralAssignee: wst.javascript <wst.javascript-inbox>
Status: RESOLVED DUPLICATE QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: cmjaun
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Laurens Holst CLA 2009-06-11 20:07:12 EDT
Build ID: M20090211-1700

Hi,

JSDT acts oddly when function literals are not followed by a semicolon. For example, let’s take the following code:

/**
 * Helper function for cross-browser hasAttribute
 */
function hasAttribute(oNode, sName) {
    // ...
}

/**
 * Helper function for cross-browser getAttribute
 */
function getAttribute(oNode, sName) {
    // ...
}

Here, the JSDoc comment of the second function does not have the correct color, and language keywords (‘function for’) are highlighted as if it not a comment. Pressing enter within the second function’s body or on the line after it will also start the line with an extra space.

Adding a semicolon directly after the function literals will ‘fix’ the issue:

function hasAttribute(oNode, sName) {
    // ...
};

Note that this issue with lack of semicolon only applies to function literals! If I write another expression, e.g. “var x = 1” inbetween the functions, the issue will not reappear.

Needless to say this is pretty annoying, especially the space being inserted. It makes JS source editing in Eclipse a bit tedious.

~Laurens
Comment 1 Chris Jaun CLA 2009-06-12 09:54:17 EDT
I believe this one is also a duplicate of 263222, which was fixed in 3.1.

*** This bug has been marked as a duplicate of bug 263222 ***