Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Check if a language/grammar file is defined twice in Workspace (Validation for language files defined twice)
Check if a language/grammar file is defined twice in Workspace [message #1816430] Tue, 29 October 2019 12:36 Go to next message
Mehmetcan Sinir is currently offline Mehmetcan SinirFriend
Messages: 55
Registered: September 2018
Member
Hi,

We have a Visual Studio Code language extension written in Xtext. We need to make sure that certain grammar files (with certain extensions) are defined only once inside the workspace, and if not show a validation error.

Is there perhaps an easy way to do this with XText?

Thanks a lot

[Updated on: Tue, 29 October 2019 12:37]

Report message to a moderator

Re: Check if a language/grammar file is defined twice in Workspace [message #1816627 is a reply to message #1816430] Fri, 01 November 2019 17:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
hi, i am not sure if i get your problem
what makes a file "defined twice"
you do you mean something like:

there should be only one

"Hello World!" in all mydsl files in the project?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Check if a language/grammar file is defined twice in Workspace [message #1816637 is a reply to message #1816627] Sat, 02 November 2019 07:33 Go to previous message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
This is a job for the validator.

Lorenzo Bettini found a very simple to understand implementation

Source: https://github.com/LorenzoBettini/packtpub-xtext-book-examples/blob/master/org.example.smalljava/src/org/example/smalljava/validation/SmallJavaValidator.xtend

@Check
def void checkNoDuplicateMember(SJMember member) {
val duplicate = member.containingClass.members.findFirst[
it != member && it.eClass == member.eClass &&
it.name == member.name
]
if (duplicate != null)
error("Duplicate member '" + member.name + "'",
SmallJavaPackage::eINSTANCE.SJMember_Name,
DUPLICATE_ELEMENT
)
}

HIH, Uli
Previous Topic:Operator overloading in Xbase Expression
Next Topic:Xtend Grey Space: It works great until it doesn't
Goto Forum:
  


Current Time: Thu Sep 19 16:08:15 GMT 2024

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

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

Back to the top