Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Auto complete with curly brackets
Auto complete with curly brackets [message #890139] Thu, 21 June 2012 09:07 Go to next message
macheke macheke is currently offline macheke machekeFriend
Messages: 7
Registered: May 2012
Junior Member
Hie

have a typical dsl with methods

function int doSomething(){
statement1;
statement2;
}

if i press enter after statement2, the editor auto inserts a closing curly bracket,although another one already exists thereby making the model invalid. how can i disable that, preferably programatically. I know the java editor preferences can disable it.

thanx
Re: Auto complete with curly brackets [message #890143 is a reply to message #890139] Thu, 21 June 2012 09:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
see org.eclipse.xtext.ui.editor.autoedit.DefaultAutoEditStrategyProvider

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Auto complete with curly brackets [message #890146 is a reply to message #890143] Thu, 21 June 2012 09:32 Go to previous messageGo to next message
macheke macheke is currently offline macheke machekeFriend
Messages: 7
Registered: May 2012
Junior Member
Great, override the configureCompoundBracesBlocks(XX) method. Thnx Christian!

[Updated on: Thu, 21 June 2012 09:32]

Report message to a moderator

Re: Auto complete with curly brackets [message #1677213 is a reply to message #890146] Sun, 15 March 2015 20:30 Go to previous messageGo to next message
QW DR is currently offline QW DRFriend
Messages: 11
Registered: March 2015
Junior Member
I share a similar problem:
I would like the editor to insert a closing '>' when a opening '<' is typed.

I have therefore written the following xtend code:
package org.xtext.ui.contentassist

import org.eclipse.xtext.ui.editor.autoedit.DefaultAutoEditStrategyProvider
import org.eclipse.xtext.ui.editor.autoedit.AbstractEditStrategyProvider

class SparqlAutoEditStrategyProvider extends DefaultAutoEditStrategyProvider {
	override public void configureStringLiteral(AbstractEditStrategyProvider.IEditStrategyAcceptor acceptor) {
		super.configure(acceptor);
		acceptor.accept(singleLineTerminals.newInstance("<", ">"), "IRIref");
	}
}


But it doesnt seem to work.

the relevan grammar Parts:
IRIref:
	value=IRI_REF

terminal IRI_REF:
    '<' !('<' | '>' | '"' | '{' | '}' | '|' | '^' | '`' | '\\' | '\u0000'..'\u0020')* '>';
Re: Auto complete with curly brackets [message #1678171 is a reply to message #1677213] Mon, 16 March 2015 05:13 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

the impl looks a bit strange. id expect

class SparqlAutoEditStrategyProvider extends DefaultAutoEditStrategyProvider {
	override public void configureStringLiteral(AbstractEditStrategyProvider.IEditStrategyAcceptor acceptor) {
		super.configureStringLiteral(acceptor);
		acceptor.accept(singleLineTerminals.newInstance("<", ">"), IDocument.DEFAULT_CONTENT_TYPE);
	}
}

with the following binding:

public class MyDslUiModule extends org.xtext.example.mydsl2.ui.AbstractMyDslUiModule {
	public MyDslUiModule(AbstractUIPlugin plugin) {
		super(plugin);
	}
	
	public Class<? extends AbstractEditStrategyProvider> bindAbstractEditStrategyProvider() {
		return SparqlAutoEditStrategyProvider.class;
	}
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:XTEXT does not consume terminals like intended
Next Topic:Xtext Survey
Goto Forum:
  


Current Time: Thu Apr 25 10:03:12 GMT 2024

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

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

Back to the top