Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove special treatment of org.eclipse.swt in API-Tools #1094

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -504,21 +504,13 @@ private int retrieveTypeModifiers(IDelta delta, String typeName, String componen
IApiComponent p = providers[index];
if (!p.equals(apiComponent)) {
String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
typeRoot = p.findTypeRoot(typeName);
} else {
typeRoot = p.findTypeRoot(typeName, id2);
}
typeRoot = p.findTypeRoot(typeName, id2);
}
index++;
}
break;
default:
if (Util.ORG_ECLIPSE_SWT.equals(id)) {
typeRoot = apiComponent.findTypeRoot(typeName);
} else {
typeRoot = apiComponent.findTypeRoot(typeName, id);
}
typeRoot = apiComponent.findTypeRoot(typeName, id);
}
if (typeRoot != null) {
IApiType structure = typeRoot.getStructure();
Expand Down Expand Up @@ -554,21 +546,13 @@ private int retrieveTypeModifiers(IDelta delta, String typeName, String componen
IApiComponent p = providers[index];
if (!p.equals(apiComponent)) {
String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
typeRoot = p.findTypeRoot(typeName);
} else {
typeRoot = p.findTypeRoot(typeName, id2);
}
typeRoot = p.findTypeRoot(typeName, id2);
}
index++;
}
break;
default:
if (Util.ORG_ECLIPSE_SWT.equals(id)) {
typeRoot = apiComponent.findTypeRoot(typeName);
} else {
typeRoot = apiComponent.findTypeRoot(typeName, id);
}
typeRoot = apiComponent.findTypeRoot(typeName, id);
}
if (typeRoot != null) {
IApiType structure = typeRoot.getStructure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,88 +176,85 @@
}
apiDescriptionFile.delete();
}
File[] allFiles = null;
Map<String, String> manifestMap = null;
IApiTypeContainer classFileContainer = null;
if (!this.projectLocation.endsWith(Util.ORG_ECLIPSE_SWT)) {
// create the directory class file container used to resolve
// signatures during tag scanning
String[] allBinaryLocations = this.binaryLocations.split(File.pathSeparator);
List<IApiTypeContainer> allContainers = new ArrayList<>();
IApiTypeContainer container = null;
for (String allBinaryLocation : allBinaryLocations) {
container = getContainer(allBinaryLocation);
if (container == null) {
throw new IllegalArgumentException(
NLS.bind(CoreMessages.api_generation_invalidBinaryLocation, allBinaryLocation));
}
allContainers.add(container);
}
classFileContainer = new CompositeApiTypeContainer(null, allContainers);
File manifestFile = null;
File manifestDir = new File(root, "META-INF"); //$NON-NLS-1$
if (manifestDir.exists() && manifestDir.isDirectory()) {
manifestFile = new File(manifestDir, "MANIFEST.MF"); //$NON-NLS-1$
// create the directory class file container used to resolve
// signatures during tag scanning
String[] allBinaryLocations = this.binaryLocations.split(File.pathSeparator);
List<IApiTypeContainer> allContainers = new ArrayList<>();
IApiTypeContainer container = null;
for (String allBinaryLocation : allBinaryLocations) {
container = getContainer(allBinaryLocation);
if (container == null) {
throw new IllegalArgumentException(
NLS.bind(CoreMessages.api_generation_invalidBinaryLocation, allBinaryLocation));
}
if (manifestFile != null && manifestFile.exists()) {
try (BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(manifestFile));) {
manifestMap = ManifestElement.parseBundleManifest(inputStream, null);
this.apiPackages = collectApiPackageNames(manifestMap);
} catch (IOException | BundleException e) {
ApiPlugin.log(e);
}
allContainers.add(container);
}
IApiTypeContainer classFileContainer = new CompositeApiTypeContainer(null, allContainers);
File manifestFile = null;
File manifestDir = new File(root, "META-INF"); //$NON-NLS-1$
if (manifestDir.exists() && manifestDir.isDirectory()) {
manifestFile = new File(manifestDir, "MANIFEST.MF"); //$NON-NLS-1$
}
if (manifestFile != null && manifestFile.exists()) {
try (BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(manifestFile));) {
manifestMap = ManifestElement.parseBundleManifest(inputStream, null);
this.apiPackages = collectApiPackageNames(manifestMap);
} catch (IOException | BundleException e) {
ApiPlugin.log(e);
}
if (this.manifests != null) {
String[] allManifestFiles = this.manifests.split(File.pathSeparator);
for (String allManifestFile : allManifestFiles) {
File currentManifest = new File(allManifestFile);
Set<String> currentApiPackages = null;
if (currentManifest.exists()) {
try {
if (isZipJarFile(currentManifest.getName())) {
try (ZipFile zipFile = new ZipFile(currentManifest)) {
final ZipEntry entry = zipFile.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$
if (entry != null) {
InputStream inputStream = zipFile.getInputStream(entry);
manifestMap = ManifestElement.parseBundleManifest(inputStream, null);
currentApiPackages = collectApiPackageNames(manifestMap);

}
}
} else {
try (InputStream inputStream = new FileInputStream(currentManifest)) {
}
if (this.manifests != null) {
String[] allManifestFiles = this.manifests.split(File.pathSeparator);
for (String allManifestFile : allManifestFiles) {
File currentManifest = new File(allManifestFile);
Set<String> currentApiPackages = null;
if (currentManifest.exists()) {
try {
if (isZipJarFile(currentManifest.getName())) {
try (ZipFile zipFile = new ZipFile(currentManifest)) {
final ZipEntry entry = zipFile.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$
if (entry != null) {
InputStream inputStream = zipFile.getInputStream(entry);
manifestMap = ManifestElement.parseBundleManifest(inputStream, null);
currentApiPackages = collectApiPackageNames(manifestMap);

}
}
} catch (IOException | BundleException e) {
ApiPlugin.log(e);
}
}
if (currentApiPackages != null) {
if (this.apiPackages == null) {
this.apiPackages = currentApiPackages;
} else {
this.apiPackages.addAll(currentApiPackages);
try (InputStream inputStream = new FileInputStream(currentManifest)) {
manifestMap = ManifestElement.parseBundleManifest(inputStream, null);
currentApiPackages = collectApiPackageNames(manifestMap);
}
}
} catch (IOException | BundleException e) {
ApiPlugin.log(e);
}
}
if (currentApiPackages != null) {
if (this.apiPackages == null) {
this.apiPackages = currentApiPackages;
} else {
this.apiPackages.addAll(currentApiPackages);
}
}
}
FileFilter fileFilter = path -> (path.isFile() && Util.isJavaFileName(path.getName()) && isApi(path.getParent())) || path.isDirectory();
allFiles = Util.getAllFiles(root, fileFilter);
if (this.sourceLocations != null) {
String[] allSourceLocations = this.sourceLocations.split(File.pathSeparator);
for (String currentSourceLocation : allSourceLocations) {
File[] allFiles2 = Util.getAllFiles(new File(currentSourceLocation), fileFilter);
if (allFiles2 != null) {
if (allFiles == null) {
allFiles = allFiles2;
} else {
int length = allFiles.length;
int length2 = allFiles2.length;
System.arraycopy(allFiles, 0, (allFiles = new File[length + length2]), 0, length);
System.arraycopy(allFiles2, 0, allFiles, length, length2);
}
}
FileFilter fileFilter = path -> (path.isFile() && Util.isJavaFileName(path.getName())
&& isApi(path.getParent())) || path.isDirectory();
File[] allFiles = Util.getAllFiles(root, fileFilter);
if (this.sourceLocations != null) {
String[] allSourceLocations = this.sourceLocations.split(File.pathSeparator);
for (String currentSourceLocation : allSourceLocations) {
File[] allFiles2 = Util.getAllFiles(new File(currentSourceLocation), fileFilter);
if (allFiles2 != null) {
if (allFiles == null) {
allFiles = allFiles2;
} else {
int length = allFiles.length;
int length2 = allFiles2.length;
System.arraycopy(allFiles, 0, (allFiles = new File[length + length2]), 0, length);
System.arraycopy(allFiles2, 0, allFiles, length, length2);
}
}
}
Expand Down Expand Up @@ -379,7 +376,7 @@
*/
private String resolveCompliance(Map<String, String> manifestmap) {
if (manifestmap != null) {
String eename = manifestmap.get(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT);

Check warning on line 379 in apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/APIFileGenerator.java

View check run for this annotation

Jenkins - eclipse-pde / Compiler and API Tools

Deprecation

NORMAL: The field Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT is deprecated
if (eename != null) {
if ("J2SE-1.4".equals(eename)) { //$NON-NLS-1$
return JavaCore.VERSION_1_4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,11 +1309,7 @@ private void checkCompatibility(final String typeName, final IApiComponent refer
}
IApiTypeRoot classFile = null;
try {
if (Util.ORG_ECLIPSE_SWT.equals(id)) {
classFile = component.findTypeRoot(typeName);
} else {
classFile = component.findTypeRoot(typeName, id);
}
classFile = component.findTypeRoot(typeName, id);
} catch (CoreException e) {
ApiPlugin.log(e);
}
Expand All @@ -1331,11 +1327,7 @@ private void checkCompatibility(final String typeName, final IApiComponent refer
IApiComponent p = providers[index];
if (!p.equals(component)) {
String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
classFile = p.findTypeRoot(typeName);
} else {
classFile = p.findTypeRoot(typeName, id2);
}
classFile = p.findTypeRoot(typeName, id2);
if (classFile != null) {
IRequiredComponentDescription[] components = component.getRequiredComponents();
for (IRequiredComponentDescription description : components) {
Expand Down Expand Up @@ -1865,15 +1857,10 @@ private void processDelta(final IDelta delta, final IApiComponent reference, fin
if (Flags.isProtected(modifiers)) {
String typeName = delta.getTypeName();
if (typeName != null) {
IApiTypeRoot typeRoot = null;
IApiType type = null;
try {
String id = component.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id)) {
typeRoot = component.findTypeRoot(typeName);
} else {
typeRoot = component.findTypeRoot(typeName, id);
}
IApiTypeRoot typeRoot = component.findTypeRoot(typeName, id);
if (typeRoot == null) {
String packageName = Signatures.getPackageName(typeName);
// check if the type is provided by a
Expand All @@ -1885,11 +1872,7 @@ private void processDelta(final IDelta delta, final IApiComponent reference, fin
IApiComponent p = providers[index];
if (!p.equals(component)) {
String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
typeRoot = p.findTypeRoot(typeName);
} else {
typeRoot = p.findTypeRoot(typeName, id2);
}
typeRoot = p.findTypeRoot(typeName, id2);
}
index++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,25 +555,17 @@ protected List<IApiTypeContainer> createApiTypeContainers() throws CoreException
List<IApiComponent> all = new ArrayList<>();
// build the classpath from bundle and all fragments
all.add(this);
boolean considerFragments = true;
if (Util.ORG_ECLIPSE_SWT.equals(getSymbolicName())) {
// if SWT is a project to be built/analyzed don't consider its
// fragments
considerFragments = !isApiEnabled();
}
if (considerFragments) {
BundleDescription[] fragments = getBundleDescription().getFragments();
for (BundleDescription fragment : fragments) {
if (!fragment.isResolved()) {
continue;
}
IApiComponent component = getBaseline().getApiComponent(fragment.getSymbolicName());
if (component != null) {
// force initialization of the fragment so we can
// retrieve its class file containers
component.getApiTypeContainers();
all.add(component);
}
BundleDescription[] fragments = getBundleDescription().getFragments();
for (BundleDescription fragment : fragments) {
if (!fragment.isResolved()) {
continue;
}
IApiComponent component = getBaseline().getApiComponent(fragment.getSymbolicName());
if (component != null) {
// force initialization of the fragment so we can
// retrieve its class file containers
component.getApiTypeContainers();
all.add(component);
}
}
Iterator<IApiComponent> iterator = all.iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,8 @@ public static IDelta compare(final IApiTypeRoot typeRoot2, final IApiComponent c
return NO_DELTA;
}
String typeName = typeRoot2.getTypeName();
IApiTypeRoot typeRoot = null;
String id = component.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id)) {
typeRoot = component.findTypeRoot(typeName);
} else {
typeRoot = component.findTypeRoot(typeName, id);
}
IApiTypeRoot typeRoot = component.findTypeRoot(typeName, id);
final IApiDescription apiDescription2 = component2.getApiDescription();
IApiAnnotations elementDescription2 = apiDescription2.resolveAnnotations(typeDescriptor2.getHandle());
int visibility = 0;
Expand Down Expand Up @@ -614,17 +609,9 @@ static boolean filterType(final int visibilityModifiers, IApiAnnotations element
private static IDelta internalCompare(final IApiComponent component, final IApiComponent component2, final IApiBaseline referenceBaseline, final IApiBaseline baseline, final int visibilityModifiers, final Delta globalDelta, final IProgressMonitor monitor) throws CoreException {
final Set<String> typeRootBaseLineNames = new HashSet<>();
final String id = component.getSymbolicName();
IApiTypeContainer[] typeRootContainers = null;
IApiTypeContainer[] typeRootContainers2 = null;
final SubMonitor localmonitor = SubMonitor.convert(monitor, 4);
final boolean isSWT = Util.ORG_ECLIPSE_SWT.equals(id);
if (isSWT) {
typeRootContainers = component.getApiTypeContainers();
typeRootContainers2 = component2.getApiTypeContainers();
} else {
typeRootContainers = component.getApiTypeContainers(id);
typeRootContainers2 = component2.getApiTypeContainers(id);
}
IApiTypeContainer[] typeRootContainers = component.getApiTypeContainers(id);
IApiTypeContainer[] typeRootContainers2 = component2.getApiTypeContainers(id);
final IApiDescription apiDescription = component.getApiDescription();
final IApiDescription apiDescription2 = component2.getApiDescription();
if (typeRootContainers != null) {
Expand Down Expand Up @@ -652,12 +639,7 @@ public void visit(String packageName, IApiTypeRoot typeRoot) {
// Annotation is missing, not an API?
visibility = 0;
}
IApiTypeRoot typeRoot2 = null;
if (isSWT) {
typeRoot2 = component2.findTypeRoot(typeName);
} else {
typeRoot2 = component2.findTypeRoot(typeName, id);
}
IApiTypeRoot typeRoot2 = component2.findTypeRoot(typeName, id);
IApiComponent provider = null;
IApiDescription providerApiDesc = null;
boolean reexported = false;
Expand All @@ -673,11 +655,7 @@ public void visit(String packageName, IApiTypeRoot typeRoot) {
IApiComponent p = providers[index];
if (!p.equals(component2)) {
String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
typeRoot2 = p.findTypeRoot(typeName);
} else {
typeRoot2 = p.findTypeRoot(typeName, id2);
}
typeRoot2 = p.findTypeRoot(typeName, id2);
if (typeRoot2 != null) {
provider = p;
providerApiDesc = p.getApiDescription();
Expand Down Expand Up @@ -813,12 +791,7 @@ public void visit(String packageName, IApiTypeRoot typeRoot) {
if (elementDescription != null) {
visibility = elementDescription.getVisibility();
}
IApiTypeRoot typeRoot2 = null;
if (isSWT) {
typeRoot2 = component2.findTypeRoot(typeName);
} else {
typeRoot2 = component2.findTypeRoot(typeName, id);
}
IApiTypeRoot typeRoot2 = component2.findTypeRoot(typeName, id);
IApiDescription providerApiDesc = null;
if (typeRoot2 == null) {
// check if the type is provided
Expand All @@ -831,11 +804,7 @@ public void visit(String packageName, IApiTypeRoot typeRoot) {
IApiComponent p = providers[index];
if (!p.equals(component2)) {
String id2 = p.getSymbolicName();
if (Util.ORG_ECLIPSE_SWT.equals(id2)) {
typeRoot2 = p.findTypeRoot(typeName);
} else {
typeRoot2 = p.findTypeRoot(typeName, id2);
}
typeRoot2 = p.findTypeRoot(typeName, id2);
if (typeRoot2 != null) {
providerApiDesc = p.getApiDescription();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ private void cancelBuild(Object jobfamily) {

public static final IPath MANIFEST_PROJECT_RELATIVE_PATH = IPath.fromOSString(JarFile.MANIFEST_NAME);

public static final String ORG_ECLIPSE_SWT = "org.eclipse.swt"; //$NON-NLS-1$

public static final int LATEST_OPCODES_ASM = Opcodes.ASM9;

/**
Expand Down
Loading