Search code examples
xtext

How to get name of input file in Xtext


I am implementing a language where name of the file needs to be the same as name of the class. How can I get name of the file in validator? If I can't do that, is there any other way to do what I want?


Solution

  • you can as any EObject for its eResource() and that for its getURI(). That will allow you to get the file name (lastSegment). you may want to trimFileExtension() first.