public abstract class AbstractBasicEnvironment extends java.lang.Object implements BasicEnvironment2
BasicEnvironment interface, providing
default behaviours for most features.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractBasicEnvironment(BasicEnvironment parent)
Initializes me with the specified parent environment, which should be
of the same type as me.
|
| Modifier and Type | Method and Description |
|---|---|
void |
analyzerError(java.lang.String problemMessage,
java.lang.String problemContext,
int startOffset,
int endOffset)
Convenience method invoking
getProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity. |
void |
analyzerError(java.lang.String problemMessage,
java.lang.String problemContext,
java.util.List<?> problemObjects)
Convenience method invoking
getProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity. |
void |
analyzerError(java.lang.String problemMessage,
java.lang.String problemContext,
java.lang.Object problemObject)
Convenience method invoking
getProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity. |
void |
analyzerWarning(java.lang.String problemMessage,
java.lang.String problemContext,
java.lang.Object problemObject)
Convenience method invoking
getProblemHandler().analyzerProblem
with a ProblemHandler.warningSeverity. |
protected java.util.Map<Option<?>,java.lang.Object> |
basicGetOptions() |
java.util.Map<Option<?>,java.lang.Object> |
clearOptions()
Clears all options.
|
protected ProblemHandler |
createDefaultProblemHandler(AbstractParser parser) |
protected FormattingHelper |
createFormattingHelper()
Obtains the new or existing formatting-helper for this environment
to use.
|
<T> T |
getAdapter(java.lang.Class<T> adapterType)
The abstract environment implementation is adaptable.
|
CSTNode |
getASTMapping(java.lang.Object object)
Return the mapping of an astNode to its originating cstNode, so that
AST-based analysis may report error messages exploiting the CST context, or
to support incremental AST/CST update.
|
java.util.Map<java.lang.Object,CSTNode> |
getASTNodeToCSTNodeMap() |
FormattingHelper |
getFormatter()
Return the message formatter that may be used to format object-related contributions
to problem messages.
|
java.util.Map<Option<?>,java.lang.Object> |
getOptions()
Obtains a copy of my map of options.
|
BasicEnvironment |
getParent() |
AbstractParser |
getParser()
Return the syntactic parser from which source tokens and text amy be obtained.
|
ProblemHandler |
getProblemHandler()
Obtains a problem handler to service lexer, parser, analyzer, validator, ...
|
<T> T |
getValue(Option<T> option)
Obtains the value of the specified option's setting in the my
options map.
|
void |
initASTMapping(java.lang.Object astNode,
CSTNode cstNode)
Initialize the mapping of an object (typically an astNode) to its originating cstNode,
so that AST-based analysis may report error messages exploiting the CST context, or
to support incremental AST/CST update.
|
void |
initASTMapping(java.lang.Object fromAstNode,
CSTNode cstNode,
java.lang.Object toAstNode)
Initialize the asymmetric mapping of an object (typically an astNode) to
its originating cstNode, and of a cstNode to its consequent object
(typically an astNode) so that AST-based analysis may report error
messages exploiting the CST context, or to support incremental AST/CST
update.
|
boolean |
isEnabled(Option<java.lang.Boolean> option)
Queries whether the specified boolean-valued option is enabled.
|
void |
lexerError(int errorCode,
int startOffset,
int endOffset)
Convenience method invoking
getProblemHandler().lexerProblem
with a ProblemHandler.errorSeverity. |
void |
parserError(int errorCode,
int leftToken,
int rightToken,
java.lang.String tokenText)
Convenience method invoking
getProblemHandler().parserProblem
with a ProblemHandler.errorSeverity. |
void |
problem(ProblemHandler.Severity severity,
ProblemHandler.Phase phase,
java.lang.String problemMessage,
java.lang.String problemContext,
java.lang.Object problemObject)
Generically reports a problem about some object.
|
<T> void |
putOptions(java.util.Map<? extends Option<T>,? extends T> options)
Adds options to apply to my behaviour.
|
<T> T |
removeOption(Option<T> option)
Removes the specified option.
|
<T> java.util.Map<Option<T>,T> |
removeOptions(java.util.Collection<Option<T>> options)
Removes the specified options.
|
void |
setASTNodeToCSTNodeMap(java.util.Map<java.lang.Object,CSTNode> astNodeToCstNodeMap) |
<T> void |
setOption(Option<T> option,
T value)
Add an option to apply to my behaviour.
|
protected void |
setParent(BasicEnvironment parent)
Assigns me a parent environment after construction.
|
void |
setParser(AbstractParser parser)
Define the syntactic parser from which source tokens and text amy be obtained.
|
ProblemHandler |
setProblemHandler(ProblemHandler newProblemHandler)
Define the handler for any problem reports.
|
void |
utilityError(java.lang.String problemMessage,
java.lang.String problemContext,
java.lang.Object problemObject)
Convenience method invoking
getProblemHandler().utilityProblem
with a ProblemHandler.errorSeverity. |
void |
validatorError(java.lang.String problemMessage,
java.lang.String problemContext,
java.lang.Object problemObject)
Convenience method invoking
getProblemHandler().validatorProblem
with a ProblemHandler.errorSeverity. |
protected AbstractBasicEnvironment(BasicEnvironment parent)
parent - an environment of the same type as me (or null)public <T> T getAdapter(java.lang.Class<T> adapterType)
ProblemHandler interface.
Subclasses may override or extend this implementation.
getAdapter in interface AdaptableT - the requested adapter interfaceadapterType - the requested adapter interfacenull
if this environment does not adapt to itpublic void analyzerError(java.lang.String problemMessage,
java.lang.String problemContext,
java.lang.Object problemObject)
BasicEnvironmentgetProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity.analyzerError in interface BasicEnvironmentproblemMessage - message describing the problemproblemContext - optional message describing the reporting contextproblemObject - optional object associated with the problempublic void analyzerError(java.lang.String problemMessage,
java.lang.String problemContext,
java.util.List<?> problemObjects)
BasicEnvironmentgetProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity.analyzerError in interface BasicEnvironmentproblemMessage - message describing the problemproblemContext - optional message describing the reporting contextproblemObjects - optional sequence of objects associated with the problempublic void analyzerError(java.lang.String problemMessage,
java.lang.String problemContext,
int startOffset,
int endOffset)
BasicEnvironmentgetProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity.analyzerError in interface BasicEnvironmentproblemMessage - message describing the problemproblemContext - optional message describing the reporting contextstartOffset - character index at the start of the errorendOffset - character index beyond the end of the errorpublic void analyzerWarning(java.lang.String problemMessage,
java.lang.String problemContext,
java.lang.Object problemObject)
BasicEnvironmentgetProblemHandler().analyzerProblem
with a ProblemHandler.warningSeverity.analyzerWarning in interface BasicEnvironmentproblemMessage - message describing the problemproblemContext - optional message describing the reporting contextproblemObject - optional object associated with the problemprotected ProblemHandler createDefaultProblemHandler(AbstractParser parser)
public BasicEnvironment getParent()
public AbstractParser getParser()
BasicEnvironmentgetParser in interface BasicEnvironmentpublic java.util.Map<java.lang.Object,CSTNode> getASTNodeToCSTNodeMap()
public CSTNode getASTMapping(java.lang.Object object)
BasicEnvironmentgetASTMapping in interface BasicEnvironmentpublic FormattingHelper getFormatter()
BasicEnvironmentgetFormatter in interface BasicEnvironmentprotected FormattingHelper createFormattingHelper()
AbstractFormattingHelper; subclasses may override.public ProblemHandler getProblemHandler()
BasicEnvironmentgetProblemHandler in interface BasicEnvironmentpublic void initASTMapping(java.lang.Object astNode,
CSTNode cstNode)
BasicEnvironmentinitASTMapping in interface BasicEnvironmentpublic void initASTMapping(java.lang.Object fromAstNode,
CSTNode cstNode,
java.lang.Object toAstNode)
BasicEnvironment2initASTMapping in interface BasicEnvironment2fromAstNode - source of the AST-to-CST mappingcstNode - target of the AST-to-CST mapping and source of the CST-to-AST
mappingtoAstNode - target of the CST-to-AST mappingpublic void lexerError(int errorCode,
int startOffset,
int endOffset)
BasicEnvironmentgetProblemHandler().lexerProblem
with a ProblemHandler.errorSeverity.lexerError in interface BasicEnvironmenterrorCode - the ParserErrorCodes value identifying the errorstartOffset - character index at the start of the errorendOffset - character index beyond the end of the errorpublic void parserError(int errorCode,
int leftToken,
int rightToken,
java.lang.String tokenText)
BasicEnvironmentgetProblemHandler().parserProblem
with a ProblemHandler.errorSeverity.parserError in interface BasicEnvironmenterrorCode - the ParserErrorCodes value identifying the errorleftToken - the lexical token index at the left hand edge of the errorrightToken - the lexical token index at the right hand edge of the errortokenText - additional text apprropriate to the ParserErrorCodes value.public void setASTNodeToCSTNodeMap(java.util.Map<java.lang.Object,CSTNode> astNodeToCstNodeMap)
protected void setParent(BasicEnvironment parent)
null if I previously had one.parent - my new parentpublic void setParser(AbstractParser parser)
BasicEnvironmentsetParser in interface BasicEnvironmentpublic ProblemHandler setProblemHandler(ProblemHandler newProblemHandler)
BasicEnvironmentsetProblemHandler in interface BasicEnvironmentpublic void utilityError(java.lang.String problemMessage,
java.lang.String problemContext,
java.lang.Object problemObject)
BasicEnvironmentgetProblemHandler().utilityProblem
with a ProblemHandler.errorSeverity.utilityError in interface BasicEnvironmentproblemMessage - message describing the problemproblemContext - optional message describing the reporting contextproblemObject - optional object associated with the problempublic void validatorError(java.lang.String problemMessage,
java.lang.String problemContext,
java.lang.Object problemObject)
BasicEnvironmentgetProblemHandler().validatorProblem
with a ProblemHandler.errorSeverity.validatorError in interface BasicEnvironmentproblemMessage - message describing the problemproblemContext - optional message describing the reporting contextproblemObject - optional object associated with the problempublic void problem(ProblemHandler.Severity severity, ProblemHandler.Phase phase, java.lang.String problemMessage, java.lang.String problemContext, java.lang.Object problemObject)
BasicEnvironmentproblem in interface BasicEnvironmentseverity - the severity of the problemphase - the phase in which the problem was encounteredproblemMessage - message describing the problemproblemContext - optional message describing the reporting contextproblemObject - optional object associated with the problemprotected java.util.Map<Option<?>,java.lang.Object> basicGetOptions()
public java.util.Map<Option<?>,java.lang.Object> getOptions()
CustomizablegetOptions in interface Customizablepublic <T> void setOption(Option<T> option, T value)
CustomizablesetOption in interface Customizableoption - the optionvalue - the option's valuepublic <T> void putOptions(java.util.Map<? extends Option<T>,? extends T> options)
CustomizableputOptions in interface Customizableoptions - the optionspublic <T> T removeOption(Option<T> option)
CustomizableremoveOption in interface Customizableoption - the option to removepublic <T> java.util.Map<Option<T>,T> removeOptions(java.util.Collection<Option<T>> options)
CustomizableremoveOptions in interface Customizableoptions - the options to removepublic java.util.Map<Option<?>,java.lang.Object> clearOptions()
CustomizableclearOptions in interface Customizablepublic boolean isEnabled(Option<java.lang.Boolean> option)
CustomizableisEnabled in interface Customizableoption - an optionpublic <T> T getValue(Option<T> option)
CustomizablegetValue in interface Customizableoption - the option to query