io.sarl.lang.extralanguage.validator
Class AbstractExtraLanguageValidator
All Known Subclasses:
PyValidator
abstract class AbstractExtraLanguageValidator
extends java.lang.Object
The abstract implementation of a validator for an extra target language.

This abstract implementation is not a EValidator implementation because the Xtext EValidator infrastructure has issues with error reporting when the validator is dynamically added (as it is in the support class).
Maven Group Identifier:
io.sarl.lang
Maven Artifact Identifier:
compiler
Since:
0.6
Property Summary
Modifier and type Property and description
protected Context context
Replies the current context.
protected java.lang.String errorMessageFormat
Replies the message format to be used for building an alert message.
IExtraLanguageKeywordProvider extraLanguageKeywordProvider
Replies the provider of the extra-language keywords.
protected IExtraLanguageConversionInitializer featureConverterInitializer
Replies the initializer for the feature converter.
ExtraLanguageFeatureNameConverter featureNameConverter
Replies the feature name converter.
ExtraLanguageTypeConverter typeConverter
Replies the type converter.
protected IExtraLanguageConversionInitializer typeConverterInitializer
Replies the initializer for the type converter.
Nested Type Summary
Modifier and type Type and description
protected class AbstractExtraLanguageValidator.Context
Validation context.
protected class AbstractExtraLanguageValidator.MethodWrapper
Method wrapper.
Constructor Summary
Constructor and description
new(IExtraLanguageKeywordProvider)
Constructor.
Action Summary
Modifier and type Action and description
protected void collectMethods(Class<T>,Collection<E>,Collection<E>)
Collect the check methods.
protected ExtraLanguageFeatureNameConverter createFeatureNameConverterInstance(IExtraLanguageConversionInitializer,IExtraLanguageGeneratorContext)
Create the instance of the feature name converter.
protected MethodWrapper createMethodWrapper(Method)
Create the method wrapper.
protected ExtraLanguageTypeConverter createTypeConverterInstance(IExtraLanguageConversionInitializer,IExtraLanguageGeneratorContext)
Create the instance of the type converter.
protected void doCheckMemberFeatureCallMapping(XAbstractFeatureCall,Procedure3<P1,P2,P3>,Function2<P1,P2,Result>)
Check if the feature call could be translated to the extra-language.
protected boolean doTypeMappingCheck(EObject,JvmType,Procedure3<P1,P2,P3>)
Do a type mapping check.
protected void error(String,EObject,EStructuralFeature)
Generate an error for the extra-language.
protected Context getContext
Replies the current context.
protected abstract java.lang.String getErrorMessageFormat
Replies the message format to be used for building an alert message.
IExtraLanguageKeywordProvider getExtraLanguageKeywordProvider
Replies the provider of the extra-language keywords.
protected abstract IExtraLanguageConversionInitializer getFeatureConverterInitializer
Replies the initializer for the feature converter.
ExtraLanguageFeatureNameConverter getFeatureNameConverter
Replies the feature name converter.
ExtraLanguageTypeConverter getTypeConverter
Replies the type converter.
protected abstract IExtraLanguageConversionInitializer getTypeConverterInitializer
Replies the initializer for the type converter.
protected void handleInvocationTargetException(Throwable,Context)
Handle an exception.
protected void info(String,EObject,EStructuralFeature)
Generate an information message for the extra-language.
protected void initializeContext(Context)
Initialize the given context.
protected boolean isResponsible(Map<K,V>,EObject)
Replies if the validator is responsible to validate the given object.
void setInjector(Injector)
Change the injector.
void validate(StateAccess,ValidationMessageAcceptor)
Validate the given resource.
protected void warning(String,EObject,EStructuralFeature)
Generate a warning for the extra-language.
Property Details
context
protected val context : Context
Replies the current context.

This property is an alias for the action: getContext

Returns:
the current context.
errorMessageFormat
protected val errorMessageFormat : java.lang.String
Replies the message format to be used for building an alert message.

The replied format must be compatible with format(Object) with the first argument {0} equals to the text of the alert message.

This property is an alias for the action: getErrorMessageFormat

Returns:
the alert message format.
extraLanguageKeywordProvider
val extraLanguageKeywordProvider : IExtraLanguageKeywordProvider
Replies the provider of the extra-language keywords.

This property is an alias for the action: getExtraLanguageKeywordProvider

Returns:
the provider.
Since:
0.8
featureConverterInitializer
protected val featureConverterInitializer : IExtraLanguageConversionInitializer
Replies the initializer for the feature converter.

This property is an alias for the action: getFeatureConverterInitializer

Returns:
the initializer.
featureNameConverter
val featureNameConverter : ExtraLanguageFeatureNameConverter
Replies the feature name converter.

This property is an alias for the action: getFeatureNameConverter

Returns:
the feature name converter.
typeConverter
val typeConverter : ExtraLanguageTypeConverter
Replies the type converter.

This property is an alias for the action: getTypeConverter

Returns:
the type converter.
typeConverterInitializer
protected val typeConverterInitializer : IExtraLanguageConversionInitializer
Replies the initializer for the type converter.

This property is an alias for the action: getTypeConverterInitializer

