Move plsql into own sub-module

This commit is contained in:
Andreas Dangel
2014-10-04 18:40:22 +02:00
parent a8ef0ec863
commit 802af053cf
98 changed files with 271 additions and 59 deletions

File diff suppressed because it is too large Load Diff

185
pmd-plsql/pom.xml Normal file
View File

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>pmd-plsql</artifactId>
<name>PMD PL/SQL</name>
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-aggregate</artifactId>
<version>5.1.4-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<useDefaultDelimiters>false</useDefaultDelimiters>
<delimiters>
<delimiter>${*}</delimiter>
</delimiters>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<target>
<ant antfile="src/main/ant/alljavacc.xml">
<property name="target" value="${project.build.directory}/generated-sources/javacc" />
<property name="javacc.jar" value="${settings.localRepository}/net/java/dev/javacc/javacc/${javacc.version}/javacc-${javacc.version}.jar" />
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-javacc-generated-sources</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/javacc</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- As Clover can be quite an hassle, know that you can skip
it by using the following option when running mvn: $ mvn clean -Dmaven.clover.skip=true
site -->
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<configuration>
<jdk>${java.version}</jdk>
<licenseLocation>${basedir}/../pmd/licences/clover2.license</licenseLocation>
</configuration>
<executions>
<execution>
<phase>pre-site</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<xdocDirectory>${project.build.directory}/generated-xdocs</xdocDirectory>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-test</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-testutil</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<exclusions>
<exclusion>
<artifactId>xercesImpl</artifactId>
<groupId>xerces</groupId>
</exclusion>
<exclusion>
<artifactId>xalan</artifactId>
<groupId>xalan</groupId>
</exclusion>
<exclusion>
<artifactId>icu4j</artifactId>
<groupId>com.ibm.icu</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<classifier>dom</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.java.dev.javacc</groupId>
<artifactId>javacc</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,82 @@
<project name="pmd" default="alljavacc" basedir="../../">
<property name="javacc-home.path" value="target/lib" />
<target name="alljavacc"
description="Generates all JavaCC aspects within PMD"
depends="checkUpToDate,init,plsqljjtree,cleanup" />
<target name="checkUpToDate">
<uptodate property="javaccBuildNotRequired" targetfile="${target}/last-generated-timestamp">
<srcfiles dir="etc/grammar" includes="*.jj*"/>
</uptodate>
<echo message="up to date check: javaccBuildNotRequired=${javaccBuildNotRequired}"/>
</target>
<target name="init" unless="javaccBuildNotRequired">
<mkdir dir="${javacc-home.path}" />
<copy file="${javacc.jar}" tofile="${javacc-home.path}/javacc.jar" />
<mkdir dir="${target}"/>
<touch file="${target}/last-generated-timestamp"/>
</target>
<target name="cleanup">
<delete dir="${javacc-home.path}" />
</target>
<target name="plsqljjtree" description="Generates the PlSQL parser and AST source files" unless="javaccBuildNotRequired">
<delete dir="${target}/net/sourceforge/pmd/lang/plsql/ast" />
<mkdir dir="${target}/net/sourceforge/pmd/lang/plsql/ast" />
<jjtree target="etc/grammar/PldocAST.jjt"
outputdirectory="${target}/net/sourceforge/pmd/lang/plsql/ast"
javacchome="${javacc-home.path}" />
<!-- Ensure generated using CharStream interface -->
<javacc static="false"
usercharstream="false"
target="${target}/net/sourceforge/pmd/lang/plsql/ast/PldocAST.jj"
outputdirectory="${target}/net/sourceforge/pmd/lang/plsql/ast"
javacchome="${javacc-home.path}" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/SimpleNode.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/Node.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/SimpleCharStream.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/TokenMgrError.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTArguments.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTDatatype.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTFormalParameter.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTIfStatement.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTInput.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTMethodDeclaration.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTMethodDeclarator.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTName.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTPackageBody.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTPackageSpecification.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTPrimaryPrefix.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTPrimarySuffix.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTProgramUnit.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTTriggerTimingPointSection.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTTriggerUnit.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTTypeMethod.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTTypeSpecification.java" />
<delete file="${target}/net/sourceforge/pmd/lang/plsql/ast/ASTVariableOrConstantDeclaratorId.java" />
<replace file="${target}/net/sourceforge/pmd/lang/plsql/ast/PLSQLParserVisitor.java"
token="SimpleNode"
value="PLSQLNode" />
<replace file="${target}/net/sourceforge/pmd/lang/plsql/ast/PLSQLParserTokenManager.java"
token="class PLSQLParserTokenManager"
value="class PLSQLParserTokenManager extends net.sourceforge.pmd.lang.ast.AbstractTokenManager" />
<replace file="${target}/net/sourceforge/pmd/lang/plsql/ast/JJTPLSQLParserState.java">
<replacetoken>public class</replacetoken>
<replacevalue><![CDATA[import net.sourceforge.pmd.lang.ast.Node;
public class]]></replacevalue>
</replace>
<replace file="${target}/net/sourceforge/pmd/lang/plsql/ast/ParseException.java"
token="extends Exception"
value="extends net.sourceforge.pmd.lang.ast.ParseException" />
</target>
</project>

