public abstract class AbstractBasicEnvironment extends Object implements BasicEnvironment2
BasicEnvironment
interface, providing
default behaviours for most features.Modifier and Type | Method and Description |
---|---|
void |
analyzerError(String problemMessage,
String problemContext,
int startOffset,
int endOffset)
Convenience method invoking
getProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity . |
void |
analyzerError(String problemMessage,
String problemContext,
List<?> problemObjects)
Convenience method invoking
getProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity . |
void |
analyzerError(String problemMessage,
String problemContext,
Object problemObject)
Convenience method invoking
getProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity . |
void |
analyzerWarning(String problemMessage,
String problemContext,
Object problemObject)
Convenience method invoking
getProblemHandler().analyzerProblem
with a ProblemHandler.warningSeverity . |
Map<Option<?>,Object> |
clearOptions()
Clears all options.
|
<T> T |
getAdapter(Class<T> adapterType)
The abstract environment implementation is adaptable.
|
CSTNode |
getASTMapping(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.
|
Map<Object,CSTNode> |
getASTNodeToCSTNodeMap() |
FormattingHelper |
getFormatter()
Return the message formatter that may be used to format object-related contributions
to problem messages.
|
Map<Option<?>,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(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(Object fromAstNode,
CSTNode cstNode,
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<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,
String tokenText)
Convenience method invoking
getProblemHandler().parserProblem
with a ProblemHandler.errorSeverity . |
void |
problem(ProblemHandler.Severity severity,
ProblemHandler.Phase phase,
String problemMessage,
String problemContext,
Object problemObject)
Generically reports a problem about some object.
|
<T> void |
putOptions(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> Map<Option<T>,T> |
removeOptions(Collection<Option<T>> options)
Removes the specified options.
|
void |
setASTNodeToCSTNodeMap(Map<Object,CSTNode> astNodeToCstNodeMap) |
<T> void |
setOption(Option<T> option,
T value)
Add an option to apply to my behaviour.
|
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(String problemMessage,
String problemContext,
Object problemObject)
Convenience method invoking
getProblemHandler().utilityProblem
with a ProblemHandler.errorSeverity . |
void |
validatorError(String problemMessage,
String problemContext,
Object problemObject)
Convenience method invoking
getProblemHandler().validatorProblem
with a ProblemHandler.errorSeverity . |
public <T> T getAdapter(Class<T> adapterType)
ProblemHandler
interface.
Subclasses may override or extend this implementation.
getAdapter
in interface Adaptable
T
- the requested adapter interfaceadapterType
- the requested adapter interfacenull
if this environment does not adapt to itpublic void analyzerError(String problemMessage, String problemContext, Object problemObject)
BasicEnvironment
getProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity
.analyzerError
in interface BasicEnvironment
problemMessage
- message describing the problemproblemContext
- optional message describing the reporting contextproblemObject
- optional object associated with the problempublic void analyzerError(String problemMessage, String problemContext, List<?> problemObjects)
BasicEnvironment
getProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity
.analyzerError
in interface BasicEnvironment
problemMessage
- message describing the problemproblemContext
- optional message describing the reporting contextproblemObjects
- optional sequence of objects associated with the problempublic void analyzerError(String problemMessage, String problemContext, int startOffset, int endOffset)
BasicEnvironment
getProblemHandler().analyzerProblem
with a ProblemHandler.errorSeverity
.analyzerError
in interface BasicEnvironment
problemMessage
- 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(String problemMessage, String problemContext, Object problemObject)
BasicEnvironment
getProblemHandler().analyzerProblem
with a ProblemHandler.warningSeverity
.analyzerWarning
in interface BasicEnvironment
problemMessage
- message describing the problemproblemContext
- optional message describing the reporting contextproblemObject
- optional object associated with the problempublic BasicEnvironment getParent()
public AbstractParser getParser()
BasicEnvironment
getParser
in interface BasicEnvironment
public CSTNode getASTMapping(Object object)
BasicEnvironment
getASTMapping
in interface BasicEnvironment
public FormattingHelper getFormatter()
BasicEnvironment
getFormatter
in interface BasicEnvironment
public ProblemHandler getProblemHandler()
BasicEnvironment
getProblemHandler
in interface BasicEnvironment
public void initASTMapping(Object astNode, CSTNode cstNode)
BasicEnvironment
initASTMapping
in interface BasicEnvironment
public void initASTMapping(Object fromAstNode, CSTNode cstNode, Object toAstNode)
BasicEnvironment2
initASTMapping
in interface BasicEnvironment2
fromAstNode
- 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)
BasicEnvironment
getProblemHandler().lexerProblem
with a ProblemHandler.errorSeverity
.lexerError
in interface BasicEnvironment
errorCode
- 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, String tokenText)
BasicEnvironment
getProblemHandler().parserProblem
with a ProblemHandler.errorSeverity
.parserError
in interface BasicEnvironment
errorCode
- 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 setParser(AbstractParser parser)
BasicEnvironment
setParser
in interface BasicEnvironment
public ProblemHandler setProblemHandler(ProblemHandler newProblemHandler)
BasicEnvironment
setProblemHandler
in interface BasicEnvironment
public void utilityError(String problemMessage, String problemContext, Object problemObject)
BasicEnvironment
getProblemHandler().utilityProblem
with a ProblemHandler.errorSeverity
.utilityError
in interface BasicEnvironment
problemMessage
- message describing the problemproblemContext
- optional message describing the reporting contextproblemObject
- optional object associated with the problempublic void validatorError(String problemMessage, String problemContext, Object problemObject)
BasicEnvironment
getProblemHandler().validatorProblem
with a ProblemHandler.errorSeverity
.validatorError
in interface BasicEnvironment
problemMessage
- message describing the problemproblemContext
- optional message describing the reporting contextproblemObject
- optional object associated with the problempublic void problem(ProblemHandler.Severity severity, ProblemHandler.Phase phase, String problemMessage, String problemContext, Object problemObject)
BasicEnvironment
problem
in interface BasicEnvironment
severity
- 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 problempublic Map<Option<?>,Object> getOptions()
Customizable
getOptions
in interface Customizable
public <T> void setOption(Option<T> option, T value)
Customizable
setOption
in interface Customizable
option
- the optionvalue
- the option's valuepublic <T> void putOptions(Map<? extends Option<T>,? extends T> options)
Customizable
putOptions
in interface Customizable
options
- the optionspublic <T> T removeOption(Option<T> option)
Customizable
removeOption
in interface Customizable
option
- the option to removepublic <T> Map<Option<T>,T> removeOptions(Collection<Option<T>> options)
Customizable
removeOptions
in interface Customizable
options
- the options to removepublic Map<Option<?>,Object> clearOptions()
Customizable
clearOptions
in interface Customizable
public boolean isEnabled(Option<Boolean> option)
Customizable
isEnabled
in interface Customizable
option
- an optionpublic <T> T getValue(Option<T> option)
Customizable
getValue
in interface Customizable
option
- the option to queryCopyright © 2005, 2018 IBM Corporation and others. All Rights Reserved.