From e29dba9ef863615667ebedc2f22d6f4a70d53e46 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Sat, 19 Jan 2019 11:22:58 +0100 Subject: [PATCH 01/18] Next dev cycle --- database-parser/pom.xml | 2 +- listing-parser/pom.xml | 2 +- openedge-checks/pom.xml | 6 +++--- openedge-plugin/pom.xml | 8 ++++---- pom.xml | 2 +- profiler-parser/pom.xml | 2 +- proparse/pom.xml | 4 ++-- rcode-reader/pom.xml | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/database-parser/pom.xml b/database-parser/pom.xml index 56ae9cdee..b89b65c5b 100644 --- a/database-parser/pom.xml +++ b/database-parser/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers database-parser - 2.3.0 + 2.4.0-SNAPSHOT OpenEdge database definition lexer and parser OpenEdge dump files parser diff --git a/listing-parser/pom.xml b/listing-parser/pom.xml index e96009082..c02591f89 100644 --- a/listing-parser/pom.xml +++ b/listing-parser/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers listing-parser - 2.3.0 + 2.4.0-SNAPSHOT OpenEdge listing so-called parser OpenEdge listing files parser diff --git a/openedge-checks/pom.xml b/openedge-checks/pom.xml index d71d1e984..d16abccce 100644 --- a/openedge-checks/pom.xml +++ b/openedge-checks/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.checks openedge-checks - 2.3.0 + 2.4.0-SNAPSHOT OpenEdge checks OpenEdge checks @@ -54,12 +54,12 @@ eu.rssw.openedge.parsers database-parser - 2.3.0 + 2.4.0-SNAPSHOT eu.rssw.openedge.parsers proparse - 2.3.0 + 2.4.0-SNAPSHOT org.testng diff --git a/openedge-plugin/pom.xml b/openedge-plugin/pom.xml index 09829d364..1b30db767 100644 --- a/openedge-plugin/pom.xml +++ b/openedge-plugin/pom.xml @@ -4,7 +4,7 @@ eu.rssw.sonar.openedge sonar-openedge-plugin - 2.3.0 + 2.4.0-SNAPSHOT sonar-plugin OpenEdge plugin for SonarQube @@ -62,17 +62,17 @@ eu.rssw.openedge.checks openedge-checks - 2.3.0 + 2.4.0-SNAPSHOT eu.rssw.openedge.parsers listing-parser - 2.3.0 + 2.4.0-SNAPSHOT eu.rssw.openedge.parsers profiler-parser - 2.3.0 + 2.4.0-SNAPSHOT commons-lang diff --git a/pom.xml b/pom.xml index c5491b498..66c2cd142 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ eu.rssw sonar-openedge pom - 2.3.0 + 2.4.0-SNAPSHOT OpenEdge plugin for SonarQube http://www.riverside-software.fr/ Open source code analysis for OpenEdge diff --git a/profiler-parser/pom.xml b/profiler-parser/pom.xml index 1f0a90b47..59dbb84d2 100644 --- a/profiler-parser/pom.xml +++ b/profiler-parser/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers profiler-parser - 2.3.0 + 2.4.0-SNAPSHOT OpenEdge profiler output lexer and parser OpenEdge profiler files parser diff --git a/proparse/pom.xml b/proparse/pom.xml index 1937bddb1..e350b6730 100644 --- a/proparse/pom.xml +++ b/proparse/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers proparse - 2.3.0 + 2.4.0-SNAPSHOT Proparse ABL code parser @@ -54,7 +54,7 @@ eu.rssw.openedge.rcode rcode-reader - 2.3.0 + 2.4.0-SNAPSHOT antlr diff --git a/rcode-reader/pom.xml b/rcode-reader/pom.xml index 6aa698899..6d3da22e1 100644 --- a/rcode-reader/pom.xml +++ b/rcode-reader/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.rcode rcode-reader - 2.3.0 + 2.4.0-SNAPSHOT rcode-reader rcode reader From 9166def3fc63b753a2651c34f9f8f5919f916166 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Mon, 21 Jan 2019 22:54:17 +0100 Subject: [PATCH 02/18] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6dd15ff78..d905f24a1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# OpenEdge plugin for SonarQube +# CABL - Code Analyzer for ABL -The OpenEdge plugin for SonarQube enables analysis of OpenEdge procedural and object-oriented code, and reports: +CABL enables analysis of OpenEdge procedural and object-oriented code on the SonarQube platform, by reporting: * Metrics (lines of code, comment density, complexity, shared objects, ...) * Issues found in the source code and DF files, such as performance killers, usage of deprecated keywords, ... * Code coverage from unit tests From f1f73fd55b40e9731f9abf42ebf5d0d1f268df49 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Tue, 5 Feb 2019 08:51:48 +0100 Subject: [PATCH 03/18] Delayed initialization of OpenEdgeSettings object (#645) Issue #644 --- .../openedge/foundation/OpenEdgeSettings.java | 7 ++++ .../sensor/OpenEdgeCodeColorizer.java | 2 +- .../sensor/OpenEdgeProparseSensor.java | 2 +- .../sensor/OpenEdgeWarningsSensor.java | 2 +- .../openedge/foundation/CPDCallbackTest.java | 36 +++++++++++++------ 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeSettings.java b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeSettings.java index d60dbaf4b..a253e1a2a 100644 --- a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeSettings.java +++ b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeSettings.java @@ -89,6 +89,7 @@ public class OpenEdgeSettings { private final SonarRuntime runtime; // Internal use + private boolean init = false; private final List sourcePaths = new ArrayList<>(); private final List binariesDirs = new ArrayList<>(); private final List pctDirs = new ArrayList<>(); @@ -105,6 +106,11 @@ public OpenEdgeSettings(Configuration config, FileSystem fileSystem, SonarRuntim this.config = config; this.fileSystem = fileSystem; this.runtime = runtime; + } + + public final void init() { + if (init) + return; LOG.info("Loading OpenEdge settings for server ID '{}' '{}'", config.get(CoreProperties.SERVER_ID).orElse(""), config.get(CoreProperties.PERMANENT_SERVER_ID).orElse("")); @@ -118,6 +124,7 @@ public OpenEdgeSettings(Configuration config, FileSystem fileSystem, SonarRuntim if (useXrefFilter()) { LOG.info("XML XREF filter activated [{}]", getXrefBytesAsString()); } + init = true; } private final void initializeDirectories(Configuration config, FileSystem fileSystem) { diff --git a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeCodeColorizer.java b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeCodeColorizer.java index f16d950ef..6fe0744c6 100644 --- a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeCodeColorizer.java +++ b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeCodeColorizer.java @@ -61,7 +61,7 @@ public void describe(SensorDescriptor descriptor) { public void execute(SensorContext context) { if (context.runtime().getProduct() == SonarProduct.SONARLINT) return; - + settings.init(); RefactorSession session = settings.getProparseSession(); for (InputFile file : context.fileSystem().inputFiles( diff --git a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeProparseSensor.java b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeProparseSensor.java index 7a44f2c09..309fbf42a 100644 --- a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeProparseSensor.java +++ b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeProparseSensor.java @@ -157,7 +157,7 @@ public void describe(SensorDescriptor descriptor) { public void execute(SensorContext context) { if (settings.skipProparseSensor()) return; - + settings.init(); components.initializeLicense(context); components.initializeChecks(context); for (Map.Entry entry : components.getProparseRules().entrySet()) { diff --git a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeWarningsSensor.java b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeWarningsSensor.java index 7f8dffb03..68fe82991 100644 --- a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeWarningsSensor.java +++ b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/sensor/OpenEdgeWarningsSensor.java @@ -67,7 +67,7 @@ public void describe(SensorDescriptor descriptor) { public void execute(SensorContext context) { if (context.runtime().getProduct() == SonarProduct.SONARLINT) return; - + settings.init(); int warningsImportNum = 0; final RuleKey defaultWarningRuleKey = RuleKey.of(Constants.STD_REPOSITORY_KEY, OpenEdgeRulesDefinition.COMPILER_WARNING_RULEKEY); diff --git a/openedge-plugin/src/test/java/org/sonar/plugins/openedge/foundation/CPDCallbackTest.java b/openedge-plugin/src/test/java/org/sonar/plugins/openedge/foundation/CPDCallbackTest.java index a398bf655..166aaa76b 100644 --- a/openedge-plugin/src/test/java/org/sonar/plugins/openedge/foundation/CPDCallbackTest.java +++ b/openedge-plugin/src/test/java/org/sonar/plugins/openedge/foundation/CPDCallbackTest.java @@ -60,9 +60,11 @@ public void initContext() throws IOException { @Test public void test1() { SensorContextTester context = SensorContextTester.create(new File(BASEDIR)); + OpenEdgeSettings settings = new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)); + settings.init(); InputFile inputFile = getInputFile(context, "cpd01.p"); ParseUnit unit = getParseUnit(inputFile); - ICallback callback = new CPDCallback(context, inputFile, new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)), unit); + ICallback callback = new CPDCallback(context, inputFile, settings, unit); unit.getTopNode().walk(callback); callback.getResult().save(); @@ -77,9 +79,11 @@ public void test1() { @Test public void test2() { SensorContextTester context = SensorContextTester.create(new File(BASEDIR)); + OpenEdgeSettings settings = new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)); + settings.init(); InputFile inputFile = getInputFile(context, "cpd02.p"); ParseUnit unit = getParseUnit(inputFile); - ICallback callback = new CPDCallback(context, inputFile, new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)), unit); + ICallback callback = new CPDCallback(context, inputFile, settings, unit); unit.getTopNode().walk(callback); callback.getResult().save(); @@ -97,9 +101,11 @@ public void test2() { @Test public void test3() { SensorContextTester context = SensorContextTester.create(new File(BASEDIR)); + OpenEdgeSettings settings = new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)); + settings.init(); InputFile inputFile = getInputFile(context, "cpd03.p"); ParseUnit unit = getParseUnit(inputFile); - ICallback callback = new CPDCallback(context, inputFile, new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)), unit); + ICallback callback = new CPDCallback(context, inputFile, settings, unit); unit.getTopNode().walk(callback); callback.getResult().save(); @@ -114,9 +120,11 @@ public void test3() { @Test public void testNoProperties() { SensorContextTester context = SensorContextTester.create(new File(BASEDIR)); + OpenEdgeSettings settings = new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)); + settings.init(); InputFile inputFile = getInputFile(context, "cpd04.p"); ParseUnit unit = getParseUnit(inputFile); - ICallback callback = new CPDCallback(context, inputFile, new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)), unit); + ICallback callback = new CPDCallback(context, inputFile, settings, unit); unit.getTopNode().walk(callback); callback.getResult().save(); List lines = context.cpdTokens(inputFile.key()); @@ -127,10 +135,12 @@ public void testNoProperties() { @Test public void testAnnotations() { SensorContextTester context = SensorContextTester.create(new File(BASEDIR)); + context.settings().setProperty(Constants.CPD_ANNOTATIONS, "Generated"); + OpenEdgeSettings settings = new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)); + settings.init(); InputFile inputFile = getInputFile(context, "cpd04.p"); ParseUnit unit = getParseUnit(inputFile); - context.settings().setProperty(Constants.CPD_ANNOTATIONS, "Generated"); - ICallback callback = new CPDCallback(context, inputFile, new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)), unit); + ICallback callback = new CPDCallback(context, inputFile, settings, unit); unit.getTopNode().walk(callback); callback.getResult().save(); @@ -142,10 +152,12 @@ public void testAnnotations() { @Test public void testProcedures() { SensorContextTester context = SensorContextTester.create(new File(BASEDIR)); + context.settings().setProperty(Constants.CPD_PROCEDURES, "p1,p4,p3"); + OpenEdgeSettings settings = new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)); + settings.init(); InputFile inputFile = getInputFile(context, "cpd04.p"); ParseUnit unit = getParseUnit(inputFile); - context.settings().setProperty(Constants.CPD_PROCEDURES, "p1,p4,p3"); - ICallback callback = new CPDCallback(context, inputFile, new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)), unit); + ICallback callback = new CPDCallback(context, inputFile, settings, unit); unit.getTopNode().walk(callback); callback.getResult().save(); @@ -157,11 +169,13 @@ public void testProcedures() { @Test public void testAnnotationsAndProcedures() { SensorContextTester context = SensorContextTester.create(new File(BASEDIR)); - InputFile inputFile = getInputFile(context, "cpd04.p"); - ParseUnit unit = getParseUnit(inputFile); context.settings().setProperty(Constants.CPD_ANNOTATIONS, "Generated"); context.settings().setProperty(Constants.CPD_PROCEDURES, "p1,p4,p5"); - ICallback callback = new CPDCallback(context, inputFile, new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)), unit); + OpenEdgeSettings settings = new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)); + settings.init(); + InputFile inputFile = getInputFile(context, "cpd04.p"); + ParseUnit unit = getParseUnit(inputFile); + ICallback callback = new CPDCallback(context, inputFile, settings, unit); unit.getTopNode().walk(callback); callback.getResult().save(); From bc249a71311e9d52f56dcb1c48d310016f75ed57 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Tue, 5 Feb 2019 09:17:37 +0100 Subject: [PATCH 04/18] Sonar warnings --- .../plugins/openedge/foundation/OpenEdgeDB.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeDB.java b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeDB.java index d9c4f5b11..70655a2db 100644 --- a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeDB.java +++ b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeDB.java @@ -19,32 +19,18 @@ */ package org.sonar.plugins.openedge.foundation; -import java.util.List; - import org.sonar.api.resources.AbstractLanguage; import org.sonar.plugins.openedge.api.Constants; -import com.google.common.collect.ImmutableList; - public class OpenEdgeDB extends AbstractLanguage { - public final List extensions; public OpenEdgeDB() { super(Constants.DB_LANGUAGE_KEY, "OpenEdgeDB"); - extensions = ImmutableList.of(".df"); } @Override public String[] getFileSuffixes() { - return extensions.toArray(new String[] {}); + return new String[] { ".df" }; } - /** - * Returns the list of managed extensions - * - * @return A non-null List - */ - public List getFileSuffixesList() { - return extensions; - } } From e2cffebd6ffc50e56a130c3a6fc061e132534cab Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Mon, 11 Mar 2019 15:42:32 +0100 Subject: [PATCH 05/18] Issue #648 - Support for SERIALIZABLE and NON-SERIALIZABLE keywords --- BaseTokenTypes.txt | 3 ++- proparse/BaseTokenTypes.txt | 3 ++- proparse/src/main/antlr/JPTreeParser.g | 2 +- proparse/src/main/antlr/proparse.g | 2 ++ proparse/src/main/java/org/prorefactor/core/ABLNodeType.java | 1 + .../test/java/org/prorefactor/core/unittest/BugFixTest.java | 5 +++++ proparse/src/test/resources/data/bugsfixed/serialkw.cls | 5 +++++ 7 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 proparse/src/test/resources/data/bugsfixed/serialkw.cls diff --git a/BaseTokenTypes.txt b/BaseTokenTypes.txt index 02be872d4..5f024a250 100644 --- a/BaseTokenTypes.txt +++ b/BaseTokenTypes.txt @@ -1232,4 +1232,5 @@ OPTIONSFILE=1234 SINGLERUN=1235 SINGLETON=1236 PROCESSARCHITECTURE=1237 -Last_Token_Number=1238 +NONSERIALIZABLE=1238 +Last_Token_Number=1239 diff --git a/proparse/BaseTokenTypes.txt b/proparse/BaseTokenTypes.txt index 02be872d4..5f024a250 100644 --- a/proparse/BaseTokenTypes.txt +++ b/proparse/BaseTokenTypes.txt @@ -1232,4 +1232,5 @@ OPTIONSFILE=1234 SINGLERUN=1235 SINGLETON=1236 PROCESSARCHITECTURE=1237 -Last_Token_Number=1238 +NONSERIALIZABLE=1238 +Last_Token_Number=1239 diff --git a/proparse/src/main/antlr/JPTreeParser.g b/proparse/src/main/antlr/JPTreeParser.g index 15c3dbe8b..6f45ad70f 100644 --- a/proparse/src/main/antlr/JPTreeParser.g +++ b/proparse/src/main/antlr/JPTreeParser.g @@ -1399,7 +1399,7 @@ def_shared: ; def_modifiers: - ( PRIVATE | PROTECTED | PUBLIC | STATIC | ABSTRACT | OVERRIDE | FINAL )* + ( PRIVATE | PROTECTED | PUBLIC | STATIC | ABSTRACT | OVERRIDE | FINAL | NONSERIALIZABLE | SERIALIZABLE )* ; definebrowsestate: diff --git a/proparse/src/main/antlr/proparse.g b/proparse/src/main/antlr/proparse.g index 939b5c782..2e0bca55d 100644 --- a/proparse/src/main/antlr/proparse.g +++ b/proparse/src/main/antlr/proparse.g @@ -2021,6 +2021,8 @@ definestatement: | ABSTRACT | STATIC | OVERRIDE + | NONSERIALIZABLE + | SERIALIZABLE )* ( definebrowsestate {sthd(##,BROWSE);} | definebufferstate {sthd(##,BUFFER);} diff --git a/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java b/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java index 93be53037..9a1f730ae 100644 --- a/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java +++ b/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java @@ -891,6 +891,7 @@ public enum ABLNodeType { NOMAP(ProParserTokenTypes.NOMAP, "no-map", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), NOMESSAGE(ProParserTokenTypes.NOMESSAGE, "no-message", 6, NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), NONE(ProParserTokenTypes.NONE, "none", NodeTypesOption.KEYWORD), + NONSERIALIZABLE(ProParserTokenTypes.NONSERIALIZABLE, "non-serializable", NodeTypesOption.KEYWORD), NOPAUSE(ProParserTokenTypes.NOPAUSE, "no-pause", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), NOPREFETCH(ProParserTokenTypes.NOPREFETCH, "no-prefetch", 8, NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), NORETURNVALUE(ProParserTokenTypes.NORETURNVALUE, "no-return-value", 13, NodeTypesOption.KEYWORD, diff --git a/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java b/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java index 62cd7d37f..562e4c2d3 100644 --- a/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java +++ b/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java @@ -348,6 +348,11 @@ public void test36() throws ANTLRException { // genericTest("CacheChild.cls"); // } + @Test + public void testSerializableKeyword() throws ANTLRException { + genericTest("serialkw.cls"); + } + @Test public void testSaxWriter() throws ANTLRException { genericTest("sax-writer.p"); diff --git a/proparse/src/test/resources/data/bugsfixed/serialkw.cls b/proparse/src/test/resources/data/bugsfixed/serialkw.cls new file mode 100644 index 000000000..c49ebc40c --- /dev/null +++ b/proparse/src/test/resources/data/bugsfixed/serialkw.cls @@ -0,0 +1,5 @@ +class serialkw abstract serializable: + define private serializable temp-table test no-undo + field test as integer. + define non-serializable property prop as char get. +end class. From 8b5751fffc7ba8fb5d18e5e0a30a82b201ebe5ae Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Mon, 11 Mar 2019 15:36:46 +0100 Subject: [PATCH 06/18] Issue #648 - Lexer enhancement on negative hex numbers --- .../prorefactor/proparse/antlr4/Lexer.java | 43 +++++++++--- .../prorefactor/core/unittest/LexerTest.java | 66 +++++++++++++++++++ .../src/test/resources/data/lexer/lexer16.p | 1 + .../src/test/resources/data/lexer/lexer17.p | 1 + 4 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 proparse/src/test/resources/data/lexer/lexer16.p create mode 100644 proparse/src/test/resources/data/lexer/lexer17.p diff --git a/proparse/src/main/java/org/prorefactor/proparse/antlr4/Lexer.java b/proparse/src/main/java/org/prorefactor/proparse/antlr4/Lexer.java index f51d58512..d4d9db778 100644 --- a/proparse/src/main/java/org/prorefactor/proparse/antlr4/Lexer.java +++ b/proparse/src/main/java/org/prorefactor/proparse/antlr4/Lexer.java @@ -213,6 +213,15 @@ public ProToken nextToken() { return makeToken(ABLNodeType.BACKTICK); case '0': + getChar(); + if ((currChar == 'x') || (currChar == 'X')) { + append(); + getChar(); + return digitStart(true); + } else { + return digitStart(false); + } + case '1': case '2': case '3': @@ -223,7 +232,7 @@ public ProToken nextToken() { case '8': case '9': getChar(); - return digitStart(); + return digitStart(false); case '.': getChar(); @@ -491,7 +500,7 @@ ProToken quotedString() { return makeToken(ABLNodeType.QSTRING); } - ProToken digitStart() { + ProToken digitStart(boolean hex) { LOGGER.trace("Entering digitStart()"); ABLNodeType ttype = ABLNodeType.NUMBER; @@ -516,6 +525,17 @@ ProToken digitStart() { case 'd': case 'e': case 'f': + if (hex) { + append(); + getChar(); + break; + } else { + append(); + getChar(); + if (ttype != ABLNodeType.FILENAME) + ttype = ABLNodeType.ID; + break; + } case 'g': case 'h': case 'i': @@ -579,15 +599,21 @@ ProToken digitStart() { } ProToken plusMinusStart(ABLNodeType inputType) { - LOGGER.trace("Entering plusMinusStart()"); + LOGGER.trace("Entering plusMinusStart()"); ABLNodeType ttype = ABLNodeType.NUMBER; for_loop : for (;;) { switch (currChar) { - // We don't know here if the plus or minus is in the middle or at the end. - // Don't change ttype. - case '+': - case '-': case '0': + append(); + getChar(); + if ((currChar == 'x') || (currChar == 'X')) { + append(); + getChar(); + return digitStart(true); + } else { + return digitStart(false); + } + case '1': case '2': case '3': @@ -599,7 +625,8 @@ ProToken plusMinusStart(ABLNodeType inputType) { case '9': append(); getChar(); - break; + return digitStart(false); + // Leave comma out of this. -1, might be part of an expression list. case '#': case '$': diff --git a/proparse/src/test/java/org/prorefactor/core/unittest/LexerTest.java b/proparse/src/test/java/org/prorefactor/core/unittest/LexerTest.java index 0aa05740c..194967a39 100644 --- a/proparse/src/test/java/org/prorefactor/core/unittest/LexerTest.java +++ b/proparse/src/test/java/org/prorefactor/core/unittest/LexerTest.java @@ -856,4 +856,70 @@ public void testProparseDirectivePreprocessPhase() throws TokenStreamException { assertEquals(tok.getNodeType(), ABLNodeType.PERIOD); } + @Test + public void testHexNumbers() throws TokenStreamException { + ParseUnit unit = new ParseUnit(new File(SRC_DIR, "lexer16.p"), session); + TokenStream stream = unit.lex(); + + ProToken tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.MESSAGE); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.WS); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.NUMBER); + assertEquals(tok.getText(), "125"); + + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.WS); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.NUMBER); + assertEquals(tok.getText(), "0x65"); + + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.WS); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.NUMBER); + assertEquals(tok.getText(), "0X66"); + + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.WS); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.NUMBER); + assertEquals(tok.getText(), "0xfb"); + + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.WS); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.NUMBER); + assertEquals(tok.getText(), "0xab"); + + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.WS); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.NUMBER); + assertEquals(tok.getText(), "-0x01"); + + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.PERIOD); + } + + @Test + public void testHexNumbers2() throws TokenStreamException { + ParseUnit unit = new ParseUnit(new File(SRC_DIR, "lexer17.p"), session); + TokenStream stream = unit.lex(); + + ProToken tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.MESSAGE); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.WS); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.NUMBER); + assertEquals(tok.getText(), "125"); + + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.WS); + tok = (ProToken) stream.nextToken(); + assertEquals(tok.getType(), ProParserTokenTypes.ID); + assertEquals(tok.getText(), "0x2g8"); + } } diff --git a/proparse/src/test/resources/data/lexer/lexer16.p b/proparse/src/test/resources/data/lexer/lexer16.p new file mode 100644 index 000000000..21c0427fa --- /dev/null +++ b/proparse/src/test/resources/data/lexer/lexer16.p @@ -0,0 +1 @@ +MESSAGE 125 0x65 0X66 0xfb 0xab -0x01. diff --git a/proparse/src/test/resources/data/lexer/lexer17.p b/proparse/src/test/resources/data/lexer/lexer17.p new file mode 100644 index 000000000..7491f3150 --- /dev/null +++ b/proparse/src/test/resources/data/lexer/lexer17.p @@ -0,0 +1 @@ +MESSAGE 125 0x2g8. From 871e9da42e15e2c198cb39515e40012942fbe044 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Mon, 11 Mar 2019 15:09:47 +0100 Subject: [PATCH 07/18] Add a few widget attributes to the keywords list --- BaseTokenTypes.txt | 8 +++++++- proparse/BaseTokenTypes.txt | 8 +++++++- .../src/main/java/org/prorefactor/core/ABLNodeType.java | 6 ++++++ proparse/src/test/resources/treeparser04-expect/frames.p | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/BaseTokenTypes.txt b/BaseTokenTypes.txt index 5f024a250..089fc1050 100644 --- a/BaseTokenTypes.txt +++ b/BaseTokenTypes.txt @@ -1233,4 +1233,10 @@ SINGLERUN=1235 SINGLETON=1236 PROCESSARCHITECTURE=1237 NONSERIALIZABLE=1238 -Last_Token_Number=1239 +CHECKED=1239 +SENSITIVE=1240 +HIDDEN=1241 +VISIBLE=1242 +CHARSET=1243 +SCREENVALUE=1244 +Last_Token_Number=1245 diff --git a/proparse/BaseTokenTypes.txt b/proparse/BaseTokenTypes.txt index 5f024a250..089fc1050 100644 --- a/proparse/BaseTokenTypes.txt +++ b/proparse/BaseTokenTypes.txt @@ -1233,4 +1233,10 @@ SINGLERUN=1235 SINGLETON=1236 PROCESSARCHITECTURE=1237 NONSERIALIZABLE=1238 -Last_Token_Number=1239 +CHECKED=1239 +SENSITIVE=1240 +HIDDEN=1241 +VISIBLE=1242 +CHARSET=1243 +SCREENVALUE=1244 +Last_Token_Number=1245 diff --git a/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java b/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java index 9a1f730ae..816cb450c 100644 --- a/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java +++ b/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java @@ -197,7 +197,9 @@ public enum ABLNodeType { CHAINED(ProParserTokenTypes.CHAINED, "chained", NodeTypesOption.KEYWORD), CHARACTER(ProParserTokenTypes.CHARACTER, "character", 4, NodeTypesOption.KEYWORD), CHARACTERLENGTH(ProParserTokenTypes.CHARACTERLENGTH, "characterlength", NodeTypesOption.KEYWORD), + CHARSET(ProParserTokenTypes.CHARSET, "charset", NodeTypesOption.KEYWORD), CHECK(ProParserTokenTypes.CHECK, "check", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), + CHECKED(ProParserTokenTypes.CHECKED, "checked", NodeTypesOption.KEYWORD), CHOOSE(ProParserTokenTypes.CHOOSE, "choose", NodeTypesOption.KEYWORD), CHR(ProParserTokenTypes.CHR, "chr", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED, NodeTypesOption.MAY_BE_REGULAR_FUNC), @@ -625,6 +627,7 @@ public enum ABLNodeType { HELPTOPIC(ProParserTokenTypes.HELPTOPIC, "help-topic", NodeTypesOption.KEYWORD), HEXDECODE(ProParserTokenTypes.HEXDECODE, "hex-decode", NodeTypesOption.KEYWORD, NodeTypesOption.MAY_BE_REGULAR_FUNC), HEXENCODE(ProParserTokenTypes.HEXENCODE, "hex-encode", NodeTypesOption.KEYWORD, NodeTypesOption.MAY_BE_REGULAR_FUNC), + HIDDEN(ProParserTokenTypes.HIDDEN, "hidden", NodeTypesOption.KEYWORD), HIDE(ProParserTokenTypes.HIDE, "hide", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), HINT(ProParserTokenTypes.HINT, "hint", NodeTypesOption.KEYWORD), HORIZONTAL(ProParserTokenTypes.HORIZONTAL, "horizontal", 4, NodeTypesOption.KEYWORD), @@ -1194,6 +1197,7 @@ public enum ABLNodeType { SCREENIO(ProParserTokenTypes.SCREENIO, "screen-io", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), SCREENLINES(ProParserTokenTypes.SCREENLINES, "screen-lines", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED, NodeTypesOption.MAY_BE_NO_ARG_FUNC), + SCREENVALUE(ProParserTokenTypes.SCREENVALUE, "screen-value", NodeTypesOption.KEYWORD), SCROLL(ProParserTokenTypes.SCROLL, "scroll", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), SCROLLABLE(ProParserTokenTypes.SCROLLABLE, "scrollable", NodeTypesOption.KEYWORD), SCROLLBARHORIZONTAL(ProParserTokenTypes.SCROLLBARHORIZONTAL, "scrollbar-horizontal", 11, NodeTypesOption.KEYWORD), @@ -1217,6 +1221,7 @@ public enum ABLNodeType { SEMI(ProParserTokenTypes.SEMI, ";", NodeTypesOption.SYMBOL), SEND(ProParserTokenTypes.SEND, "send", NodeTypesOption.KEYWORD), SENDSQLSTATEMENT(ProParserTokenTypes.SENDSQLSTATEMENT, "send-sql-statement", 8, NodeTypesOption.KEYWORD), + SENSITIVE(ProParserTokenTypes.SENSITIVE, "sensitive", NodeTypesOption.KEYWORD), SEPARATECONNECTION(ProParserTokenTypes.SEPARATECONNECTION, "separate-connection", NodeTypesOption.KEYWORD), SEPARATORS(ProParserTokenTypes.SEPARATORS, "separators", NodeTypesOption.KEYWORD), SERIALIZABLE(ProParserTokenTypes.SERIALIZABLE, "serializable", NodeTypesOption.KEYWORD), @@ -1458,6 +1463,7 @@ public enum ABLNodeType { VERTICAL(ProParserTokenTypes.VERTICAL, "vertical", 4, NodeTypesOption.KEYWORD), VIEW(ProParserTokenTypes.VIEW, "view", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), VIEWAS(ProParserTokenTypes.VIEWAS, "view-as", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), + VISIBLE(ProParserTokenTypes.VISIBLE, "visible", NodeTypesOption.KEYWORD), VMS(ProParserTokenTypes.VMS, "vms", NodeTypesOption.KEYWORD), VOID(ProParserTokenTypes.VOID, "void", NodeTypesOption.KEYWORD), diff --git a/proparse/src/test/resources/treeparser04-expect/frames.p b/proparse/src/test/resources/treeparser04-expect/frames.p index 4be9dc97c..3ea8d9490 100644 --- a/proparse/src/test/resources/treeparser04-expect/frames.p +++ b/proparse/src/test/resources/treeparser04-expect/frames.p @@ -498,7 +498,7 @@ PROGRAM_ROOT defaultFrame: ""frames: "" t12 t11 t10 f9 f8a f8b t6 t4a f3a f3b FIELD_REF bBothFrames2 ID bBothFrames2 OBJCOLON : - ID SENSITIVE + SENSITIVE SENSITIVE IN IN FRAME FRAME ID F2a From 7b5923884b572e8e607b74987c544b89c206876e Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Mon, 11 Mar 2019 18:16:08 +0100 Subject: [PATCH 08/18] XOR keyword --- BaseTokenTypes.txt | 3 ++- proparse/BaseTokenTypes.txt | 3 ++- proparse/src/main/antlr/JPTreeParser.g | 1 + proparse/src/main/antlr/proparse.g | 6 +++++- .../src/main/java/org/prorefactor/core/ABLNodeType.java | 1 + .../test/java/org/prorefactor/core/unittest/BugFixTest.java | 5 +++++ proparse/src/test/resources/data/bugsfixed/xor.p | 3 +++ 7 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 proparse/src/test/resources/data/bugsfixed/xor.p diff --git a/BaseTokenTypes.txt b/BaseTokenTypes.txt index 089fc1050..114e2735a 100644 --- a/BaseTokenTypes.txt +++ b/BaseTokenTypes.txt @@ -1239,4 +1239,5 @@ HIDDEN=1241 VISIBLE=1242 CHARSET=1243 SCREENVALUE=1244 -Last_Token_Number=1245 +XOR=1245 +Last_Token_Number=1246 diff --git a/proparse/BaseTokenTypes.txt b/proparse/BaseTokenTypes.txt index 089fc1050..114e2735a 100644 --- a/proparse/BaseTokenTypes.txt +++ b/proparse/BaseTokenTypes.txt @@ -1239,4 +1239,5 @@ HIDDEN=1241 VISIBLE=1242 CHARSET=1243 SCREENVALUE=1244 -Last_Token_Number=1245 +XOR=1245 +Last_Token_Number=1246 diff --git a/proparse/src/main/antlr/JPTreeParser.g b/proparse/src/main/antlr/JPTreeParser.g index 6f45ad70f..d533170fe 100644 --- a/proparse/src/main/antlr/JPTreeParser.g +++ b/proparse/src/main/antlr/JPTreeParser.g @@ -726,6 +726,7 @@ lockhow: expression: #(OR expression expression ) + | #(XOR expression expression ) | #(AND expression expression ) | #(NOT expression ) | #(MATCHES expression expression ) diff --git a/proparse/src/main/antlr/proparse.g b/proparse/src/main/antlr/proparse.g index 2e0bca55d..891456ef9 100644 --- a/proparse/src/main/antlr/proparse.g +++ b/proparse/src/main/antlr/proparse.g @@ -796,7 +796,11 @@ expression: ; orExpression: - andExpression (options{greedy=true;}: OR^ andExpression { ##.setOperator(); } )* + xorExpression (options{greedy=true;}: OR^ xorExpression { ##.setOperator(); } )* + ; + +xorExpression: + andExpression (options{greedy=true;}: XOR^ andExpression { ##.setOperator(); } )* ; andExpression: diff --git a/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java b/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java index 816cb450c..f651a3685 100644 --- a/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java +++ b/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java @@ -1512,6 +1512,7 @@ public enum ABLNodeType { XMLNODETYPE(ProParserTokenTypes.XMLNODETYPE, "xml-node-type", NodeTypesOption.KEYWORD), XNODEREF(ProParserTokenTypes.XNODEREF, "x-noderef", NodeTypesOption.KEYWORD), XOF(ProParserTokenTypes.XOF, "x-of", NodeTypesOption.KEYWORD), + XOR(ProParserTokenTypes.XOR, "xor", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), XREF(ProParserTokenTypes.XREF, "xref", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), XREFXML(ProParserTokenTypes.XREFXML, "xref-xml", NodeTypesOption.KEYWORD), diff --git a/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java b/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java index 562e4c2d3..3f50d1703 100644 --- a/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java +++ b/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java @@ -353,6 +353,11 @@ public void testSerializableKeyword() throws ANTLRException { genericTest("serialkw.cls"); } + @Test + public void testXor() throws ANTLRException { + genericTest("xor.p"); + } + @Test public void testSaxWriter() throws ANTLRException { genericTest("sax-writer.p"); diff --git a/proparse/src/test/resources/data/bugsfixed/xor.p b/proparse/src/test/resources/data/bugsfixed/xor.p new file mode 100644 index 000000000..7fd769cb5 --- /dev/null +++ b/proparse/src/test/resources/data/bugsfixed/xor.p @@ -0,0 +1,3 @@ +DEFINE VARIABLE xx AS OpenEdge.Core.System.ErrorSeverityEnum. +xx = OpenEdge.Core.System.ErrorSeverityEnum:Critical. +MESSAGE xx XOR OpenEdge.Core.System.ErrorSeverityEnum:Critical XOR OpenEdge.Core.System.ErrorSeverityEnum:MESSAGE. From 3f12777a3a9c4c4362ed05d8cef693de5f86ddd5 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Mon, 18 Mar 2019 17:10:23 +0100 Subject: [PATCH 09/18] Add tag to invalid USE-INDEX nodes --- .../java/org/prorefactor/core/IConstants.java | 4 ++++ .../prorefactor/treeparser01/TP01Support.java | 3 +++ .../core/unittest/TP01SymbolActionTest.java | 23 +++++++++++++++++++ .../data/tp01ProcessTests/ttUseIdx.p | 1 + 4 files changed, 31 insertions(+) diff --git a/proparse/src/main/java/org/prorefactor/core/IConstants.java b/proparse/src/main/java/org/prorefactor/core/IConstants.java index 716df4443..8f9ca832a 100644 --- a/proparse/src/main/java/org/prorefactor/core/IConstants.java +++ b/proparse/src/main/java/org/prorefactor/core/IConstants.java @@ -146,6 +146,10 @@ public class IConstants { */ public static final int FILE_NAME_ARRAY = -220; + // In statement: DEFINE TEMP-TABLE ... LIKE ... USE-INDEX xxx + // xxx can point to an invalid index + public static final int INVALID_USEINDEX = 2800; + private IConstants() { // Shouldn't be instantiated } diff --git a/proparse/src/main/java/org/prorefactor/treeparser01/TP01Support.java b/proparse/src/main/java/org/prorefactor/treeparser01/TP01Support.java index 09394629c..b75eac5d4 100644 --- a/proparse/src/main/java/org/prorefactor/treeparser01/TP01Support.java +++ b/proparse/src/main/java/org/prorefactor/treeparser01/TP01Support.java @@ -453,6 +453,9 @@ public void defineUseIndex(JPNode recNode, JPNode idNode) throws SemanticExcepti if (idx != null) { // ABL compiler quirk: idNode doesn't have to be a real index. Undefined behavior in this case currDefTable.getTable().add(new Index(currDefTable.getTable(), idx.getName(), idx.isUnique(), idx.isPrimary())); + } else { + // Mark idNode as INVALID_INDEX + idNode.attrSet(IConstants.INVALID_USEINDEX, IConstants.TRUE); } currDefTableUseIndex = true; } diff --git a/proparse/src/test/java/org/prorefactor/core/unittest/TP01SymbolActionTest.java b/proparse/src/test/java/org/prorefactor/core/unittest/TP01SymbolActionTest.java index ed00a4844..0ed00af26 100644 --- a/proparse/src/test/java/org/prorefactor/core/unittest/TP01SymbolActionTest.java +++ b/proparse/src/test/java/org/prorefactor/core/unittest/TP01SymbolActionTest.java @@ -15,6 +15,7 @@ ********************************************************************************/ package org.prorefactor.core.unittest; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; @@ -22,6 +23,9 @@ import java.io.File; +import org.prorefactor.core.ABLNodeType; +import org.prorefactor.core.IConstants; +import org.prorefactor.core.JPNode; import org.prorefactor.core.unittest.util.RoutineHandler; import org.prorefactor.core.unittest.util.UnitTestModule; import org.prorefactor.refactor.RefactorSession; @@ -146,5 +150,24 @@ public void testTreeParser01() throws ANTLRException { ParseUnit pu = new ParseUnit(new File("src/test/resources/data/tp01ProcessTests/ttUseIdx.p"), session); TP01Support walkAction = new TP01Support(session, pu); pu.treeParser(new TreeParser01(walkAction)); + + boolean found1 = false; + boolean found2 = false; + for (JPNode node : pu.getTopNode().query(ABLNodeType.DEFINE)) { + if ((node.getState2() == ABLNodeType.TEMPTABLE.getType()) + && "myTT2".equals(node.nextNode().nextNode().getText())) { + assertEquals(node.query(ABLNodeType.USEINDEX).get(0).nextNode().attrGet(IConstants.INVALID_USEINDEX), + IConstants.TRUE); + found1 = true; + } + if ((node.getState2() == ABLNodeType.TEMPTABLE.getType()) + && "myTT3".equals(node.nextNode().nextNode().getText())) { + assertEquals(node.query(ABLNodeType.USEINDEX).get(0).nextNode().attrGet(IConstants.INVALID_USEINDEX), 0); + found2 = true; + } + } + assertTrue(found1); + assertTrue(found2); } + } diff --git a/proparse/src/test/resources/data/tp01ProcessTests/ttUseIdx.p b/proparse/src/test/resources/data/tp01ProcessTests/ttUseIdx.p index a9738147a..19587b920 100644 --- a/proparse/src/test/resources/data/tp01ProcessTests/ttUseIdx.p +++ b/proparse/src/test/resources/data/tp01ProcessTests/ttUseIdx.p @@ -2,3 +2,4 @@ define temp-table myTT no-undo field fld1 as character index idx1 is primary unique fld1. define temp-table myTT2 no-undo like myTT use-index fld1. +define temp-table myTT3 no-undo like myTT use-index idx1. From 1b1c51a1b91851f0cbdeaa47e428130fe1915052 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Tue, 19 Mar 2019 11:19:38 +0100 Subject: [PATCH 10/18] Missing keywords in unreserved list --- proparse/src/main/antlr/proparse.g | 7 +++++++ .../java/org/prorefactor/core/unittest/BugFixTest.java | 5 +++++ proparse/src/test/resources/data/bugsfixed/bug43.p | 3 +++ 3 files changed, 15 insertions(+) create mode 100644 proparse/src/test/resources/data/bugsfixed/bug43.p diff --git a/proparse/src/main/antlr/proparse.g b/proparse/src/main/antlr/proparse.g index 891456ef9..3ded1185c 100644 --- a/proparse/src/main/antlr/proparse.g +++ b/proparse/src/main/antlr/proparse.g @@ -4396,6 +4396,8 @@ unreservedkeyword: | CHAINED | CHARACTER | CHARACTERLENGTH + | CHARSET + | CHECKED | CHOOSE | CLASS | CLIENTPRINCIPAL @@ -4586,6 +4588,7 @@ unreservedkeyword: | HELPTOPIC | HEXDECODE | HEXENCODE + | HIDDEN | HINT | HORIZONTAL | HTMLENDOFLINE @@ -4727,6 +4730,7 @@ unreservedkeyword: | NOJOINBYSQLDB | NOLOOKAHEAD | NONE + | NONSERIALIZABLE | NORMAL | NORMALIZE | NOROWMARKERS @@ -4851,6 +4855,7 @@ unreservedkeyword: | SAXATTRIBUTES | SAXREADER | SAXWRITER + | SCREENVALUE | SCROLLABLE | SCROLLBARHORIZONTAL | SCROLLBARVERTICAL @@ -4860,6 +4865,7 @@ unreservedkeyword: | SELECTIONLIST | SEND | SENDSQLSTATEMENT + | SENSITIVE | SEPARATECONNECTION | SEPARATORS | SERIALIZABLE @@ -4982,6 +4988,7 @@ unreservedkeyword: | VARIABLE | VERBOSE | VERTICAL + | VISIBLE | VMS | VOID | WAIT diff --git a/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java b/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java index 3f50d1703..5caff19f4 100644 --- a/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java +++ b/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java @@ -337,6 +337,11 @@ public void test36() throws ANTLRException { genericTest("bug36.p"); } + @Test + public void test43() throws ANTLRException { + genericTest("bug43.p"); + } + // Next two tests : same exception should be thrown in both cases // @Test(expectedExceptions = {ProparseRuntimeException.class}) // public void testCache1() throws ANTLRException { diff --git a/proparse/src/test/resources/data/bugsfixed/bug43.p b/proparse/src/test/resources/data/bugsfixed/bug43.p new file mode 100644 index 000000000..7b2e0c098 --- /dev/null +++ b/proparse/src/test/resources/data/bugsfixed/bug43.p @@ -0,0 +1,3 @@ +define variable hidden as char. +define variable visible as char. +define variable screen-value as char. From 162b76fc6a5053e7fd4f7eee20e8e833bba3dad1 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Wed, 20 Mar 2019 10:11:47 +0100 Subject: [PATCH 11/18] Additional logger in last token filter --- .../antlr4/FunctionKeywordTokenFilter.java | 17 ++++++++++++++++- proparse/src/test/java/simplelogger.properties | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/proparse/src/main/java/org/prorefactor/proparse/antlr4/FunctionKeywordTokenFilter.java b/proparse/src/main/java/org/prorefactor/proparse/antlr4/FunctionKeywordTokenFilter.java index 1f447e4f5..039c95c5f 100644 --- a/proparse/src/main/java/org/prorefactor/proparse/antlr4/FunctionKeywordTokenFilter.java +++ b/proparse/src/main/java/org/prorefactor/proparse/antlr4/FunctionKeywordTokenFilter.java @@ -22,6 +22,8 @@ import org.antlr.v4.runtime.TokenFactory; import org.antlr.v4.runtime.TokenSource; import org.prorefactor.core.ABLNodeType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Convert some tokens to another type when not followed by LEFTPAREN: @@ -32,6 +34,8 @@ * */ public class FunctionKeywordTokenFilter implements TokenSource { + private static final Logger LOGGER = LoggerFactory.getLogger(FunctionKeywordTokenFilter.class); + private final TokenSource source; private final Queue heap = new LinkedList<>(); @@ -42,7 +46,11 @@ public FunctionKeywordTokenFilter(TokenSource source) { @Override public Token nextToken() { if (!heap.isEmpty()) { - return heap.poll(); + Token tok = heap.poll(); + if (LOGGER.isTraceEnabled()) { + logToken(tok); + } + return tok; } ProToken currToken = (ProToken) source.nextToken(); @@ -64,9 +72,16 @@ else if (currToken.getNodeType() == ABLNodeType.GETCODEPAGE) } else if (currToken.getNodeType() == ABLNodeType.GETCODEPAGES) currToken.setNodeType(ABLNodeType.GETCODEPAGE); } + if (LOGGER.isTraceEnabled()) { + logToken(currToken); + } return currToken; } + private void logToken(Token tok) { + LOGGER.trace("'{}' -- {}", tok.getText(), ABLNodeType.getNodeType(tok.getType())); + } + @Override public int getLine() { return source.getLine(); diff --git a/proparse/src/test/java/simplelogger.properties b/proparse/src/test/java/simplelogger.properties index bfdb0e8ac..f913d16a3 100644 --- a/proparse/src/test/java/simplelogger.properties +++ b/proparse/src/test/java/simplelogger.properties @@ -14,6 +14,7 @@ org.slf4j.simpleLogger.defaultLogLevel=info #org.slf4j.simpleLogger.log.org.prorefactor.proparse.antlr4.ProgressLexer=trace #org.slf4j.simpleLogger.log.org.prorefactor.proparse.antlr4.Lexer=trace #org.slf4j.simpleLogger.log.org.prorefactor.proparse.antlr4.PostLexer=trace +#org.slf4j.simpleLogger.log.org.prorefactor.proparse.antlr4.FunctionKeywordTokenFilter=trace #org.slf4j.simpleLogger.log.org.prorefactor.proparse.antlr4.PreproEval=trace #org.slf4j.simpleLogger.log.org.prorefactor.proparse.antlr4.TokenList=trace From 6421ba4ee3789566bc2d4d3dfa1786618e0df36e Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Wed, 20 Mar 2019 10:12:53 +0100 Subject: [PATCH 12/18] Additional unit test for NAMEDOT token --- .../prorefactor/core/unittest/LexerTest.java | 45 +++++++++++++++++++ .../test/resources/data/lexer/tokenlist09.p | 5 +++ 2 files changed, 50 insertions(+) create mode 100644 proparse/src/test/resources/data/lexer/tokenlist09.p diff --git a/proparse/src/test/java/org/prorefactor/core/unittest/LexerTest.java b/proparse/src/test/java/org/prorefactor/core/unittest/LexerTest.java index 194967a39..0d57766b9 100644 --- a/proparse/src/test/java/org/prorefactor/core/unittest/LexerTest.java +++ b/proparse/src/test/java/org/prorefactor/core/unittest/LexerTest.java @@ -281,6 +281,51 @@ public void testTokenList08() throws TokenStreamException { assertEquals(stream.nextToken().getType(), ProParserTokenTypes.PLUS); } + @Test + public void testTokenList09() throws TokenStreamException { + ParseUnit unit = new ParseUnit(new File(SRC_DIR, "tokenlist09.p"), session); + TokenStream stream = unit.lex(); + // First line + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.ID); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.NAMEDOT); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.ID); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.PERIOD); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.WS); + // Second line + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.ID); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.PERIOD); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.WS); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.ID); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.PERIOD); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.WS); + // Third line: comment after period results in NAMEDOT + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.ID); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.NAMEDOT); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.COMMENT); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.ID); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.PERIOD); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.WS); + // Fourth line: same behaviour even if there's a space after the comment + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.ID); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.NAMEDOT); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.COMMENT); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.WS); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.ID); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.PERIOD); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.WS); + // Fifth line: this line doesn't compile... + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.MESSAGE); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.WS); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.QSTRING); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.NAMEDOT); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.COMMENT); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.MESSAGE); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.WS); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.QSTRING); + assertEquals(stream.nextToken().getType(), ProParserTokenTypes.PERIOD); + } + + @Test public void testPostLexer01() throws TokenStreamException { ParseUnit unit = new ParseUnit(new File(SRC_DIR, "postlexer01.p"), session); diff --git a/proparse/src/test/resources/data/lexer/tokenlist09.p b/proparse/src/test/resources/data/lexer/tokenlist09.p new file mode 100644 index 000000000..645562488 --- /dev/null +++ b/proparse/src/test/resources/data/lexer/tokenlist09.p @@ -0,0 +1,5 @@ +customer.name. +customer. name. +customer./* comment */name. +customer./* comment */ name. +message "xx"./* comment */message "yy". From a7616f0c219208d832037924488f66096fbb8be9 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Fri, 19 Apr 2019 10:22:10 +0200 Subject: [PATCH 13/18] Fix NPE in database parser (#659) Issue #658 --- .../rssw/antlr/database/DumpFileVisitor.java | 2 +- .../eu/rssw/antlr/database/TestDumpFile.java | 12 ++++++++++ .../src/test/resources/ascIndex.df | 23 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 database-parser/src/test/resources/ascIndex.df diff --git a/database-parser/src/main/java/eu/rssw/antlr/database/DumpFileVisitor.java b/database-parser/src/main/java/eu/rssw/antlr/database/DumpFileVisitor.java index 6ff8068f7..7a674220b 100644 --- a/database-parser/src/main/java/eu/rssw/antlr/database/DumpFileVisitor.java +++ b/database-parser/src/main/java/eu/rssw/antlr/database/DumpFileVisitor.java @@ -309,7 +309,7 @@ public Void visitIndexField(IndexFieldContext ctx) { } if (table != null) { IndexField idxFld = new IndexField(table.getField(ctx.field.getText()), - "ascending".equalsIgnoreCase(ctx.order.getText())); + ((ctx.order == null) || "ascending".equalsIgnoreCase(ctx.order.getText()))); indexes.peek().addField(idxFld); } else { // Log error ? diff --git a/database-parser/src/test/java/eu/rssw/antlr/database/TestDumpFile.java b/database-parser/src/test/java/eu/rssw/antlr/database/TestDumpFile.java index 3aeedd0f0..a2d1a83f6 100644 --- a/database-parser/src/test/java/eu/rssw/antlr/database/TestDumpFile.java +++ b/database-parser/src/test/java/eu/rssw/antlr/database/TestDumpFile.java @@ -120,4 +120,16 @@ public void testSerialize() throws IOException { assertEquals(db2.getTable("Order").getIndex("CustOrder").getFields().size(), 2); } + @Test + public void testAscIndex() throws IOException { + // Delete triggers on table + DatabaseDescription db = DumpFileUtils.getDatabaseDescription(new File("src/test/resources/ascIndex.df")); + assertNotNull(db.getTable("Tab1")); + assertNotNull(db.getTable("Tab1").getIndex("Idx1")); + assertNotNull(db.getTable("Tab1").getIndex("Idx1").getFields()); + assertEquals(db.getTable("Tab1").getIndex("Idx1").getFields().size(), 3); + assertTrue(db.getTable("Tab1").getIndex("Idx1").getFields().get(0).isAscending()); + assertTrue(db.getTable("Tab1").getIndex("Idx1").getFields().get(1).isAscending()); + assertFalse(db.getTable("Tab1").getIndex("Idx1").getFields().get(2).isAscending()); + } } diff --git a/database-parser/src/test/resources/ascIndex.df b/database-parser/src/test/resources/ascIndex.df new file mode 100644 index 000000000..a596b8dad --- /dev/null +++ b/database-parser/src/test/resources/ascIndex.df @@ -0,0 +1,23 @@ +ADD TABLE "Tab1" + DESCRIPTION "XYZ" + FROZEN + DUMP-NAME "Tab1" + +ADD FIELD "Fld1" OF "Tab1" AS character + FORMAT "x(24)" + MANDATORY + +ADD FIELD "Fld2" OF "Tab1" AS character + FORMAT "x(24)" + MANDATORY + +ADD FIELD "Fld2" OF "Tab1" AS character + FORMAT "x(24)" + MANDATORY + +ADD INDEX "Idx1" ON "Tab1" + PRIMARY + INDEX-FIELD "Fld1" + INDEX-FIELD "Fld2" ASCENDING + INDEX-FIELD "Fld3" DESCENDING +. From 85cb13c47e642a3cbd2c63d671884764266c9913 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Fri, 19 Apr 2019 10:23:54 +0200 Subject: [PATCH 14/18] DYNAMIC-PROPERTY keyword (#660) Issue #657 --- BaseTokenTypes.txt | 3 ++- proparse/BaseTokenTypes.txt | 3 ++- proparse/src/main/antlr/JPTreeParser.g | 1 + proparse/src/main/antlr/proparse.g | 1 + .../src/main/java/org/prorefactor/core/ABLNodeType.java | 2 ++ .../test/java/org/prorefactor/core/unittest/BugFixTest.java | 5 +++++ proparse/src/test/resources/data/bugsfixed/dynprop.p | 6 ++++++ 7 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 proparse/src/test/resources/data/bugsfixed/dynprop.p diff --git a/BaseTokenTypes.txt b/BaseTokenTypes.txt index 114e2735a..6ca72e6d4 100644 --- a/BaseTokenTypes.txt +++ b/BaseTokenTypes.txt @@ -1240,4 +1240,5 @@ VISIBLE=1242 CHARSET=1243 SCREENVALUE=1244 XOR=1245 -Last_Token_Number=1246 +DYNAMICPROPERTY=1246 +Last_Token_Number=1247 diff --git a/proparse/BaseTokenTypes.txt b/proparse/BaseTokenTypes.txt index 114e2735a..6ca72e6d4 100644 --- a/proparse/BaseTokenTypes.txt +++ b/proparse/BaseTokenTypes.txt @@ -1240,4 +1240,5 @@ VISIBLE=1242 CHARSET=1243 SCREENVALUE=1244 XOR=1245 -Last_Token_Number=1246 +DYNAMICPROPERTY=1246 +Last_Token_Number=1247 diff --git a/proparse/src/main/antlr/JPTreeParser.g b/proparse/src/main/antlr/JPTreeParser.g index d533170fe..63506b45e 100644 --- a/proparse/src/main/antlr/JPTreeParser.g +++ b/proparse/src/main/antlr/JPTreeParser.g @@ -488,6 +488,7 @@ argfunc: | #(DECRYPT funargs ) | #(DYNAMICCAST funargs ) | #(DYNAMICNEXTVALUE funargs ) + | #(DYNAMICPROPERTY funargs ) | #(ENCODE funargs ) | #(ENCRYPT funargs ) | #(EXP funargs ) diff --git a/proparse/src/main/antlr/proparse.g b/proparse/src/main/antlr/proparse.g index 3ded1185c..91fd7153b 100644 --- a/proparse/src/main/antlr/proparse.g +++ b/proparse/src/main/antlr/proparse.g @@ -501,6 +501,7 @@ argfunc: | DECRYPT^ | DYNAMICCAST^ | DYNAMICNEXTVALUE^ + | DYNAMICPROPERTY^ | ENCODE^ | ENCRYPT^ | EXP^ diff --git a/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java b/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java index f651a3685..1860262c1 100644 --- a/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java +++ b/proparse/src/main/java/org/prorefactor/core/ABLNodeType.java @@ -398,6 +398,8 @@ public enum ABLNodeType { DYNAMICNEW(ProParserTokenTypes.DYNAMICNEW, "dynamic-new", NodeTypesOption.KEYWORD), DYNAMICNEXTVALUE(ProParserTokenTypes.DYNAMICNEXTVALUE, "dynamic-next-value", NodeTypesOption.KEYWORD, NodeTypesOption.MAY_BE_REGULAR_FUNC), + DYNAMICPROPERTY(ProParserTokenTypes.DYNAMICPROPERTY, "dynamic-property", NodeTypesOption.KEYWORD, + NodeTypesOption.RESERVED), // E EACH(ProParserTokenTypes.EACH, "each", NodeTypesOption.KEYWORD, NodeTypesOption.RESERVED), diff --git a/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java b/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java index 5caff19f4..8bac9b313 100644 --- a/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java +++ b/proparse/src/test/java/org/prorefactor/core/unittest/BugFixTest.java @@ -422,6 +422,11 @@ public void testDoubleColon() throws ANTLRException { genericTest("double-colon.p"); } + @Test + public void testDynProp() throws ANTLRException { + genericTest("dynprop.p"); + } + @Test public void testTildeInComment() throws ANTLRException { TokenStream stream = genericLex("comment-tilde.p"); diff --git a/proparse/src/test/resources/data/bugsfixed/dynprop.p b/proparse/src/test/resources/data/bugsfixed/dynprop.p new file mode 100644 index 000000000..42e2d6ed9 --- /dev/null +++ b/proparse/src/test/resources/data/bugsfixed/dynprop.p @@ -0,0 +1,6 @@ +define variable xx as Progress.Lang.Object. +define temp-table tt no-undo + field fld1 as char + index idx1 is primary fld1. +find first tt. +dynamic-property(xx, buffer tt:buffer-field(fld1):name). From ca5419ae853ae4730df33e1fd78290bd90e68db1 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Fri, 19 Apr 2019 11:42:35 +0200 Subject: [PATCH 15/18] Stop SonarLint analysis in case of invalid DB schema (#661) Issue #654 --- .../openedge/foundation/OpenEdgeSettings.java | 9 +++++- .../sensor/OpenEdgeProparseSensorTest.java | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeSettings.java b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeSettings.java index a253e1a2a..af00d2c52 100644 --- a/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeSettings.java +++ b/openedge-plugin/src/main/java/org/sonar/plugins/openedge/foundation/OpenEdgeSettings.java @@ -642,7 +642,14 @@ private Collection readSchemaFromProp1(Configuration config, FileSyst try { desc = DumpFileUtils.getDatabaseDescription(fileSystem.resolvePath(str), dbName); } catch (IOException caught) { - LOG.error("Unable to parse " + str, caught); + // Interrupt SonarLint analysis as this is the only way to have a notification for invalid DF file + // By default, analysis log is not visible + if (runtime.getProduct() == SonarProduct.SONARLINT) { + throw new RuntimeException("Unable to read database schema from '" + dfFile.getName() + + "', please check value of property '" + Constants.DATABASES + "'", caught); + } else { + LOG.error("Unable to parse " + str, caught); + } } if ((desc != null) && (runtime.getProduct() == SonarProduct.SONARLINT)) { try (OutputStream os = new FileOutputStream(serFile)) { diff --git a/openedge-plugin/src/test/java/org/sonar/plugins/openedge/sensor/OpenEdgeProparseSensorTest.java b/openedge-plugin/src/test/java/org/sonar/plugins/openedge/sensor/OpenEdgeProparseSensorTest.java index 7ace08cd8..f21fa2578 100644 --- a/openedge-plugin/src/test/java/org/sonar/plugins/openedge/sensor/OpenEdgeProparseSensorTest.java +++ b/openedge-plugin/src/test/java/org/sonar/plugins/openedge/sensor/OpenEdgeProparseSensorTest.java @@ -28,6 +28,7 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import org.prorefactor.refactor.settings.ProparseSettings.OperatingSystem; import org.sonar.api.SonarQubeSide; @@ -126,4 +127,31 @@ public void testPreprocessorSettings02() throws Exception { assertEquals(oeSettings.getProparseSession().getProparseSettings().getProversion(), "11.7"); } + @Test + public void testInvalidDBInSonarLint() throws Exception { + SensorContextTester context = TestProjectSensorContext.createContext(); + context.settings().setProperty(Constants.DATABASES, "src/schema/invalid.df"); + + OpenEdgeSettings oeSettings = new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarLint(VERSION)); + try { + oeSettings.getProparseSession(); + fail("RuntimeException should have been thrown"); + } catch (RuntimeException caught) { + + } + } + + @Test + public void testInvalidDBInSonarQube() throws Exception { + SensorContextTester context = TestProjectSensorContext.createContext(); + context.settings().setProperty(Constants.DATABASES, "src/schema/invalid.df"); + + OpenEdgeSettings oeSettings = new OpenEdgeSettings(context.config(), context.fileSystem(), SonarRuntimeImpl.forSonarQube(VERSION, SonarQubeSide.SCANNER)); + try { + oeSettings.getProparseSession(); + } catch (RuntimeException caught) { + fail("No RuntimeException should have been thrown"); + } + } + } From 85ccbf43a697e284e88a0502d83239fe1546a698 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Wed, 24 Apr 2019 15:13:10 +0200 Subject: [PATCH 16/18] Use synchronized Map as parseBuildDirectory is multi-threaded (#663) And using Map#put() from multiple threads Issue #532 --- .../main/java/org/prorefactor/refactor/RefactorSession.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proparse/src/main/java/org/prorefactor/refactor/RefactorSession.java b/proparse/src/main/java/org/prorefactor/refactor/RefactorSession.java index f128065ef..3a5389b67 100644 --- a/proparse/src/main/java/org/prorefactor/refactor/RefactorSession.java +++ b/proparse/src/main/java/org/prorefactor/refactor/RefactorSession.java @@ -18,6 +18,7 @@ import java.io.File; import java.nio.charset.Charset; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -45,7 +46,7 @@ public class RefactorSession { private final Charset charset; // Structure from rcode - private final Map typeInfoMap = new HashMap<>(); + private final Map typeInfoMap = Collections.synchronizedMap(new HashMap<>()); @Inject public RefactorSession(IProparseSettings proparseSettings, ISchema schema) { From 42cb15051f98414567152498d7235477c6901127 Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Fri, 26 Apr 2019 17:38:45 +0200 Subject: [PATCH 17/18] Remove deprecated methods --- .../java/org/prorefactor/core/JPNode.java | 42 ++++------------ .../org/prorefactor/core/JPNodeQuery.java | 48 ++++--------------- 2 files changed, 18 insertions(+), 72 deletions(-) diff --git a/proparse/src/main/java/org/prorefactor/core/JPNode.java b/proparse/src/main/java/org/prorefactor/core/JPNode.java index f13eb6785..83fb2f485 100644 --- a/proparse/src/main/java/org/prorefactor/core/JPNode.java +++ b/proparse/src/main/java/org/prorefactor/core/JPNode.java @@ -445,20 +445,10 @@ public List queryMainFile(ABLNodeType type, ABLNodeType... findTypes) { } /** - * Get an array of all descendant nodes (including this node) of a given type - */ - public List queryStateHead(ABLNodeType type, ABLNodeType... findTypes) { - JPNodeQuery query = new JPNodeQuery(true, type, findTypes); - walk(query); - - return query.getResult(); - } - - /** - * Get an array of all descendant nodes of a given type within current statement + * Get an array of all descendant statement nodes (including this node) */ - public List queryCurrentStatement(ABLNodeType type, ABLNodeType... findTypes) { - JPNodeQuery query = new JPNodeQuery(false, false, this.getStatement(), type, findTypes); + public List queryStateHead() { + JPNodeQuery query = new JPNodeQuery(true); walk(query); return query.getResult(); @@ -466,35 +456,19 @@ public List queryCurrentStatement(ABLNodeType type, ABLNodeType... findT /** * Get an array of all descendant nodes (including this node) of a given type - * @deprecated Since 2.1.3, use {@link JPNode#query(ABLNodeType, ABLNodeType...)} */ - @Deprecated - public List query(Integer... findTypes) { - JPNodeQuery query = new JPNodeQuery(findTypes); - walk(query); - - return query.getResult(); - } - - /** - * Get an array of all descendant nodes (including this node) of a given type - * @deprecated Since 2.1.3, use {@link JPNode#queryMainFile(ABLNodeType, ABLNodeType...)} - */ - @Deprecated - public List queryMainFile(Integer... findTypes) { - JPNodeQuery query = new JPNodeQuery(false, true, null, findTypes); + public List queryStateHead(ABLNodeType type, ABLNodeType... findTypes) { + JPNodeQuery query = new JPNodeQuery(true, type, findTypes); walk(query); return query.getResult(); } /** - * Get an array of all descendant nodes (including this node) of a given type - * @deprecated Since 2.1.3, use {@link JPNode#queryStateHead(ABLNodeType, ABLNodeType...)} + * Get an array of all descendant nodes of a given type within current statement */ - @Deprecated - public List queryStateHead(Integer... findTypes) { - JPNodeQuery query = new JPNodeQuery(true, findTypes); + public List queryCurrentStatement(ABLNodeType type, ABLNodeType... findTypes) { + JPNodeQuery query = new JPNodeQuery(false, false, this.getStatement(), type, findTypes); walk(query); return query.getResult(); diff --git a/proparse/src/main/java/org/prorefactor/core/JPNodeQuery.java b/proparse/src/main/java/org/prorefactor/core/JPNodeQuery.java index 5fbe9254c..1125e032c 100644 --- a/proparse/src/main/java/org/prorefactor/core/JPNodeQuery.java +++ b/proparse/src/main/java/org/prorefactor/core/JPNodeQuery.java @@ -16,7 +16,6 @@ import java.util.ArrayList; import java.util.EnumSet; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -27,53 +26,26 @@ class JPNodeQuery implements ICallback> { private final boolean mainFileOnly; private final JPNode currStatement; - /** - * @deprecated Since 2.1.3, use {@link JPNodeQuery#JPNodeQuery(ABLNodeType, ABLNodeType...)} - */ - @Deprecated - public JPNodeQuery(Integer... types) { - this(false, false, null, types); - } - - /** - * @deprecated Since 2.1.3, use {@link JPNodeQuery#JPNodeQuery(boolean, ABLNodeType, ABLNodeType...)} - */ - @Deprecated - public JPNodeQuery(boolean stateHeadOnly, Integer... types) { - this(stateHeadOnly, false, null, types); - } - - /** - * @deprecated Since 2.1.3, use {@link JPNodeQuery#JPNodeQuery(boolean, boolean, ABLNodeType, ABLNodeType...)} - */ - @Deprecated - public JPNodeQuery(boolean stateHeadOnly, boolean mainFileOnly, JPNode currentStatement, Integer... types) { - this.stateHeadOnly = stateHeadOnly; - this.mainFileOnly = mainFileOnly; - if ((currentStatement != null) && (currentStatement.getStatement() != null)) { - this.currStatement = currentStatement.getStatement(); - } else { - this.currStatement = null; - } - this.findTypes = new HashSet<>(); - for (Integer i : types) { - findTypes.add(ABLNodeType.getNodeType(i)); - } - } - public JPNodeQuery(ABLNodeType type, ABLNodeType... types) { this(false, false, null, type, types); } + public JPNodeQuery(boolean stateHeadOnly) { + this(stateHeadOnly, false, null, null); + } + public JPNodeQuery(boolean stateHeadOnly, ABLNodeType type, ABLNodeType... types) { - this(stateHeadOnly, false, null, type , types); + this(stateHeadOnly, false, null, type, types); } - public JPNodeQuery(boolean stateHeadOnly, boolean mainFileOnly, JPNode currentStatement, ABLNodeType type, ABLNodeType... types) { + public JPNodeQuery(boolean stateHeadOnly, boolean mainFileOnly, JPNode currentStatement, ABLNodeType type, ABLNodeType... types) { this.stateHeadOnly = stateHeadOnly; this.mainFileOnly = mainFileOnly; this.currStatement = currentStatement; - this.findTypes = EnumSet.of(type, types); + if (type == null) + this.findTypes = EnumSet.noneOf(ABLNodeType.class); + else + this.findTypes = EnumSet.of(type, types); } @Override From baccb03f5b4103ca622a42e428fe4dfb6138b56c Mon Sep 17 00:00:00 2001 From: Gilles QUERRET Date: Mon, 29 Apr 2019 17:35:06 +0200 Subject: [PATCH 18/18] Prepare version 2.4.0 --- database-parser/pom.xml | 2 +- listing-parser/pom.xml | 2 +- openedge-checks/pom.xml | 6 +++--- openedge-plugin/pom.xml | 8 ++++---- pom.xml | 2 +- profiler-parser/pom.xml | 2 +- proparse/pom.xml | 4 ++-- rcode-reader/pom.xml | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/database-parser/pom.xml b/database-parser/pom.xml index b89b65c5b..7600e5ec4 100644 --- a/database-parser/pom.xml +++ b/database-parser/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers database-parser - 2.4.0-SNAPSHOT + 2.4.0 OpenEdge database definition lexer and parser OpenEdge dump files parser diff --git a/listing-parser/pom.xml b/listing-parser/pom.xml index c02591f89..65e9f087b 100644 --- a/listing-parser/pom.xml +++ b/listing-parser/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers listing-parser - 2.4.0-SNAPSHOT + 2.4.0 OpenEdge listing so-called parser OpenEdge listing files parser diff --git a/openedge-checks/pom.xml b/openedge-checks/pom.xml index d16abccce..8eeeb62ee 100644 --- a/openedge-checks/pom.xml +++ b/openedge-checks/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.checks openedge-checks - 2.4.0-SNAPSHOT + 2.4.0 OpenEdge checks OpenEdge checks @@ -54,12 +54,12 @@ eu.rssw.openedge.parsers database-parser - 2.4.0-SNAPSHOT + 2.4.0 eu.rssw.openedge.parsers proparse - 2.4.0-SNAPSHOT + 2.4.0 org.testng diff --git a/openedge-plugin/pom.xml b/openedge-plugin/pom.xml index 1b30db767..3d5101c5d 100644 --- a/openedge-plugin/pom.xml +++ b/openedge-plugin/pom.xml @@ -4,7 +4,7 @@ eu.rssw.sonar.openedge sonar-openedge-plugin - 2.4.0-SNAPSHOT + 2.4.0 sonar-plugin OpenEdge plugin for SonarQube @@ -62,17 +62,17 @@ eu.rssw.openedge.checks openedge-checks - 2.4.0-SNAPSHOT + 2.4.0 eu.rssw.openedge.parsers listing-parser - 2.4.0-SNAPSHOT + 2.4.0 eu.rssw.openedge.parsers profiler-parser - 2.4.0-SNAPSHOT + 2.4.0 commons-lang diff --git a/pom.xml b/pom.xml index 66c2cd142..e07e47cf2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ eu.rssw sonar-openedge pom - 2.4.0-SNAPSHOT + 2.4.0 OpenEdge plugin for SonarQube http://www.riverside-software.fr/ Open source code analysis for OpenEdge diff --git a/profiler-parser/pom.xml b/profiler-parser/pom.xml index 59dbb84d2..1fcf5742c 100644 --- a/profiler-parser/pom.xml +++ b/profiler-parser/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers profiler-parser - 2.4.0-SNAPSHOT + 2.4.0 OpenEdge profiler output lexer and parser OpenEdge profiler files parser diff --git a/proparse/pom.xml b/proparse/pom.xml index e350b6730..eec418204 100644 --- a/proparse/pom.xml +++ b/proparse/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers proparse - 2.4.0-SNAPSHOT + 2.4.0 Proparse ABL code parser @@ -54,7 +54,7 @@ eu.rssw.openedge.rcode rcode-reader - 2.4.0-SNAPSHOT + 2.4.0 antlr diff --git a/rcode-reader/pom.xml b/rcode-reader/pom.xml index 6d3da22e1..07885dc6c 100644 --- a/rcode-reader/pom.xml +++ b/rcode-reader/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.rcode rcode-reader - 2.4.0-SNAPSHOT + 2.4.0 rcode-reader rcode reader