Remove plsql processing stages

This commit is contained in:
Clément Fournier
2020-12-15 11:36:17 +01:00
parent c519b84024
commit c37c87655b
5 changed files with 12 additions and 88 deletions

View File

@ -16,11 +16,6 @@ import net.sourceforge.pmd.lang.plsql.ast.PLSQLParser;
*/
public class PLSQLHandler extends AbstractPmdLanguageVersionHandler {
public PLSQLHandler() {
super(PlsqlProcessingStage.class);
}
@Override
public Parser getParser() {
return new PLSQLParser();

View File

@ -1,70 +0,0 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.plsql;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.sourceforge.pmd.annotation.Experimental;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.ast.AstAnalysisContext;
import net.sourceforge.pmd.lang.ast.AstProcessingStage;
import net.sourceforge.pmd.lang.ast.RootNode;
import net.sourceforge.pmd.lang.plsql.ast.ASTInput;
import net.sourceforge.pmd.lang.plsql.symboltable.SymbolFacade;
/**
* PL-SQL AST processing stages.
*
* @author Clément Fournier
* @since 7.0.0
*/
@Experimental
public enum PlsqlProcessingStage implements AstProcessingStage<PlsqlProcessingStage> {
/**
* Symbol table analysis.
*/
SYMBOL_RESOLUTION("Symbol table") {
@Override
public void processAST(RootNode rootNode, AstAnalysisContext configuration) {
new SymbolFacade().initializeWith((ASTInput) rootNode);
}
};
private final String displayName;
private final List<PlsqlProcessingStage> dependencies;
PlsqlProcessingStage(String displayName, PlsqlProcessingStage... dependencies) {
this.displayName = displayName;
this.dependencies = Collections.unmodifiableList(Arrays.asList(dependencies));
}
@Override
public Language getLanguage() {
return LanguageRegistry.findLanguageByTerseName("plsql");
}
@Override
public List<PlsqlProcessingStage> getDependencies() {
return dependencies;
}
@Override
public String getDisplayName() {
return displayName;
}
}

View File

@ -6,10 +6,12 @@ package net.sourceforge.pmd.lang.plsql.ast;
import org.checkerframework.checker.nullness.qual.Nullable;
import net.sourceforge.pmd.benchmark.TimeTracker;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.ParseException;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument;
import net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeParserAdapter;
import net.sourceforge.pmd.lang.plsql.symboltable.SymbolFacade;
public class PLSQLParser extends JjtreeParserAdapter<ASTInput> {
@ -25,7 +27,9 @@ public class PLSQLParser extends JjtreeParserAdapter<ASTInput> {
@Override
protected ASTInput parseImpl(CharStream cs, ParserTask task) throws ParseException {
return new PLSQLParserImpl(cs).Input().addTaskInfo(task);
ASTInput root = new PLSQLParserImpl(cs).Input().addTaskInfo(task);
TimeTracker.bench("PLSQL symbols", () -> SymbolFacade.process(root));
return root;
}
}

View File

@ -8,10 +8,8 @@ import java.util.logging.Logger;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.ast.AstProcessingStage;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.plsql.PLSQLLanguageModule;
import net.sourceforge.pmd.lang.plsql.PlsqlProcessingStage;
import net.sourceforge.pmd.lang.plsql.ast.ASTInput;
import net.sourceforge.pmd.lang.plsql.ast.ASTPackageBody;
import net.sourceforge.pmd.lang.plsql.ast.ASTPackageSpecification;
@ -85,14 +83,6 @@ public abstract class AbstractPLSQLRule extends AbstractRule implements PLSQLPar
return false;
}
@Override
public boolean dependsOn(AstProcessingStage<?> stage) {
if (!(stage instanceof PlsqlProcessingStage)) {
throw new IllegalArgumentException("Processing stage wasn't a " + PLSQLLanguageModule.NAME + " one: " + stage);
}
return true;
}
/*
* Treat all Executable Code
*/

View File

@ -6,8 +6,13 @@ package net.sourceforge.pmd.lang.plsql.symboltable;
import net.sourceforge.pmd.lang.plsql.ast.ASTInput;
public class SymbolFacade {
public void initializeWith(ASTInput node) {
public final class SymbolFacade {
private SymbolFacade() {
}
public static void process(ASTInput node) {
ScopeAndDeclarationFinder sc = new ScopeAndDeclarationFinder();
node.acceptVisitor(sc, null);
OccurrenceFinder of = new OccurrenceFinder();