Returns:
the initializer.
Constructor Details
new(IExtraLanguageKeywordProvider)
new(IExtraLanguageKeywordProvider)
Constructor.
Parameters:
keywordProvider - the provider of extra-language keywords.
Since:
0.8
Action Details
collectMethods(Class<T>,Collection<E>,Collection<E>)
protected def collectMethods(Class<T>,Collection<E>,Collection<E>)
Collect the check methods.
Parameters:
clazz - the type to explore.
visitedClasses - the visited classes.
result - the collected methods.
createFeatureNameConverterInstance(IExtraLanguageConversionInitializer,IExtraLanguageGeneratorContext)
protected def createFeatureNameConverterInstance(IExtraLanguageConversionInitializer,IExtraLanguageGeneratorContext) : ExtraLanguageFeatureNameConverter
Create the instance of the feature name converter.
Parameters:
initializer - the converter initializer.
context - the generation context.
Returns:
the feature name converter.
createMethodWrapper(Method)
protected def createMethodWrapper(Method) : MethodWrapper
Create the method wrapper.
Parameters:
method - the wrapped method.
Returns:
the wrapper.
createTypeConverterInstance(IExtraLanguageConversionInitializer,IExtraLanguageGeneratorContext)
protected def createTypeConverterInstance(IExtraLanguageConversionInitializer,IExtraLanguageGeneratorContext) : ExtraLanguageTypeConverter
Create the instance of the type converter.
Parameters:
initializer - the converter initializer.
context - the generation context.
Returns:
the type converter.
doCheckMemberFeatureCallMapping(XAbstractFeatureCall,Procedure3<P1,P2,P3>,Function2<P1,P2,Result>)
protected def doCheckMemberFeatureCallMapping(XAbstractFeatureCall,Procedure3<P1,P2,P3>,Function2<P1,P2,Result>)
Check if the feature call could be translated to the extra-language.
Parameters:
featureCall - the feature call.
typeErrorHandler - the error handler for the type conversion.
featureErrorHandler - the error handler for the feature call conversion.
doTypeMappingCheck(EObject,JvmType,Procedure3<P1,P2,P3>)
protected def doTypeMappingCheck(EObject,JvmType,Procedure3<P1,P2,P3>) : boolean
Do a type mapping check.
Parameters:
source - the source of the type.
type - the type to check.
errorHandler - the error handler.
Returns:
true if a type mapping is defined.
error(String,EObject,EStructuralFeature)
protected def error(String,EObject,EStructuralFeature)
Generate an error for the extra-language.

This function generates an error, a warning, or an information depending on the extra-language generation's configuration.
Parameters:
message - the error message.
source - the source of the error.
feature - the structural feature.
getContext
protected def getContext : Context
Replies the current context.
Returns:
the current context.
getErrorMessageFormat
protected def getErrorMessageFormat : java.lang.String
Replies the message format to be used for building an alert message.

The replied format must be compatible with format(Object) with the first argument {0} equals to the text of the alert message.
Returns:
the alert message format.
getExtraLanguageKeywordProvider
def getExtraLanguageKeywordProvider : IExtraLanguageKeywordProvider
Replies the provider of the extra-language keywords.
Returns:
the provider.
Since:
0.8
getFeatureConverterInitializer
protected def getFeatureConverterInitializer : IExtraLanguageConversionInitializer
Replies the initializer for the feature converter.
Returns:
the initializer.
getFeatureNameConverter
def getFeatureNameConverter : ExtraLanguageFeatureNameConverter
Replies the feature name converter.
Returns:
the feature name converter.
getTypeConverter
def getTypeConverter : ExtraLanguageTypeConverter
Replies the type converter.
Returns:
the type converter.
getTypeConverterInitializer
protected def getTypeConverterInitializer : IExtraLanguageConversionInitializer
Replies the initializer for the type converter.
Returns:
the initializer.
handleInvocationTargetException(Throwable,Context)
protected def handleInvocationTargetException(Throwable,Context)
Handle an exception.
Parameters:
targetException - the exception.
context - the context.
info(String,EObject,EStructuralFeature)
protected def info(String,EObject,EStructuralFeature)
Generate an information message for the extra-language.

This function generates an error, a warning, or an information depending on the extra-language generation's configuration.
Parameters:
message - the info message.
source - the source of the error.
feature - the structural feature.
initializeContext(Context)
protected def initializeContext(Context)
Initialize the given context. This function in invoked when the validator is called with a resource and before the validation on the resource's content is started.
Parameters:
validatorContext - the context to initialize.
Since:
0.8
isResponsible(Map<K,V>,EObject)
protected def isResponsible(Map<K,V>,EObject) : boolean
Replies if the validator is responsible to validate the given object.
Parameters:
context - the context.
eObject - the validated object.
Returns:
true if the validator could be run.
setInjector(Injector)
def setInjector(Injector)
Change the injector.
Parameters:
injector - the injector.
validate(StateAccess,ValidationMessageAcceptor)
def validate(StateAccess,ValidationMessageAcceptor)
Validate the given resource.
Parameters:
validationState - the current validation state.
messageAcceptor - the message acceptor.
warning(String,EObject,EStructuralFeature)
protected def warning(String,EObject,EStructuralFeature)
Generate a warning for the extra-language.

This function generates an error, a warning, or an information depending on the extra-language generation's configuration.
Parameters:
message - the warning message.
source - the source of the error.
feature - the structural feature.