diff --git a/.gitattributes b/.gitattributes index 56f38997e44..e74d65df3a8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,8 @@ +# to allow github to index the build directory +# we need to override the defaults of github here +# see https://docs.github.com/en/search-github/searching-on-github/finding-files-on-github +build/** linguist-generated=false + * text=auto # Generic files diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 7ee31bd55f6..7aea1a371c6 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -27,6 +27,10 @@ jobs: java-version: '17' distribution: 'temurin' cache: maven + - name: Set up Maven + uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f # v4.5 + with: + maven-version: 3.9.2 - name: Install GCC & GDB & other build essentials run: | sudo apt-get -y install build-essential gcc g++ gdb gdbserver @@ -42,7 +46,6 @@ jobs: clean verify -B -V \ -Dmaven.test.failure.ignore=true \ -DexcludedGroups=flakyTest,slowTest \ - -P baseline-compare-and-replace \ -P build-standalone-debugger-rcp \ -Ddsf.gdb.tests.timeout.multiplier=50 \ -Ddsf-gdb.skip.tests=$(test ${{ steps.filter.outputs.dsf }} == 'false' && echo 'true' || echo 'false') \ diff --git a/.github/workflows/code-cleanliness.yml b/.github/workflows/code-cleanliness.yml index 903ad9ca760..d12756bb871 100644 --- a/.github/workflows/code-cleanliness.yml +++ b/.github/workflows/code-cleanliness.yml @@ -17,6 +17,10 @@ jobs: java-version: '17' distribution: 'temurin' cache: maven + - name: Set up Maven + uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f # v4.5 + with: + maven-version: 3.9.2 - name: Install dependencies run: | sudo apt-get update && sudo apt-get install -y --no-install-recommends \ @@ -25,7 +29,11 @@ jobs: run: | curl -sL https://download.eclipse.org/eclipse/downloads/drops4/R-4.23-202203080310/eclipse-SDK-4.23-linux-gtk-x86_64.tar.gz | tar xz - name: Run Check Code Cleanliness - run: ECLIPSE=$PWD/eclipse/eclipse ./releng/scripts/check_code_cleanliness.sh + run: ECLIPSE=$PWD/eclipse/eclipse ./releng/scripts/check_code_cleanliness_only.sh + - name: Run Bundle Versions Bumped + run: ./releng/scripts/check_bundle_versions.sh + - name: Report on Bundle Versions Bumped + run: ./releng/scripts/check_bundle_versions_report.sh - name: Upload Logs uses: actions/upload-artifact@v3 if: success() || failure() diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index f41af146d2d..879349e7b7b 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -3,6 +3,6 @@ org.eclipse.tycho tycho-build - 3.0.3 + 4.0.1 diff --git a/BUILDING.md b/BUILDING.md index f897c3886d6..339bffc54c8 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -57,6 +57,10 @@ replace. To do that run with the `baseline-compare-and-replace` profile. Requires verify phase of maven to run, i.e. will not run with `mvn package` even if profile is specified. +#### api-baseline-check + +`api-baseline-check` checks the API of CDT matches the [API policy](https://github.com/eclipse-cdt/cdt/blob/main/POLICY.md#api) + #### production Runs the production steps of the build. This profile can only be run on the CDT CI machines diff --git a/Jenkinsfile b/Jenkinsfile index e56194241fd..346a2f829a3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,6 +42,7 @@ pipeline { -Dmaven.test.failure.ignore=true \ -DexcludedGroups=flakyTest,slowTest \ -P baseline-compare-and-replace \ + -P api-baseline-check \ -Ddsf.gdb.tests.timeout.multiplier=50 \ -Dindexer.timeout=300 \ -P production \ diff --git a/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF index 50ceeff5b34..0d6ccda43f5 100644 --- a/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.cdt.autotools.core;singleton:=true -Bundle-Version: 2.2.0.qualifier +Bundle-Version: 2.2.100.qualifier Bundle-Activator: org.eclipse.cdt.autotools.core.AutotoolsPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="3.4.0", @@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.4.0", org.eclipse.core.resources;bundle-version="3.4.0", org.eclipse.ui.ide;bundle-version="3.4.0", org.eclipse.cdt.managedbuilder.core;bundle-version="5.0.100", - org.eclipse.cdt.core;bundle-version="6.5.0", + org.eclipse.cdt.core;bundle-version="8.3.0", org.eclipse.cdt.ui;bundle-version="5.1.0", org.eclipse.cdt.managedbuilder.ui;bundle-version="5.0.100", org.eclipse.cdt.managedbuilder.gnu.ui;bundle-version="5.0.100", diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java index aa418c7c7a6..2f4db8600f3 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java @@ -27,7 +27,6 @@ import java.util.Random; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; @@ -38,6 +37,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfiguration.Option; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; @@ -55,6 +55,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -203,8 +204,7 @@ private Map getSavedConfigs(IProject project) { IPath fileLocation = project.getLocation().append(CFG_FILE_NAME); File dirFile = fileLocation.toFile(); Map cfgList = new HashMap<>(); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); + DocumentBuilder db = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); if (dirFile.exists()) { Document d = db.parse(dirFile); Element e = d.getDocumentElement(); @@ -269,7 +269,8 @@ else if (nameNode != null) { } } } catch (ParserConfigurationException | SAXException | IOException e) { - e.printStackTrace(); + Platform.getLog(AutotoolsConfigurationManager.class) + .error("Error while parsing .autotools file in project", e); //$NON-NLS-1$ } } return list; diff --git a/build/org.eclipse.cdt.autotools.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.autotools.tests/META-INF/MANIFEST.MF index 5f901940622..950adb2ed45 100644 --- a/build/org.eclipse.cdt.autotools.tests/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.autotools.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.cdt.autotools.tests;singleton:=true -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.1.100.qualifier Bundle-Vendor: %provider Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, @@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.ui, org.junit, org.eclipse.ui.ide, org.eclipse.jface.text, - org.eclipse.cdt.core, + org.eclipse.cdt.core;bundle-version="8.3.0", org.eclipse.cdt.autotools.ui;bundle-version="1.0.0", org.eclipse.cdt.core.tests Bundle-ActivationPolicy: lazy diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java index 9b7703a0801..a28b2d61522 100644 --- a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java +++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java @@ -25,7 +25,6 @@ import java.util.Map; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.cdt.autotools.core.AutotoolsOptionConstants; @@ -33,6 +32,7 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; @@ -535,8 +535,7 @@ public void testGetAndUpdateConfigureOptions() throws Exception { try { IPath fileLocation = testProject.getLocation().append(".autotools"); //$NON-NLS-1$ File dirFile = fileLocation.toFile(); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); + DocumentBuilder db = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); assertTrue(dirFile.exists()); Document d = db.parse(dirFile); Element e = d.getDocumentElement(); diff --git a/build/org.eclipse.cdt.autotools.ui.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.autotools.ui.tests/META-INF/MANIFEST.MF index 480e62dc1fa..d60a8d99f3e 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.autotools.ui.tests/META-INF/MANIFEST.MF @@ -2,11 +2,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.cdt.autotools.ui.tests -Bundle-Version: 1.1.0.qualifier +Bundle-Version: 1.1.100.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.swtbot.go, org.eclipse.core.resources, - org.eclipse.cdt.core + org.eclipse.cdt.core;bundle-version="8.3.0" Bundle-ActivationPolicy: lazy Fragment-Host: org.eclipse.cdt.autotools.ui Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameterTest.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameterTest.java index 19ca5536edf..2cc4a0af765 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameterTest.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameterTest.java @@ -24,8 +24,8 @@ import java.util.regex.Pattern; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; @@ -108,8 +108,7 @@ public void t1canSetConfigParm() throws Exception { File f = new File(path.toOSString()); assertTrue(f.exists()); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); + DocumentBuilder db = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document d = db.parse(f); Element e = d.getDocumentElement(); // Get the stored configuration data @@ -320,8 +319,7 @@ public void t3newConfigCopiesParms() throws Exception { path = project.getLocation().append(".autotools"); f = new File(path.toOSString()); assertTrue(f.exists()); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); + DocumentBuilder db = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document d = db.parse(f); Element e = d.getDocumentElement(); // Get the stored configuration data diff --git a/build/org.eclipse.cdt.autotools.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.autotools.ui/META-INF/MANIFEST.MF index e3cf7ec011d..0402e3316c7 100644 --- a/build/org.eclipse.cdt.autotools.ui/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.autotools.ui/META-INF/MANIFEST.MF @@ -2,14 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.cdt.autotools.ui;singleton:=true -Bundle-Version: 2.2.100.qualifier +Bundle-Version: 2.2.200.qualifier Bundle-Activator: org.eclipse.cdt.autotools.ui.AutotoolsUIPlugin Bundle-Localization: plugin Bundle-Vendor: %provider Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.cdt.autotools.core;bundle-version="1.0.0", - org.eclipse.cdt.core;bundle-version="5.1.0", + org.eclipse.cdt.core;bundle-version="8.3.0", org.eclipse.core.resources;bundle-version="3.5.0", org.eclipse.cdt.managedbuilder.core;bundle-version="6.0.0", org.eclipse.jface.text;bundle-version="3.5.0", diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfTextHover.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfTextHover.java index 39ce54a840c..d9fcb14782e 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfTextHover.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfTextHover.java @@ -42,6 +42,7 @@ import org.eclipse.cdt.internal.autotools.ui.HTMLPrinter; import org.eclipse.cdt.internal.autotools.ui.HTMLTextPresenter; import org.eclipse.cdt.internal.autotools.ui.preferences.AutotoolsEditorPreferenceConstants; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -168,12 +169,14 @@ protected static Document getACDoc(String acDocVer) { docStream = new FileInputStream(p.toFile()); } } - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory factory = XmlProcessorFactoryCdt + .createDocumentBuilderFactoryIgnoringDOCTYPE(); factory.setValidating(false); try { DocumentBuilder builder = factory.newDocumentBuilder(); doc = builder.parse(docStream); } catch (SAXException | ParserConfigurationException | IOException saxEx) { + AutotoolsPlugin.log(saxEx); doc = null; } finally { if (docStream != null) @@ -218,7 +221,8 @@ protected static Document getAMDoc(String amDocVer) { docStream = new FileInputStream(p.toFile()); } } - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory factory = XmlProcessorFactoryCdt + .createDocumentBuilderFactoryIgnoringDOCTYPE(); factory.setValidating(false); try { DocumentBuilder builder = factory.newDocumentBuilder(); diff --git a/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF index d275926573f..8a0af3cccd0 100644 --- a/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.make.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.make.core; singleton:=true -Bundle-Version: 7.6.200.qualifier +Bundle-Version: 7.6.300.qualifier Bundle-Activator: org.eclipse.cdt.make.core.MakeCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -19,7 +19,7 @@ Export-Package: org.eclipse.cdt.make.core, org.eclipse.cdt.make.internal.core.scannerconfig.jobs;x-internal:=true, org.eclipse.cdt.make.internal.core.scannerconfig.util;x-internal:=true, org.eclipse.cdt.make.internal.core.scannerconfig2;x-internal:=true -Require-Bundle: org.eclipse.cdt.core;bundle-version="[8.0.0,9.0.0)", +Require-Bundle: org.eclipse.cdt.core;bundle-version="[8.3.0,9.0.0)", org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java index 1a53a4004bc..9c29eef67da 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java @@ -24,12 +24,11 @@ import java.util.List; import java.util.Map.Entry; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.XmlStorageUtil; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.make.core.IMakeCommonBuildInfo; import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.core.MakeCorePlugin; @@ -237,7 +236,7 @@ public void saveTargets() throws CoreException { */ protected ICStorageElement translateInputStreamToDocument(InputStream input) { try { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input); + Document document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().parse(input); return XmlStorageUtil.createCStorageTree(document); } catch (Exception e) { MakeCorePlugin.log(e); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java index 8d219406413..c8cc8d36b13 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java @@ -25,15 +25,14 @@ import java.util.Map; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable; import org.eclipse.cdt.make.core.scannerconfig.InfoContext; @@ -159,7 +158,7 @@ private Document getDocument(IProject project) throws CoreException { Document document = ref != null ? ref.get() : null; if (document == null) { try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); IPath path = getDiscoveredScannerConfigStore(project); if (path.toFile().exists()) { // read form file @@ -292,7 +291,8 @@ public void saveDiscoveredScannerInfoToState(IProject project, InfoContext conte // Transform the document to something we can save in a file ByteArrayOutputStream stream = new ByteArrayOutputStream(); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF index ee41ef55a15..ee9274b6cf9 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF @@ -33,7 +33,7 @@ Export-Package: org.eclipse.cdt.build.core.scannerconfig, org.eclipse.cdt.managedbuilder.templateengine, org.eclipse.cdt.managedbuilder.templateengine.processes, org.eclipse.cdt.newmake.core -Require-Bundle: org.eclipse.cdt.core;bundle-version="[8.0.0,9.0.0)", +Require-Bundle: org.eclipse.cdt.core;bundle-version="[8.3.0,9.0.0)", org.eclipse.core.resources;bundle-version="[3.14.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index 0b30d850a50..f6fffda1ebe 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -38,14 +38,12 @@ import java.util.TreeMap; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; @@ -67,6 +65,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.XmlStorageUtil; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyManager; import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider; @@ -1089,7 +1088,7 @@ public static boolean saveBuildInfoLegacy(IProject project, boolean force) { // Create document Exception err = null; try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = builder.newDocument(); // Get the build information for the project @@ -1111,7 +1110,8 @@ public static boolean saveBuildInfoLegacy(IProject project, boolean force) { // Transform the document to something we can save in a file ByteArrayOutputStream stream = new ByteArrayOutputStream(); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -1261,7 +1261,7 @@ private static boolean updateBuildInfo(IProject project, boolean force) throws C // Create document Exception err = null; try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = builder.newDocument(); // Get the build information for the project @@ -1284,7 +1284,7 @@ private static boolean updateBuildInfo(IProject project, boolean force) throws C // Transform the document to something we can save in a file ByteArrayOutputStream stream = new ByteArrayOutputStream(); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -1836,7 +1836,7 @@ private static ManagedBuildInfo loadOldStyleBuildInfo(final IProject project) th // So there is a project file, load the information there try (InputStream stream = new FileInputStream(cdtbuild)) { - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document document = parser.parse(stream); String fileVersion = null; @@ -2516,7 +2516,7 @@ public static boolean manages(IResource resource) { // if (file.exists()) { // try { // InputStream stream = file.getContents(); - // DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + // DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); // Document document = parser.parse(stream); // NodeList nodes = document.getElementsByTagName(ROOT_NODE_NAME); // return (nodes.getLength() > 0); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java index 3a0683862b1..40044b0c74e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject12.java @@ -23,8 +23,8 @@ import java.util.Vector; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IConfiguration; @@ -709,7 +709,7 @@ public static void doProjectUpdate(IProgressMonitor monitor, final IProject proj try { // Load the old build file InputStream stream = new FileInputStream(settingsFile); - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document document = parser.parse(stream); // Clone the target based on the proper target definition diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java index be4db6fe38c..1d7faa749c4 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject20.java @@ -19,8 +19,8 @@ import java.util.Vector; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IBuilder; import org.eclipse.cdt.managedbuilder.core.IConfiguration; @@ -78,7 +78,7 @@ static void doProjectUpdate(IProgressMonitor monitor, final IProject project) th try { // Load the old build file InputStream stream = new FileInputStream(settingsFile); - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document document = parser.parse(stream); // Clone the target based on the proper target definition diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/XMLDumper.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/XMLDumper.java index 7d3dc6e1111..4aa59bac8cb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/XMLDumper.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/XMLDumper.java @@ -19,14 +19,13 @@ import java.lang.reflect.Modifier; import java.util.HashMap; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -53,7 +52,8 @@ public static void main(String[] args) { Document document = dumper.getDocument(); StringWriter writer = new StringWriter(); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.transform(new DOMSource(document), new StreamResult(writer)); System.out.println("STRXML = " + writer.toString()); //Spit out DOM as a String //$NON-NLS-1$ @@ -74,7 +74,7 @@ public Document getDocument() { } public XMLDumper(Object obj) throws ParserConfigurationException { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); document.appendChild(createObject(obj)); } diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 8d1303efaa9..d3c9947083d 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -55,7 +55,16 @@ Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.make.ui, org.eclipse.cdt.managedbuilder.core, org.eclipse.cdt.managedbuilder.ui, - org.eclipse.cdt.ui", + org.eclipse.cdt.ui, + org.eclipse.cdt.autotools.core, + org.eclipse.cdt.autotools.tests, + org.eclipse.cdt.autotools.ui, + org.eclipse.cdt.autotools.ui.tests, + org.eclipse.cdt.core.tests, + org.eclipse.cdt.debug.ui, + org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui, + org.eclipse.cdt.testsrunner.boost, + org.eclipse.cdt.testsrunner.qttest", org.eclipse.cdt.internal.core.browser;x-friends:="org.eclipse.cdt.ui", org.eclipse.cdt.internal.core.cdtvariables;x-internal:=true, org.eclipse.cdt.internal.core.dom;x-internal:=true, diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java index 2d61d250bf5..6da0b75442a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java @@ -23,12 +23,10 @@ import java.util.Map.Entry; import java.util.TreeMap; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; @@ -41,6 +39,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.internal.core.Util; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.preferences.DefaultScope; @@ -194,7 +193,7 @@ private void addProjectContentTypeMappings(Map> cont public void storeMappings(WorkspaceLanguageConfiguration config) throws CoreException { try { // Encode mappings as XML and serialize as a String. - Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + Document doc = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); Element rootElement = doc.createElement(WORKSPACE_MAPPINGS); doc.appendChild(rootElement); addContentTypeMappings(config.getWorkspaceMappings(), rootElement); @@ -233,7 +232,7 @@ public WorkspaceLanguageConfiguration decodeWorkspaceMappings() throws CoreExcep // The mappings are encoded as XML in a String so we need to parse it. InputSource input = new InputSource(new StringReader(encodedMappings)); try { - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(input); + Document document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().parse(input); config.setWorkspaceMappings(decodeContentTypeMappings(document.getDocumentElement())); return config; } catch (SAXException e) { @@ -247,7 +246,7 @@ public WorkspaceLanguageConfiguration decodeWorkspaceMappings() throws CoreExcep private Transformer createSerializer() throws CoreException { try { - return TransformerFactory.newInstance().newTransformer(); + return XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE().newTransformer(); } catch (TransformerConfigurationException e) { throw new CoreException(Util.createStatus(e)); } catch (TransformerFactoryConfigurationError e) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index c566cb899c3..ff79da4909e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -45,14 +45,12 @@ import java.util.concurrent.CopyOnWriteArraySet; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; @@ -98,6 +96,7 @@ import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PatternNameMap; import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.core.model.CElementDelta; import org.eclipse.cdt.internal.core.settings.model.CExternalSettinsDeltaCalculator.ExtSettingsDelta; import org.eclipse.cdt.internal.core.settings.model.xml.InternalXmlStorageElement; @@ -918,7 +917,8 @@ private void serializePreference(String key, InternalXmlStorageElement element) ByteArrayOutputStream stream = new ByteArrayOutputStream(); FileOutputStream fileStream = null; try { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -1234,7 +1234,7 @@ private void initProviderInfo() { public ICStorageElement createPreferenceStorage(String key, boolean createEmptyIfNotFound, boolean readOnly) throws CoreException { try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = null; Element element = null; InputStream stream = null; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionStorageManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionStorageManager.java index 8636b6030f2..d8580296895 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionStorageManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionStorageManager.java @@ -27,13 +27,11 @@ import java.util.concurrent.ConcurrentHashMap; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; @@ -41,6 +39,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.settings.model.ICProjectDescriptionStorageType.CProjectDescriptionStorageTypeProxy; import org.eclipse.cdt.internal.core.settings.model.xml.XmlProjectDescriptionStorage; @@ -67,6 +66,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; +import org.xml.sax.SAXException; /** * Class that marshals creation of AbstractCProjectDescriptionStorages @@ -163,7 +163,7 @@ private void writeProjectStorageType(IProject project, CProjectDescriptionStorag throws CoreException { Document doc; try { - doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + doc = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); // Set the version ProcessingInstruction instruction = doc.createProcessingInstruction( ICProjectDescriptionStorageType.STORAGE_VERSION_NAME, type.version.toString()); @@ -175,7 +175,8 @@ private void writeProjectStorageType(IProject project, CProjectDescriptionStorag XmlUtil.prettyFormat(doc); ByteArrayOutputStream stream = new ByteArrayOutputStream(); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ // Indentation is done with XmlUtil.prettyFormat(doc) @@ -222,7 +223,7 @@ private AbstractCProjectDescriptionStorage loadProjectStorage(IProject project) InputStream stream = null; try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); stream = getInputStreamForIFile(project, ICProjectDescriptionStorageType.STORAGE_FILE_NAME); if (stream != null) { Document doc = builder.parse(stream); @@ -352,7 +353,7 @@ private synchronized void initExtensionPoints() { CProjectDescriptionStorageTypeProxy type = initStorageType(configEl); if (type != null) { if (!m.containsKey(type.id)) - m.put(type.id, new LinkedList()); + m.put(type.id, new LinkedList<>()); m.get(type.id).add(type); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java index a6df97cb85a..8a0c98eaff6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlProjectDescriptionStorage.java @@ -26,14 +26,12 @@ import java.net.URI; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; @@ -44,6 +42,7 @@ import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter; import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.envvar.ContributedEnvironment; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; @@ -543,7 +542,8 @@ private ByteArrayOutputStream write(ICStorageElement element) throws CoreExcepti ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ // Indentation is done with XmlUtil.prettyFormat(doc) @@ -632,7 +632,7 @@ protected long serialize(IContainer container, String file, ICStorageElement ele private ICStorageElement readOldCDTProjectFile(IProject project) throws CoreException { ICStorageElement storage = null; try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = null; InputStream stream = getSharedProperty(project, OLD_CDTPROJECT_FILE_NAME); if (stream != null) { @@ -669,7 +669,7 @@ private ICStorageElement readOldCDTProjectFile(IProject project) throws CoreExce protected InternalXmlStorageElement createStorage(IContainer container, String fileName, boolean reCreate, boolean createEmptyIfNotFound, boolean readOnly) throws CoreException { try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = null; Element element = null; InputStream stream = null; @@ -851,7 +851,7 @@ public void projectMove(IProject newProject) { */ public Element createXmlElementCopy(InternalXmlStorageElement el) throws CoreException { try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = builder.newDocument(); Element newXmlEl = null; synchronized (doc) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java index 47941d136b6..67e760ef4ea 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/xml/XmlStorageElement.java @@ -22,17 +22,16 @@ import java.util.Set; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.core.settings.model.ICSettingsStorage; import org.eclipse.cdt.core.settings.model.ICStorageElement; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.core.runtime.CoreException; import org.w3c.dom.Document; @@ -462,7 +461,7 @@ protected Element createXmlElementCopy() throws CoreException { try { synchronized (fLock) { Element newXmlEl = null; - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = builder.newDocument(); synchronized (doc) { if (fElement.getParentNode().getNodeType() == Node.DOCUMENT_NODE) { @@ -513,7 +512,8 @@ public String toString() { synchronized (fLock) { try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); // Indentation is done with XmlUtil.prettyFormat(doc). // For debugging, the prettyFormat may not have been run yet, // so turning this to "yes" may be helpful on occasion. diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java index 92268fd5fa6..db9b5472f72 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/UserDefinedVariableSupplier.java @@ -25,13 +25,11 @@ import java.util.Set; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; @@ -39,6 +37,7 @@ import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.ICdtVariable; import org.eclipse.cdt.core.settings.model.ICStorageElement; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo; @@ -94,7 +93,7 @@ private StorableCdtVariables getStorableMacros(int contextType, Object contextDa } private UserDefinedVariableSupplier() { - fListeners = Collections.synchronizedSet(new HashSet()); + fListeners = Collections.synchronizedSet(new HashSet<>()); } public static UserDefinedVariableSupplier getInstance() { @@ -532,7 +531,7 @@ protected void storeWorkspaceMacros(StorableCdtVariables macros, boolean force) private StorableCdtVariables loadMacrosFromStream(InputStream stream, boolean readOnly) { try { - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); InputSource inputSource = new InputSource(stream); Document document = parser.parse(inputSource); Element rootElement = document.getDocumentElement(); @@ -554,8 +553,7 @@ private StorableCdtVariables loadMacrosFromStream(InputStream stream, boolean re private ByteArrayOutputStream storeMacrosToStream(StorableCdtVariables macros) throws CoreException { try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document document = builder.newDocument(); Element rootElement = document.createElement(StorableCdtVariables.MACROS_ELEMENT_NAME); @@ -563,7 +561,8 @@ private ByteArrayOutputStream storeMacrosToStream(StorableCdtVariables macros) t ICStorageElement storageElement = new XmlStorageElement(rootElement); macros.serialize(storageElement); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java index aed2d2650cd..b5408c3aacf 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java @@ -20,7 +20,6 @@ import java.util.List; import java.util.Map; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Result; import javax.xml.transform.TransformerConfigurationException; @@ -29,6 +28,7 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -126,7 +126,7 @@ private void initSharedDefaults() { if (length == 0) { parsedXML = createDefaultXMLFormat(parsedXML); } - document = DocumentBuilderFactory.newInstance().newDocumentBuilder() + document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE() .parse(parsedXML.toURI().toURL().openStream()); } catch (Exception exp) { TemplateEngineUtil.log(exp); @@ -198,7 +198,7 @@ public void addToBackEndStorage(String name, String value) { */ public void updateToBackEndStorage(String updateName, String updateValue) { try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder() + document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE() .parse(parsedXML.toURI().toURL().openStream()); } catch (Exception exp) { TemplateEngineUtil.log(exp); @@ -227,7 +227,7 @@ public void updateToBackEndStorage(String updateName, String updateValue) { */ public void deleteBackEndStorage(String[] deleteName) { try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder() + document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE() .parse(parsedXML.toURI().toURL().openStream()); } catch (Exception exp) { TemplateEngineUtil.log(exp); @@ -261,7 +261,7 @@ public void deleteBackEndStorage(String[] deleteName) { private File createDefaultXMLFormat(File xmlFile) { Document d; try { - d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + d = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); } catch (ParserConfigurationException e) { TemplateEngineUtil.log(e); return xmlFile; @@ -272,7 +272,7 @@ private File createDefaultXMLFormat(File xmlFile) { element.setAttribute(TemplateEngineHelper.VALUE, ""); //$NON-NLS-1$ DOMSource domSource = new DOMSource(d); - TransformerFactory transFactory = TransformerFactory.newInstance(); + TransformerFactory transFactory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); try { FileOutputStream fos = null; @@ -303,7 +303,7 @@ private File createDefaultXMLFormat(File xmlFile) { private void generateSharedXML(File xmlFile) { Document d; try { - d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + d = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); } catch (ParserConfigurationException e) { TemplateEngineUtil.log(e); return; @@ -317,7 +317,7 @@ private void generateSharedXML(File xmlFile) { } DOMSource domSource = new DOMSource(d); - TransformerFactory transFactory = TransformerFactory.newInstance(); + TransformerFactory transFactory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Result fileResult = new StreamResult(xmlFile); try { transFactory.newTransformer().transform(domSource, fileResult); diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java index f8a709f1dc1..82bbf3879e3 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java @@ -20,9 +20,9 @@ import java.util.List; import java.util.Map; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.osgi.util.NLS; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -54,7 +54,8 @@ public class TemplateDescriptor { public TemplateDescriptor(URL descriptorURL, String pluginId) throws TemplateInitializationException { String msg = NLS.bind(Messages.TemplateCore_init_failed, descriptorURL.toString()); try { - this.document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(descriptorURL.openStream()); + this.document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE() + .parse(descriptorURL.openStream()); } catch (ParserConfigurationException pce) { throw new TemplateInitializationException(msg, pce); } catch (IOException ioe) { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlProcessorFactoryCdt.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlProcessorFactoryCdt.java new file mode 100644 index 00000000000..0e753806034 --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlProcessorFactoryCdt.java @@ -0,0 +1,189 @@ +/******************************************************************************* + * Copyright (c) 2023 Joerg Kubitz and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.cdt.internal.core; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.TransformerFactory; + +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; + +/** + * XML processing which prohibits external entities. + * + * Copied from https://github.com/eclipse-jdt/eclipse.jdt.debug/blob/1d59af8a6a37f9cf8143d73d94e4c1c3555363d6/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/XmlProcessorFactoryJdtDebug.java + * + * @see RSPEC-2755 + */ +public class XmlProcessorFactoryCdt { + private XmlProcessorFactoryCdt() { + // static Utility only + } + + private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY_ERROR_ON_DOCTYPE = createDocumentBuilderFactoryWithErrorOnDOCTYPE(); + private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY_IGNORING_DOCTYPE = createDocumentBuilderFactoryIgnoringDOCTYPE(); + private static final SAXParserFactory SAX_FACTORY_ERROR_ON_DOCTYPE = createSAXFactoryWithErrorOnDOCTYPE(false); + private static final SAXParserFactory SAX_FACTORY_ERROR_ON_DOCTYPE_NS = createSAXFactoryWithErrorOnDOCTYPE(true); + private static final SAXParserFactory SAX_FACTORY_IGNORING_DOCTYPE = createSAXFactoryIgnoringDOCTYPE(); + + /** + * Creates TransformerFactory which throws TransformerException when detecting external entities. + * + * @return javax.xml.transform.TransformerFactory + */ + public static TransformerFactory createTransformerFactoryWithErrorOnDOCTYPE() { + TransformerFactory factory = TransformerFactory.newInstance(); + // prohibit the use of all protocols by external entities: + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); //$NON-NLS-1$ + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); //$NON-NLS-1$ + return factory; + } + + /** + * Creates DocumentBuilderFactory which throws SAXParseException when detecting external entities. It's magnitudes faster to call + * {@link #createDocumentBuilderWithErrorOnDOCTYPE()}. + * + * @return javax.xml.parsers.DocumentBuilderFactory + */ + public static synchronized DocumentBuilderFactory createDocumentBuilderFactoryWithErrorOnDOCTYPE() { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + // completely disable DOCTYPE declaration: + try { + factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); //$NON-NLS-1$ + } catch (ParserConfigurationException e) { + throw new RuntimeException(e.getMessage(), e); + } + return factory; + } + + /** + * Creates DocumentBuilderFactory which ignores external entities. It's magnitudes faster to call {@link #createDocumentBuilderIgnoringDOCTYPE()}. + * + * @return javax.xml.parsers.DocumentBuilderFactory + */ + public static synchronized DocumentBuilderFactory createDocumentBuilderFactoryIgnoringDOCTYPE() { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + try { + // completely disable external entities declarations: + factory.setFeature("http://xml.org/sax/features/external-general-entities", false); //$NON-NLS-1$ + factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); //$NON-NLS-1$ + } catch (ParserConfigurationException e) { + throw new RuntimeException(e.getMessage(), e); + } + return factory; + } + + /** + * Creates DocumentBuilder which throws SAXParseException when detecting external entities. The builder is not thread safe. + * + * @return javax.xml.parsers.DocumentBuilder + * @throws ParserConfigurationException + */ + public static DocumentBuilder createDocumentBuilderWithErrorOnDOCTYPE() throws ParserConfigurationException { + return DOCUMENT_BUILDER_FACTORY_ERROR_ON_DOCTYPE.newDocumentBuilder(); + } + + /** + * Creates DocumentBuilder which ignores external entities. The builder is not thread safe. + * + * @return javax.xml.parsers.DocumentBuilder + * @throws ParserConfigurationException + */ + public static DocumentBuilder createDocumentBuilderIgnoringDOCTYPE() throws ParserConfigurationException { + return DOCUMENT_BUILDER_FACTORY_IGNORING_DOCTYPE.newDocumentBuilder(); + } + + /** + * Creates DocumentBuilderFactory which throws SAXParseException when detecting external entities. + * + * @return javax.xml.parsers.DocumentBuilderFactory + */ + public static SAXParserFactory createSAXFactoryWithErrorOnDOCTYPE() { + SAXParserFactory f = SAXParserFactory.newInstance(); + try { + // force org.xml.sax.SAXParseException for any DOCTYPE: + f.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); //$NON-NLS-1$ + } catch (Exception e) { + throw new RuntimeException(e); + } + return f; + } + + private static synchronized SAXParserFactory createSAXFactoryWithErrorOnDOCTYPE(boolean awareness) { + SAXParserFactory f = SAXParserFactory.newInstance(); + f.setNamespaceAware(awareness); + try { + // force org.xml.sax.SAXParseException for any DOCTYPE: + f.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); //$NON-NLS-1$ + } catch (Exception e) { + throw new RuntimeException(e); + } + return f; + } + + private static synchronized SAXParserFactory createSAXFactoryIgnoringDOCTYPE() { + SAXParserFactory f = SAXParserFactory.newInstance(); + try { + // ignore DOCTYPE: + f.setFeature("http://xml.org/sax/features/external-general-entities", false); //$NON-NLS-1$ + f.setFeature("http://xml.org/sax/features/external-parameter-entities", false); //$NON-NLS-1$ + f.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); //$NON-NLS-1$ + } catch (Exception e) { + throw new RuntimeException(e); + } + return f; + } + + /** + * Creates SAXParser which throws SAXParseException when detecting external entities. + * + * @return javax.xml.parsers.SAXParser + */ + + public static SAXParser createSAXParserWithErrorOnDOCTYPE() throws ParserConfigurationException, SAXException { + return createSAXParserWithErrorOnDOCTYPE(false); + } + + /** + * Creates SAXParser which throws SAXParseException when detecting external entities. + * + * @param namespaceAware + * parameter for SAXParserFactory + * + * @return javax.xml.parsers.SAXParser + */ + public static SAXParser createSAXParserWithErrorOnDOCTYPE(boolean namespaceAware) + throws ParserConfigurationException, SAXException { + if (namespaceAware) { + return SAX_FACTORY_ERROR_ON_DOCTYPE_NS.newSAXParser(); + } + return SAX_FACTORY_ERROR_ON_DOCTYPE.newSAXParser(); + } + + /** + * Creates SAXParser which does not throw Exception when detecting external entities but ignores them. + * + * @return javax.xml.parsers.SAXParser + */ + public static SAXParser createSAXParserIgnoringDOCTYPE() + throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException, SAXException { + SAXParser parser = SAX_FACTORY_IGNORING_DOCTYPE.newSAXParser(); + parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); //$NON-NLS-1$ + parser.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); //$NON-NLS-1$ + return parser; + } +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java index 5dda1e8c309..2bbcd815b0f 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java @@ -25,12 +25,10 @@ import java.util.Arrays; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; @@ -63,7 +61,7 @@ public class XmlUtil { * @throws ParserConfigurationException in case of a problem retrieving {@link DocumentBuilder}. */ public static Document newDocument() throws ParserConfigurationException { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); return builder.newDocument(); } @@ -227,7 +225,7 @@ private static void prettyFormat(Node node, String indentLevel, String indent) { */ private static Document loadXml(InputStream xmlStream) throws CoreException { try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); return builder.parse(xmlStream); } catch (Exception e) { throw new CoreException(CCorePlugin.createStatus(Messages.XmlUtil_InternalErrorLoading, e)); @@ -370,7 +368,8 @@ private static FileOutputStream getFileOutputStreamWorkaround(java.io.File store private static byte[] toByteArray(Document doc) throws CoreException { try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, ENCODING_UTF_8); // Indentation is done with XmlUtil.prettyFormat(doc). diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironmentLoader.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironmentLoader.java index 0895ec976b2..ba624801b04 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironmentLoader.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/envvar/StorableEnvironmentLoader.java @@ -20,18 +20,17 @@ import java.io.UnsupportedEncodingException; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.ICStorageElement; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.core.settings.model.xml.XmlStorageElement; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; @@ -148,7 +147,7 @@ static ICStorageElement environmentStorageFromString(String env) { if (env == null) return null; try { - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); InputSource inputSource = new InputSource(new ByteArrayInputStream(env.getBytes())); Document document = parser.parse(inputSource); Element el = document.getDocumentElement(); @@ -170,8 +169,7 @@ static ICStorageElement environmentStorageFromString(String env) { private ByteArrayOutputStream storeEnvironmentToStream(StorableEnvironment env) throws CoreException { try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document document = builder.newDocument(); Element el = document.createElement(StorableEnvironment.ENVIRONMENT_ELEMENT_NAME); @@ -179,7 +177,8 @@ private ByteArrayOutputStream storeEnvironmentToStream(StorableEnvironment env) XmlStorageElement rootElement = new XmlStorageElement(el); env.serialize(rootElement); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF index 0ec28e7d4a8..ec1c2b87881 100644 --- a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.ui.tests; singleton:=true -Bundle-Version: 5.5.300.qualifier +Bundle-Version: 5.5.400.qualifier Bundle-Activator: org.eclipse.cdt.ui.testplugin.CTestPlugin Bundle-Localization: plugin Export-Package: org.eclipse.cdt.ui.testplugin, @@ -26,7 +26,7 @@ Require-Bundle: org.eclipse.jface.text, org.eclipse.ui.views, org.eclipse.ui.workbench.texteditor, org.junit, - org.eclipse.cdt.core, + org.eclipse.cdt.core;bundle-version="8.3.0", org.eclipse.cdt.core.tests, org.eclipse.help, org.eclipse.core.runtime, diff --git a/core/org.eclipse.cdt.ui.tests/pom.xml b/core/org.eclipse.cdt.ui.tests/pom.xml index 211ff730dff..31bd2da6ff8 100644 --- a/core/org.eclipse.cdt.ui.tests/pom.xml +++ b/core/org.eclipse.cdt.ui.tests/pom.xml @@ -21,7 +21,7 @@ ../../pom.xml - 5.5.300-SNAPSHOT + 5.5.400-SNAPSHOT org.eclipse.cdt.ui.tests eclipse-test-plugin diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestSharedDefaults.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestSharedDefaults.java index 19084032772..c13b8ea3483 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestSharedDefaults.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestSharedDefaults.java @@ -16,12 +16,11 @@ import java.io.File; import java.util.List; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.cdt.core.templateengine.SharedDefaults; import org.eclipse.cdt.core.templateengine.TemplateEngine; import org.eclipse.cdt.core.templateengine.TemplateEngineHelper; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -59,7 +58,7 @@ protected void tearDown() { private String getValueFromBackEndStorate(String key) throws Exception { File parsedXML = TemplateEngineHelper.getSharedDefaultLocation("shareddefaults.xml"); - Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder() + Document document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE() .parse(parsedXML.toURI().toURL().openStream()); List sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index 3566e8c5271..a955b6d60e9 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -104,7 +104,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true, org.eclipse.cdt.ui.wizards.conversion, org.eclipse.cdt.utils.ui.controls Import-Package: org.apache.commons.io;version="[2.8.0,3.0.0)" -Require-Bundle: org.eclipse.cdt.core;bundle-version="[8.0.0,9.0.0)", +Require-Bundle: org.eclipse.cdt.core;bundle-version="[8.3.0,9.0.0)", org.eclipse.compare;bundle-version="[3.8.500,4.0.0)", org.eclipse.core.expressions;bundle-version="[3.8.200,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.9.500,2.0.0)", diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java index 8b41bd5c808..e3d71168dae 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java @@ -19,17 +19,16 @@ import java.io.IOException; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.ui.text.CHelpBookDescriptor; import org.eclipse.cdt.internal.ui.text.CHelpSettings; import org.eclipse.cdt.ui.CUIPlugin; @@ -104,7 +103,7 @@ private static CHelpSettings createHelpSettings(IProject project) { if (file.isFile()) { try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = builder.parse(file); NodeList nodes = doc.getElementsByTagName(ELEMENT_ROOT); @@ -187,7 +186,7 @@ public void serialize(ICHelpInvocationContext context) { File file = getSettingsFile(); try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc; Element rootElement = null; @@ -210,7 +209,8 @@ public void serialize(ICHelpInvocationContext context) { FileWriter writer = new FileWriter(file); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java index 6181ae206d4..03a70d6ca28 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java @@ -23,9 +23,9 @@ import java.util.List; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; +import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.ICHelpBook; import org.eclipse.cdt.ui.ICHelpProvider; import org.eclipse.cdt.ui.ICHelpResourceDescriptor; @@ -42,7 +42,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; -import org.xml.sax.SAXException; public class CHelpProvider implements ICHelpProvider { @@ -175,7 +174,7 @@ private void loadFile(IConfigurationElement el, ArrayList chbl, Stri InputStream stream = new FileInputStream(fname); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); InputSource src = new InputSource(reader); - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); doc = builder.parse(src); Element e = doc.getDocumentElement(); if (NODE_HEAD.equals(e.getNodeName())) { @@ -189,9 +188,8 @@ private void loadFile(IConfigurationElement el, ArrayList chbl, Stri } } } - } catch (ParserConfigurationException e) { - } catch (SAXException e) { - } catch (IOException e) { + } catch (Exception e) { + CUIPlugin.log("Failed to load helpbook in " + pluginId, e); //$NON-NLS-1$ } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java index bacafcf0c80..33990efeed1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java @@ -32,17 +32,15 @@ import java.util.Map; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.ui.CUIException; import org.eclipse.cdt.internal.ui.CUIStatus; import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile; @@ -235,8 +233,7 @@ public List readProfilesFromFile(File file) throws CoreException { protected static List readProfilesFromStream(InputSource inputSource) throws CoreException { final ProfileDefaultHandler handler = new ProfileDefaultHandler(); try { - final SAXParserFactory factory = SAXParserFactory.newInstance(); - final SAXParser parser = factory.newSAXParser(); + final SAXParser parser = XmlProcessorFactoryCdt.createSAXParserWithErrorOnDOCTYPE(); parser.parse(inputSource, handler); } catch (SAXException e) { throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message); @@ -282,8 +279,7 @@ public void writeProfilesToFile(Collection profiles, File file, String private static void writeProfilesToStream(Collection profiles, OutputStream stream, String encoding, IProfileVersioner profileVersioner) throws CoreException { try { - final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - final DocumentBuilder builder = factory.newDocumentBuilder(); + final DocumentBuilder builder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); final Document document = builder.newDocument(); final Element rootElement = document.createElement(XML_NODE_ROOT); @@ -299,7 +295,8 @@ private static void writeProfilesToStream(Collection profiles, OutputSt } } - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Transformer transformer = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE() + .newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, encoding); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java index 72f9fde5d06..d87979abb20 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java @@ -21,7 +21,6 @@ import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamResult; @@ -29,6 +28,7 @@ import org.eclipse.cdt.core.resources.ResourcesUtil; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICFolderDescription; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.runtime.IPath; @@ -93,7 +93,8 @@ private FileOutputStream getFileOutputStream(IProjectSettingsWizardPage page) th */ @Override public boolean finish(IProjectSettingsWizardPage page) { - SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance(); + SAXTransformerFactory factory = (SAXTransformerFactory) XmlProcessorFactoryCdt + .createTransformerFactoryWithErrorOnDOCTYPE(); TransformerHandler handler = null; try { handler = factory.newTransformerHandler(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java index 11d6e650060..1fd81cb84bf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java @@ -29,6 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICFolderDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -230,7 +231,7 @@ public void warning(SAXParseException e) throws SAXException { * will do its own validation programatically. */ private static Document parse(InputStream in) throws SettingsImportExportException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory factory = XmlProcessorFactoryCdt.createDocumentBuilderFactoryWithErrorOnDOCTYPE(); factory.setValidating(false); factory.setNamespaceAware(false); factory.setIgnoringComments(true); diff --git a/debug/org.eclipse.cdt.debug.application.product/debug.product b/debug/org.eclipse.cdt.debug.application.product/debug.product index 6ec3554810b..0fa84f1750c 100644 --- a/debug/org.eclipse.cdt.debug.application.product/debug.product +++ b/debug/org.eclipse.cdt.debug.application.product/debug.product @@ -203,7 +203,7 @@ Java and all Java-based trademarks are trademarks of Oracle Corporation in the U - + diff --git a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF index e8c495c3b57..821fa86542e 100644 --- a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true -Bundle-Version: 8.8.100.qualifier +Bundle-Version: 8.8.200.qualifier Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -38,7 +38,7 @@ Export-Package: org.eclipse.cdt.debug.core, org.eclipse.cdt.dsf.ui, org.eclipse.cdt.tests.dsf.gdb", org.eclipse.cdt.debug.internal.core.srcfinder;x-internal:=true -Require-Bundle: org.eclipse.cdt.core;bundle-version="[8.0.0,9.0.0)", +Require-Bundle: org.eclipse.cdt.core;bundle-version="[8.3.0,9.0.0)", org.eclipse.core.filesystem;bundle-version="1.2.0", org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java index 74768b88cbf..9a510412b35 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java @@ -46,6 +46,7 @@ import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint2; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; @@ -227,7 +228,7 @@ public static boolean isReferencedProject(IProject parent, IProject project) { */ public static String serializeDocument(Document doc, boolean indent) throws IOException, TransformerException { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no"); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java index 1cef56047b6..43a11b3e433 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/BreakpointActionManager.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -26,6 +25,7 @@ import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; @@ -192,7 +192,7 @@ private void loadActionData() { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(actionData))).getDocumentElement(); @@ -246,10 +246,8 @@ public void revertActionData() { public void saveActionData() { String actionData = ""; //$NON-NLS-1$ - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("breakpointActionData"); //$NON-NLS-1$ @@ -265,7 +263,7 @@ public void saveActionData() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java index ec41579706a..004e28c97cf 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java @@ -23,7 +23,6 @@ import java.util.List; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; @@ -32,6 +31,7 @@ import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.core.resources.ResourceLookup; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IStorage; @@ -279,7 +279,7 @@ public String getMemento() throws CoreException { Document document = null; Throwable ex = null; try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); Element node = document.createElement(ELEMENT_NAME); document.appendChild(node); node.setAttribute(ATTR_DIRECTORY, getDirectory().toOSString()); @@ -307,7 +307,7 @@ public void initializeFrom(String memento) throws CoreException { Exception ex = null; try { Element root = null; - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); StringReader reader = new StringReader(memento); InputSource source = new InputSource(reader); root = parser.parse(source).getDocumentElement(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java index b312529bfd2..5e4e4561426 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java @@ -21,7 +21,6 @@ import java.util.LinkedList; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; @@ -29,6 +28,7 @@ import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.core.resources.ResourceLookup; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -208,7 +208,7 @@ public String getMemento() throws CoreException { Document document = null; Throwable ex = null; try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); Element node = document.createElement(ELEMENT_NAME); document.appendChild(node); node.setAttribute(ATTR_PROJECT, getProject().getName()); @@ -234,7 +234,7 @@ public void initializeFrom(String memento) throws CoreException { Exception ex = null; try { Element root = null; - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); StringReader reader = new StringReader(memento); InputSource source = new InputSource(reader); root = parser.parse(source).getDocumentElement(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java index 57d0f388db8..d4eb106dae6 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java @@ -24,7 +24,6 @@ import java.util.List; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; @@ -35,6 +34,7 @@ import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -239,7 +239,7 @@ public String getMemento() throws CoreException { Document document = null; Throwable ex = null; try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); Element node = document.createElement(SOURCE_LOCATOR_NAME); document.appendChild(node); ICSourceLocation[] locations = getSourceLocations(); @@ -269,7 +269,7 @@ public void initializeFromMemento(String memento) throws CoreException { Exception ex = null; try { Element root = null; - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); StringReader reader = new StringReader(memento); InputSource source = new InputSource(reader); root = parser.parse(source).getDocumentElement(); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java index e168b2dc024..fff66ff4200 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java @@ -25,7 +25,6 @@ import java.util.Set; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; @@ -41,6 +40,7 @@ import org.eclipse.cdt.debug.core.sourcelookup.IMappingSourceContainer; import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.internal.core.resources.ResourceLookup; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.resources.IFile; @@ -73,7 +73,7 @@ public static String getCommonSourceLocationsMemento(ICSourceLocation[] location Document document = null; Throwable ex = null; try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); Element element = document.createElement(NAME_COMMON_SOURCE_LOCATIONS); document.appendChild(element); saveSourceLocations(document, element, locations); @@ -108,7 +108,7 @@ public static ICSourceLocation[] getCommonSourceLocationsFromMemento(String meme ICSourceLocation[] result = new ICSourceLocation[0]; if (!isEmpty(memento)) { try { - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); StringReader reader = new StringReader(memento); InputSource source = new InputSource(reader); Element root = parser.parse(source).getDocumentElement(); diff --git a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF index da4ea5862dd..88cbd57ad25 100644 --- a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF @@ -51,7 +51,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.16.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.7.0,4.0.0)", org.eclipse.cdt.debug.core;bundle-version="[7.0.0,9.0.0)", org.eclipse.cdt.ui;bundle-version="[8.0.0,9.0.0)", - org.eclipse.cdt.core;bundle-version="[8.0.0,9.0.0)", + org.eclipse.cdt.core;bundle-version="[8.3.0,9.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)", org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)", diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java index f7881551a12..5824549d3e1 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ExternalToolAction.java @@ -18,7 +18,6 @@ import java.text.MessageFormat; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -28,6 +27,7 @@ import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction; import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; @@ -132,10 +132,8 @@ public String getIdentifier() { public String getMemento() { String executeData = ""; //$NON-NLS-1$ if (externalToolName != null) { - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("launchConfigName"); //$NON-NLS-1$ @@ -145,7 +143,7 @@ public String getMemento() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -179,7 +177,7 @@ public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement(); String value = root.getAttribute("configName"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java index 2fc6c8e116a..c9c674d17d3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/LogAction.java @@ -18,7 +18,6 @@ import java.text.MessageFormat; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -29,6 +28,7 @@ import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction; import org.eclipse.cdt.debug.core.breakpointactions.ILogActionEnabler; import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -117,10 +117,8 @@ public String getIdentifier() { public String getMemento() { String logData = ""; //$NON-NLS-1$ - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("logData"); //$NON-NLS-1$ @@ -131,7 +129,7 @@ public String getMemento() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -174,7 +172,7 @@ public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement(); String value = root.getAttribute("message"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java index c78d5fc6056..5af7fc7cfe9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ResumeAction.java @@ -18,7 +18,6 @@ import java.text.MessageFormat; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -31,6 +30,7 @@ import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -113,10 +113,8 @@ public String getIdentifier() { public String getMemento() { String resumeData = ""; //$NON-NLS-1$ - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("resumeData"); //$NON-NLS-1$ @@ -126,7 +124,7 @@ public String getMemento() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -161,7 +159,7 @@ public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement(); String value = root.getAttribute("pauseTime"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugAction.java index dfcef5b7672..17be6142b38 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugAction.java @@ -17,7 +17,6 @@ import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -30,6 +29,7 @@ import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -123,10 +123,8 @@ public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMoni public String getMemento() { String reverseDebugData = ""; //$NON-NLS-1$ - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("reverseDebugData"); //$NON-NLS-1$ @@ -136,7 +134,7 @@ public String getMemento() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -159,7 +157,7 @@ public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement(); String value = root.getAttribute("operation"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java index f3cdfba317d..cf7f0c70913 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundAction.java @@ -27,7 +27,6 @@ import javax.sound.sampled.SourceDataLine; import javax.sound.sampled.UnsupportedAudioFileException; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -37,6 +36,7 @@ import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.breakpointactions.AbstractBreakpointAction; import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -137,10 +137,8 @@ public String getTypeName() { public String getMemento() { String soundData = ""; //$NON-NLS-1$ if (soundFile != null) { - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("soundData"); //$NON-NLS-1$ @@ -150,7 +148,7 @@ public String getMemento() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -170,10 +168,15 @@ public String getMemento() { @Override public void initializeFromMemento(String data) { + if (data == null || data.isBlank()) { + // An empty string will cause a sax parser error below + return; + } + Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement(); String value = root.getAttribute("file"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java index 1abe58efa37..0115037e5e3 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/SoundActionPage.java @@ -20,7 +20,6 @@ import java.util.Iterator; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -29,6 +28,7 @@ import org.eclipse.cdt.debug.core.breakpointactions.IBreakpointAction; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.swt.widgets.Composite; @@ -161,7 +161,7 @@ private void loadRecentSounds() { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(recentSoundData))).getDocumentElement(); @@ -198,10 +198,8 @@ private void loadRecentSounds() { public void saveRecentSounds() { String recentSoundData = ""; //$NON-NLS-1$ - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("recentSounds"); //$NON-NLS-1$ @@ -218,7 +216,7 @@ public void saveRecentSounds() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java index 550704c551a..b92f213ae43 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/OldDefaultSourceLocator.java @@ -18,7 +18,6 @@ import java.text.MessageFormat; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; @@ -27,6 +26,7 @@ import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.ResourcesPlugin; @@ -80,7 +80,7 @@ public String getMemento() throws CoreException { Document document = null; Throwable ex = null; try { - document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + document = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); Element element = document.createElement(ELEMENT_NAME); document.appendChild(element); element.setAttribute(ATTR_PROJECT, getCSourceLocator().getProject().getName()); @@ -109,7 +109,7 @@ public void initializeFromMemento(String memento) throws CoreException { Exception ex = null; try { Element root = null; - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); StringReader reader = new StringReader(memento); InputSource source = new InputSource(reader); root = parser.parse(source).getDocumentElement(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/META-INF/MANIFEST.MF index 5ba9b64fdc1..388338d68d1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui;singleton:=true -Bundle-Version: 1.3.100.qualifier +Bundle-Version: 1.3.200.qualifier Bundle-Activator: org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.MulticoreVisualizerUIPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, @@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.visualizer.core, org.eclipse.cdt.visualizer.ui, org.eclipse.debug.ui, - org.eclipse.cdt.core, + org.eclipse.cdt.core;bundle-version="8.3.0", org.eclipse.cdt.debug.ui Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/MementoUtils.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/MementoUtils.java index 927ed963c96..3e13df4e8a7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/MementoUtils.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/utils/MementoUtils.java @@ -22,13 +22,13 @@ import java.util.Map; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -61,10 +61,8 @@ public static String decodeStringFromMemento(String memento) { public static String encodeMapIntoMemento(Map keyPairValues) { String returnValue = null; - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement(ROOT_ELEMENT_TAGNAME); @@ -80,7 +78,7 @@ public static String encodeMapIntoMemento(Map keyPairValues) { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -103,7 +101,7 @@ public static Map decodeMapFromMemento(String memento) { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(memento))).getDocumentElement(); NodeList nodeList = root.getChildNodes(); @@ -142,10 +140,8 @@ public static Map decodeMapFromMemento(String memento) { public static String encodeListIntoMemento(List labels) { String returnValue = null; - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement(ROOT_ELEMENT_TAGNAME); @@ -159,7 +155,7 @@ public static String encodeListIntoMemento(List labels) { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -182,7 +178,7 @@ public static List decodeListFromMemento(String memento) { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(memento))).getDocumentElement(); NodeList nodeList = root.getChildNodes(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF index cf33744fc78..842dbd27860 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF @@ -9,7 +9,7 @@ Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.dsf, org.eclipse.debug.core, - org.eclipse.cdt.core, + org.eclipse.cdt.core;bundle-version="8.3.0", org.eclipse.cdt.debug.core, org.eclipse.core.variables, org.eclipse.cdt.launch;bundle-version="10.3.0", diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/CollectAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/CollectAction.java index 9e41cac83d0..cc5feccc30d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/CollectAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/CollectAction.java @@ -18,7 +18,6 @@ import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -26,6 +25,7 @@ import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; @@ -124,10 +124,8 @@ public String getIdentifier() { public String getMemento() { String collectData = ""; //$NON-NLS-1$ - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement(COLLECT_ACTION_ELEMENT_NAME); @@ -142,7 +140,7 @@ public String getMemento() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -189,7 +187,7 @@ public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/EvaluateAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/EvaluateAction.java index 0ac7c8dff84..a372db23e53 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/EvaluateAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/EvaluateAction.java @@ -19,7 +19,6 @@ import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -27,6 +26,7 @@ import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; @@ -62,10 +62,8 @@ public String getIdentifier() { public String getMemento() { String collectData = ""; //$NON-NLS-1$ - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("evalData"); //$NON-NLS-1$ @@ -75,7 +73,7 @@ public String getMemento() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -108,7 +106,7 @@ public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement(); fEvalString = root.getAttribute("evalString"); //$NON-NLS-1$ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/TracepointActionManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/TracepointActionManager.java index 02de3bb747c..15b1e2d0df6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/TracepointActionManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/TracepointActionManager.java @@ -19,7 +19,6 @@ import java.util.Iterator; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -27,6 +26,7 @@ import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -90,7 +90,7 @@ private void loadActionData() { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(actionData))).getDocumentElement(); @@ -146,10 +146,8 @@ public void revertActionData() { public void saveActionData() { String actionData = ""; //$NON-NLS-1$ - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("tracepointActionData"); //$NON-NLS-1$ @@ -168,7 +166,7 @@ public void saveActionData() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/WhileSteppingAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/WhileSteppingAction.java index 76b796c414f..86eee46217c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/WhileSteppingAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/WhileSteppingAction.java @@ -19,7 +19,6 @@ import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -27,6 +26,7 @@ import javax.xml.transform.stream.StreamResult; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; @@ -98,10 +98,8 @@ public String getIdentifier() { public String getMemento() { String collectData = ""; //$NON-NLS-1$ - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = null; try { - docBuilder = dfactory.newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element rootElement = doc.createElement("whileSteppingData"); //$NON-NLS-1$ @@ -112,7 +110,7 @@ public String getMemento() { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + TransformerFactory factory = XmlProcessorFactoryCdt.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -145,7 +143,7 @@ public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; try { - parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + parser = XmlProcessorFactoryCdt.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement(); setStepCount(Integer.parseInt(root.getAttribute("whileSteppingCount"))); //$NON-NLS-1$ diff --git a/jsoncdb/org.eclipse.cdt.jsoncdb.core/META-INF/MANIFEST.MF b/jsoncdb/org.eclipse.cdt.jsoncdb.core/META-INF/MANIFEST.MF index 4a137711cab..3197628ce3f 100644 --- a/jsoncdb/org.eclipse.cdt.jsoncdb.core/META-INF/MANIFEST.MF +++ b/jsoncdb/org.eclipse.cdt.jsoncdb.core/META-INF/MANIFEST.MF @@ -18,10 +18,10 @@ Require-Bundle: org.eclipse.ui.workbench;bundle-version="3.8.0", org.eclipse.core.resources;bundle-version="3.13.700", org.eclipse.core.runtime;bundle-version="3.17.100", org.eclipse.cdt.core, - org.eclipse.jface, - com.google.gson, - org.apache.commons.io;bundle-version="2.6.0" + org.eclipse.jface Automatic-Module-Name: org.eclipse.cdt.jsoncdb.core -Import-Package: org.eclipse.e4.core.contexts;version="1.7.0", +Import-Package: com.google.gson;version="[2.10.1,3.0.0)", + org.apache.commons.io;version="[2.13.0,3.0.0)", + org.eclipse.e4.core.contexts;version="1.7.0", org.osgi.service.component.annotations;version="1.2.0" Service-Component: OSGI-INF/org.eclipse.cdt.jsoncdb.core.internal.ParserPreferencesAccess.xml diff --git a/memory/org.eclipse.cdt.debug.ui.memory.search/META-INF/MANIFEST.MF b/memory/org.eclipse.cdt.debug.ui.memory.search/META-INF/MANIFEST.MF index b90a88f68c1..74698569585 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.search/META-INF/MANIFEST.MF +++ b/memory/org.eclipse.cdt.debug.ui.memory.search/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.debug.ui.memory.search;singleton:=true -Bundle-Version: 1.5.0.qualifier +Bundle-Version: 1.5.100.qualifier Bundle-Activator: org.eclipse.cdt.debug.ui.memory.search.MemorySearchPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/memory/org.eclipse.cdt.debug.ui.memory.search/src/org/eclipse/cdt/debug/ui/memory/search/MemorySearchResultsPage.java b/memory/org.eclipse.cdt.debug.ui.memory.search/src/org/eclipse/cdt/debug/ui/memory/search/MemorySearchResultsPage.java index ad73dc2559c..cd976a29bf1 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.search/src/org/eclipse/cdt/debug/ui/memory/search/MemorySearchResultsPage.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.search/src/org/eclipse/cdt/debug/ui/memory/search/MemorySearchResultsPage.java @@ -22,6 +22,8 @@ import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ISelectionChangedListener; @@ -47,6 +49,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IMemento; +import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.part.Page; public class MemorySearchResultsPage extends Page implements ISearchResultPage, IQueryListener { @@ -107,8 +110,8 @@ public void setID(String id) { @Override public void setInput(ISearchResult search, Object uiState) { - if (search instanceof MemorySearchResult) { - ((MemorySearchResult) search).addListener(new ISearchResultListener() { + if (search instanceof MemorySearchResult result) { + result.addListener(new ISearchResultListener() { @Override public void searchResultChanged(SearchResultEvent e) { Display.getDefault().asyncExec(() -> fTreeViewer.refresh()); @@ -173,46 +176,68 @@ public Object[] getElements(Object inputElement) { @Override public void selectionChanged(final SelectionChangedEvent event) { - if (event.getSelection() instanceof StructuredSelection) { - IMemoryRenderingContainer containers[] = ((IMemorySearchQuery) fQuery).getMemoryView() - .getMemoryRenderingContainers(); - MemoryMatch match = (MemoryMatch) ((StructuredSelection) event.getSelection()).getFirstElement(); - if (match != null) { - for (int i = 0; i < containers.length; i++) { - IMemoryRendering rendering = containers[i].getActiveRendering(); - if (rendering instanceof IRepositionableMemoryRendering) { - try { - ((IRepositionableMemoryRendering) rendering).goToAddress(match.getStartAddress()); - } catch (DebugException e) { - MemorySearchPlugin.logError( - Messages.getString("MemorySearchResultsPage.RepositioningMemoryViewFailed"), //$NON-NLS-1$ - e); - } - } - - if (rendering != null) { - // Temporary, until platform accepts/adds new interface for setting the selection - try { - Method m = rendering.getClass().getMethod("setSelection", //$NON-NLS-1$ - new Class[] { BigInteger.class, BigInteger.class }); - if (m != null) - m.invoke(rendering, match.getStartAddress(), match.getEndAddress()); - } catch (Exception e) { - // do nothing - } - } + IMemoryRenderingContainer containers[] = ((IMemorySearchQuery) fQuery).getMemoryView() + .getMemoryRenderingContainers(); + if (containers == null || containers.length == 0) + return; + + if (event.getSelection() instanceof StructuredSelection sel + && sel.getFirstElement() instanceof MemoryMatch match) { + + for (int i = 0; i < containers.length; i++) { + IMemoryRendering rendering = containers[i].getActiveRendering(); + if (!(rendering instanceof IRepositionableMemoryRendering repositionable)) + continue; + + try { + repositionable.goToAddress(match.getStartAddress()); + } catch (DebugException e) { + MemorySearchPlugin.logError( + Messages.getString("MemorySearchResultsPage.RepositioningMemoryViewFailed"), //$NON-NLS-1$ + e); + } + + // Temporary, until platform accepts/adds new interface for setting the selection + try { + Method m = rendering.getClass().getMethod("setSelection", //$NON-NLS-1$ + new Class[] { BigInteger.class, BigInteger.class }); + if (m != null) + m.invoke(rendering, match.getStartAddress(), match.getEndAddress()); + } catch (NoSuchMethodException e) { + // Not all renderings have a compatible setSelection + // ideally this would be an interface we can check instead + // of using reflection! + } catch (Exception e) { + MemorySearchPlugin.logError( + "Exception while invoking the setSelection method for the current rendering", //$NON-NLS-1$ + e); } } } } }); + fTreeViewer.addDoubleClickListener(new IDoubleClickListener() { + + @Override + public void doubleClick(DoubleClickEvent event) { + // Open the memory view to emphasize the effect of the memory address selection in the search + if (event.getSelection() instanceof StructuredSelection sel + && sel.getFirstElement() instanceof MemoryMatch) { + IWorkbenchPart wb = ((IMemorySearchQuery) fQuery).getMemoryView().getSite().getPart(); + if (wb == null) + return; + getSite().getPage().activate(wb); + } + } + + }); fTreeViewer.setLabelProvider(new ILabelProvider() { @Override public String getText(Object element) { - if (element instanceof MemoryMatch) - return "0x" + ((MemoryMatch) element).getStartAddress().toString(16); //$NON-NLS-1$ + if (element instanceof MemoryMatch match) + return "0x" + match.getStartAddress().toString(16); //$NON-NLS-1$ return element.toString(); } diff --git a/pom.xml b/pom.xml index c9fef9e1a1e..b77cdc7d6d0 100644 --- a/pom.xml +++ b/pom.xml @@ -25,12 +25,8 @@ CDT Parent - - 3.6.3 - 3.0.5 + 3.9.1 + 4.0.1 1.3.4 jacoco http://ci.eclipse.org/cdt/job/cdt-master/lastSuccessfulBuild/artifact/releng/org.eclipse.cdt.repo/target/repository @@ -49,6 +45,8 @@ -Xms256m -Xmx512m -ea --add-opens=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED https://download.eclipse.org/tools/cdt/releases/11.2/cdt-11.2.0/ + https://download.eclipse.org/tools/cdt/releases/latest/ + https://download.eclipse.org/releases/latest/ + @@ -206,4 +206,4 @@ -ea -consolelog - \ No newline at end of file + diff --git a/releng/scripts/check_bundle_versions.sh b/releng/scripts/check_bundle_versions.sh new file mode 100755 index 00000000000..23867346b91 --- /dev/null +++ b/releng/scripts/check_bundle_versions.sh @@ -0,0 +1,41 @@ +#!/bin/bash +############################################################################### +# Copyright (c) 2018, 2023 Kichwa Coders Ltd and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +############################################################################### + +set -e +set -o pipefail + +if test ! -z "$(git status -s -uno)"; then + echo "You have changes. Please stash them before continuing." + exit 1 +fi + +## +# Make sure all versions have been bumped appropriately compared to the baseline +## +logfile=baseline-compare-and-replace.log +echo "Running 'mvn verify -P baseline-compare-and-replace' to make sure all versions" +echo "have been appropriately incremented." + + +if ${MVN:-mvn} \ + clean verify -B -V --fail-at-end \ + -DskipDoc=true \ + -DskipTests=true \ + -P baseline-compare-and-replace \ + -P api-baseline-check \ + 2>&1 | tee ${logfile}; then + echo "SUCCESS - Maven check all versions have been bumped appropriately appears to have completed successfully" + echo "SUCCESS - Maven check all versions have been bumped appropriately appears to have completed successfully" >> ${logfile} +else + echo "FAILED - Maven check all versions have been bumped appropriately appears to have failed. See the report in the next build step." + echo "FAILED - Maven check all versions have been bumped appropriately appears to have failed. See the report in the next build step." >> ${logfile} +fi diff --git a/releng/scripts/check_bundle_versions_report.sh b/releng/scripts/check_bundle_versions_report.sh new file mode 100755 index 00000000000..ae8beadd9c6 --- /dev/null +++ b/releng/scripts/check_bundle_versions_report.sh @@ -0,0 +1,76 @@ +#!/bin/bash +############################################################################### +# Copyright (c) 2018, 2023 Kichwa Coders Ltd and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +############################################################################### + +set -e + +if test ! -z "$(git status -s -uno)"; then + echo "You have changes. Please stash them before continuing." + exit 1 +fi + +## +# Make sure all versions have been bumped appropriately compared to the baseline +## +logfile=baseline-compare-and-replace.log +bundles_only_qualifier_changed=$(grep "Only qualifier changed" ${logfile} | sed -e 's/^.*Only qualifier changed for .//' -e 's@/.*@@' | sort) +if [ -n "$bundles_only_qualifier_changed" ]; then + echo + echo "The following bundles are missing a service segment version bump:" + for bundle in $bundles_only_qualifier_changed; do + echo " - $bundle" + done + echo "Please bump service segment by 100 if on main branch" + echo "The log of this build is above" + echo "See: https://wiki.eclipse.org/Version_Numbering#When_to_change_the_service_segment" + echo +fi + +bundles_same_version_different_content=$(grep "baseline and build artifacts have same version but different contents" ${logfile} | sed -e 's/^.* on project //' -e 's@: baseline.*@@' | sort) +if [ -n "$bundles_same_version_different_content" ]; then + echo + echo "The following bundles have same version as baseline, but different contents:" + for bundle in $bundles_same_version_different_content; do + echo " - $bundle" + done + echo "This can happen for a variety of reasons:" + echo " - The comparison filters in the root pom.xml are not working" + echo " - Different versions of Java are being used to compile compared to the baseline" + echo " - A dependency has changed causing the generated classes to be different" + echo "The log of this build is above" + echo "Please bump service segment by 100 if on main branch" + echo "See: https://wiki.eclipse.org/Version_Numbering#When_to_change_the_service_segment" + echo +fi + +api_errors=$(grep "API ERROR" ${logfile} | grep -v "0 API ERRORS" || true) +if [ -n "$api_errors" ]; then + echo + echo "API Errors were detected when running the build:" + grep "API ERROR" ${logfile} | grep -v "0 API ERRORS" || true + major_version=$(grep "The major version should be incremented" ${logfile}) + if [ -n "$major_version" ]; then + echo "WARNING: some of the API errors report as 'major version should be incremented'. Incrementing the" + echo "major version is only allowed on major new versions of CDT. This error indicates that API has been" + echo "broken in some incompatible way. An project committer can help explain what to do if the (lengthy)" + echo "documentation below needs interpreting for this use case.". + fi + echo "See https://github.com/eclipse-cdt/cdt/blob/main/POLICY.md#api for details" +fi + +success=$(grep "SUCCESS - Maven check all versions have been bumped appropriately appears to have completed successfully" ${logfile}) +if [ -n "$success" ]; then + echo "Maven check all versions have been bumped appropriately appears to have completed successfully" +elif [ -z "$bundles_only_qualifier_changed" ] && [ -z "$bundles_same_version_different_content" ]; then + echo "Maven 'check all versions have been bumped appropriately' failed! Please see the" + echo "log of the failed maven run above" + exit 1 +fi diff --git a/releng/scripts/check_code_cleanliness.sh b/releng/scripts/check_code_cleanliness.sh index 0452f281cc5..b86f7f075ee 100755 --- a/releng/scripts/check_code_cleanliness.sh +++ b/releng/scripts/check_code_cleanliness.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################### -# Copyright (c) 2018, 2020 Kichwa Coders Ltd and others. +# Copyright (c) 2018, 2023 Kichwa Coders Ltd and others. # # This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 @@ -17,93 +17,7 @@ if test ! -z "$(git status -s -uno)"; then exit 1 fi -## -# Check the features are all branded and all content has proper licenses -## DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -${DIR}/check_features.sh -${DIR}/check_license.sh - -## -# The next set of scripts automatically apply formatting and other rules -# to CDT. At the end of this, git repo is checked for no diffs. -## -${DIR}/do_all_code_cleanups.sh - -## -# Check that none of the above caused any changes -## -if test -z "$(git status -s -uno)"; then - echo "Tree looks clean!" -else - echo "Tree is dirty - something needs to be cleaned up in your commit (more info below)" - echo "Result of git status" - git status - echo "Result of git diff" - git diff - echo "Tree is dirty - something needs to be cleaned up in your commit (see above for git status/diff). The 'something'" - echo "is likely a misformatted file, extra whitespace at end of line, or something similar. The diff above" - echo "shows what changes you need to apply to your patch to get it past the code cleanliness check." - exit 1 -fi - -## -# Error out if there are dependencies that are not allowed in the dlls, exes, sos -## -DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -echo "Checking dependencies of all .dll, .exe and .so files in CDT to make" -echo "sure no dependencies on unexpected or newer libraries are accidentally" -echo "introduced." -${DIR}/check_dll_dependencies.sh -${DIR}/check_glibc_dependencies.sh - - -## -# Make sure all versions have been bumped appropriately compared to the baseline -## -logfile=baseline-compare-and-replace.log -echo "Running 'mvn verify -P baseline-compare-and-replace' to make sure all versions" -echo "have been appropriately incremented. The check output is very verbose, so it is" -echo "redirected to ${logfile} which is archived as part of the build artifacts." -if ${MVN:-mvn} \ - clean verify -B -V --fail-at-end \ - -DskipDoc=true \ - -DskipTests=true \ - -P baseline-compare-and-replace >${logfile} 2>&1; then - echo "Maven check all versions have been bumped appropriately appears to have completed successfully" -else - bundles_only_qualifier_changed=$(grep "Only qualifier changed" ${logfile} | sed -e 's/^.*Only qualifier changed for .//' -e 's@/.*@@' | sort) - if [ -n "$bundles_only_qualifier_changed" ]; then - echo "The following bundles are missing a service segment version bump:" - for bundle in $bundles_only_qualifier_changed; do - echo " - $bundle" - done - echo "Please bump service segment by 100 if on master branch" - echo "The log of this build is part of the artifacts" - echo "See: https://wiki.eclipse.org/Version_Numbering#When_to_change_the_service_segment" - echo - fi - - bundles_same_version_different_content=$(grep "baseline and build artifacts have same version but different contents" ${logfile} | sed -e 's/^.* on project //' -e 's@: baseline.*@@' | sort) - if [ -n "$bundles_same_version_different_content" ]; then - echo "The following bundles have same version as baseline, but different contents:" - for bundle in $bundles_same_version_different_content; do - echo " - $bundle" - done - echo "This can happen for a variety of reasons:" - echo " - The comparison filters in the root pom.xml are not working" - echo " - Different versions of Java are being used to compile compared to the baseline" - echo " - A dependency has changed causing the generated classes to be different" - echo "The log of this build is part of the artifacts" - echo "Please bump service segment by 100 if on master branch" - echo "See: https://wiki.eclipse.org/Version_Numbering#When_to_change_the_service_segment" - echo - fi - - if [ -z "$bundles_only_qualifier_changed" ] && [ -z "$bundles_same_version_different_content" ]; then - echo "Maven 'check all versions have been bumped appropriately' failed! Please see the" - echo "log of the failed maven run which is available as part of the artifacts in a" - echo "file called baseline-compare-and-replace.log" - fi - exit 1 -fi +${DIR}/check_code_cleanliness_only.sh +${DIR}/check_bundle_versions.sh +${DIR}/check_bundle_versions_report.sh diff --git a/releng/scripts/check_code_cleanliness_only.sh b/releng/scripts/check_code_cleanliness_only.sh new file mode 100755 index 00000000000..8082b39ddbf --- /dev/null +++ b/releng/scripts/check_code_cleanliness_only.sh @@ -0,0 +1,58 @@ +#!/bin/bash +############################################################################### +# Copyright (c) 2018, 2023 Kichwa Coders Ltd and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +############################################################################### + +set -e + +if test ! -z "$(git status -s -uno)"; then + echo "You have changes. Please stash them before continuing." + exit 1 +fi + +## +# Check the features are all branded and all content has proper licenses +## +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +${DIR}/check_features.sh +${DIR}/check_license.sh + +## +# The next set of scripts automatically apply formatting and other rules +# to CDT. At the end of this, git repo is checked for no diffs. +## +${DIR}/do_all_code_cleanups.sh + +## +# Check that none of the above caused any changes +## +if test -z "$(git status -s -uno)"; then + echo "Tree looks clean!" +else + echo "Tree is dirty - something needs to be cleaned up in your commit (more info below)" + echo "Result of git status" + git status + echo "Result of git diff" + git diff + echo "Tree is dirty - something needs to be cleaned up in your commit (see above for git status/diff). The 'something'" + echo "is likely a misformatted file, extra whitespace at end of line, or something similar. The diff above" + echo "shows what changes you need to apply to your patch to get it past the code cleanliness check." + exit 1 +fi + +## +# Error out if there are dependencies that are not allowed in the dlls, exes, sos +## +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +echo "Checking dependencies of all .dll, .exe and .so files in CDT to make" +echo "sure no dependencies on unexpected or newer libraries are accidentally" +echo "introduced." +${DIR}/check_dll_dependencies.sh +${DIR}/check_glibc_dependencies.sh diff --git a/testsrunner/org.eclipse.cdt.testsrunner.boost/META-INF/MANIFEST.MF b/testsrunner/org.eclipse.cdt.testsrunner.boost/META-INF/MANIFEST.MF index 87071d35bd3..3388a5063b9 100644 --- a/testsrunner/org.eclipse.cdt.testsrunner.boost/META-INF/MANIFEST.MF +++ b/testsrunner/org.eclipse.cdt.testsrunner.boost/META-INF/MANIFEST.MF @@ -2,13 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.testsrunner.boost;singleton:=true -Bundle-Version: 7.2.0.qualifier +Bundle-Version: 7.2.100.qualifier Bundle-Activator: org.eclipse.cdt.testsrunner.internal.boost.BoostTestsRunnerPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0", - org.eclipse.cdt.testsrunner;bundle-version="3.5.0" + org.eclipse.cdt.testsrunner;bundle-version="3.5.0", + org.eclipse.cdt.core;bundle-version="8.3.0" Export-Package: org.eclipse.cdt.testsrunner.internal.boost;x-friends:="org.eclipse.cdt.testsrunner.tests" Automatic-Module-Name: org.eclipse.cdt.testsrunner.boost diff --git a/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerMessages.java b/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerMessages.java index 71911af35d5..37ea0c1003c 100644 --- a/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerMessages.java +++ b/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Anton Gorenkov. + * Copyright (c) 2011, 2023 Anton Gorenkov and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -21,6 +21,10 @@ public class BoostTestsRunnerMessages extends NLS { public static String BoostTestsRunner_io_error_prefix; public static String BoostTestsRunner_wrong_tests_paths_count; public static String BoostTestsRunner_xml_error_prefix; + public static String BoostXmlLogHandler_ContextHeader; + public static String BoostXmlLogHandler_ContextOverflow; + public static String BoostXmlLogHandler_ContextPrefix; + public static String BoostXmlLogHandler_ContextSuffix; public static String BoostXmlLogHandler_exception_suffix; public static String BoostXmlLogHandler_wrong_tag_name; static { diff --git a/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerMessages.properties b/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerMessages.properties index ba5709f28a4..e1ed91dac5b 100644 --- a/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerMessages.properties +++ b/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2011 Anton Gorenkov +# Copyright (c) 2011, 2023 Anton Gorenkov and others. # # This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 @@ -15,5 +15,9 @@ BoostTestsRunner_error_format={0}: {1} BoostTestsRunner_io_error_prefix=I/O Error BoostTestsRunner_wrong_tests_paths_count=Only on test suite or test case should be specified to rerun BoostTestsRunner_xml_error_prefix=XML parse error +BoostXmlLogHandler_ContextHeader=\nContext:\u0020 +BoostXmlLogHandler_ContextOverflow=... +BoostXmlLogHandler_ContextPrefix=\u0020[ +BoostXmlLogHandler_ContextSuffix=] BoostXmlLogHandler_exception_suffix=\nLast check point was here. BoostXmlLogHandler_wrong_tag_name=Invalid XML format: Element "{0}" is not accepted\! diff --git a/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerProvider.java b/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerProvider.java index 81eb5c60a91..1ebc252dbdb 100644 --- a/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerProvider.java +++ b/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostTestsRunnerProvider.java @@ -19,8 +19,8 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.testsrunner.launcher.ITestsRunnerProvider; import org.eclipse.cdt.testsrunner.model.ITestModelUpdater; import org.eclipse.cdt.testsrunner.model.TestingException; @@ -94,8 +94,7 @@ private String getErrorText(String prefix, String description) { @Override public void run(ITestModelUpdater modelUpdater, InputStream inputStream) throws TestingException { try { - SAXParserFactory spf = SAXParserFactory.newInstance(); - SAXParser sp = spf.newSAXParser(); + SAXParser sp = XmlProcessorFactoryCdt.createSAXParserWithErrorOnDOCTYPE(); sp.parse(inputStream, new BoostXmlLogHandler(modelUpdater)); } catch (IOException e) { diff --git a/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostXmlLogHandler.java b/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostXmlLogHandler.java index a66cbd70998..27c498def0a 100644 --- a/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostXmlLogHandler.java +++ b/testsrunner/org.eclipse.cdt.testsrunner.boost/src/org/eclipse/cdt/testsrunner/internal/boost/BoostXmlLogHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2013 Anton Gorenkov and others. + * Copyright (c) 2011, 2023 Anton Gorenkov and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,9 +15,6 @@ package org.eclipse.cdt.testsrunner.internal.boost; import java.text.MessageFormat; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; import java.util.Stack; import org.eclipse.cdt.testsrunner.model.ITestItem; @@ -49,6 +46,8 @@ public class BoostXmlLogHandler extends DefaultHandler { private static final String XML_NODE_ERROR = "Error"; //$NON-NLS-1$ private static final String XML_NODE_FATAL_ERROR = "FatalError"; //$NON-NLS-1$ private static final String XML_NODE_EXCEPTION = "Exception"; //$NON-NLS-1$ + private static final String XML_NODE_CONTEXT = "Context"; //$NON-NLS-1$ + private static final String XML_NODE_FRAME = "Frame"; //$NON-NLS-1$ // Boost.Test XML log attributes private static final String XML_ATTR_TEST_SUITE_NAME = "name"; //$NON-NLS-1$ @@ -56,18 +55,12 @@ public class BoostXmlLogHandler extends DefaultHandler { private static final String XML_ATTR_MESSAGE_FILE = "file"; //$NON-NLS-1$ private static final String XML_ATTR_MESSAGE_LINE = "line"; //$NON-NLS-1$ - /** Maps the string message level representation to the Tests Runner internal enum code. */ - private static final Map STRING_TO_MESSAGE_LEVEL; - static { - Map aMap = new HashMap<>(); - aMap.put(XML_NODE_INFO, ITestMessage.Level.Info); - aMap.put(XML_NODE_MESSAGE, ITestMessage.Level.Message); - aMap.put(XML_NODE_WARNING, ITestMessage.Level.Warning); - aMap.put(XML_NODE_ERROR, ITestMessage.Level.Error); - aMap.put(XML_NODE_FATAL_ERROR, ITestMessage.Level.FatalError); - // NOTE: Exception node is processed separately - STRING_TO_MESSAGE_LEVEL = Collections.unmodifiableMap(aMap); - } + /** + * The context can be of arbitrary length, to prevent excessively long strings + * in the tree limit the context to this length in the tree. The full context + * is available in the details tab. + */ + private static final int MAX_CONTEXT_LENGTH_IN_TREE = 50; /** The default file name for test message location. */ private static final String DEFAULT_LOCATION_FILE = null; @@ -97,6 +90,10 @@ public class BoostXmlLogHandler extends DefaultHandler { private String lastTestCaseName = ""; //$NON-NLS-1$ private static final int SAME_TEST_CASE_NAME_COUNT_START = 2; private int sameTestCaseNameCount = SAME_TEST_CASE_NAME_COUNT_START; + private StringBuilder context = new StringBuilder(); + + private boolean testCaseEnterDeferred = false; + private StringBuilder testCaseName = new StringBuilder(); BoostXmlLogHandler(ITestModelUpdater modelUpdater) { this.modelUpdater = modelUpdater; @@ -106,41 +103,61 @@ public class BoostXmlLogHandler extends DefaultHandler { public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException { + if (qName == null) { + throw createAndLogExceptionForElement(qName); + } + elementDataStack.push(new StringBuilder()); - if (qName == XML_NODE_TEST_SUITE) { + switch (qName) { + case XML_NODE_TEST_SUITE: String testSuiteName = attrs.getValue(XML_ATTR_TEST_SUITE_NAME); modelUpdater.enterTestSuite(testSuiteName); + break; - } else if (qName == XML_NODE_TEST_CASE) { - String testCaseName = attrs.getValue(XML_ATTR_TEST_CASE_NAME); + case XML_NODE_TEST_CASE: + testCaseName.setLength(0); + testCaseName.append(attrs.getValue(XML_ATTR_TEST_CASE_NAME)); - if (lastTestCaseName.equals(testCaseName)) { - testCaseName += " (" + sameTestCaseNameCount + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + if (lastTestCaseName.equals(testCaseName.toString())) { + testCaseName.append(" (" + sameTestCaseNameCount + ")"); //$NON-NLS-1$ //$NON-NLS-2$ ++sameTestCaseNameCount; } else { - lastTestCaseName = testCaseName; + lastTestCaseName = testCaseName.toString(); sameTestCaseNameCount = SAME_TEST_CASE_NAME_COUNT_START; } - modelUpdater.enterTestCase(testCaseName); + testCaseEnterDeferred = true; testStatus = Status.Passed; - - } else if (STRING_TO_MESSAGE_LEVEL.containsKey(qName) || qName == XML_NODE_LAST_CHECKPOINT) { + break; + + case XML_NODE_INFO: + case XML_NODE_MESSAGE: + case XML_NODE_WARNING: + case XML_NODE_ERROR: + case XML_NODE_FATAL_ERROR: + case XML_NODE_LAST_CHECKPOINT: fileName = attrs.getValue(XML_ATTR_MESSAGE_FILE); String lineNumberStr = attrs.getValue(XML_ATTR_MESSAGE_LINE); lineNumber = lineNumberStr != null ? Integer.parseInt(lineNumberStr.trim()) : DEFAULT_LOCATION_LINE; + break; - } else if (qName == XML_NODE_EXCEPTION) { + case XML_NODE_EXCEPTION: fileName = DEFAULT_LOCATION_FILE; lineNumber = DEFAULT_LOCATION_LINE; + break; - } else if (qName == XML_NODE_TESTING_TIME) { + case XML_NODE_CONTEXT: + case XML_NODE_FRAME: + /* handle in endElement */ + break; - } else if (qName == XML_NODE_TEST_LOG) { + case XML_NODE_TESTING_TIME: + case XML_NODE_TEST_LOG: /* just skip, do nothing */ + break; - } else { - logAndThrowErrorForElement(qName); + default: + throw createAndLogExceptionForElement(qName); } } @@ -151,7 +168,26 @@ public void startElement(String namespaceURI, String localName, String qName, At * @param level test message level */ private void addCurrentMessage(ITestMessage.Level level) { - modelUpdater.addTestMessage(fileName, lineNumber, level, elementDataStack.peek().toString()); + String text = elementDataStack.peek().toString().trim(); + if (testCaseEnterDeferred) { + if (!context.isEmpty()) { + testCaseName.append(BoostTestsRunnerMessages.BoostXmlLogHandler_ContextPrefix); + if (context.length() > MAX_CONTEXT_LENGTH_IN_TREE) { + testCaseName.append(context.subSequence(0, MAX_CONTEXT_LENGTH_IN_TREE)); + testCaseName.append(BoostTestsRunnerMessages.BoostXmlLogHandler_ContextOverflow); + } else { + testCaseName.append(context); + } + testCaseName.append(BoostTestsRunnerMessages.BoostXmlLogHandler_ContextSuffix); + } + modelUpdater.enterTestCase(testCaseName.toString()); + testCaseEnterDeferred = false; + } + if (!context.isEmpty()) { + text += BoostTestsRunnerMessages.BoostXmlLogHandler_ContextHeader + context.toString().trim(); + context.setLength(0); + } + modelUpdater.addTestMessage(fileName, lineNumber, level, text.trim()); fileName = DEFAULT_LOCATION_FILE; lineNumber = DEFAULT_LOCATION_LINE; if (level == ITestMessage.Level.Error || level == ITestMessage.Level.FatalError) { @@ -167,30 +203,68 @@ private void addCurrentMessage(ITestMessage.Level level) { @Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException { - if (qName == XML_NODE_TEST_SUITE) { + if (qName == null) { + throw createAndLogExceptionForElement(qName); + } + switch (qName) { + case XML_NODE_TEST_SUITE: modelUpdater.exitTestSuite(); + break; - } else if (qName == XML_NODE_TEST_CASE) { + case XML_NODE_TEST_CASE: + if (testCaseEnterDeferred) { + modelUpdater.enterTestCase(testCaseName.toString()); + testCaseEnterDeferred = false; + } modelUpdater.setTestStatus(testStatus); modelUpdater.exitTestCase(); + break; - } else if (qName == XML_NODE_TESTING_TIME) { + case XML_NODE_TESTING_TIME: modelUpdater.setTestingTime(Integer.parseInt(elementDataStack.peek().toString().trim()) / 1000); - - } else if (STRING_TO_MESSAGE_LEVEL.containsKey(qName)) { - addCurrentMessage(STRING_TO_MESSAGE_LEVEL.get(qName)); - - } else if (qName == XML_NODE_EXCEPTION) { + break; + + case XML_NODE_INFO: + addCurrentMessage(ITestMessage.Level.Info); + break; + case XML_NODE_MESSAGE: + addCurrentMessage(ITestMessage.Level.Message); + break; + case XML_NODE_WARNING: + addCurrentMessage(ITestMessage.Level.Warning); + break; + case XML_NODE_ERROR: + addCurrentMessage(ITestMessage.Level.Error); + break; + case XML_NODE_FATAL_ERROR: + addCurrentMessage(ITestMessage.Level.FatalError); + break; + + case XML_NODE_EXCEPTION: if (fileName != DEFAULT_LOCATION_FILE && !fileName.isEmpty() && lineNumber >= 0) { - elementDataStack.peek().append(BoostTestsRunnerMessages.BoostXmlLogHandler_exception_suffix); + StringBuilder current = elementDataStack.peek(); + String trimmed = current.toString().trim(); + current.setLength(0); + current.append(trimmed); + current.append(BoostTestsRunnerMessages.BoostXmlLogHandler_exception_suffix); } addCurrentMessage(ITestMessage.Level.Exception); + break; + + case XML_NODE_CONTEXT: + context.insert(0, elementDataStack.peek().toString().trim()); + break; + case XML_NODE_FRAME: + context.append(elementDataStack.peek().toString().trim()); + break; - } else if (qName == XML_NODE_TEST_LOG || qName == XML_NODE_LAST_CHECKPOINT) { + case XML_NODE_TEST_LOG: + case XML_NODE_LAST_CHECKPOINT: /* just skip, do nothing */ + break; - } else { - logAndThrowErrorForElement(qName); + default: + throw createAndLogExceptionForElement(qName); } elementDataStack.pop(); } @@ -207,22 +281,13 @@ public void characters(char[] ch, int start, int length) { * Throws the testing exception for the specified XML tag. * * @param tagName XML tag name - * @throws SAXException the exception that will be thrown - */ - private void logAndThrowErrorForElement(String tagName) throws SAXException { - logAndThrowError(MessageFormat.format(BoostTestsRunnerMessages.BoostXmlLogHandler_wrong_tag_name, tagName)); - } - - /** - * Throws the testing exception with the specified message. - * - * @param message the reason - * @throws SAXException the exception that will be thrown + * @return SAXException the exception that will be thrown */ - private void logAndThrowError(String message) throws SAXException { - SAXException e = new SAXException(message); + private SAXException createAndLogExceptionForElement(String tagName) { + SAXException e = new SAXException( + MessageFormat.format(BoostTestsRunnerMessages.BoostXmlLogHandler_wrong_tag_name, tagName)); BoostTestsRunnerPlugin.log(e); - throw e; + return e; } @Override diff --git a/testsrunner/org.eclipse.cdt.testsrunner.qttest/META-INF/MANIFEST.MF b/testsrunner/org.eclipse.cdt.testsrunner.qttest/META-INF/MANIFEST.MF index 40bce3b8f06..6cc4887827f 100644 --- a/testsrunner/org.eclipse.cdt.testsrunner.qttest/META-INF/MANIFEST.MF +++ b/testsrunner/org.eclipse.cdt.testsrunner.qttest/META-INF/MANIFEST.MF @@ -2,13 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.testsrunner.qttest;singleton:=true -Bundle-Version: 7.2.0.qualifier +Bundle-Version: 7.2.100.qualifier Bundle-Activator: org.eclipse.cdt.testsrunner.internal.qttest.QtTestsRunnerPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.5.0", - org.eclipse.cdt.testsrunner;bundle-version="3.5.0" + org.eclipse.cdt.testsrunner;bundle-version="3.5.0", + org.eclipse.cdt.core;bundle-version="8.3.0" Export-Package: org.eclipse.cdt.testsrunner.internal.qttest;x-friends:="org.eclipse.cdt.testsrunner.tests" Automatic-Module-Name: org.eclipse.cdt.testsrunner.qttest diff --git a/testsrunner/org.eclipse.cdt.testsrunner.qttest/src/org/eclipse/cdt/testsrunner/internal/qttest/QtTestsRunnerProvider.java b/testsrunner/org.eclipse.cdt.testsrunner.qttest/src/org/eclipse/cdt/testsrunner/internal/qttest/QtTestsRunnerProvider.java index 59fddfc0003..7ebfe967ac9 100644 --- a/testsrunner/org.eclipse.cdt.testsrunner.qttest/src/org/eclipse/cdt/testsrunner/internal/qttest/QtTestsRunnerProvider.java +++ b/testsrunner/org.eclipse.cdt.testsrunner.qttest/src/org/eclipse/cdt/testsrunner/internal/qttest/QtTestsRunnerProvider.java @@ -19,8 +19,8 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; +import org.eclipse.cdt.internal.core.XmlProcessorFactoryCdt; import org.eclipse.cdt.testsrunner.launcher.ITestsRunnerProvider; import org.eclipse.cdt.testsrunner.model.ITestModelUpdater; import org.eclipse.cdt.testsrunner.model.TestingException; @@ -111,8 +111,7 @@ private String getErrorText(String prefix, String description) { @Override public void run(ITestModelUpdater modelUpdater, InputStream inputStream) throws TestingException { try { - SAXParserFactory spf = SAXParserFactory.newInstance(); - SAXParser sp = spf.newSAXParser(); + SAXParser sp = XmlProcessorFactoryCdt.createSAXParserWithErrorOnDOCTYPE(); sp.parse(inputStream, new QtXmlLogHandler(modelUpdater)); } catch (IOException e) { diff --git a/testsrunner/org.eclipse.cdt.testsrunner.tests/src/org/eclipse/cdt/testsrunner/testsrunners/BoostTestCase.java b/testsrunner/org.eclipse.cdt.testsrunner.tests/src/org/eclipse/cdt/testsrunner/testsrunners/BoostTestCase.java index 7d84aabcbb6..000ef5aaaa4 100644 --- a/testsrunner/org.eclipse.cdt.testsrunner.tests/src/org/eclipse/cdt/testsrunner/testsrunners/BoostTestCase.java +++ b/testsrunner/org.eclipse.cdt.testsrunner.tests/src/org/eclipse/cdt/testsrunner/testsrunners/BoostTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2013 Anton Gorenkov and others. + * Copyright (c) 2011, 2023 Anton Gorenkov and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -226,7 +226,8 @@ public void testEmptyMessage() { mockModelUpdater.enterTestSuite("MainTS"); mockModelUpdater.enterTestCase("test"); mockModelUpdater.addTestMessage("file.cpp", 22, ITestMessage.Level.Info, ""); - mockModelUpdater.addTestMessage("file2.cpp", 47, ITestMessage.Level.Exception, EXCEPTION_CHECKPOINT_SUFFIX); + mockModelUpdater.addTestMessage("file2.cpp", 47, ITestMessage.Level.Exception, + EXCEPTION_CHECKPOINT_SUFFIX.trim()); mockModelUpdater.exitTestCase(); mockModelUpdater.exitTestSuite(); } @@ -245,9 +246,9 @@ public void testSpacesInBeginAndEndOfMessage() { mockModelUpdater.enterTestSuite("MainTS"); mockModelUpdater.enterTestCase("test"); - mockModelUpdater.addTestMessage("file", 42, ITestMessage.Level.Warning, " Custom warning "); + mockModelUpdater.addTestMessage("file", 42, ITestMessage.Level.Warning, "Custom warning"); mockModelUpdater.addTestMessage("file2", 47, ITestMessage.Level.Exception, - " Exception message end " + EXCEPTION_CHECKPOINT_SUFFIX); + "Exception message end" + EXCEPTION_CHECKPOINT_SUFFIX); mockModelUpdater.exitTestCase(); mockModelUpdater.exitTestSuite(); } @@ -506,4 +507,136 @@ public void testParameterizedTests() { mockModelUpdater.exitTestCase(); mockModelUpdater.exitTestSuite(); } + + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + public void testWithContextTests() { + mockModelUpdater.skipCalls("setTestStatus"); + + mockModelUpdater.enterTestSuite("MainTS"); + mockModelUpdater.enterTestCase("single-context [context 1 message here]"); + mockModelUpdater.addTestMessage("file1.cpp", 1, ITestMessage.Level.Info, "Context: context 1 message here"); + mockModelUpdater.exitTestCase(); + mockModelUpdater.enterTestCase("single-context-and-info-message [context 2 message here]"); + mockModelUpdater.addTestMessage("file2.cpp", 2, ITestMessage.Level.Info, + "info 2 message here\nContext: context 2 message here"); + mockModelUpdater.exitTestCase(); + + // I am not convinced the handling of this is correct, there is an assumption in the code that the first + // context seen in an info (or error/warning/etc) message is the one to display next to the test case + // name. This works if all the info messages have the same context, but is that an oversimplification? + // See https://github.com/eclipse-cdt/cdt/issues/459#issuecomment-1677589998 + mockModelUpdater.enterTestCase("multi-context [context 3a message here]"); + mockModelUpdater.addTestMessage("file3.cpp", 1, ITestMessage.Level.Info, "Context: context 3a message here"); + mockModelUpdater.addTestMessage("file3.cpp", 2, ITestMessage.Level.Info, "Context: context 3b message here"); + mockModelUpdater.exitTestCase(); + + mockModelUpdater.enterTestCase("error-message [context 4 message here]"); + mockModelUpdater.addTestMessage("file4.cpp", 1, ITestMessage.Level.Error, + "error 4 message here\nContext: context 4 message here"); + mockModelUpdater.exitTestCase(); + + // These tests make sure there is no off-by-one error when shortening context strings + mockModelUpdater.enterTestCase("off-by-one-check-a [very very very long context off-by-one-check 01234...]"); + mockModelUpdater.addTestMessage("off-by-one.cpp", 1, ITestMessage.Level.Error, + "Context: very very very long context off-by-one-check 01234567890"); + mockModelUpdater.exitTestCase(); + mockModelUpdater.enterTestCase("off-by-one-check-b [very very very long context off-by-one-check 01234...]"); + mockModelUpdater.addTestMessage("off-by-one.cpp", 1, ITestMessage.Level.Error, + "Context: very very very long context off-by-one-check 012345"); + mockModelUpdater.exitTestCase(); + mockModelUpdater.enterTestCase("off-by-one-check-c [very very very long context off-by-one-check 01234]"); + mockModelUpdater.addTestMessage("off-by-one.cpp", 1, ITestMessage.Level.Error, + "Context: very very very long context off-by-one-check 01234"); + mockModelUpdater.exitTestCase(); + mockModelUpdater.enterTestCase("off-by-one-check-d [very very very long context off-by-one-check 0123]"); + mockModelUpdater.addTestMessage("off-by-one.cpp", 1, ITestMessage.Level.Error, + "Context: very very very long context off-by-one-check 0123"); + mockModelUpdater.exitTestCase(); + + mockModelUpdater.exitTestSuite(); + } }