Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/V2.20'
Browse files Browse the repository at this point in the history
  • Loading branch information
gquerret committed Mar 6, 2023
2 parents 825f812 + ed54f20 commit d175c8d
Show file tree
Hide file tree
Showing 32 changed files with 491 additions and 201 deletions.
16 changes: 8 additions & 8 deletions coverage-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>coverage-report</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>

<name>JaCoCo report</name>
<description>Fake module for code coverage report in SonarQube</description>
Expand All @@ -20,37 +20,37 @@
<dependency>
<groupId>eu.rssw.openedge.rcode</groupId>
<artifactId>rcode-reader</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.sonar.openedge</groupId>
<artifactId>sonar-openedge-plugin</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>proparse</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>profiler-parser</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>listing-parser</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion database-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>

<name>OpenEdge database definition lexer and parser</name>
<description>OpenEdge dump files parser</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ public Void visitFieldColumnLabel(FieldColumnLabelContext ctx) {
return null;
}

@Override
public Void visitFieldMandatory(DumpFileGrammarParser.FieldMandatoryContext ctx) {
if (!fields.isEmpty() && ctx != null)
fields.peek().setIsMandatory(!ctx.isEmpty());

return null;
}

@Override
public Void visitFieldInitial(FieldInitialContext ctx) {
if (!fields.isEmpty() && (ctx.QUOTED_STRING() != null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class Field {
private String format;
private String initial;
private Integer maxWidth;
private Boolean isMandatory;
private Collection<Trigger> triggers = new ArrayList<>();

private int firstLine;
Expand Down Expand Up @@ -145,6 +146,14 @@ public void setLastLine(int lastLine) {
this.lastLine = lastLine;
}

public Boolean isMandatory() {
return (isMandatory != null) && (isMandatory != false);
}

public void setIsMandatory(Boolean isMandatory) {
this.isMandatory = isMandatory;
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ public void testFieldAttributes() throws IOException {

f = db.getTable("PurchaseOrder").getField("SupplierIDNum");
assertEquals(f.getColumnLabel(), "Supplier ID");

f = db.getTable("Supplier").getField("Password");
assertEquals(f.isMandatory(), Boolean.TRUE);

f = db.getTable("Supplier").getField("Phone");
assertEquals(f.isMandatory(), Boolean.FALSE);
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion listing-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>listing-parser</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>

<name>OpenEdge listing so-called parser</name>
<description>OpenEdge listing files parser</description>
Expand Down
8 changes: 4 additions & 4 deletions openedge-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>

<name>OpenEdge checks</name>
<description>OpenEdge checks</description>
Expand Down Expand Up @@ -49,18 +49,18 @@
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>7.9.6</version>
<version>8.9.10.61524</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>proparse</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class Constants {
public static final String PROPATH_DLC = "sonar.oe.propath.dlc";
public static final String DATABASES = "sonar.oe.databases";
public static final String SLINT_DATABASES = "sonar.oe.lint.databases";
public static final String SLINT_PL_CACHE = "sonar.oe.lint.pl.cache";
public static final String ALIASES = "sonar.oe.aliases";
public static final String CPD_ANNOTATIONS = "sonar.oe.cpd.annotations";
public static final String CPD_METHODS = "sonar.oe.cpd.skip_methods";
Expand Down
18 changes: 12 additions & 6 deletions openedge-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.sonar.openedge</groupId>
<artifactId>sonar-openedge-plugin</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
<packaging>sonar-plugin</packaging>

<name>OpenEdge plugin for SonarQube</name>
Expand Down Expand Up @@ -54,23 +54,23 @@
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>7.9.6</version>
<version>8.9.10.61524</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>listing-parser</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>profiler-parser</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand All @@ -80,13 +80,19 @@
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-ws</artifactId>
<version>7.9.6</version>
<version>8.9.10.61524</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api-impl</artifactId>
<version>8.9.10.61524</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@
import java.io.OutputStream;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -102,6 +105,9 @@ public class OpenEdgeSettings {
private final Set<String> cpdAnnotations = new HashSet<>();
private final Set<String> cpdMethods = new HashSet<>();
private final Set<String> cpdProcedures = new HashSet<>();
// List of all classes available in PL files. File generated by SonarLint Eclipse, and only
// read when sensor is triggered by SonarLint
private final Map<String, String> procLibCache = new HashMap<>();

private RefactorSessionEnv sessionsEnv;
private RefactorSession defaultSession;
Expand All @@ -127,12 +133,11 @@ public final void init() {
initializeDefaultPropath(config, fileSystem);
initializeCPD(config);
initializeIncludeExtensions(config);
initializeProlibCache();
rtbCompatibility = config.getBoolean(Constants.RTB_COMPATIBILITY).orElse(false);
if (rtbCompatibility)
LOG.info("Using Roundtable compatibility mode");

LOG.debug("Using backslash as escape character : {}", config.getBoolean(Constants.BACKSLASH_ESCAPE).orElse(false));
LOG.info("XML XREF filter activated");
init = true;
}

Expand Down Expand Up @@ -233,6 +238,24 @@ private final void initializeIncludeExtensions(Configuration config) {
String::toLowerCase).collect(Collectors.toList()));
}

private final void initializeProlibCache() {
if ((runtime.getProduct() == SonarProduct.SONARLINT) && config.get(Constants.SLINT_PL_CACHE).isPresent()) {
File cache = new File(config.get(Constants.SLINT_PL_CACHE).get());
if (cache.exists() && cache.isFile() && cache.canRead()) {
try {
for (String str : java.nio.file.Files.readAllLines(cache.toPath(), StandardCharsets.UTF_8)) {
int commaPos = str.indexOf(':');
if ((commaPos > 0) && (str.length() > commaPos)) {
procLibCache.putIfAbsent(str.substring(0, commaPos), str.substring(commaPos + 1));
}
}
} catch (IOException caught) {
LOG.error("Unable to read PL cache " + cache.getAbsolutePath(), caught);
}
}
}
}

public final void parseHierarchy(InputFile file) {
// SonarLint only ; try to read rcode of InputFile
String relPath = getRelativePathToSourceDirs(file);
Expand All @@ -250,20 +273,51 @@ public final void parseHierarchy(InputFile file) {
}

private final void parseHierarchy(ITypeInfo info) {
LOG.info("Injecting type info '{}'", info);
// SonarLint only - See previous method
defaultSession.injectTypeInfo(info);
if (info.getParentTypeName() != null) {
ITypeInfo inf = getRCode2(info.getParentTypeName());
if (inf != null) {
ITypeInfo inf = searchTypeInfoSonarLint(info.getParentTypeName());
if (inf != null)
parseHierarchy(inf);
}
}
for (String iface : info.getInterfaces()) {
ITypeInfo inf = getRCode2(iface);
if (inf != null) {
ITypeInfo inf = searchTypeInfoSonarLint(iface);
if (inf != null)
parseHierarchy(inf);
}
}

private final ITypeInfo searchTypeInfoSonarLint(String entry) {
// SonarLint only - See previous method
ITypeInfo inf = getRCode2(entry);
if (inf != null) {
return inf;
} else {
if (procLibCache.containsKey(entry)) {
ITypeInfo inf2 = readSonarLintPL(procLibCache.get(entry));
if (inf2 != null) {
return inf2;
}
}
}
return null;
}

private final ITypeInfo readSonarLintPL(String entry) {
// Format is FileName followed by hash followed by entry name
int hashPos = entry.indexOf('#');
if ((hashPos > -1) && (entry.length() > hashPos)) {
try {
PLReader reader = new PLReader(Paths.get(entry.substring(0, hashPos)));
RCodeInfo info = new RCodeInfo(reader.getInputStream(reader.getEntry(entry.substring(hashPos + 1))));
if (info.isClass())
return info.getTypeInfo();
} catch (Throwable caught) {
LOG.error("Unable to open '" + entry + "' from PL cache", caught);
return null;
}
}
return null;
}

private final void parseClassDocumentation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.prorefactor.proparse.support.IProparseEnvironment;
import org.sonar.api.batch.fs.FilePredicates;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultFilePredicates;
import org.sonar.api.batch.fs.internal.predicates.DefaultFilePredicates;
import org.sonar.api.batch.sensor.internal.SensorContextTester;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.plugins.openedge.OpenEdgePluginTest;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
<packaging>pom</packaging>

<name>OpenEdge plugin for SonarQube</name>
Expand Down
2 changes: 1 addition & 1 deletion profiler-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>profiler-parser</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>

<name>OpenEdge profiler output lexer and parser</name>
<description>OpenEdge profiler files parser</description>
Expand Down
4 changes: 2 additions & 2 deletions proparse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>proparse</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>

<name>Proparse</name>
<description>ABL code parser</description>
Expand Down Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>eu.rssw.openedge.rcode</groupId>
<artifactId>rcode-reader</artifactId>
<version>2.19.5</version>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
Expand Down
Loading

0 comments on commit d175c8d

Please sign in to comment.