View File

@ -0,0 +1,30 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.util.Properties;
/**
*
* @author Stuart Turton sturton@users.sourceforge.net
*/
public class PLSQLLanguage extends AbstractLanguage {
public PLSQLLanguage() {
super(new PLSQLTokenizer()
,".sql"
,".trg" //Triggers
,".prc",".fnc" // Standalone Procedures and Functions
,".pld" // Oracle*Forms
,".pls" ,".plh" ,".plb" // Packages
,".pck" ,".pks" ,".pkh" ,".pkb" // Packages
,".typ" ,".tyb" // Object Types
,".tps" ,".tpb" // Object Types
);
}
@Override
public final void setProperties(Properties properties) {
((PLSQLTokenizer)getTokenizer()).setProperties(properties);
}
}

View File

@ -0,0 +1,119 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.io.StringReader;
import java.util.Properties;
import java.util.logging.Logger;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserConstants;
import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserTokenManager;
import net.sourceforge.pmd.lang.plsql.ast.Token;
public class PLSQLTokenizer implements Tokenizer{
private final static Logger LOGGER = Logger.getLogger(PLSQLTokenizer.class.getName());
public static final String IGNORE_COMMENTS = "ignore_comments";
public static final String IGNORE_IDENTIFIERS = "ignore_identifiers";
public static final String IGNORE_LITERALS = "ignore_literals";
private boolean ignoreComments;
private boolean ignoreIdentifiers;
private boolean ignoreLiterals;
public void setProperties(Properties properties) {
/* The Tokenizer is derived from PLDoc, in which comments are very important
* When looking for duplication, we are probably not interested in comment variation,
* so we shall default ignoreComments to true
*/
ignoreComments = Boolean.parseBoolean(properties.getProperty(IGNORE_COMMENTS, "true"));
ignoreIdentifiers = Boolean.parseBoolean(properties.getProperty(IGNORE_IDENTIFIERS, "false"));
ignoreLiterals = Boolean.parseBoolean(properties.getProperty(IGNORE_LITERALS, "false"));
}
public void setIgnoreComments(boolean ignore) {
this.ignoreComments = ignore;
}
public void setIgnoreLiterals(boolean ignore) {
this.ignoreLiterals = ignore;
}
public void setIgnoreIdentifiers(boolean ignore) {
this.ignoreIdentifiers = ignore;
}
/**
* Read Reader from SourceCode and output an ordered tree of PLSQL tokens.
* @param sourceCode PLSQL source in file, string or database (any suitable object that can return
* a Reader).
* @param tokenEntries Derived based on PLSQL Abstract Syntax Tree (derived from PLDOc parser.)
*/
public void tokenize (SourceCode sourceCode, Tokens tokenEntries )
{
long encounteredTokens = 0, addedTokens = 0;
LOGGER.fine("PLSQLTokenizer: ignoreComments=="+ignoreComments);
LOGGER.fine("PLSQLTokenizer: ignoreIdentifiers=="+ignoreIdentifiers);
LOGGER.fine("PLSQLTokenizer: ignoreLiterals=="+ignoreLiterals);
String fileName = sourceCode.getFileName();
StringBuilder sb = sourceCode.getCodeBuffer();
PLSQLParserTokenManager tokenMgr = new PLSQLParserTokenManager( new SimpleCharStream( new StringReader(sb.toString())));
Token currentToken = tokenMgr.getNextToken();
while (currentToken.image.length() > 0)
{
String image = currentToken.image;
encounteredTokens++;
if (ignoreComments &&
( currentToken.kind == PLSQLParserConstants.SINGLE_LINE_COMMENT
||currentToken.kind == PLSQLParserConstants.MULTI_LINE_COMMENT
||currentToken.kind == PLSQLParserConstants.FORMAL_COMMENT
||currentToken.kind == PLSQLParserConstants.COMMENT
||currentToken.kind == PLSQLParserConstants.IN_MULTI_LINE_COMMENT
||currentToken.kind == PLSQLParserConstants.IN_FORMAL_COMMENT
)
) {
image = String.valueOf(currentToken.kind);
}
if (ignoreIdentifiers &&
(currentToken.kind == PLSQLParserConstants.IDENTIFIER
)
) {
image = String.valueOf(currentToken.kind);
}
if (ignoreLiterals
&& (
currentToken.kind == PLSQLParserConstants.UNSIGNED_NUMERIC_LITERAL
|| currentToken.kind == PLSQLParserConstants.FLOAT_LITERAL
|| currentToken.kind == PLSQLParserConstants.INTEGER_LITERAL
|| currentToken.kind == PLSQLParserConstants.CHARACTER_LITERAL
|| currentToken.kind == PLSQLParserConstants.STRING_LITERAL
|| currentToken.kind == PLSQLParserConstants.QUOTED_LITERAL
)
) {
image = String.valueOf(currentToken.kind);
}
tokenEntries.add(new TokenEntry(image, fileName, currentToken.beginLine));
addedTokens++;
currentToken = tokenMgr.getNextToken();
}
tokenEntries.add(TokenEntry.getEOF() );
LOGGER.fine(sourceCode.getFileName()
+ ": encountered " + encounteredTokens + " tokens;"
+ " added " + addedTokens + " tokens"
);
}
}

