From c37c87655b14bbeed682b6afb31512ed71e11190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Tue, 15 Dec 2020 11:36:17 +0100 Subject: [PATCH] Remove plsql processing stages --- .../pmd/lang/plsql/PLSQLHandler.java | 5 -- .../pmd/lang/plsql/PlsqlProcessingStage.java | 70 ------------------- .../pmd/lang/plsql/ast/PLSQLParser.java | 6 +- .../lang/plsql/rule/AbstractPLSQLRule.java | 10 --- .../lang/plsql/symboltable/SymbolFacade.java | 9 ++- 5 files changed, 12 insertions(+), 88 deletions(-) delete mode 100644 pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PlsqlProcessingStage.java diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLHandler.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLHandler.java index a403100e40..5c6b7295e3 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLHandler.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLHandler.java @@ -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(); diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PlsqlProcessingStage.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PlsqlProcessingStage.java deleted file mode 100644 index 53f496db42..0000000000 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PlsqlProcessingStage.java +++ /dev/null @@ -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 { - - /** - * 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 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 getDependencies() { - return dependencies; - } - - - @Override - public String getDisplayName() { - return displayName; - } - - -} - diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParser.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParser.java index c15ab94e8d..611d7d077a 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParser.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParser.java @@ -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 { @@ -25,7 +27,9 @@ public class PLSQLParser extends JjtreeParserAdapter { @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; } } diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/AbstractPLSQLRule.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/AbstractPLSQLRule.java index ddf6f17c3c..dd512e9abe 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/AbstractPLSQLRule.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/AbstractPLSQLRule.java @@ -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 */ diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/SymbolFacade.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/SymbolFacade.java index 88f645dd9b..3cda6ef332 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/SymbolFacade.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/SymbolFacade.java @@ -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();