Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Build triggered when opening file in language implemented by Xtext
Build triggered when opening file in language implemented by Xtext [message #1773385] Wed, 27 September 2017 07:59 Go to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
Hi everyone,

I am experiencing the following behavior in Xtext in our N4JS IDE (https://github.com/eclipse/n4js) developed by Xtext but also in JDT with Xtend language:

Given a workspace W with project P1, P2 to Pn. We build some Pi and cancel it in the middle. Now, when we open any file in any project Pj in a language developed by Xtext (e.g. Xtend, Xpect, N4JS), the build for Pi is triggered. This can be reproduced both in N4JS IDE and in JDT.

This seems to be Xtext behavior as this happens only to languages developed by Xtext such as Xtend, Xpect or N4JS. In JDT, opening .java files does NOT trigger a build but opening .xtend files DOES trigger a build.

Can anyone tell how to prevent this behavior from happening?

Thanks a lot!
Quang
Re: Build triggered when opening file in language implemented by Xtext [message #1773420 is a reply to message #1773385] Wed, 27 September 2017 16:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
i can see that the java builder is called as well. i have no idea what triggers the (full) build

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com

[Updated on: Wed, 27 September 2017 16:46]

Report message to a moderator

Re: Build triggered when opening file in language implemented by Xtext [message #1773423 is a reply to message #1773420] Wed, 27 September 2017 16:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
bautobuildjob is called from this stacktrace

Thread [main] (Suspended (breakpoint at line 523 in BuildManager))
owns: WorkspaceModifyDelegatingOperation (id=18482)
BuildManager.endTopLevel(boolean) line: 523
Workspace.endOperation(ISchedulingRule, boolean) line: 1484
Workspace.run(ICoreRunnable, ISchedulingRule, int, IProgressMonitor) line: 2253
Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line: 2267
WorkspaceModifyDelegatingOperation(WorkspaceModifyOperation).run(IProgressMonitor) line: 128
WorkspaceOperationRunner.run(IRunnableWithProgress, ISchedulingRule) line: 73
WorkspaceOperationRunner.run(boolean, boolean, IRunnableWithProgress) line: 63
XbaseDocumentProvider(AbstractDocumentProvider).executeOperation(AbstractDocumentProvider$DocumentProviderOperation, IProgressMonitor) line: 536
XbaseDocumentProvider(FileDocumentProvider).refreshFile(IFile, IProgressMonitor) line: 967
XbaseDocumentProvider(FileDocumentProvider).refreshFile(IFile) line: 939
XbaseDocumentProvider(FileDocumentProvider).createElementInfo(Object) line: 689
XbaseDocumentProvider(XtextDocumentProvider).createElementInfo(Object) line: 270
XbaseDocumentProvider.createElementInfo(Object) line: 111
XbaseDocumentProvider(AbstractDocumentProvider).connect(Object) line: 392
XtendEditor(AbstractTextEditor).doSetInput(IEditorInput) line: 4183
XtendEditor(StatusTextEditor).doSetInput(IEditorInput) line: 257
XtendEditor(AbstractDecoratedTextEditor).doSetInput(IEditorInput) line: 1465
XtendEditor(TextEditor).doSetInput(IEditorInput) line: 150
XtendEditor(XtextEditor).doSetInput(IEditorInput) line: 247
XtendEditor(XbaseEditor).doSetInput(IEditorInput) line: 120
AbstractTextEditor$5.run(IProgressMonitor) line: 3159
ModalContext.runInCurrentThread(IRunnableWithProgress, IProgressMonitor) line: 437
ModalContext.run(IRunnableWithProgress, boolean, IProgressMonitor, Display) line: 353
WorkbenchWindow$14.run() line: 2213
BusyIndicator.showWhile(Display, Runnable) line: 70
WorkbenchWindow.run(boolean, boolean, IRunnableWithProgress) line: 2209
XtendEditor(AbstractTextEditor).internalInit(IWorkbenchWindow, IEditorSite, IEditorInput) line: 3177
XtendEditor(AbstractTextEditor).init(IEditorSite, IEditorInput) line: 3202
XtendEditor(XtextEditor).init(IEditorSite, IEditorInput) line: 288
EditorReference.initialize(IWorkbenchPart) line: 362
CompatibilityEditor(CompatibilityPart).create() line: 333
GeneratedMethodAccessor138.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 498
MethodRequestor.execute() line: 55
InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 990
InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 955
InjectorImpl.inject(Object, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 124
InjectorImpl.internalMake(Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 399
InjectorImpl.make(Class<T>, PrimaryObjectSupplier) line: 318
ContextInjectionFactory.make(Class<T>, IEclipseContext) line: 162
ReflectionContributionFactory.createFromBundle(Bundle, IEclipseContext, IEclipseContext, URI) line: 105
ReflectionContributionFactory.doCreate(String, IEclipseContext, IEclipseContext) line: 74
ReflectionContributionFactory.create(String, IEclipseContext) line: 56
ContributedPartRenderer.createWidget(MUIElement, Object) line: 129
PartRenderingEngine.createWidget(MUIElement, Object) line: 992
PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 661
PartRenderingEngine.safeCreateGui(MUIElement) line: 767
PartRenderingEngine.access$0(PartRenderingEngine, MUIElement) line: 738
PartRenderingEngine$2.run() line: 732
SafeRunner.run(ISafeRunnable) line: 42
PartRenderingEngine.createGui(MUIElement) line: 716
PartServiceImpl$1.handleEvent(Event) line: 104
UIEventHandler$1.run() line: 40
UISynchronizer(Synchronizer).syncExec(Runnable) line: 233
UISynchronizer.syncExec(Runnable) line: 144
Display.syncExec(Runnable) line: 4885
E4Application$1.syncExec(Runnable) line: 212
UIEventHandler.handleEvent(Event) line: 36
EventHandlerWrapper.handleEvent(Event, Permission) line: 201
EventHandlerTracker.dispatchEvent(EventHandlerWrapper, Permission, int, Event) line: 196
EventHandlerTracker.dispatchEvent(Object, Object, int, Object) line: 1
EventManager.dispatchEvent(Set<Entry<K,V>>, EventDispatcher<K,V,E>, int, E) line: 230
ListenerQueue<K,V,E>.dispatchEventSynchronous(int, E) line: 148
EventAdminImpl.dispatchEvent(Event, boolean) line: 135
EventAdminImpl.sendEvent(Event) line: 78
EventComponent.sendEvent(Event) line: 39
EventBroker.send(String, Object) line: 52
UIEventPublisher.notifyChanged(Notification) line: 60
PartStackImpl(BasicNotifierImpl).eNotify(Notification) line: 374
PartStackImpl(ElementContainerImpl<T>).setSelectedElement(T) line: 173
ModelServiceImpl.showElementInWindow(MWindow, MUIElement) line: 620
ModelServiceImpl.bringToTop(MUIElement) line: 584
PartServiceImpl.delegateBringToTop(MPart) line: 769
PartServiceImpl.bringToTop(MPart) line: 401
PartServiceImpl.showPart(MPart, EPartService$PartState) line: 1214
WorkbenchPage.busyOpenEditor(IEditorInput, String, boolean, int, IMemento, boolean) line: 3261
WorkbenchPage.access$25(WorkbenchPage, IEditorInput, String, boolean, int, IMemento, boolean) line: 3176
WorkbenchPage$10.run() line: 3158
BusyIndicator.showWhile(Display, Runnable) line: 70
WorkbenchPage.openEditor(IEditorInput, String, boolean, int, IMemento, boolean) line: 3153
WorkbenchPage.openEditor(IEditorInput, String, boolean, int) line: 3117
WorkbenchPage.openEditor(IEditorInput, String, boolean) line: 3107
IDE.openEditor(IWorkbenchPage, IFile, boolean, boolean) line: 563
IDE.openEditor(IWorkbenchPage, IFile, boolean) line: 518
EditorUtility.openInEditor(IFile, boolean) line: 360
EditorUtility.openInEditor(Object, boolean) line: 167
OpenAction.run(Object[]) line: 256
OpenAction.run(IStructuredSelection) line: 221
OpenAction(SelectionDispatchAction).dispatchRun(ISelection) line: 271
OpenAction(SelectionDispatchAction).run() line: 249
PackageExplorerActionGroup.handleOpen(ISelection, boolean) line: 379
PackageExplorerPart$4.open(ISelection, boolean) line: 540
OpenAndLinkWithEditorHelper$InternalListener.open(OpenEvent) line: 46
StructuredViewer$2.run() line: 851
SafeRunner.run(ISafeRunnable) line: 42
JFaceUtil.lambda$0(ISafeRunnable) line: 44
508864177.run(ISafeRunnable) line: not available
SafeRunnable.run(ISafeRunnable) line: 173
PackageExplorerPart$PackageExplorerProblemTreeViewer(StructuredViewer).fireOpen(OpenEvent) line: 848
PackageExplorerPart$PackageExplorerProblemTreeViewer(StructuredViewer).handleOpen(SelectionEvent) line: 1163
755583709.handleOpen(SelectionEvent) line: not available
OpenStrategy.fireOpenEvent(SelectionEvent) line: 273
OpenStrategy.access$2(OpenStrategy, SelectionEvent) line: 268
OpenStrategy$1.handleEvent(Event) line: 308
EventTable.sendEvent(Event) line: 86
Display.sendEvent(EventTable, Event) line: 4272
Tree(Widget).sendEvent(Event) line: 1509
Tree(Widget).sendEvent(int, Event, boolean) line: 1532
Tree(Widget).sendEvent(int, Event) line: 1517
Tree(Widget).notifyListeners(int, Event) line: 1321
Display.runDeferredEvents() line: 4096
Display.readAndDispatch() line: 3713
PartRenderingEngine$5.run() line: 1150
Realm.runWithDefault(Realm, Runnable) line: 336
PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 1039
E4Workbench.createAndRunUI(MApplicationElement) line: 153
Workbench.lambda$3(Display, WorkbenchAdvisor, int[]) line: 680
321795476.run() line: not available
Realm.runWithDefault(Realm, Runnable) line: 336
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 594
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 148
IDEApplication.start(IApplicationContext) line: 151
EclipseAppHandle.run(Object) line: 196
EclipseAppLauncher.runApplication(Object) line: 134
EclipseAppLauncher.start(Object) line: 104
EclipseStarter.run(Object) line: 388
EclipseStarter.run(String[], Runnable) line: 243
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 498
Main.invokeFramework(String[], URL[]) line: 653
Main.basicRun(String[]) line: 590
Main.run(String[]) line: 1499
Main.main(String[]) line: 1472


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773424 is a reply to message #1773423] Wed, 27 September 2017 16:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
org.eclipse.ui.editors.text.FileDocumentProvider.getRefreshRule(Object) returns workspace as refresh rule.
jdt does not use file document but textfieldocumentprovider
see https://github.com/eclipse/xtext-eclipse/issues/264 and other issues


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773425 is a reply to message #1773424] Wed, 27 September 2017 17:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
=> i have no idea what to do about that scheduling rule since it always triggers autobuild

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773426 is a reply to message #1773425] Wed, 27 September 2017 17:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
hmmm maybe i did some bad debugging ....
need to debug more
unfortunately debugging builder is pain
and debugging breaks order


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com

[Updated on: Wed, 27 September 2017 17:10]

Report message to a moderator

Re: Build triggered when opening file in language implemented by Xtext [message #1773427 is a reply to message #1773426] Wed, 27 September 2017 17:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
yes: opening any xtext file triggers that refesh

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773431 is a reply to message #1773427] Wed, 27 September 2017 18:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
and it does not matter if the refresh is called with true/false cause buildNeeded is true anyway

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773488 is a reply to message #1773431] Thu, 28 September 2017 15:03 Go to previous messageGo to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
Hi Christian,

Thanks a lot for your answer and the debugging! Yeah, I also noticed that opening a file causes a fresh which in turns triggers the build. Regarding to your Github issue https://github.com/eclipse/xtext-eclipse/issues/264, is there any plan for Xtext to use TextFileDocumentProvider instead of FileDocumentProvider in any time soon? This would solve this problem, I assume?

Quang
Re: Build triggered when opening file in language implemented by Xtext [message #1773508 is a reply to message #1773488] Thu, 28 September 2017 17:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
No plan. My knowledge is to few and others have no time or don't want to
Main problem might be to change this without breaking api


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773551 is a reply to message #1773508] Fri, 29 September 2017 09:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5839
Registered: July 2009
Senior Member
Hi

https://bugs.eclipse.org/bugs/show_bug.cgi?id=525364 raised.

Regards

Ed Willink
Re: Build triggered when opening file in language implemented by Xtext [message #1773572 is a reply to message #1773551] Fri, 29 September 2017 14:54 Go to previous messageGo to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
Thanks for your replies Christian and Ed! Hopefully, this bug is going to be fixed in the near future :-)
Re: Build triggered when opening file in language implemented by Xtext [message #1773574 is a reply to message #1773572] Fri, 29 September 2017 15:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
I have talked to Sebastian and his estimates are even worse than mine

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773839 is a reply to message #1773574] Thu, 05 October 2017 12:16 Go to previous messageGo to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
Being desperate, I tried to override XtextDocumentProvider and remove the refresh part manually. It seems to work in our N4JS IDE. Admittedly, it is really ugly.

/**
 * This class customizes XtextDocumentProvider to prevent builds from being triggered when opening files. See:
 * https://www.eclipse.org/forums/index.php/t/1089089/
 */
public class N4JSDocumentProvider extends XtextDocumentProvider {

	@Override
	protected ElementInfo createElementInfo(Object element) throws CoreException {
		ElementInfo info;
		if (isWorkspaceExternalEditorInput(element)) {
			IDocument document = null;
			IStatus status = null;
			try {
				document = createDocument(element);
			} catch (CoreException x) {
				status = x.getStatus();
				document = createEmptyDocument();
			}

			info = new URIInfo(document, createAnnotationModel(element));
			info.fStatus = status;
		} else {
			info = _createElementInfo(element);
		}
		registerAnnotationInfoProcessor(info);
		return info;
	}

	/** Copied from {@link FileDocumentProvider#createElementInfo} */
	private ElementInfo _createElementInfo(Object element) throws CoreException {
		if (element instanceof IFileEditorInput) {

			IFileEditorInput input = (IFileEditorInput) element;
			// Custom behavior: Do NOT refresh file
			// try {
			// refreshFile(input.getFile());
			// } catch (CoreException x) {
			// handleCoreException(x, TextEditorMessages.FileDocumentProvider_createElementInfo);
			// }

			IDocument d = null;
			IStatus s = null;

			try {
				d = createDocument(element);
			} catch (CoreException x) {
				handleCoreException(x, "N4JSDocumentProvider.createElementInfo");
				s = x.getStatus();
				d = createEmptyDocument();
			}

			// Set the initial line delimiter
			if (d instanceof IDocumentExtension4) {
				String initalLineDelimiter = getLineDelimiterPreference(input.getFile());
				if (initalLineDelimiter != null)
					((IDocumentExtension4) d).setInitialLineDelimiter(initalLineDelimiter);
			}

			IAnnotationModel m = createAnnotationModel(element);
			FileSynchronizer f = new FileSynchronizer(input);
			f.install();

			FileInfo info = new FileInfo(d, m, f);
			info.fModificationStamp = computeModificationStamp(input.getFile());
			info.fStatus = s;
			info.fEncoding = getPersistedEncoding(element);
			// info.fBOM = getBOM(element);
			// Use reflection to set the private field info.fBOM
			Field field;
			try {
				field = FileInfo.class.getDeclaredField("fBOM");
				field.setAccessible(true);
				field.set(info, getBOM(element));
			} catch (NoSuchFieldException | SecurityException e) {
				// Do nothing
			} catch (IllegalArgumentException x) {
				// Do nothing
			} catch (IllegalAccessException x) {
				// Do nothing
			}

			/*
			 * The code below is a no-op in the implementation in this class because the info is not yet stored in the
			 * element map. Calling to not break clients who have overridden the method. see
			 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=109255
			 */
			cacheEncodingState(element);

			return info;
		}

		return super.createElementInfo(element);
	}

	/**
	 * Returns the default line delimiter preference for the given file.
	 *
	 * @param file
	 *            the file
	 * @return the default line delimiter
	 * @since 3.1
	 */
	private String getLineDelimiterPreference(IFile file) {
		IScopeContext[] scopeContext;
		if (file != null && file.getProject() != null) {
			// project preference
			scopeContext = new IScopeContext[] { new ProjectScope(file.getProject()) };
			String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME,
					Platform.PREF_LINE_SEPARATOR, null, scopeContext);
			if (lineDelimiter != null)
				return lineDelimiter;
		}
		// workspace preference
		scopeContext = new IScopeContext[] { InstanceScope.INSTANCE };
		return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null,
				scopeContext);
	}

	/**
	 * Returns whether the underlying file has a BOM.
	 *
	 * @param element
	 *            the element, or <code>null</code>
	 * @return <code>true</code> if the underlying file has BOM
	 */
	private byte[] getBOM(Object element) {
		if (element instanceof IFileEditorInput) {
			IFile file = ((IFileEditorInput) element).getFile();
			if (file != null) {
				try {
					IContentDescription description = file.getContentDescription();
					if (description != null)
						return (byte[]) description.getProperty(IContentDescription.BYTE_ORDER_MARK);
				} catch (CoreException ex) {
					return null;
				}
			}
		}
		return null;
	}

}

Re: Build triggered when opening file in language implemented by Xtext [message #1773842 is a reply to message #1773839] Thu, 05 October 2017 12:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
the question would be: what if the file is actually out of date ...

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773844 is a reply to message #1773842] Thu, 05 October 2017 12:50 Go to previous messageGo to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
I have just tried it in the N4JS IDE. In that case, the editor will give a warning: Resource is out of sync with the file system: '/Test/src/A.n4js'. and the content is not displayed. Then the user has to refresh the file herself/himself.
Re: Build triggered when opening file in language implemented by Xtext [message #1773851 is a reply to message #1773844] Thu, 05 October 2017 13:07 Go to previous messageGo to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
Unfortunately, this hack does not work:
!STACK 1
org.eclipse.core.internal.resources.ResourceException: Resource is out of sync with the file system: '/Test/src/A.n4js'.
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:849)
	at org.eclipse.core.internal.resources.File.getContents(File.java:277)
	at org.eclipse.ui.editors.text.FileDocumentProvider.setDocumentContent(FileDocumentProvider.java:398)
	at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.setDocumentContent(XtextDocumentProvider.java:191)
	at org.eclipse.ui.editors.text.StorageDocumentProvider.createDocument(StorageDocumentProvider.java:227)
	at org.eclipse.xtext.ui.editor.model.XtextDocumentProvider.createDocument(XtextDocumentProvider.java:149)
	at org.eclipse.n4js.ui.N4JSDocumentProvider._createElementInfo(N4JSDocumentProvider.java:74)
	at org.eclipse.n4js.ui.N4JSDocumentProvider.createElementInfo(N4JSDocumentProvider.java:52)
	at org.eclipse.ui.texteditor.AbstractDocumentProvider.connect(AbstractDocumentProvider.java:392)
	at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4178)
	at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:229)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1466)
	at org.eclipse.ui.editors.text.TextEditor.doSetInput(TextEditor.java:150)
	at org.eclipse.xtext.ui.editor.XtextEditor.doSetInput(XtextEditor.java:247)
	at org.eclipse.ui.texteditor.AbstractTextEditor$5.run(AbstractTextEditor.java:3154)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:437)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:353)
	at org.eclipse.ui.internal.WorkbenchWindow$14.run(WorkbenchWindow.java:2184)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2180)
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3172)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3197)
	at org.eclipse.xtext.ui.editor.XtextEditor.init(XtextEditor.java:288)
	at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:362)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:318)
	at sun.reflect.GeneratedMethodAccessor319.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:966)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:931)
	at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:151)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:375)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:294)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:105)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:74)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:56)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:975)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:651)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:757)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:728)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:722)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1317)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer$1.handleEvent(LazyStackRenderer.java:72)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:233)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:145)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4814)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:211)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:36)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:201)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:94)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:60)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:173)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:617)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:581)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:770)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:401)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1214)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3261)
	at org.eclipse.ui.internal.WorkbenchPage.access$25(WorkbenchPage.java:3176)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:3158)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3153)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3117)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3107)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:563)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:518)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:360)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:167)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:256)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:221)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:271)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:249)
	at org.eclipse.jdt.internal.ui.navigator.OpenAndExpand.run(OpenAndExpand.java:50)
	at org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:225)
	at org.eclipse.ui.navigator.CommonNavigatorManager$2.open(CommonNavigatorManager.java:191)
	at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:46)
	at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:855)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:173)
	at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:852)
	at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1169)
	at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:451)
	at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:278)
	at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:272)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:313)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4256)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1501)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1524)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1509)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1313)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4080)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3706)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at org.eclipse.n4js.product.N4JSApplication.start(N4JSApplication.java:141)
	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(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Re: Build triggered when opening file in language implemented by Xtext [message #1773852 is a reply to message #1773851] Thu, 05 October 2017 13:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
yes this is what i meant

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773899 is a reply to message #1773852] Fri, 06 October 2017 10:00 Go to previous messageGo to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
Christian, I am thinking of trying to reimplement XtextDocumentProvider by extending TextFileDocumentProvider. However, my knowledge of Xtext internal implementation is still limited. Moreover, the XtextDocumentProvider class barely has any documentation :( What's your suggestion?
Re: Build triggered when opening file in language implemented by Xtext [message #1773900 is a reply to message #1773899] Fri, 06 October 2017 10:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
sebastian says that the approach rs per editor will not work for this. this is the main problem

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773901 is a reply to message #1773900] Fri, 06 October 2017 10:28 Go to previous messageGo to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
What do you mean with "approach rs per editor"?
Re: Build triggered when opening file in language implemented by Xtext [message #1773903 is a reply to message #1773901] Fri, 06 October 2017 10:43 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5839
Registered: July 2009
Senior Member
Hi

Looking at the classes/@since's it would appear that Eclipse 2's Abstract/Storage/FileDocumentProvider were unhelpful and so Eclipse 3 introduced TextFileDocumentProvider.

With hindsight, it was perhaps a mistake for XtextDocumentProvider to extend FileDocumentProvider rather than TextFileDocumentProvider .

My own derivation of XtextDocumentProvider suggests that the Storage support adds needless complexity and that there are too many levels of override as similarly named methods 'collaborate' without any clear documentation. I was eventually defeated when trying to understand how a GIT commit change / Compare editor refresh changed the provided content.

In principle changing to TextFileDocumentProvider seems like a good idea, but you will have to understand and fix all the XtextDocumentProvider fudges. Just make it work for your favourite use cases then sort out compatibility, which might be very difficult without an Xtext major version change to permit the API breakage on XtextDocumentProvider. More realistically you might deprecate XtextDocumentProvider in favour of a new XtextFileDocumentProvider.

Regards

Ed Willink
Re: Build triggered when opening file in language implemented by Xtext [message #1773904 is a reply to message #1773903] Fri, 06 October 2017 11:00 Go to previous messageGo to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
In this presentation https://www.eclipse.org/eclipse/platform-text/eclipseCon/talk.pdf, on slide 10 "Available document providers", the author says that TextFileDocumentProvider replaces FileDocumentProvider which backs up Ed's suspect regarding the obsolete FileDocumentProvider.
Re: Build triggered when opening file in language implemented by Xtext [message #1773906 is a reply to message #1773904] Fri, 06 October 2017 11:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11900
Registered: July 2009
Senior Member
yes but the way xtext handles the resources / resourcesets behind an open editor will break with the new document provider


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Build triggered when opening file in language implemented by Xtext [message #1773927 is a reply to message #1773906] Fri, 06 October 2017 15:53 Go to previous messageGo to next message
Minh Quang Tran is currently offline Minh Quang TranFriend
Messages: 19
Registered: September 2017
Junior Member
I am trying to use my temporary hack mentioned above. Now, I am looking for a way to somehow refresh the file without triggering the build. Do you have any ideas?
Re: Build triggered when opening file in language implemented by Xtext [message #1773959 is a reply to message #1773927] Sat, 07 October 2017 15:26 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3098
Registered: July 2009
Senior Member
Hi Quang,

the XtextDocumentProvider provides the XtextDocument. The document is the owner of a resource set. Pretty much all the UI services are implemented based on the assumption that one document is associated with one resource set. Therefore, the document itself is the synchronization point for all modifications of the resource set. This is more or less the base line for the following argumentation:

The FileDocumentProvider implements a very simple model when it comes to writing changes to disk. Everything works directly with the resource API of Eclipse. Thus the platform:/resource URIs work rather reliably when it comes to loading referenced resources into the resource set. The TextFileDocumentProvider on the contrary works on the granularity buffers. Buffers implement an indirection between the document and the resource API of Eclipse. And they are shared across editors. Thus the synchronization does not happen anymore on the resource API level, but on the file buffer managers level. This is prone to errors / deadlocks given the different locking mechanisms for the buffers and on the documents.

Digging through the code a little bit more, I assume that it is possible to implement a kind-of working solution, but it appears to be significant effort.

Maybe we can discuss this next week.

Best
Sebastian
Previous Topic:Invalid equality test on atomic integer
Next Topic:Java 8 compatibility for Guice
Goto Forum:
  


Current Time: Wed Apr 25 03:11:14 GMT 2018

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

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