diff --git a/database-parser/pom.xml b/database-parser/pom.xml index 973ea1f34..7c6177248 100644 --- a/database-parser/pom.xml +++ b/database-parser/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers database-parser - 2.6.1 + 2.6.2 OpenEdge database definition lexer and parser OpenEdge dump files parser diff --git a/listing-parser/pom.xml b/listing-parser/pom.xml index ecd85e77f..84ff1f7ae 100644 --- a/listing-parser/pom.xml +++ b/listing-parser/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers listing-parser - 2.6.1 + 2.6.2 OpenEdge listing so-called parser OpenEdge listing files parser diff --git a/openedge-checks/pom.xml b/openedge-checks/pom.xml index 882458e8e..48de92635 100644 --- a/openedge-checks/pom.xml +++ b/openedge-checks/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.checks openedge-checks - 2.6.1 + 2.6.2 OpenEdge checks OpenEdge checks @@ -54,12 +54,12 @@ eu.rssw.openedge.parsers database-parser - 2.6.1 + 2.6.2 eu.rssw.openedge.parsers proparse - 2.6.1 + 2.6.2 org.testng diff --git a/openedge-plugin/pom.xml b/openedge-plugin/pom.xml index a559d9fe6..87aa85e9c 100644 --- a/openedge-plugin/pom.xml +++ b/openedge-plugin/pom.xml @@ -4,7 +4,7 @@ eu.rssw.sonar.openedge sonar-openedge-plugin - 2.6.1 + 2.6.2 sonar-plugin OpenEdge plugin for SonarQube @@ -62,17 +62,17 @@ eu.rssw.openedge.checks openedge-checks - 2.6.1 + 2.6.2 eu.rssw.openedge.parsers listing-parser - 2.6.1 + 2.6.2 eu.rssw.openedge.parsers profiler-parser - 2.6.1 + 2.6.2 commons-lang 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 6a97a4aee..d529b9d26 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 @@ -42,6 +42,8 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.sax.SAXSource; import org.antlr.v4.runtime.RecognitionException; import org.antlr.v4.runtime.misc.ParseCancellationException; @@ -82,7 +84,9 @@ import org.sonar.plugins.openedge.foundation.OpenEdgeRulesDefinition; import org.sonar.plugins.openedge.foundation.OpenEdgeSettings; import org.w3c.dom.Document; +import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; import com.google.common.base.Joiner; import com.google.common.base.Strings; @@ -104,6 +108,7 @@ public class OpenEdgeProparseSensor implements Sensor { private final DocumentBuilder dBuilder; private final JAXBContext context; private final Unmarshaller unmarshaller; + private final SAXParserFactory sax; // File statistics private int numFiles; @@ -126,12 +131,14 @@ public class OpenEdgeProparseSensor implements Sensor { public OpenEdgeProparseSensor(OpenEdgeSettings settings, OpenEdgeComponents components) { this.settings = settings; this.components = components; - dbFactory = DocumentBuilderFactory.newInstance(); + sax = SAXParserFactory.newInstance(); + sax.setNamespaceAware(false); + try { dbFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); dBuilder = dbFactory.newDocumentBuilder(); - context = JAXBContext.newInstance(CrossReference.class); + context = JAXBContext.newInstance("com.progress.xref", CrossReference.class.getClassLoader()); unmarshaller = context.createUnmarshaller(); } catch (ParserConfigurationException | JAXBException caught) { throw new IllegalStateException(caught); @@ -214,7 +221,6 @@ private Document parseXREF(File xrefFile) { doc = dBuilder.parse( settings.useXrefFilter() ? new InvalidXMLFilterStream(settings.getXrefBytes(), inpStream) : inpStream); xmlParseTime += (System.currentTimeMillis() - startTime); - numXREF++; } catch (SAXException | IOException caught) { LOG.error("Unable to parse XREF file " + xrefFile.getAbsolutePath(), caught); } @@ -229,11 +235,14 @@ private CrossReference jaxbXREF(File xrefFile) { LOG.debug("Parsing XML XREF file {}", xrefFile.getAbsolutePath()); try (InputStream inpStream = new FileInputStream(xrefFile)) { long startTime = System.currentTimeMillis(); - doc = (CrossReference) unmarshaller.unmarshal( + InputSource is = new InputSource( settings.useXrefFilter() ? new InvalidXMLFilterStream(settings.getXrefBytes(), inpStream) : inpStream); + XMLReader reader = sax.newSAXParser().getXMLReader(); + SAXSource source = new SAXSource(reader, is); + doc = (CrossReference) unmarshaller.unmarshal(source); xmlParseTime += (System.currentTimeMillis() - startTime); numXREF++; - } catch (JAXBException | IOException caught) { + } catch (JAXBException | SAXException | ParserConfigurationException | IOException caught) { LOG.error("Unable to parse XREF file " + xrefFile.getAbsolutePath(), caught); } } diff --git a/pom.xml b/pom.xml index 3333c91a4..b6d107da1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ eu.rssw sonar-openedge pom - 2.6.1 + 2.6.2 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 25fc015d5..d23760e4e 100644 --- a/profiler-parser/pom.xml +++ b/profiler-parser/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers profiler-parser - 2.6.1 + 2.6.2 OpenEdge profiler output lexer and parser OpenEdge profiler files parser diff --git a/proparse/pom.xml b/proparse/pom.xml index 69fc83b89..31fe789b2 100644 --- a/proparse/pom.xml +++ b/proparse/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.parsers proparse - 2.6.1 + 2.6.2 Proparse ABL code parser @@ -54,7 +54,7 @@ eu.rssw.openedge.rcode rcode-reader - 2.6.1 + 2.6.2 org.antlr diff --git a/proparse/src/main/java/com/progress/xref/CrossReference.java b/proparse/src/main/java/com/progress/xref/CrossReference.java index 9fd94f408..3821c6e1e 100644 --- a/proparse/src/main/java/com/progress/xref/CrossReference.java +++ b/proparse/src/main/java/com/progress/xref/CrossReference.java @@ -185,9 +185,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "source" -}) +@XmlType(name = "", propOrder = {"source"}) @XmlRootElement(name = "Cross-reference") public class CrossReference { diff --git a/proparse/src/main/java/com/progress/xref/package-info.java b/proparse/src/main/java/com/progress/xref/package-info.java deleted file mode 100644 index 8f28794ee..000000000 --- a/proparse/src/main/java/com/progress/xref/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2015-2019 Riverside Software - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License, v. 2.0 are satisfied: GNU Lesser General Public License v3.0 - * which is available at https://www.gnu.org/licenses/lgpl-3.0.txt - * - * SPDX-License-Identifier: EPL-2.0 OR LGPL-3.0 - ********************************************************************************/ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2019.09.04 at 08:32:00 AM UTC -// - -@javax.xml.bind.annotation.XmlSchema(namespace = "uri:schemas-progress-com:XREFD:0005", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -package com.progress.xref; diff --git a/proparse/src/main/java/org/prorefactor/treeparser/ParseUnit.java b/proparse/src/main/java/org/prorefactor/treeparser/ParseUnit.java index 9e7d38944..3bf16df12 100644 --- a/proparse/src/main/java/org/prorefactor/treeparser/ParseUnit.java +++ b/proparse/src/main/java/org/prorefactor/treeparser/ParseUnit.java @@ -275,7 +275,8 @@ public static void attachXrefToTreeParser(ProgramRootNode root, CrossReference x && ((src.getFileNum() == 1 && recNode.getFileIndex() == 0) || Files.isSameFile(srcFile.toPath(), new File(recNode.getStatement().getFileName()).toPath()))) { recNode.setLink(IConstants.WHOLE_INDEX, "WHOLE-INDEX".equals(ref.getDetail())); - recNode.setLink(IConstants.SEARCH_INDEX_NAME, ref.getObjectContext()); + recNode.setLink(IConstants.SEARCH_INDEX_NAME, + recNode.getTableBuffer().getTable().getName() + "." + ref.getObjectContext()); lFound = true; break; } diff --git a/proparse/src/test/java/org/prorefactor/core/JPNodeTest.java b/proparse/src/test/java/org/prorefactor/core/JPNodeTest.java index 587d7cd04..f2e3b2c4b 100644 --- a/proparse/src/test/java/org/prorefactor/core/JPNodeTest.java +++ b/proparse/src/test/java/org/prorefactor/core/JPNodeTest.java @@ -31,6 +31,9 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.sax.SAXSource; import org.prorefactor.core.nodetypes.RecordNameNode; import org.prorefactor.core.util.UnitTestModule; @@ -39,6 +42,9 @@ import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; import com.google.inject.Guice; import com.google.inject.Injector; @@ -68,7 +74,7 @@ public class JPNodeTest { @BeforeTest public void setUp() throws IOException, InvalidRCodeException { try { - context = JAXBContext.newInstance(CrossReference.class); + context = JAXBContext.newInstance("com.progress.xref", this.getClass().getClassLoader()); unmarshaller = context.createUnmarshaller(); } catch (JAXBException caught) { throw new IllegalStateException(caught); @@ -347,10 +353,17 @@ public void testFormatPhrase() { } @Test - public void testXref01() throws JAXBException, IOException { + public void testXref01() throws JAXBException, IOException, SAXException, ParserConfigurationException { ParseUnit unit = genericTest("xref.p"); unit.treeParser01(); - CrossReference doc = (CrossReference) unmarshaller.unmarshal(new FileInputStream(SRC_DIR + "/xref.p.xref")); + + InputSource is = new InputSource(new FileInputStream(SRC_DIR + "/xref.p.xref")); + SAXParserFactory sax = SAXParserFactory.newInstance(); + sax.setNamespaceAware(false); + XMLReader reader = sax.newSAXParser().getXMLReader(); + SAXSource source = new SAXSource(reader, is); + + CrossReference doc = (CrossReference) unmarshaller.unmarshal(source); unit.attachXref(doc); List nodes = unit.getTopNode().query(ABLNodeType.RECORD_NAME); @@ -360,14 +373,14 @@ public void testXref01() throws JAXBException, IOException { RecordNameNode item = (RecordNameNode) nodes.get(2); assertEquals(warehouse.getLink(IConstants.WHOLE_INDEX), Boolean.TRUE); - assertEquals(warehouse.getLink(IConstants.SEARCH_INDEX_NAME), "warehousenum"); + assertEquals(warehouse.getLink(IConstants.SEARCH_INDEX_NAME), "Warehouse.warehousenum"); assertEquals(customer.getLink(IConstants.WHOLE_INDEX), Boolean.FALSE); - assertEquals(customer.getLink(IConstants.SEARCH_INDEX_NAME), "CountryPost"); + assertEquals(customer.getLink(IConstants.SEARCH_INDEX_NAME), "Customer.CountryPost"); assertEquals(customer.getLink(IConstants.SORT_ACCESS), "Address"); assertEquals(item.getLink(IConstants.WHOLE_INDEX), Boolean.TRUE); - assertEquals(item.getLink(IConstants.SEARCH_INDEX_NAME), "ItemNum"); + assertEquals(item.getLink(IConstants.SEARCH_INDEX_NAME), "Item.ItemNum"); } } diff --git a/rcode-reader/pom.xml b/rcode-reader/pom.xml index c57885c51..0d7631881 100644 --- a/rcode-reader/pom.xml +++ b/rcode-reader/pom.xml @@ -4,7 +4,7 @@ eu.rssw.openedge.rcode rcode-reader - 2.6.1 + 2.6.2 rcode-reader rcode reader