Community
Participate
Working Groups
Eclipse Build ID: I20090129-1800 WTP Build ID: 3.1M4-20081219210304 to reproduce: 1) create a JS file with the following content (function() { return { v: function() { A.a(dojo.hitch(this, function() { var v1= B.b(dojo.hitch(this, function() {})); }), C.c()); } }; ); })(); 2) try hitting enter at the end of line 1 - 3 observe: the keystroke is ignored
raising severity as this is a major annoyance. I can't type a line break after almost every opening curly brace I've typed!
Created attachment 128457 [details] Adds a try/catch statement to catch an exception in the JavaAutoIndentStrategy
This is happening due to an IllegalArgumentException in the JavaAutoIndentStrategy class. It looks like the parser was having trouble with the syntax in the sample JS code and was creating objects with an illegal source end position. java.lang.IllegalArgumentException at org.eclipse.wst.jsdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2537) at org.eclipse.wst.jsdt.core.dom.ASTConverter.convertToVariableDeclarationStatement(ASTConverter.java:2968) at org.eclipse.wst.jsdt.core.dom.ASTConverter.checkAndAddMultipleLocalDeclaration(ASTConverter.java:321) at org.eclipse.wst.jsdt.core.dom.ASTConverter.convert(ASTConverter.java:443) at org.eclipse.wst.jsdt.core.dom.ASTConverter.convert(ASTConverter.java:1237) at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.convert(JavaScriptUnitResolver.java:262) at org.eclipse.wst.jsdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:887) at org.eclipse.wst.jsdt.core.dom.ASTParser.createAST(ASTParser.java:647) at org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy.isClosed(JavaAutoIndentStrategy.java:516) at org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy.smartIndentAfterNewLine(JavaAutoIndentStrategy.java:303) at org.eclipse.wst.jsdt.internal.ui.text.java.JavaAutoIndentStrategy.customizeDocumentCommand(JavaAutoIndentStrategy.java:1211) at org.eclipse.jface.text.TextViewer.customizeDocumentCommand(TextViewer.java:3623) at org.eclipse.jface.text.TextViewer.handleVerifyEvent(TextViewer.java:3645) at org.eclipse.jface.text.source.projection.ProjectionViewer.handleVerifyEvent(ProjectionViewer.java:1269) at org.eclipse.jface.text.TextViewer$TextVerifyListener.verifyText(TextViewer.java:426) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:770) at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:6444) at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:7263) at org.eclipse.swt.custom.StyledText.doContent(StyledText.java:2425) at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5670) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5695) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5398) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) This fix doesn't directly address the root cause, it just catches the exception and allows the Enter key press to be processed. An error in the indent strategy shouldn't break the editor.
Releasing workaround.
Nitin, this needs to go into the 3.0.5 steam as well.
Similar change made for 3.0.5.