ceylon-ide-eclipse icon indicating copy to clipboard operation
ceylon-ide-eclipse copied to clipboard

Format is incredibly flakey

Open gavinking opened this issue 9 years ago • 3 comments

Format keeps crashing with stuff like this:


ceylon.language.Exception "Unexpected token 'import' ([@0,0:5='import',<55>,1:0]), expected 'shared' instead"
    at ceylon.formatter.FormattingWriter$13.$call$(FormattingWriter.ceylon:641)
    at ceylon.formatter.FormattingWriter$13.$call$(FormattingWriter.ceylon:617)
    at ceylon.formatter.FormattingWriter.fastForward$priv$(FormattingWriter.ceylon:1121)
    at ceylon.formatter.FormattingWriter.writeToken$canonical$(FormattingWriter.ceylon:617)
    at ceylon.formatter.FormattingWriter.writeToken(FormattingWriter.ceylon:507)
    at ceylon.formatter.FormattingVisitor.visitIdentifier(FormattingVisitor.ceylon:893)
    at com.redhat.ceylon.compiler.typechecker.tree.VisitorAdaptor.visit(VisitorAdaptor.java:595)
    at com.redhat.ceylon.compiler.typechecker.tree.Tree$Identifier.visit(Tree.java:7836)
    at ceylon.formatter.FormattingVisitor.visitBaseMemberExpression(FormattingVisitor.ceylon:253)
    at com.redhat.ceylon.compiler.typechecker.tree.VisitorAdaptor.visit(VisitorAdaptor.java:487)
    at com.redhat.ceylon.compiler.typechecker.tree.Tree$BaseMemberExpression.visit(Tree.java:6313)
    at com.redhat.ceylon.compiler.typechecker.tree.Walker.walkPostfixExpression(Walker.java:1383)
    at com.redhat.ceylon.compiler.typechecker.tree.Walker.walkInvocationExpression(Walker.java:1387)
    at com.redhat.ceylon.compiler.typechecker.tree.Walker.walkAnnotation(Walker.java:1740)
    at com.redhat.ceylon.compiler.typechecker.tree.Tree$Annotation.visitChildren(Tree.java:7760)
    at ceylon.formatter.FormattingVisitor.visitAnnotation(FormattingVisitor.ceylon:109)
    at com.redhat.ceylon.compiler.typechecker.tree.VisitorAdaptor.visit(VisitorAdaptor.java:589)
    at com.redhat.ceylon.compiler.typechecker.tree.Tree$Annotation.visit(Tree.java:7752)
    at com.redhat.ceylon.compiler.typechecker.tree.Walker.walkAnnotationList(Walker.java:1754)
    at com.redhat.ceylon.compiler.typechecker.tree.Tree$AnnotationList.visitChildren(Tree.java:7812)
    at com.redhat.ceylon.compiler.typechecker.tree.VisitorAdaptor.visitAny(VisitorAdaptor.java:10)
    at ceylon.formatter.FormattingVisitor.visitAny(FormattingVisitor.ceylon:2250)
    at com.redhat.ceylon.compiler.typechecker.tree.VisitorAdaptor.visitAnnotationList(VisitorAdaptor.java:592)
    at com.redhat.ceylon.compiler.typechecker.tree.VisitorAdaptor.visit(VisitorAdaptor.java:593)
    at com.redhat.ceylon.compiler.typechecker.tree.Tree$AnnotationList.visit(Tree.java:7804)
    at ceylon.formatter.FormattingVisitor.visitAnyClass(FormattingVisitor.ceylon:135)
    at com.redhat.ceylon.compiler.typechecker.tree.VisitorAdaptor.visitClassDefinition(VisitorAdaptor.java:70)
    at com.redhat.ceylon.compiler.typechecker.tree.VisitorAdaptor.visit(VisitorAdaptor.java:71)
    at com.redhat.ceylon.compiler.typechecker.tree.Tree$ClassDefinition.visit(Tree.java:941)
    at ceylon.formatter.format_.format(format.ceylon:72)
    at com.redhat.ceylon.eclipse.code.editor.FormatAction.format(FormatAction.java:198)
    at com.redhat.ceylon.eclipse.code.editor.FormatAction.run(FormatAction.java:86)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
    at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:122)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
    at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:493)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:286)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:507)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:558)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:378)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:324)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:86)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1105)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4225)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1491)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1514)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1499)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1528)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1524)
    at org.eclipse.swt.widgets.Canvas.sendKeyEvent(Canvas.java:496)
    at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:1060)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5784)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
    at org.eclipse.swt.internal.cocoa.NSResponder.interpretKeyEvents(NSResponder.java:68)
    at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:594)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5694)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:227)
    at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2130)
    at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2337)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5756)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:5193)
    at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5342)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
    at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:128)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3695)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
    Suppressed: ceylon.language.Exception "Unexpected token 'import' ([@0,0:5='import',<55>,1:0]), expected '' instead"
        at ceylon.formatter.FormattingWriter$13.$call$(FormattingWriter.ceylon:641)
        at ceylon.formatter.FormattingWriter$13.$call$(FormattingWriter.ceylon:617)
        at ceylon.formatter.FormattingWriter.fastForward$priv$(FormattingWriter.ceylon:1121)
        at ceylon.formatter.FormattingWriter.writeToken$canonical$(FormattingWriter.ceylon:617)
        at ceylon.formatter.FormattingWriter.writeToken(FormattingWriter.ceylon:507)
        at ceylon.formatter.FormattingWriter.destroy(FormattingWriter.ceylon:1193)
        at ceylon.formatter.FormattingVisitor.destroy(FormattingVisitor.ceylon:2254)
        at ceylon.formatter.format_.format(format.ceylon:71)
        ... 70 more

That just doesn't make any sense at all.

@lucaswerkmeister what is up with this?

gavinking avatar Oct 13 '15 17:10 gavinking

Can you be a bit more precise? Is this formatting the editor or pasted Java-to-Ceylon code? If the former, are you formatting a selection or the full file?

lucaswerkmeister avatar Oct 13 '15 17:10 lucaswerkmeister

In the editor. It happens in both cases.

gavinking avatar Oct 13 '15 17:10 gavinking

I’m removing the “high priority” tag and moving this to 1.3. In general, the formatter does not aim to support syntactically invalid code, since I have no clue about how the ANTLR parser recovers. (I do mostly take into account places where the grammar is explicitly lenient, e. g. case (), import ceylon.collection;.) If you give me concrete examples which crash the formatter, I’ll try to fix them, but I don’t see anything here which blocks the 1.2 release.

lucaswerkmeister avatar Oct 28 '15 00:10 lucaswerkmeister