merge scope blocks? [message #767218] |
Sat, 17 December 2011 10:47 |
Phil R Messages: 99 Registered: September 2011 |
Member |
|
|
Hi,
I have searched around for merging 2 scope blocks but I couldn't find any solution.
for example:
namespace Root {
...
}
<othernames>
// continue Root:
namespace Root {
..
}
EDIT: SOLVED
-Phil
[Updated on: Sun, 19 February 2012 14:24] Report message to a moderator
|
|
|
|
|
|
Re: merge scope blocks? [message #767592 is a reply to message #767584] |
Sun, 18 December 2011 12:41 |
|
Hi,
i still do not understand what is the behaviour you want to have? that is your expected behaviour when you mix uri and namespace based scoping?
or do you want to mix it at all? if youd share a complete reproducable grammar that would be a lot easier to understand.
id i understand you correct you want to have imported namespace based scoping but only imported stuff visible from global scoping.
but in your sample models you do not any imports of uris
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: merge scope blocks? [message #767605 is a reply to message #767595] |
Sun, 18 December 2011 13:26 |
|
Hi,
still do not understand you you need this import uri stuff at all
Model:
includes+=IncludeFile*
elements+=Namespace*;
IncludeFile:
'#include' importedNamespace=FQN
;
AbstactElement:
Element | Namespace | Import
;
Import:
"using" importedNamespace=FQN
;
Namespace:
"namespace" name=ID "{"
elements+=AbstactElement*
"}"
;
Element:
"element" name=ID ("uses" uses=[Element|FQN])?
;
FQN: ID ("." ID)*;
public class MyDslQualifiedNameProvider extends
DefaultDeclarativeQualifiedNameProvider {
QualifiedName qualifiedName(Model m) {
String name = m.eResource().getURI().trimFileExtension().lastSegment();
return QualifiedName.create(name);
}
}
public class MyDslImportedNamespaceAwareLocalScopeProvider extends
ImportedNamespaceAwareLocalScopeProvider {
protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, boolean ignoreCase) {
List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList();
SimpleAttributeResolver<EObject, String> importResolver = SimpleAttributeResolver.newResolver(String.class,
"importedNamespace");
EList<EObject> eContents = context.eContents();
for (EObject child : eContents) {
String value = importResolver.getValue(child);
ImportNormalizer resolver = createImportedNamespaceResolver(value+".*", ignoreCase);
if (resolver != null)
importedNamespaceResolvers.add(resolver);
}
if (context instanceof Namespace) {
ImportNormalizer resolver2 = createImportedNamespaceResolver(((Namespace)context).getName()+".*", ignoreCase);
if (resolver2 != null) {
importedNamespaceResolvers.add(resolver2);
}
}
return importedNamespaceResolvers;
}
}
public class MyDslRuntimeModule extends
org.xtext.example.mydsl.AbstractMyDslRuntimeModule {
@Override
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return MyDslQualifiedNameProvider.class;
}
public void configureIScopeProviderDelegate(com.google.inject.Binder binder) {
binder.bind(IScopeProvider.class)
.annotatedWith(
Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE))
.to(MyDslImportedNamespaceAwareLocalScopeProvider.class);
}
}
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03898 seconds