Skip to content

Commit

Permalink
Merge branch 'master' into manifest_bund_add
Browse files Browse the repository at this point in the history
  • Loading branch information
alshamams authored Sep 6, 2023
2 parents 34d8f24 + 7915cc4 commit 8ff8263
Show file tree
Hide file tree
Showing 160 changed files with 2,136 additions and 1,673 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: CodeQL call

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: '45 8 * * 1'

jobs:
callCodeQLworkflow:
uses: eclipse-platform/eclipse.platform.releng.aggregator/.github/workflows/codeQLworkflow.yml@master
11 changes: 7 additions & 4 deletions apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Bundle-SymbolicName: org.eclipse.pde.api.tools.tests
Bundle-Version: 1.3.200.qualifier
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.core.runtime,
org.junit,
org.eclipse.pde.api.tools;bundle-version="1.0.600",
org.eclipse.jdt.launching;bundle-version="[3.6.100,4.0.0)",
org.eclipse.debug.core,
Expand Down Expand Up @@ -33,15 +32,19 @@ Export-Package: org.eclipse.pde.api.tools.anttasks.tests,
org.eclipse.pde.api.tools.builder.tests.tags,
org.eclipse.pde.api.tools.builder.tests.usage,
org.eclipse.pde.api.tools.comparator.tests,
org.eclipse.pde.api.tools.model.tests;uses:="junit.framework,org.eclipse.pde.api.tools.model.component",
org.eclipse.pde.api.tools.model.tests,
org.eclipse.pde.api.tools.problems.tests,
org.eclipse.pde.api.tools.reference.tests,
org.eclipse.pde.api.tools.search.tests,
org.eclipse.pde.api.tools.tests,
org.eclipse.pde.api.tools.tests.util,
org.eclipse.pde.api.tools.util.tests;uses:="junit.framework"
org.eclipse.pde.api.tools.util.tests
Bundle-Activator: org.eclipse.pde.api.tools.tests.ApiTestsPlugin
Bundle-ActivationPolicy: lazy
Eclipse-BundleShape: dir
Import-Package: org.eclipse.equinox.frameworkadmin
Import-Package: junit.framework,
org.eclipse.equinox.frameworkadmin,
org.junit,
org.junit.runner,
org.junit.runners
Automatic-Module-Name: org.eclipse.pde.api.tools.tests
2 changes: 1 addition & 1 deletion apitools/org.eclipse.pde.api.tools.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.eclipse.pde</groupId>
<artifactId>eclipse.pde</artifactId>
<version>4.29.0-SNAPSHOT</version>
<version>4.30.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>org.eclipse.pde.api.tools.tests</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;

import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -63,7 +63,7 @@ private void runTaskAndVerify(String resourceName) throws Exception, CoreExcepti
IFile reportFile = buildFolder.getFile("report.xml"); //$NON-NLS-1$
assertTrue("report.xml must exist", reportFile.exists()); //$NON-NLS-1$
InputSource is = new InputSource(reportFile.getContents());
DocumentBuilder db = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
DocumentBuilder db = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
Document doc = db.parse(is);
NodeList elems = doc.getElementsByTagName("delta"); //$NON-NLS-1$
boolean found = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;

