Mib.xtext |
---|
Import: name='IMPORTS' defs+=ImpDef+ ';'; ImpDef: objects+=ImpObject (',' objects+=ImpObject)* 'FROM' name=ID; ImpObject: name=ID; |
And re-point imp to macro as well as simplify Identifier:
Mib.xtext |
---|
Identifier: ObjectType | (name=ID mibType value=OidValue); // ObjectType | (name=MibObject mibType value=OidValue); ObjectType: name=ID imp=[Macro] 'SYNTAX' mibType 'ACCESS' ID 'STATUS' ID // name=MibObject imp=[MibObject] 'SYNTAX' mibType 'ACCESS' ID 'STATUS' ID ('DESCRIPTION' STRING)? ('REFERENCE' STRING)? ('INDEX' '{' mibType (',' mibType)* '}')? ('DEFVAL' '{' INT | STRING '}')? value=OidValue; OidValue: '::=' '{' parent=[Identifier]? oidnum=INT '}'; // '::=' '{' parent=[MibObject]? oidnum=INT '}'; |
And since we are not using "importedNamespace" attribute, we need to complete the namespace by overriding "internalGetImportedNamespaceResolvers()" - note that I used "getImportedNamespace()" on earlier example - but that can't be used here as Xtext not able to know all the imported object since the structure is pretty complex in MIB. Hence overriding the "internalGetImportedNamespaceResolvers()" which is in fact the caller for "getImportedNamespace()" is more appropriate here.
MibImportedNamespaceAwareLocalScopeProvider.xtend |
---|
class MibImportedNamespaceAwareLocalScopeProvider extends ImportedNamespaceAwareLocalScopeProvider { override List |
And of course bind this class by:
MibRuntimeModule.java |
---|
public class MibRuntimeModule extends com.ravi.mib.xtext.AbstractMibRuntimeModule { @Override public void configureIScopeProviderDelegate(com.google.inject.Binder binder) { binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class) .annotatedWith( com.google.inject.name.Names .named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE)) .to(MibImportedNamespaceAwareLocalScopeProvider.class); } } |
Now, "Open-Declaration" (i.e F3) feature should work for both "Mib object identifier" and "OBJECT-TYPE" macro, open up file that contains those definitions.
No comments:
Post a Comment