net.sourceforge.nrl.parser.ast.impl
Class ModelReferenceHelper

java.lang.Object
  extended by net.sourceforge.nrl.parser.ast.impl.ModelReferenceHelper

public class ModelReferenceHelper
extends Object

A helper class for resolving model references against a model. This class is mainly used by AntlrModelResolver.

The job of the class is to navigate the model and resolve name strings to attributes or model elements.

Author:
Christian Nentwich

Constructor Summary
ModelReferenceHelper()
           
 
Method Summary
static IModelElement getModelElement(String elementName, ModelReferenceImpl ref, IModelCollection models, List<NRLError> errors)
          Look up a model element by name, handling both absolute and qualified names.
protected static void raiseError(List<NRLError> errors, ModelReferenceImpl ref, int statusCode, String message)
          Helper method to raise errors on model references more efficiently.
static void resolveReference(ModelReferenceImpl ref, IModelCollection models, IModelElement contextElement, IClassifier initialContext, VariableContext variableContext, Map<String,IVariableDeclaration> globalVariableContext, List<NRLError> errors)
          Resolve a reference by looking up the initial step and traversing a path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelReferenceHelper

public ModelReferenceHelper()
Method Detail

resolveReference

public static void resolveReference(ModelReferenceImpl ref,
                                    IModelCollection models,
                                    IModelElement contextElement,
                                    IClassifier initialContext,
                                    VariableContext variableContext,
                                    Map<String,IVariableDeclaration> globalVariableContext,
                                    List<NRLError> errors)
Resolve a reference by looking up the initial step and traversing a path.

This implements a fall-back algorithm to find the initial step of the path and then resolve all further steps.

If the fallback algorithm fails or encounters ambiguity, an error is raised. If any error at all occurs, the initial step on the model reference is set to null and the reference remains invalid.

Parameters:
ref - the reference to resolve
models - the models to look up elements in
contextElement - the "current" (nearest enclosing) context element
initialContext - the overall rule/fragment context
variableContext - a stack of IVariable objects, with variable declarations in scope
errors - a collection of semantic errors to add to if necessary

getModelElement

public static IModelElement getModelElement(String elementName,
                                            ModelReferenceImpl ref,
                                            IModelCollection models,
                                            List<NRLError> errors)
Look up a model element by name, handling both absolute and qualified names.

Parameters:
elementName - the element name
ref - the reference in which the name occurred
models - the models to search
errors - the error list to add to if an error occurs
Returns:
the element or null if not found

raiseError

protected static void raiseError(List<NRLError> errors,
                                 ModelReferenceImpl ref,
                                 int statusCode,
                                 String message)
Helper method to raise errors on model references more efficiently.

Parameters:
errors -
statusCode -
message -


Copyright © 2006-2013. All Rights Reserved.