View File

@ -0,0 +1,23 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.plsql;
import java.util.List;
import net.sourceforge.pmd.lang.DataFlowHandler;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.dfa.DataFlowNode;
import net.sourceforge.pmd.lang.plsql.ast.ASTLabelledStatement;
import net.sourceforge.pmd.lang.plsql.dfa.PLSQLDataFlowNode;
public class PLSQLDataFlowHandler implements DataFlowHandler {
public DataFlowNode createDataFlowNode(List<DataFlowNode> dataFlow, Node node) {
return new PLSQLDataFlowNode(dataFlow, node);
}
public Class<ASTLabelledStatement> getLabelStatementNodeClass() {
return ASTLabelledStatement.class;
}
}

View File

@ -0,0 +1,100 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.plsql;
import java.io.Writer;
import net.sf.saxon.sxpath.IndependentContext;
import net.sourceforge.pmd.lang.AbstractLanguageVersionHandler;
import net.sourceforge.pmd.lang.DataFlowHandler;
import net.sourceforge.pmd.lang.Parser;
import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.lang.VisitorStarter;
import net.sourceforge.pmd.lang.XPathHandler;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.xpath.DocumentNavigator;
import net.sourceforge.pmd.lang.dfa.DFAGraphRule;
import net.sourceforge.pmd.lang.plsql.ast.ASTInput;
import net.sourceforge.pmd.lang.plsql.ast.DumpFacade;
import net.sourceforge.pmd.lang.plsql.ast.PLSQLNode;
import net.sourceforge.pmd.lang.plsql.dfa.DFAPLSQLGraphRule;
import net.sourceforge.pmd.lang.plsql.dfa.DataFlowFacade;
import net.sourceforge.pmd.lang.plsql.rule.PLSQLRuleViolationFactory;
import net.sourceforge.pmd.lang.plsql.symboltable.SymbolFacade;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
import org.jaxen.Navigator;
/**
* Implementation of LanguageVersionHandler for the PLSQL AST. It uses anonymous classes
* as adapters of the visitors to the VisitorStarter interface.
*
* @author sturton - PLDoc - pldoc.sourceforge.net
*/
public class PLSQLHandler extends AbstractLanguageVersionHandler {
public Parser getParser(ParserOptions parserOptions) {
return new PLSQLParser(parserOptions);
}
public RuleViolationFactory getRuleViolationFactory() {
return PLSQLRuleViolationFactory.INSTANCE;
}
@Override
public DFAGraphRule getDFAGraphRule() {
return new DFAPLSQLGraphRule();
}
@Override
public DataFlowHandler getDataFlowHandler() {
return new PLSQLDataFlowHandler();
}
@Override
public VisitorStarter getDataFlowFacade() {
return new VisitorStarter() {
public void start(Node rootNode) {
new DataFlowFacade().initializeWith(getDataFlowHandler(), (ASTInput) rootNode);
}
};
}
@Override
public VisitorStarter getSymbolFacade() {
return new VisitorStarter() {
public void start(Node rootNode) {
new SymbolFacade().initializeWith((ASTInput) rootNode);
}
};
}
@Override
public VisitorStarter getDumpFacade(final Writer writer, final String prefix, final boolean recurse) {
return new VisitorStarter() {
public void start(Node rootNode) {
new DumpFacade().initializeWith(writer, prefix, recurse, (PLSQLNode) rootNode);
}
};
}
@Override
/**
* Return minimal XPathHandler to cope with Jaxen XPath Rules.
*/
public XPathHandler getXPathHandler() {
return new XPathHandler() {
public void initialize() {
}
public void initialize(IndependentContext context) {
}
public Navigator getNavigator() {
return new DocumentNavigator();
}
};
}
}