import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
Expand Down Expand Up @@ -66,7 +66,7 @@ private IFolder runTaskAndVerify(String resourceName) throws Exception, CoreExce
public void test1() throws Exception {
IFolder reportFolder = runTaskAndVerify("test1"); //$NON-NLS-1$
InputSource is = new InputSource(reportFolder.getFile("not_searched.xml").getContents()); //$NON-NLS-1$
DocumentBuilder db = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
DocumentBuilder db = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
Document doc = db.parse(is);

NodeList elems = doc.getElementsByTagName("component"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;

import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
Expand Down Expand Up @@ -60,7 +60,7 @@ private void runTaskAndVerify(String resourceName) throws Exception, CoreExcepti
assertTrue("report folder must exist", folder.exists()); //$NON-NLS-1$
assertTrue("report xml must exist", folder.getFile("compare.xml").exists()); //$NON-NLS-1$ //$NON-NLS-2$
InputSource is = new InputSource(folder.getFile("compare.xml").getContents()); //$NON-NLS-1$
DocumentBuilder db = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
DocumentBuilder db = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
Document doc = db.parse(is);
NodeList elems = doc.getElementsByTagName("delta"); //$NON-NLS-1$
boolean found = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

Expand Down Expand Up @@ -458,8 +457,7 @@ public boolean isDisposed() {
return false;
}
}
List<IApiComponent> allComponents = new ArrayList<>();
String[] componentNames = new String[] {
IApiComponent[] components = Stream.of( //
"org.eclipse.swt", //$NON-NLS-1$
"org.eclipse.equinox.simpleconfigurator.manipulator", //$NON-NLS-1$
"org.eclipse.team.ui", //$NON-NLS-1$
Expand Down Expand Up @@ -503,7 +501,6 @@ public boolean isDisposed() {
"org.eclipse.jdt", //$NON-NLS-1$
"org.eclipse.osgi.util", //$NON-NLS-1$
"org.sat4j.pb", //$NON-NLS-1$
"org.hamcrest.core", //$NON-NLS-1$
"org.eclipse.jdt.junit4.runtime", //$NON-NLS-1$
"org.eclipse.equinox.p2.artifact.repository", //$NON-NLS-1$
"org.eclipse.core.databinding.property", //$NON-NLS-1$
Expand Down Expand Up @@ -644,13 +641,8 @@ public boolean isDisposed() {
"org.eclipse.equinox.app", //$NON-NLS-1$
"org.eclipse.ui.net", //$NON-NLS-1$
"org.eclipse.equinox.p2.publisher", //$NON-NLS-1$
"org.eclipse.ecf.provider.filetransfer.httpclient", //$NON-NLS-1$
};
for (String componentName : componentNames) {
allComponents.add(new LocalApiComponent(componentName));
}
IApiComponent[] components = new IApiComponent[allComponents.size()];
allComponents.toArray(components);
"org.eclipse.ecf.provider.filetransfer.httpclient" //$NON-NLS-1$
).map(LocalApiComponent::new).toArray(IApiComponent[]::new);
FilteredElements excludedElements = new FilteredElements();
try {
Util.collectRegexIds(line, excludedElements, components, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
Expand All @@ -45,7 +46,6 @@
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;
import org.eclipse.pde.api.tools.ui.internal.IApiToolsConstants;
import org.eclipse.pde.api.tools.ui.internal.views.APIToolingView;
import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;

/**
* Drop-down action to select the active session.
Expand Down Expand Up @@ -155,7 +155,7 @@ protected IStatus run(IProgressMonitor monitor) {
}
writer = new BufferedWriter(new FileWriter(reportFile));
Result result = new StreamResult(writer);
TransformerFactory f = PDEXmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE();
TransformerFactory f = XmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE();
Transformer trans = f.newTransformer(xsltSource);
trans.transform(xmlSource, result);
} catch (TransformerException | IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package org.eclipse.pde.api.tools.internal;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
Expand Down Expand Up @@ -46,7 +45,6 @@
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
import org.eclipse.pde.api.tools.internal.provisional.scanner.TagScanner;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.xml.sax.Attributes;
Expand Down Expand Up @@ -458,27 +456,16 @@ private boolean isAPIToolsNature(File dotProjectFile) {
* @return true if it contains a source extension point, false otherwise
*/
private boolean containsAPIToolsNature(String pluginXMLContents) {
SAXParser saxParser = null;
try {
saxParser = PDEXmlProcessorFactory.createSAXParserIgnoringDOCTYPE();
} catch (ParserConfigurationException | SAXException e) {
// ignore
}

if (saxParser == null) {
return false;
}

// Parse
InputSource inputSource = new InputSource(new BufferedReader(new StringReader(pluginXMLContents)));
try {
@SuppressWarnings("restriction")
SAXParser saxParser = org.eclipse.core.internal.runtime.XmlProcessorFactory
.createSAXParserIgnoringDOCTYPE();
APIToolsNatureDefaultHandler defaultHandler = new APIToolsNatureDefaultHandler();
saxParser.parse(inputSource, defaultHandler);
saxParser.parse(new InputSource(new StringReader(pluginXMLContents)), defaultHandler);
return defaultHandler.isAPIToolsNature();
} catch (SAXException | IOException e) {
// ignore
} catch (SAXException | IOException | ParserConfigurationException e) {
return false;
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public Object start(IApplicationContext context) throws Exception {
setTargetPlatform(args.tpFile);

project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
// wait untill all jobs has finished that might be sceduled as part of the
// build...
while (!Job.getJobManager().isIdle()) {
Thread.yield();
}
IMarker[] allProblemMarkers = project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
Predicate<IMarker> isAPIMarker = marker -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public String toString() {

@Override
public boolean equals(Object obj) {
if (obj instanceof ApiAnnotations) {
ApiAnnotations desc = (ApiAnnotations) obj;
if (obj instanceof ApiAnnotations desc) {
return this.bits == desc.bits;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import org.eclipse.pde.core.plugin.ModelEntry;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.internal.core.DependencyManager;
import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Expand Down Expand Up @@ -373,7 +372,7 @@ private void writeBaselineDescription(IApiBaseline baseline, OutputStream stream
try {
stream.write(xml.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
abort("Error writing pofile descrition", e); //$NON-NLS-1$
throw new CoreException(Status.error("Error writing pofile descrition", e)); //$NON-NLS-1$
}
}

Expand Down Expand Up @@ -422,18 +421,6 @@ private String getProfileXML(IApiBaseline baseline) throws CoreException {
return Util.serializeDocument(document);
}

/**
* Throws a core exception with the given message and underlying exception,
* if any.
*
* @param message error message
* @param e underlying exception or <code>null</code>
* @throws CoreException
*/
private static void abort(String message, Throwable e) throws CoreException {
throw new CoreException(Status.error(message, e));
}

/**
* Restore a baseline from the given input stream (persisted baseline).
*
Expand All @@ -444,14 +431,8 @@ private static void abort(String message, Throwable e) throws CoreException {
*/
public IApiComponent[] readBaselineComponents(ApiBaseline baseline, InputStream stream) throws CoreException {
long start = System.currentTimeMillis();
DocumentBuilder parser = null;
DocumentBuilder parser = getConfiguredParser();
IApiComponent[] restored = null;
try {
parser = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
parser.setErrorHandler(new DefaultHandler());
} catch (ParserConfigurationException | FactoryConfigurationError e) {
abort("Error restoring API baseline", e); //$NON-NLS-1$
}
try {
Document document = parser.parse(stream);
Element root = document.getDocumentElement();
Expand Down Expand Up @@ -505,14 +486,26 @@ public IApiComponent[] readBaselineComponents(ApiBaseline baseline, InputStream
restored = components.toArray(new IApiComponent[components.size()]);
}
} catch (IOException | SAXException e) {
abort("Error restoring API baseline", e); //$NON-NLS-1$
throw new CoreException(Status.error("Error restoring API baseline", e)); //$NON-NLS-1$
}
if (ApiPlugin.DEBUG_BASELINE_MANAGER) {
System.out.println("Time to restore a persisted baseline : " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
return restored;
}

private static DocumentBuilder getConfiguredParser() throws CoreException {
try {
@SuppressWarnings("restriction")
DocumentBuilder parser = org.eclipse.core.internal.runtime.XmlProcessorFactory
.createDocumentBuilderWithErrorOnDOCTYPE();
parser.setErrorHandler(new DefaultHandler());
return parser;
} catch (ParserConfigurationException | FactoryConfigurationError e) {
throw new CoreException(Status.error("Error restoring API baseline", e)); //$NON-NLS-1$
}
}

@Override
public void saving(ISaveContext context) throws CoreException {
if (!fNeedsSaving) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ private void restoreNode(ProjectApiDescription apiDesc, Element element, Manifes
break;
}
case IApiXmlConstants.ELEMENT_FIELD:
if (parentNode.element instanceof IReferenceTypeDescriptor) {
IReferenceTypeDescriptor type = (IReferenceTypeDescriptor) parentNode.element;
if (parentNode.element instanceof IReferenceTypeDescriptor type) {
int vis = getInt(element, IApiXmlConstants.ATTR_VISIBILITY);
int res = getInt(element, IApiXmlConstants.ATTR_RESTRICTIONS);
String name = element.getAttribute(IApiXmlConstants.ATTR_NAME);
Expand All @@ -366,8 +365,7 @@ private void restoreNode(ProjectApiDescription apiDesc, Element element, Manifes
}
break;
case IApiXmlConstants.ELEMENT_METHOD:
if (parentNode.element instanceof IReferenceTypeDescriptor) {
IReferenceTypeDescriptor type = (IReferenceTypeDescriptor) parentNode.element;
if (parentNode.element instanceof IReferenceTypeDescriptor type) {
int vis = getInt(element, IApiXmlConstants.ATTR_VISIBILITY);
int res = getInt(element, IApiXmlConstants.ATTR_RESTRICTIONS);
String name = element.getAttribute(IApiXmlConstants.ATTR_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public boolean isIncludeMinimum() {

@Override
public boolean equals(Object obj) {
if (obj instanceof BundleVersionRange) {
BundleVersionRange range = (BundleVersionRange) obj;
if (obj instanceof BundleVersionRange range) {
return fRange.equals(range.fRange);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public Key(int t, int m) {

@Override
public boolean equals(Object obj) {
if (obj instanceof Key) {
Key other = (Key) obj;
if (obj instanceof Key other) {
return type == other.type && member == other.member;
}
return super.equals(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public RequiredComponentDescription(String id, IVersionRange range, boolean isOp

@Override
public boolean equals(Object obj) {
if (obj instanceof RequiredComponentDescription) {
RequiredComponentDescription desc = (RequiredComponentDescription) obj;
if (obj instanceof RequiredComponentDescription desc) {
return fId.equals(desc.fId) && fRange.equals(desc.fRange);
}
return super.equals(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public boolean considerReference(IReference reference, IProgressMonitor monitor)
} catch (CoreException ce) {
// do nothing, skip it
}
if (member instanceof IApiMethod) {
IApiMethod method = (IApiMethod) member;
if (member instanceof IApiMethod method) {
if (method.isDefaultMethod()) {
return considerReference(reference, monitor);
}
Expand Down
Loading

0 comments on commit 8ff8263

Please sign in to comment.