Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Strange editor redraw problem
Strange editor redraw problem [message #1707785] Wed, 09 September 2015 11:04 Go to next message
Aleksandar Toshovski is currently offline Aleksandar ToshovskiFriend
Messages: 78
Registered: December 2011
Member
I'm experiencing a very strange rendering problem with xtext. When I go to the end of a line and make a new line, the editor doesn't get rendered right... For example the line disappears or it adds one new line before the line and one after.. I attached a screenshot example. I think something is wrong with the drawing in the editor, but I dont't understand what's the cause. I use the latest milestone of Xtext 2.9 and Mars. There are also no exceptions in the logs.

I've detached all kind of validators and hilighting calculators, but the problem still exists. I also regenerated multiple times the plugins from the grammar.


The problem occurs under Linux and Windows.
I would appreciate tips, how to investigate the problem and to find a solution.
  • Attachment: problem.png
    (Size: 36.79KB, Downloaded 170 times)
Re: Strange editor redraw problem [message #1712946 is a reply to message #1707785] Thu, 29 October 2015 14:02 Go to previous messageGo to next message
Aleksandar Toshovski is currently offline Aleksandar ToshovskiFriend
Messages: 78
Registered: December 2011
Member
Hello,

I'm still experiencing this problem. I also tested the code under Windows and Ubuntu and I have on both OS the same problem. Any ideas?

When I select the whole text area with Ctrl + A, then the rendering gets refreshed. but moving the cursor up and down, the rendering gets broken again.


Re: Strange editor redraw problem [message #1712948 is a reply to message #1712946] Thu, 29 October 2015 14:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
can you please file a ticket

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Strange editor redraw problem [message #1712952 is a reply to message #1712948] Thu, 29 October 2015 14:30 Go to previous messageGo to next message
Aleksandar Toshovski is currently offline Aleksandar ToshovskiFriend
Messages: 78
Registered: December 2011
Member
Hello Christian,

is it a known bug?

I'll try to investigate further the problem and give you more input in the ticket.
Re: Strange editor redraw problem [message #1712953 is a reply to message #1712952] Thu, 29 October 2015 14:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
no it is not. thus please file a new one with everything needed to reproduce the problem

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Strange editor redraw problem [message #1712989 is a reply to message #1707785] Thu, 29 October 2015 17:38 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
On 09.09.15 13:04, Aleksandar Toshovski wrote:
> I'm experiencing a very strange rendering problem with xtext. When I go to the end of a line and make a new line, the editor doesn't get rendered right... For example the line disappears or it adds one new line before the line and one after.. I attached a screenshot example. I think something is wrong with the drawing in the editor, but I dont't understand what's the cause. I use the latest milestone of Xtext 2.9 and Mars. There are also no exceptions in the logs.
>
> I've detached all kind of validators and hilighting calculators, but the problem still exists. I also regenerated multiple times the plugins from the grammar.
>
>
> The problem occurs under Linux and Windows.
> I would appreciate tips, how to investigate the problem and to find a solution.
>

Does this happen in plain-text editors, too?

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: Strange editor redraw problem [message #1713046 is a reply to message #1712989] Fri, 30 October 2015 09:51 Go to previous message
Aleksandar Toshovski is currently offline Aleksandar ToshovskiFriend
Messages: 78
Registered: December 2011
Member
No, it doesn't. Yesterday found the cause of the problem, but I'm not sure I understand why. A colleague of mine has implemented a PropertyTester, which causes the problem. When I remove the code it works normally. The funny thing is that we have two DSL languages: dsl1 and dsl2. The dsl2 extends dsl1. He implemented that in the first language and the problem occurs only in the second dsl. And it occurs after editing and saving the file. When I continue editing the editor gets broken.

package dsl.ui.tester;

import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.xtext.nodemodel.ICompositeNode;
import org.eclipse.xtext.nodemodel.ILeafNode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.model.IXtextDocument;
import org.eclipse.xtext.ui.editor.utils.EditorUtils;
import org.eclipse.xtext.util.concurrent.IUnitOfWork;

import dsl.Model;

public class TextSelectedPropertyTester extends PropertyTester {

	@Override
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
		if (property.equals("stringSelected")) {
			ISelection selection = EditorUtils.getActiveXtextEditor().getSelectionProvider().getSelection();
			if (selection instanceof ITextSelection) {

				int offset = ((ITextSelection) selection).getOffset();
				boolean containsQuoteSymbol = ((ITextSelection) selection).getText().contains("\"");
				if (containsQuoteSymbol)
					return false;
				IXtextDocument document = EditorUtils.getActiveXtextEditor().getDocument();
				Model model = getModel(document);
				if(model==null){
					return false;
				}
				ICompositeNode node = NodeModelUtils.getNode(model);
				ILeafNode leafNode = NodeModelUtils.findLeafNodeAtOffset(node, offset);
				if (leafNode != null && leafNode.getText().startsWith("\"") && leafNode.getText().endsWith("\"")) {
					return true;
				}
			}

		}
		return false;
	}

	private Model getModel(IXtextDocument document) {
		return document.readOnly(new IUnitOfWork<Model, XtextResource>() {
			@Override
			public Model exec(XtextResource resource) throws Exception {
				if(resource.getContents().get(0) instanceof Model){
					return (Model) resource.getContents().get(0);
				}
				return null;
			}

		});
	}

}


The extension point
<extension
          point="org.eclipse.core.expressions.propertyTesters">
       <propertyTester
             class="dsl.ui.tester.TextSelectedPropertyTester"
             id="dsl.textSelection.tester"
             namespace="dsl.ui"
             properties="stringSelected"
             type="java.lang.Object">
       </propertyTester>
    </extension>  

[Updated on: Fri, 30 October 2015 09:53]

Report message to a moderator

Previous Topic:is it possible to add link for EObject in XtextBuilderParticipant class
Next Topic:Null-Pointer Exception when using AssertError
Goto Forum:
  


Current Time: Wed Sep 25 01:04:52 GMT 2024

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

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

Back to the top