View File

@ -0,0 +1,25 @@
package net.sourceforge.pmd.lang.plsql;
import net.sourceforge.pmd.lang.BaseLanguageModule;
import net.sourceforge.pmd.lang.plsql.rule.PLSQLRuleChainVisitor;
/**
* Created by christoferdutz on 20.09.14.
*/
public class PLSQLLanguageModule extends BaseLanguageModule {
public static final String NAME = "PLSQL";
public PLSQLLanguageModule() {
super(NAME, null, "plsql", PLSQLRuleChainVisitor.class,
"sql", "trg",
"prc", "fnc",
"pld", // Oracle*Forms
"pls" ,"plh" ,"plb", // Packages
"pck" ,"pks" ,"pkh" ,"pkb", // Packages
"typ" ,"tyb", // Object Types
"tps" ,"tpb" /* Object Types*/);
addVersion("", new PLSQLHandler(), true);
}
}

View File

@ -0,0 +1,58 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.plsql;
import java.io.Reader;
import java.util.HashMap;
import java.util.Map;
import net.sourceforge.pmd.lang.AbstractParser;
import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.AbstractTokenManager;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.ParseException;
import net.sourceforge.pmd.util.IOUtil;
/**
* Adapter for the PLSQLParser.
*/
public class PLSQLParser extends AbstractParser {
/*
* Wrapped PLSQL AST parser
*/
private net.sourceforge.pmd.lang.plsql.ast.PLSQLParser parser;
public PLSQLParser(ParserOptions parserOptions) {
super(parserOptions);
}
@Override
public TokenManager createTokenManager(Reader source) {
return new PLSQLTokenManager(IOUtil.skipBOM(source));
}
/**
* Subclass should override this method to modify the PLSQLParser as needed.
*/
protected net.sourceforge.pmd.lang.plsql.ast.PLSQLParser createPLSQLParser(Reader source) throws ParseException {
Reader in = IOUtil.skipBOM(source);
parser = new net.sourceforge.pmd.lang.plsql.ast.PLSQLParser(in);
return parser;
}
public boolean canParse() {
return true;
}
public Node parse(String fileName, Reader source) throws ParseException {
AbstractTokenManager.setFileName(fileName);
return createPLSQLParser(source).Input();
}
public Map<Integer, String> getSuppressMap() {
return new HashMap<Integer, String>(); // FIXME
}
}

View File

@ -0,0 +1,29 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.plsql;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserTokenManager;
/**
* PLSQL Token Manager implementation.
*/
public class PLSQLTokenManager implements TokenManager {
private final PLSQLParserTokenManager tokenManager;
public PLSQLTokenManager(Reader source) {
tokenManager = new PLSQLParserTokenManager(new SimpleCharStream(source));
}
public Object getNextToken() {
return tokenManager.getNextToken();
}
public void setFileName(String fileName) {
tokenManager.setFileName(fileName);
}
}

View File

