Package com.sonarsource.cobol.api.ast
Class CobolAstVisitor
- java.lang.Object
-
- com.sonarsource.cobol.api.ast.CobolAstVisitor
-
- All Implemented Interfaces:
AstVisitor
,org.sonar.squid.api.CodeVisitor
- Direct Known Subclasses:
CobolCheck
public abstract class CobolAstVisitor extends Object implements org.sonar.squid.api.CodeVisitor, AstVisitor
Base class to visit an AST (Abstract Syntactic Tree) generated by a parser. Methods are visited in the following sequential order : init(), visitFile(), visitNode(), leaveNode(), leaveFile() and destroy()
-
-
Field Summary
Fields Modifier and Type Field Description protected CobolGrammar
grammar
-
Constructor Summary
Constructors Constructor Description CobolAstVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addSourceCode(org.sonar.squid.api.SourceCode child)
Deprecated.void
destroy()
Destroy the visitor.List<AstNodeType>
getAstNodeTypesToVisit()
This method can't be overridden.Charset
getCharset()
protected CicsGrammar
getCicsGrammar()
CobolFile
getCobolFile()
protected CobolGrammar
getCobolGrammar()
Comments
getComments()
CobolExecutionFlow
getExecutionFlow()
Deprecated.File
getFile()
Deprecated.UsegetCobolFile()
.protected DB2Grammar
getSqlGrammar()
CobolSymbolTable
getSymbolTable()
void
init()
Initialize the visitor.void
leaveFile(AstNode astNode)
Called once a computation unit tree has been fully visited.void
leaveNode(AstNode astNode)
Called once an AST node has been fully visited.org.sonar.squid.api.SourceCode
peekSourceCode()
Deprecated.void
popSourceCode()
Deprecated.void
processMetrics(org.sonar.squid.indexer.SquidIndex index)
Deprecated.void
setCharset(Charset charset)
void
setCobolFile(CobolFile cobolFile)
void
setComments(Comments comments)
Do not usevoid
setExecutionFlow(CobolExecutionFlow executionFlow)
Deprecated.void
setFile(File file)
Deprecated.Use#setCobolFile()
.void
setGrammar(CobolGrammar grammar)
Do not usevoid
setSourceCodeStack(Deque<org.sonar.squid.api.SourceCode> sourceCodeStack)
Deprecated.void
setSymbolTable(CobolSymbolTable symbolTable)
Do not usevoid
subscribeTo(AstNodeType... astNodeTypes)
This method must called into the init() method when a Cobol AST visitor wants to subscribe to a set of AST node type.void
visitFile(AstNode astNode)
Called before starting visiting a computation unit tree.void
visitNode(AstNode astNode)
Called to process an AST node whose type has been registered to be visited.
-
-
-
Field Detail
-
grammar
protected CobolGrammar grammar
-
-
Method Detail
-
getAstNodeTypesToVisit
public final List<AstNodeType> getAstNodeTypesToVisit()
This method can't be overridden. The method subscribeTo(AstNodeType... astNodeTypes) must be used to while overriding the public void init() method.- Specified by:
getAstNodeTypesToVisit
in interfaceAstVisitor
- Returns:
- the AST node types this must be registered for.
-
subscribeTo
public final void subscribeTo(AstNodeType... astNodeTypes)
This method must called into the init() method when a Cobol AST visitor wants to subscribe to a set of AST node type.
-
setSourceCodeStack
@Deprecated public final void setSourceCodeStack(Deque<org.sonar.squid.api.SourceCode> sourceCodeStack)
Deprecated.Do not use
-
setGrammar
public final void setGrammar(CobolGrammar grammar)
Do not use
-
setComments
public final void setComments(Comments comments)
Do not use
-
setSymbolTable
public final void setSymbolTable(CobolSymbolTable symbolTable)
Do not use
-
getSymbolTable
public final CobolSymbolTable getSymbolTable()
-
getComments
public final Comments getComments()
-
addSourceCode
@Deprecated public final void addSourceCode(org.sonar.squid.api.SourceCode child)
Deprecated.Do not use
-
popSourceCode
@Deprecated public final void popSourceCode()
Deprecated.Do not use
-
peekSourceCode
@Deprecated public final org.sonar.squid.api.SourceCode peekSourceCode()
Deprecated.Do not use
-
init
public void init()
Initialize the visitor. This is the time to verify that the visitor has everything required to perform it job. This method is called once.
-
visitFile
public void visitFile(@Nullable AstNode astNode)
Called before starting visiting a computation unit tree. Ideal place to initialize information that is to be collected while processing the tree.- Specified by:
visitFile
in interfaceAstVisitor
- Parameters:
astNode
- the root of the tree, ornull
if no tree
-
visitNode
public void visitNode(AstNode astNode)
Called to process an AST node whose type has been registered to be visited.- Specified by:
visitNode
in interfaceAstVisitor
- Parameters:
astNode
- the AST node to process
-
leaveFile
public void leaveFile(@Nullable AstNode astNode)
Called once a computation unit tree has been fully visited. Ideal place to report on information collected while processing a tree.- Specified by:
leaveFile
in interfaceAstVisitor
- Parameters:
astNode
- the root of the tree, ornull
if no tree
-
leaveNode
public void leaveNode(AstNode astNode)
Called once an AST node has been fully visited.- Specified by:
leaveNode
in interfaceAstVisitor
- Parameters:
astNode
- the AST node which has been visited
-
processMetrics
@Deprecated public void processMetrics(org.sonar.squid.indexer.SquidIndex index)
Deprecated.Called afterleaveFile(AstNode)
, after metrics have been aggregated.
-
destroy
public void destroy()
Destroy the visitor. It is being retired from service.
-
setFile
@Deprecated public final void setFile(File file)
Deprecated.Use#setCobolFile()
.
-
getFile
@Deprecated public final File getFile()
Deprecated.UsegetCobolFile()
.
-
getCharset
public Charset getCharset()
-
setCharset
public void setCharset(Charset charset)
-
getCobolFile
public CobolFile getCobolFile()
-
setCobolFile
public void setCobolFile(CobolFile cobolFile)
-
getCobolGrammar
protected final CobolGrammar getCobolGrammar()
-
getSqlGrammar
protected final DB2Grammar getSqlGrammar()
-
getCicsGrammar
protected final CicsGrammar getCicsGrammar()
-
setExecutionFlow
@Deprecated public final void setExecutionFlow(CobolExecutionFlow executionFlow)
Deprecated.
-
getExecutionFlow
@Deprecated public final CobolExecutionFlow getExecutionFlow()
Deprecated.
-
-