Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Formatting DSL File
Formatting DSL File [message #1733891] Wed, 01 June 2016 21:00 Go to next message
Mansour Al is currently offline Mansour AlFriend
Messages: 44
Registered: June 2016
Member
I am new to Xtext, and trying to write a demo language to exercise the concepts. I started with the 15 minutes tutorial, and stuck where I need to add formatting for the file being edited.
I looked around in the examples, and found that they use "auto-inject", but I don't see where the formatter comes from or how to customize it. For example:

https://github.com/eclipse/xtext/blob/v2.9.0/examples/org.eclipse.xtext.xtext.ui.examples/contents/org.eclipse.xtext.example.domainmodel/src/org/eclipse/xtext/example/domainmodel/GenerateDomainmodel.mwe2

Has:
// formatter API
fragment = formatting2.Formatter2Fragment {}

while the formatter is in the package: org.eclipse.xtext.example.domainmodel.formatting2;

I am not sure here, I understand what is going on, or where to customize it. Additionally to keep things simple, I prefer not to use "auto-inject" until I understand what is going on. So if there's a way to use formatter, it will be much appreciated. Here's my GenerateMyDsl.mwe2:

var rootPath = ".."

Workflow {
	
	component = XtextGenerator {
		configuration = {
			project = StandardProjectConfig {
				baseName = "org.xtext.example.mydsl"
				rootPath = rootPath
				runtimeTest = {
					enabled = true
				}
				eclipsePlugin = {
					enabled = true
				}
				eclipsePluginTest = {
					enabled = true
				}
				web = {
					enabled = true
				}
				createEclipseMetaData = true
			}
			code = {
				encoding = "US-ASCII"
				fileHeader = "/*\n * generated by Xtext \${version}\n */"
			}
		}
		language = StandardLanguage {
			name = "org.xtext.example.mydsl.MyDsl"
			fileExtensions = "demo"

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}
			
			formatter={
				generateStub = true
			}
		}
	}
}



Thank you
Re: Formatting DSL File [message #1733896 is a reply to message #1733891] Thu, 02 June 2016 04:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Idee you regenerate with that workflow you'll get a formatterr class to
fill out


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Formatting DSL File [message #1734013 is a reply to message #1733896] Fri, 03 June 2016 02:46 Go to previous message
Mansour Al is currently offline Mansour AlFriend
Messages: 44
Registered: June 2016
Member
Thank you Christian
Previous Topic:Xbase fails at finding common Types
Next Topic:ISerializationContext cannot be resolved to a type
Goto Forum:
  


Current Time: Thu Apr 25 16:55:58 GMT 2024

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

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

Back to the top