Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ImportURI - Processing & Scoping
ImportURI - Processing & Scoping [message #889972] Wed, 20 June 2012 12:55 Go to next message
Bastian Barton is currently offline Bastian BartonFriend
Messages: 8
Registered: June 2012
Junior Member
Hi Folks,

I am currently working on an xText-Project for FORTRAN90 in OpenVMS dialect.
(Don't worry, this is not the place where I'm talking about semantic Whitespaces Wink)

Currently I'm facing some difficulties resolving the VMS-styled URIs. I've spent ages browsing docs, tuts and forums - I don't get it Smile Well here's what I've got (as simplified as possible):

Grammar
grammar vms.fortran.VmsFortran with org.eclipse.xtext.common.Terminals

generate vmsFortran "[...]vms/fortran/VmsFortran"

Model:
	includes+=Include*
	elements+=Declaration*
	elements+=Call*;
	
Include:
	'include' importURI=STRING;

Declaration:
	'integer' name=ID;
	
Call:
	var=[Declaration|ID];


MWE
            // java-based API for validation
            fragment = validation.JavaValidatorFragment {
            //    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
            //    composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
            }

            // scoping and exporting API
            fragment = scoping.ImportURIScopingFragment { ignoreCase = true }
            fragment = exporting.SimpleNamesFragment {}

            // scoping and exporting API
            //fragment = scoping.ImportNamespacesScopingFragment { ignoreCase= true }
            //fragment = exporting.QualifiedNamesFragment {}


RuntimeModule
public class VmsFortranRuntimeModule extends vms.fortran.AbstractVmsFortranRuntimeModule {
	
	public Class<? extends ImportUriResolver> bindImportUriResolver() {
		return VmsFortranImportUriResolver.class;
	
	}

}


UriResolver
public class VmsFortranImportUriResolver extends ImportUriResolver {
	
	private static final Logger LOGGER = Logger.getLogger(VmsFortranImportUriResolver.class);
	
	public VmsFortranImportUriResolver() {
		super();
		LOGGER.setLevel(Level.INFO);
	}
	
	@Override
	public String resolve(EObject object) {
		
		final String vmsUri = super.resolve(object);
		final String winUri = VmsPathConverter.getInstance().convert(vmsUri);
		
		LOGGER.info(vmsUri + "  -->  " + winUri);
		
		return "platform:/resource/"+winUri;
	}
}


and here come the questions:

- At the moment all declarations are visible everywhere within the project. That's nasty if it consists of say 10.000 resources. What do I have to do about the Scoping?

- The importURI resolver doesn't seem to be called at all. At least I do not get any Logger output, no matter if I launch RuntimeIDE or standalone with deployed Plugin. When I add the UriValidator, it IS called 3 times, and two of them with 'null' uris. But then, the parser quits work at this point.

- Is it possible to place a hyperlink right on the Include statement? Allthough it might look like that
      include '($SSDEV)'


Thx so much in advance!
Bastian
Re: ImportURI - Processing & Scoping [message #889975 is a reply to message #889972] Wed, 20 June 2012 13:04 Go to previous messageGo to next message
Bastian Barton is currently offline Bastian BartonFriend
Messages: 8
Registered: June 2012
Junior Member
Sorry I forgot the End statements in the grammer. I fixed it:
Model:
	includes+=Include*
	elements+=Declaration*
	elements+=Call*;
	
Include:
	'include' importURI=STRING ';' ;

Declaration:
	'integer' name=ID ';' ;
	
Call:
	var=[Declaration|ID] ';' ;


But the problem remains Sad
Re: ImportURI - Processing & Scoping [message #892494 is a reply to message #889972] Thu, 28 June 2012 12:54 Go to previous message
Thomas Hergenröder is currently offline Thomas HergenröderFriend
Messages: 22
Registered: February 2012
Junior Member
The scoping is explained here: www.eclipse.org/Xtext/documentation.html#scoping.

I think something like this to scope only the delectations of the same model: UNTESTED PSEUDO CODE
public IScope scope_Call_var(final Call call, final EReference ref) {
   return scopeFor(call.eObject.elements.filter(typeof(Declaration)));
}


If I click on a crossreference while pressing CTRL it acts like a hyperlink.

I do not know who to turn an URI into an hyperlink into the internet.

Post a reply If you have any questions.
Previous Topic:Xtext integration with GMF
Next Topic:How to disable project nature notification
Goto Forum:
  


Current Time: Fri Apr 26 00:44:26 GMT 2024

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

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

Back to the top