@ -0,0 +1,31 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTArguments.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTArguments extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode{
public ASTArguments(int id) {
super(id);
}
public ASTArguments(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
public int getArgumentCount() {
if (this.jjtGetNumChildren() == 0) {
return 0;
}
return this.jjtGetChild(0).jjtGetNumChildren();
}
}
/* JavaCC - OriginalChecksum=ac664fde2b2da90710e74c7e9413f59d (do not edit this line) */

View File

@ -0,0 +1,28 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTDatatype.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTDatatype extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode{
public ASTDatatype(int id) {
super(id);
}
public ASTDatatype(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
public String getTypeImage() {
return getImage();
}
}
/* JavaCC - OriginalChecksum=1fa2236ed99d4558f9581a175534f60e (do not edit this line) */

View File

@ -0,0 +1,33 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTFormalParameter.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTFormalParameter extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode{
public ASTFormalParameter(int id) {
super(id);
}
public ASTFormalParameter(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
public ASTDatatype getTypeNode() {
for (int i = 0; i < jjtGetNumChildren(); i++) {
if (jjtGetChild(i) instanceof ASTDatatype) {
return (ASTDatatype) jjtGetChild(i);
}
}
throw new IllegalStateException("ASTType not found");
}
}
/* JavaCC - OriginalChecksum=38c9b79b92b886cd6d4930425644aab3 (do not edit this line) */

View File

@ -0,0 +1,34 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTIfStatement.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTIfStatement extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode{
public ASTIfStatement(int id) {
super(id);
}
public ASTIfStatement(PLSQLParser p, int id) {
super(p, id);
}
private boolean hasElse;
public void setHasElse() {
this.hasElse = true;
}
public boolean hasElse() {
return this.hasElse;
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
}
/* JavaCC - OriginalChecksum=593efca5606eb54375cc42fe11ab9f67 (do not edit this line) */

View File

@ -0,0 +1,26 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTInput.java Version 4.3 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package net.sourceforge.pmd.lang.plsql.ast;
import net.sourceforge.pmd.lang.ast.RootNode;
public
class ASTInput extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode implements RootNode {
public ASTInput(int id) {
super(id);
}
public ASTInput(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
}
/* JavaCC - OriginalChecksum=dce06d3ff338546c4a77f0075b1ed936 (do not edit this line) */

View File

@ -0,0 +1,39 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTMethodDeclaration.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTMethodDeclaration extends AbstractPLSQLNode implements ExecutableCode {
public ASTMethodDeclaration(int id) {
super(id);
}
public ASTMethodDeclaration(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* Gets the name of the method.
*
* @return a String representing the name of the method
*/
@Override
public String getMethodName() {
ASTMethodDeclarator md = getFirstDescendantOfType(ASTMethodDeclarator.class);
if (md != null) {
return md.getImage();
}
return null;
}
}
/* JavaCC - OriginalChecksum=f4e143bd15adcb918d9ecd2757108a24 (do not edit this line) */

View File

@ -0,0 +1,28 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTMethodDeclarator.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTMethodDeclarator extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode{
public ASTMethodDeclarator(int id) {
super(id);
}
public ASTMethodDeclarator(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
public int getParameterCount() {
return this.jjtGetChild(0).jjtGetNumChildren();
}
}
/* JavaCC - OriginalChecksum=e8cd0d5365aa4895507ff58801756649 (do not edit this line) */

View File

@ -0,0 +1,36 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTName.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
import net.sourceforge.pmd.lang.symboltable.NameDeclaration;
public class ASTName extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode{
public ASTName(int id) {
super(id);
}
public ASTName(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
private NameDeclaration nd;
public void setNameDeclaration(NameDeclaration nd) {
this.nd = nd;
}
public NameDeclaration getNameDeclaration() {
return this.nd;
}
}
/* JavaCC - OriginalChecksum=6632a8172232ffa3f56efbf465e4eb8e (do not edit this line) */

View File

@ -0,0 +1,35 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTPackageBody.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTPackageBody extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode
implements OracleObject {
public ASTPackageBody(int id) {
super(id);
}
public ASTPackageBody(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* Gets the name of the Oracle Object.
*
* @return a String representing the name of the Oracle Object
*/
@Override
public String getObjectName() {
return this.getImage();
}
}
/* JavaCC - OriginalChecksum=785e6293e6c4f9271c8377157e7dfa07 (do not edit this line) */

View File

@ -0,0 +1,35 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTPackageSpecification.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTPackageSpecification extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode
implements OracleObject {
public ASTPackageSpecification(int id) {
super(id);
}
public ASTPackageSpecification(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* Gets the name of the Oracle Object.
*
* @return a String representing the name of the Oracle Object
*/
@Override
public String getObjectName() {
return this.getImage();
}
}
/* JavaCC - OriginalChecksum=f002db7d2f63fdbb3a5339191c15692f (do not edit this line) */

View File

@ -0,0 +1,35 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTPrimaryPrefix.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTPrimaryPrefix extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode{
public ASTPrimaryPrefix(int id) {
super(id);
}
public ASTPrimaryPrefix(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
private boolean usesSelfModifier;
public void setUsesSelfModifier() {
usesSelfModifier = true;
}
public boolean usesSelfModifier() {
return this.usesSelfModifier;
}
}
/* JavaCC - OriginalChecksum=35d49f19f54d584ebf4d8b4f022496c3 (do not edit this line) */

View File

@ -0,0 +1,57 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTPrimarySuffix.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTPrimarySuffix extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode{
public ASTPrimarySuffix(int id) {
super(id);
}
public ASTPrimarySuffix(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
private boolean isArguments;
private boolean isArrayDereference;
public void setIsArrayDereference() {
isArrayDereference = true;
}
public boolean isArrayDereference() {
return isArrayDereference;
}
public void setIsArguments() {
this.isArguments = true;
}
public boolean isArguments() {
return this.isArguments;
}
/**
* Get the number of arguments for this primary suffix. One should call
* {@link #isArguments()} to see if there are arguments. If this method is
* called when there are no arguments it returns <code>-1</code>.
* @return A non-negative argument number when there are arguments,
* <code>-1</code> otherwise.
*/
public int getArgumentCount() {
if (!this.isArguments()) {
return -1;
}
return ((ASTArguments)jjtGetChild(jjtGetNumChildren()-1)).getArgumentCount();
}
}
/* JavaCC - OriginalChecksum=5b2263901be5de081a66c8930ce58545 (do not edit this line) */

View File

@ -0,0 +1,63 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTProgramUnit.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
import net.sourceforge.pmd.lang.dfa.DFAGraphMethod;
public class ASTProgramUnit extends AbstractPLSQLNode implements ExecutableCode, OracleObject, DFAGraphMethod {
public ASTProgramUnit(int id) {
super(id);
}
public ASTProgramUnit(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* Gets the name of the method.
*
* @return a String representing the name of the method
*/
@Override
public String getMethodName() {
ASTMethodDeclarator md = getFirstChildOfType(ASTMethodDeclarator.class);
if (md != null) {
return md.getImage();
}
return null;
}
@Override
public String getName() {
return getMethodName();
}
/**
* Gets the name of the Oracle Object.
*
* @return a String representing the name of the Oracle Object
*/
@Override
public String getObjectName() {
//This _IS_ a schema-level Program Unit
if (null == this.jjtGetParent())
{
return this.getImage();
}
else
{
return this.getImage();
}
}
}
/* JavaCC - OriginalChecksum=be7a6f22fbbdc65a66b8033359b677bc (do not edit this line) */

View File

@ -0,0 +1,39 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTTriggerTimingPointSection.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
import net.sourceforge.pmd.lang.dfa.DFAGraphMethod;
public class ASTTriggerTimingPointSection extends AbstractPLSQLNode implements ExecutableCode, DFAGraphMethod {
public ASTTriggerTimingPointSection(int id) {
super(id);
}
public ASTTriggerTimingPointSection(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* return executable's name.
* @return
*/
public String getMethodName() {
return getImage() ;
}
@Override
public String getName() {
return getMethodName();
}
}
/* JavaCC - OriginalChecksum=ee9e04c0fd739f2d5d61c4eef34c70f6 (do not edit this line) */

View File

@ -0,0 +1,50 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTTriggerUnit.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
import net.sourceforge.pmd.lang.dfa.DFAGraphMethod;
public class ASTTriggerUnit extends AbstractPLSQLNode implements ExecutableCode, OracleObject, DFAGraphMethod {
public ASTTriggerUnit(int id) {
super(id);
}
public ASTTriggerUnit(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* Gets the name of the trigger.
*
* @return a String representing the name of the trigger
*/
public String getMethodName() {
return getImage();
}
@Override
public String getName() {
return getMethodName();
}
/**
* Gets the name of the Oracle Object.
*
* @return a String representing the name of the Oracle Object
*/
@Override
public String getObjectName() {
return getImage();
}
}
/* JavaCC - OriginalChecksum=07e71d00050b4945c960cb84ed1cad6c (do not edit this line) */

View File

@ -0,0 +1,44 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTTypeMethod.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
import net.sourceforge.pmd.lang.dfa.DFAGraphMethod;
public class ASTTypeMethod extends AbstractPLSQLNode implements ExecutableCode, DFAGraphMethod {
public ASTTypeMethod(int id) {
super(id);
}
public ASTTypeMethod(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* Gets the name of the method.
*
* @return a String representing the name of the method
*/
public String getMethodName() {
ASTMethodDeclarator md = getFirstChildOfType(ASTMethodDeclarator.class);
if (md != null) {
return md.getImage();
}
return null;
}
@Override
public String getName() {
return getMethodName();
}
}
/* JavaCC - OriginalChecksum=657963d26263c637fa18391bce82f1c1 (do not edit this line) */

View File

@ -0,0 +1,35 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTTypeSpecification.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
public class ASTTypeSpecification extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode
implements OracleObject {
public ASTTypeSpecification(int id) {
super(id);
}
public ASTTypeSpecification(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
/**
* Gets the name of the Oracle Object.
*
* @return a String representing the name of the Oracle Object
*/
@Override
public String getObjectName() {
return this.getImage();
}
}
/* JavaCC - OriginalChecksum=71647f77a828bee6feba3ee70c44206c (do not edit this line) */

View File

@ -0,0 +1,89 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. ASTVariableOrConstantDeclaratorId.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
import java.util.List;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.symboltable.NameDeclaration;
import net.sourceforge.pmd.lang.symboltable.NameOccurrence;
public class ASTVariableOrConstantDeclaratorId extends net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode{
public ASTVariableOrConstantDeclaratorId(int id) {
super(id);
}
public ASTVariableOrConstantDeclaratorId(PLSQLParser p, int id) {
super(p, id);
}
/** Accept the visitor. **/
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
private int arrayDepth;
private NameDeclaration nameDeclaration;
public NameDeclaration getNameDeclaration() {
return nameDeclaration;
}
public void setNameDeclaration(NameDeclaration decl) {
nameDeclaration = decl;
}
public List<NameOccurrence> getUsages() {
return getScope().getDeclarations().get(nameDeclaration);
}
public void bumpArrayDepth() {
arrayDepth++;
}
public int getArrayDepth() {
return arrayDepth;
}
public boolean isArray() {
return arrayDepth > 0;
}
public Node getTypeNameNode() {
if (jjtGetParent() instanceof ASTFormalParameter) {
return findTypeNameNode(jjtGetParent());
}
else if (jjtGetParent().jjtGetParent() instanceof ASTVariableOrConstantDeclaration
||
jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration
)
{
return findTypeNameNode(jjtGetParent().jjtGetParent());
}
throw new RuntimeException("Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
}
public ASTDatatype getTypeNode() {
if (jjtGetParent() instanceof ASTFormalParameter) {
return ((ASTFormalParameter) jjtGetParent()).getTypeNode();
} else {
Node n = jjtGetParent().jjtGetParent();
if (n instanceof ASTVariableOrConstantDeclaration || n instanceof ASTFieldDeclaration) {
return n.getFirstChildOfType(ASTDatatype.class);
}
}
throw new RuntimeException("Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
}
private Node findTypeNameNode(Node node) {
ASTDatatype typeNode = (ASTDatatype) node.jjtGetChild(0);
return typeNode.jjtGetChild(0);
}
}
/* JavaCC - OriginalChecksum=935037739d9116b8c87f25deb4faa2d0 (do not edit this line) */

View File

@ -0,0 +1,118 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
/* Generated By:JJTree: Do not edit this line. SimpleNode.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=AST,NODE_EXTENDS=net.sourceforge.pmd.lang.ast.AbstractNode,NODE_FACTORY= */
package net.sourceforge.pmd.lang.plsql.ast;
import net.sourceforge.pmd.lang.symboltable.Scope;
public abstract class AbstractPLSQLNode extends net.sourceforge.pmd.lang.ast.AbstractNode implements PLSQLNode {
protected Object value;
protected PLSQLParser parser;
protected Scope scope;
public AbstractPLSQLNode(int i) {
super(i);
}
public AbstractPLSQLNode(PLSQLParser p, int i) {
this(i);
parser = p;
}
public void jjtOpen() {
if (beginLine == -1 && parser.token.next != null) {
beginLine = parser.token.next.beginLine;
beginColumn = parser.token.next.beginColumn;
}
}
public void jjtClose() {
if (beginLine == -1 && (children == null || children.length == 0)) {
beginColumn = parser.token.beginColumn;
}
if (beginLine == -1) {
beginLine = parser.token.beginLine;
}
endLine = parser.token.endLine;
endColumn = parser.token.endColumn;
}
public void jjtSetValue(Object value) { this.value = value; }
public Object jjtGetValue() { return value; }
@Override
public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
@Override
public Object childrenAccept(PLSQLParserVisitor visitor, Object data) {
if (children != null) {
for (int i = 0; i < children.length; ++i) {
((PLSQLNode)children[i]).jjtAccept(visitor, data);
}
}
return data;
}
/* You can override these two methods in subclasses of SimpleNode to
customize the way the node appears when the tree is dumped. If
your output uses more than one line you should override
toString(String), otherwise overriding toString() is probably all
you need to do. */
public String toString() { return PLSQLParserTreeConstants.jjtNodeName[id]; }
public String toString(String prefix) { return prefix + toString(); }
/* Override this method if you want to customize how the node dumps
out its children. */
public void dump(String prefix) {
System.out.println(toString(prefix));
if (children != null) {
for (int i = 0; i < children.length; ++i) {
AbstractPLSQLNode n = (AbstractPLSQLNode)children[i];
if (n != null) {
n.dump(prefix + " ");
}
}
}
}
/**
* Return node image converted to the normal Oracle form.
*
* <p>
* Normally this is uppercase, unless the names is quoted ("name").
* </p>
*/
public String getCanonicalImage() { return PLSQLParser.canonicalName(this.getImage()); }
/** Convert arbitrary String to normal Oracle format, under assumption that the passed image is an Oracle name.
*
* <p>
* This a helper method for PLSQL classes dependent on SimpleNode, that would otherwise have to import PLSQParser.
* </p>
* @param image
* @return
*/
static public String getCanonicalImage(String image) { return PLSQLParser.canonicalName(image); }
@Override
public Scope getScope() {
if (scope == null) {
return ((PLSQLNode) parent).getScope();
}
return scope;
}
@Override
public void setScope(Scope scope) {
this.scope = scope;
}
}
/* JavaCC - OriginalChecksum=3f651517d5069f856891d89230562ac4 (do not edit this line) */

View File

@ -0,0 +1,106 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.plsql.ast;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
public class DumpFacade extends PLSQLParserVisitorAdapter {
private PrintWriter writer;
private boolean recurse;
public void initializeWith(Writer writer, String prefix, boolean recurse, PLSQLNode node) {
this.writer = (writer instanceof PrintWriter) ? (PrintWriter) writer : new PrintWriter(writer);
this.recurse = recurse;
this.visit(node, prefix);
try {
writer.flush();
} catch (IOException e) {
throw new RuntimeException("Problem flushing PrintWriter.", e);
}
}
@Override
public Object visit(PLSQLNode node, Object data) {
dump(node, (String) data);
if (recurse) {
return super.visit(node, data + " ");
} else {
return data;
}
}
private void dump(PLSQLNode node, String prefix) {
//
// Dump format is generally composed of the following items...
//
// 1) Dump prefix
writer.print(prefix);
// 2) JJT Name of the Node
writer.print(node.toString());
//
// If there are any additional details, then:
// 1) A colon
// 2) The Node.getImage() if it is non-empty
// 3) Extras in parentheses
//
// Standard image handling
String image = node.getImage();
// Special image handling (e.g. Nodes with normally null images)
if (node instanceof ASTBooleanLiteral) {
image = node.getImage();
} else if (node instanceof ASTPrimaryPrefix) {
ASTPrimaryPrefix primaryPrefix = (ASTPrimaryPrefix) node;
String result = null;
/*
if (primaryPrefix.usesSuperModifier()) {
result = "super";
} else if (primaryPrefix.usesThisModifier()) {
result = "this";
}
*/
if (image != null) {
result += "." + image;
}
image = result;
} else if (node instanceof ASTPrimarySuffix) {
ASTPrimarySuffix primarySuffix = (ASTPrimarySuffix) node;
if (primarySuffix.isArrayDereference()) {
if (image == null) {
image = "[";
} else {
image = "[" + image;
}
}
}
// Extras
List<String> extras = new ArrayList<String>();
// Output image and extras
if (image != null || !extras.isEmpty()) {
writer.print(':');
if (image != null) {
writer.print(image);
}
for (String extra : extras) {
writer.print('(');
writer.print(extra);
writer.print(')');
}
}
writer.println();
}
}

Some files were not shown because too many files have changed in this diff Show More