Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » IllegalStateException when formatting
IllegalStateException when formatting [message #1776316] Wed, 15 November 2017 09:37 Go to next message
Nikita Dümmel is currently offline Nikita DümmelFriend
Messages: 15
Registered: September 2017
Junior Member
Hello,

Im getting following issue:
1927597 [main] ERROR org.eclipse.xtext.ui.editor.formatting2.ContentFormatter$FormattingUnitOfWork  - Error formatting platform:/resource/de.ubt.ai1.athena.testPluginProject/src/test.athena: null
java.lang.IllegalStateException
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:229)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.process(NodeModelBasedRegionAccessBuilder.java:220)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.getEObjectToTokensMap(NodeModelBasedRegionAccessBuilder.java:87)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccess.<init>(NodeModelBasedRegionAccess.java:29)
	at org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccessBuilder.create(NodeModelBasedRegionAccessBuilder.java:58)
	at org.eclipse.xtext.formatting2.regionaccess.TextRegionAccessBuilder.create(TextRegionAccessBuilder.java:37)
	at org.eclipse.xtext.ui.editor.formatting2.ContentFormatter.initRequest(ContentFormatter.java:126)
	at org.eclipse.xtext.ui.editor.formatting2.ContentFormatter.exec(ContentFormatter.java:88)
	at org.eclipse.xtext.ui.editor.formatting2.ContentFormatter$FormattingUnitOfWork.exec(ContentFormatter.java:57)
	at org.eclipse.xtext.ui.editor.formatting2.ContentFormatter$FormattingUnitOfWork.exec(ContentFormatter.java:1)
	at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:91)
	at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:520)
	at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.priorityReadOnly(XtextDocument.java:485)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.priorityReadOnly(XtextDocument.java:142)
	at org.eclipse.xtext.ui.editor.formatting2.ContentFormatter.format(ContentFormatter.java:103)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:992)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1461)
	at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:130)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:127)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
	at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:118)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:92)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:305)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:239)
	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:494)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:287)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:527)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:577)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:385)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:331)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:88)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1271)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1078)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1088)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1130)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1126)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1547)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4962)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:364)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4843)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:359)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5178)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2560)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3815)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
	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:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1472)


when calling the formatter on this code:
type Point : structure {
	attribute x : integer;
	attribute y : integer;
}

main {	
	variable a : integer;
	a <-- 3;
	
	variable b : integer;
	b <-- a; 	// works fine
	
	variable p : Point;
	p.x <-- 2; 	// works fine
	p.y <-- a; 	// IllegalStateException 
	_output(p);
}


The formatter works fine except for similar cases like in the code above.
In such cases the execution stops with the error before I even get into the formatter.
Xtend IDE and Xtext Complete SDK are updated to version 2.13.0.v20171020-0920.
The code generation works fine (with traced codegen).

The formatter is the generated stub with some extensions to see if it works:
class AthenaFormatter extends AbstractFormatter2 {
	
	@Inject extension AthenaGrammarAccess

	def dispatch void format(Program program, extension IFormattableDocument document) {
		// TODO: format HiddenRegions around keywords, attributes, cross references, etc. 
		for (TypeDeclaration typeDeclaration : program.getTypeDeclarations()) {
			typeDeclaration.format;
			typeDeclaration.append[setNewLines(2)];
		}
		for (Operation operation : program.getOperations()) {
			operation.format;
			operation.append[setNewLines(2)];
		}
		program.getMainBlock.format;
	}

	def dispatch void format(Enumeration enumeration, extension IFormattableDocument document) {
		// TODO: format HiddenRegions around keywords, attributes, cross references, etc. 
		for (EnumTypeValue enumTypeValue : enumeration.getValues()) {
			enumTypeValue.format;
		}
	}
	
	// TODO: implement for Composition, Operation, Block, Return, Conditional, WhileLoop, ForEachLoop, OperationCall, Attribute, Parameter, VariableDeclaration, Assignment, QualifiedAccess, Xor, Or, And, Equality, Comparison, AddSub, MulDiv, Exponent, Cast, ParenthesizedExpression, Not, Reference, ListDeclaration, ListInitRepetition, ListInitRange, ListInitElements
}



Regards,
Nikita.
Re: IllegalStateException when formatting [message #1776332 is a reply to message #1776316] Wed, 15 November 2017 12:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12237
Registered: July 2009
Senior Member
this sounds like a bug to me. can you open a issue at github.com/eclipse/xtext-core

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: IllegalStateException when formatting [message #1776344 is a reply to message #1776332] Wed, 15 November 2017 13:57 Go to previous message
Nikita Dümmel is currently offline Nikita DümmelFriend
Messages: 15
Registered: September 2017
Junior Member
Opened an issue:
https://github.com/eclipse/xtext-core/issues/548
Previous Topic:[DELETE PLEASE] Configurable issue code is not registered - check binding for...
Next Topic:Custom validation of constraints from existing metamodel
Goto Forum:
  


Current Time: Sat Sep 22 01:25:55 GMT 2018

Powered by FUDForum. Page generated in 0.02077 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top