|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008, 2013 IBM Corporation and others. |
2 |
* Copyright (c) 2008, 2016 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 27-36
Link Here
|
| 27 |
|
27 |
|
| 28 |
import org.apache.tools.ant.BuildException; |
28 |
import org.apache.tools.ant.BuildException; |
| 29 |
import org.apache.tools.ant.Task; |
29 |
import org.apache.tools.ant.Task; |
| 30 |
import org.eclipse.jdt.core.Signature; |
|
|
| 31 |
import org.eclipse.osgi.util.NLS; |
30 |
import org.eclipse.osgi.util.NLS; |
| 32 |
import org.eclipse.pde.api.tools.internal.IApiXmlConstants; |
31 |
import org.eclipse.pde.api.tools.internal.IApiXmlConstants; |
| 33 |
import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta; |
|
|
| 34 |
import org.eclipse.pde.api.tools.internal.util.Util; |
32 |
import org.eclipse.pde.api.tools.internal.util.Util; |
| 35 |
import org.xml.sax.Attributes; |
33 |
import org.xml.sax.Attributes; |
| 36 |
import org.xml.sax.SAXException; |
34 |
import org.xml.sax.SAXException; |
|
Lines 53-58
Link Here
|
| 53 |
private Map<String, List<Entry>> map; |
51 |
private Map<String, List<Entry>> map; |
| 54 |
private String typename; |
52 |
private String typename; |
| 55 |
private int elementType; |
53 |
private int elementType; |
|
|
54 |
private String message; |
| 55 |
private boolean compatible; |
| 56 |
|
| 56 |
/** |
57 |
/** |
| 57 |
* String component id to ArrayList of String resolver error messages |
58 |
* String component id to ArrayList of String resolver error messages |
| 58 |
*/ |
59 |
*/ |
|
Lines 70-76
Link Here
|
| 70 |
if (IApiXmlConstants.ELEMENT_RESOLVER_ERRORS.equals(name)) { |
71 |
if (IApiXmlConstants.ELEMENT_RESOLVER_ERRORS.equals(name)) { |
| 71 |
isResolverSection = false; |
72 |
isResolverSection = false; |
| 72 |
} else if (IApiXmlConstants.DELTA_ELEMENT_NAME.equals(name)) { |
73 |
} else if (IApiXmlConstants.DELTA_ELEMENT_NAME.equals(name)) { |
| 73 |
Entry entry = new Entry(this.flags, this.elementType, this.key, this.typename, this.arguments, this.kind); |
74 |
Entry entry = new Entry(this.flags, this.elementType, this.key, this.typename, this.arguments, this.kind, this.message, this.compatible); |
| 74 |
List<Entry> list = this.map.get(this.componentID); |
75 |
List<Entry> list = this.map.get(this.componentID); |
| 75 |
if (list != null) { |
76 |
if (list != null) { |
| 76 |
list.add(entry); |
77 |
list.add(entry); |
|
Lines 103-108
Link Here
|
| 103 |
*/ |
104 |
*/ |
| 104 |
private void printAttribute(Attributes attributes, String name) { |
105 |
private void printAttribute(Attributes attributes, String name) { |
| 105 |
System.out.println("\t" + name + " = " + String.valueOf(attributes.getValue(name))); //$NON-NLS-1$ //$NON-NLS-2$ |
106 |
System.out.println("\t" + name + " = " + String.valueOf(attributes.getValue(name))); //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
107 |
} |
| 108 |
|
| 109 |
/* |
| 110 |
* Only used in debug mode |
| 111 |
*/ |
| 112 |
private void printFlagsAttribute(Attributes attributes, String name) { |
| 113 |
System.out.println("\t" + name + " = " + String.valueOf(Util.getDeltaFlagsName(Integer.valueOf(attributes.getValue(name))))); //$NON-NLS-1$ //$NON-NLS-2$ |
| 106 |
} |
114 |
} |
| 107 |
|
115 |
|
| 108 |
@Override |
116 |
@Override |
|
Lines 139-151
Link Here
|
| 139 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_COMPATIBLE); |
147 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_COMPATIBLE); |
| 140 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_COMPONENT_ID); |
148 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_COMPONENT_ID); |
| 141 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_ELEMENT_TYPE); |
149 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_ELEMENT_TYPE); |
| 142 |
printAttribute(attributes, IApiXmlConstants.ATTR_FLAGS); |
150 |
printFlagsAttribute(attributes, IApiXmlConstants.ATTR_FLAGS); |
| 143 |
printAttribute(attributes, IApiXmlConstants.ATTR_KEY); |
151 |
printAttribute(attributes, IApiXmlConstants.ATTR_KEY); |
| 144 |
printAttribute(attributes, IApiXmlConstants.ATTR_KIND); |
152 |
printAttribute(attributes, IApiXmlConstants.ATTR_KIND); |
| 145 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_NEW_MODIFIERS); |
153 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_NEW_MODIFIERS); |
| 146 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_OLD_MODIFIERS); |
154 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_OLD_MODIFIERS); |
| 147 |
printAttribute(attributes, IApiXmlConstants.ATTR_RESTRICTIONS); |
155 |
printAttribute(attributes, IApiXmlConstants.ATTR_RESTRICTIONS); |
| 148 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_TYPE_NAME); |
156 |
printAttribute(attributes, IApiXmlConstants.ATTR_NAME_TYPE_NAME); |
|
|
157 |
printAttribute(attributes, IApiXmlConstants.ATTR_MESSAGE); |
| 149 |
} |
158 |
} |
| 150 |
final String value = attributes.getValue(IApiXmlConstants.ATTR_NAME_COMPONENT_ID); |
159 |
final String value = attributes.getValue(IApiXmlConstants.ATTR_NAME_COMPONENT_ID); |
| 151 |
if (value == null) { |
160 |
if (value == null) { |
|
Lines 159-164
Link Here
|
| 159 |
this.typename = attributes.getValue(IApiXmlConstants.ATTR_NAME_TYPE_NAME); |
168 |
this.typename = attributes.getValue(IApiXmlConstants.ATTR_NAME_TYPE_NAME); |
| 160 |
this.key = attributes.getValue(IApiXmlConstants.ATTR_KEY); |
169 |
this.key = attributes.getValue(IApiXmlConstants.ATTR_KEY); |
| 161 |
this.kind = attributes.getValue(IApiXmlConstants.ATTR_KIND); |
170 |
this.kind = attributes.getValue(IApiXmlConstants.ATTR_KIND); |
|
|
171 |
this.message = attributes.getValue(IApiXmlConstants.ATTR_MESSAGE); |
| 172 |
String compatibleValue = attributes.getValue(IApiXmlConstants.ATTR_NAME_COMPATIBLE); |
| 173 |
this.compatible = Boolean.parseBoolean(compatibleValue); |
| 162 |
} else if (IApiXmlConstants.ELEMENT_DELTA_MESSAGE_ARGUMENTS.equals(name)) { |
174 |
} else if (IApiXmlConstants.ELEMENT_DELTA_MESSAGE_ARGUMENTS.equals(name)) { |
| 163 |
if (this.argumentsList == null) { |
175 |
if (this.argumentsList == null) { |
| 164 |
this.argumentsList = new ArrayList<>(); |
176 |
this.argumentsList = new ArrayList<>(); |
|
Lines 183-193
Link Here
|
| 183 |
String key; |
195 |
String key; |
| 184 |
String typeName; |
196 |
String typeName; |
| 185 |
String kind; |
197 |
String kind; |
|
|
198 |
String message; |
| 199 |
boolean compatible; |
| 186 |
|
200 |
|
| 187 |
private static final String ADDED = "ADDED"; //$NON-NLS-1$ |
201 |
private static final String ADDED = "ADDED"; //$NON-NLS-1$ |
| 188 |
private static final String REMOVED = "REMOVED"; //$NON-NLS-1$ |
202 |
private static final String REMOVED = "REMOVED"; //$NON-NLS-1$ |
| 189 |
|
203 |
|
| 190 |
public Entry(int flags, int elementType, String key, String typeName, String[] arguments, String kind) { |
204 |
public Entry(int flags, int elementType, String key, String typeName, String[] arguments, String kind, String message, boolean compatible) { |
| 191 |
this.flags = flags; |
205 |
this.flags = flags; |
| 192 |
this.key = key.replace('/', '.'); |
206 |
this.key = key.replace('/', '.'); |
| 193 |
if (typeName != null) { |
207 |
if (typeName != null) { |
|
Lines 196-308
Link Here
|
| 196 |
this.arguments = arguments; |
210 |
this.arguments = arguments; |
| 197 |
this.kind = kind; |
211 |
this.kind = kind; |
| 198 |
this.elementType = elementType; |
212 |
this.elementType = elementType; |
|
|
213 |
this.message = message; |
| 214 |
this.compatible = compatible; |
| 199 |
} |
215 |
} |
| 200 |
|
216 |
|
| 201 |
public String getDisplayString() { |
217 |
public String getDisplayString() { |
| 202 |
StringBuffer buffer = new StringBuffer(); |
218 |
return this.message; |
| 203 |
if (this.typeName != null && this.typeName.length() != 0) { |
|
|
| 204 |
buffer.append(this.typeName); |
| 205 |
switch (this.flags) { |
| 206 |
case IDelta.API_METHOD_WITH_DEFAULT_VALUE: |
| 207 |
case IDelta.API_METHOD_WITHOUT_DEFAULT_VALUE: |
| 208 |
case IDelta.API_METHOD: |
| 209 |
case IDelta.METHOD: |
| 210 |
case IDelta.METHOD_WITH_DEFAULT_VALUE: |
| 211 |
case IDelta.METHOD_WITHOUT_DEFAULT_VALUE: |
| 212 |
int indexOf = this.key.indexOf('('); |
| 213 |
if (indexOf == -1) { |
| 214 |
return null; |
| 215 |
} |
| 216 |
int index = indexOf; |
| 217 |
String selector = key.substring(0, index); |
| 218 |
String descriptor = key.substring(index, key.length()); |
| 219 |
buffer.append('#'); |
| 220 |
buffer.append(Signature.toString(descriptor, selector, null, false, true)); |
| 221 |
break; |
| 222 |
case IDelta.API_CONSTRUCTOR: |
| 223 |
case IDelta.CONSTRUCTOR: |
| 224 |
indexOf = key.indexOf('('); |
| 225 |
if (indexOf == -1) { |
| 226 |
return null; |
| 227 |
} |
| 228 |
index = indexOf; |
| 229 |
selector = key.substring(0, index); |
| 230 |
descriptor = key.substring(index, key.length()); |
| 231 |
buffer.append('#'); |
| 232 |
buffer.append(Signature.toString(descriptor, selector, null, false, false)); |
| 233 |
break; |
| 234 |
case IDelta.FIELD: |
| 235 |
case IDelta.API_FIELD: |
| 236 |
case IDelta.ENUM_CONSTANT: |
| 237 |
case IDelta.API_ENUM_CONSTANT: |
| 238 |
buffer.append('#'); |
| 239 |
buffer.append(this.key); |
| 240 |
break; |
| 241 |
case IDelta.TYPE_MEMBER: |
| 242 |
case IDelta.API_TYPE: |
| 243 |
case IDelta.REEXPORTED_TYPE: |
| 244 |
case IDelta.REEXPORTED_API_TYPE: |
| 245 |
buffer.append('.'); |
| 246 |
buffer.append(this.key); |
| 247 |
break; |
| 248 |
case IDelta.DEPRECATION: |
| 249 |
switch (this.elementType) { |
| 250 |
case IDelta.ANNOTATION_ELEMENT_TYPE: |
| 251 |
case IDelta.INTERFACE_ELEMENT_TYPE: |
| 252 |
case IDelta.ENUM_ELEMENT_TYPE: |
| 253 |
case IDelta.CLASS_ELEMENT_TYPE: |
| 254 |
buffer.append('.'); |
| 255 |
buffer.append(this.key); |
| 256 |
break; |
| 257 |
case IDelta.CONSTRUCTOR_ELEMENT_TYPE: |
| 258 |
indexOf = key.indexOf('('); |
| 259 |
if (indexOf == -1) { |
| 260 |
return null; |
| 261 |
} |
| 262 |
index = indexOf; |
| 263 |
selector = key.substring(0, index); |
| 264 |
descriptor = key.substring(index, key.length()); |
| 265 |
buffer.append('#'); |
| 266 |
buffer.append(Signature.toString(descriptor, selector, null, false, false)); |
| 267 |
break; |
| 268 |
case IDelta.METHOD_ELEMENT_TYPE: |
| 269 |
indexOf = key.indexOf('('); |
| 270 |
if (indexOf == -1) { |
| 271 |
return null; |
| 272 |
} |
| 273 |
index = indexOf; |
| 274 |
selector = key.substring(0, index); |
| 275 |
descriptor = key.substring(index, key.length()); |
| 276 |
buffer.append('#'); |
| 277 |
buffer.append(Signature.toString(descriptor, selector, null, false, true)); |
| 278 |
break; |
| 279 |
case IDelta.FIELD_ELEMENT_TYPE: |
| 280 |
buffer.append('#'); |
| 281 |
buffer.append(this.key); |
| 282 |
break; |
| 283 |
default: |
| 284 |
break; |
| 285 |
} |
| 286 |
break; |
| 287 |
default: |
| 288 |
break; |
| 289 |
} |
| 290 |
} else { |
| 291 |
switch (this.flags) { |
| 292 |
case IDelta.MAJOR_VERSION: |
| 293 |
buffer.append(NLS.bind(Messages.deltaReportTask_entry_major_version, this.arguments)); |
| 294 |
break; |
| 295 |
case IDelta.MINOR_VERSION: |
| 296 |
buffer.append(NLS.bind(Messages.deltaReportTask_entry_minor_version, this.arguments)); |
| 297 |
break; |
| 298 |
case IDelta.API_BASELINE_ELEMENT_TYPE: |
| 299 |
buffer.append(this.key); |
| 300 |
break; |
| 301 |
default: |
| 302 |
break; |
| 303 |
} |
| 304 |
} |
| 305 |
return CommonUtilsTask.convertToHtml(String.valueOf(buffer)); |
| 306 |
} |
219 |
} |
| 307 |
|
220 |
|
| 308 |
public String getDisplayKind() { |
221 |
public String getDisplayKind() { |
|
Lines 312-317
Link Here
|
| 312 |
return Messages.RemovedElement; |
225 |
return Messages.RemovedElement; |
| 313 |
} |
226 |
} |
| 314 |
return Messages.ChangedElement; |
227 |
return Messages.ChangedElement; |
|
|
228 |
} |
| 229 |
|
| 230 |
public boolean getCompatible() { |
| 231 |
return this.compatible; |
| 315 |
} |
232 |
} |
| 316 |
} |
233 |
} |
| 317 |
|
234 |
|
|
Lines 393-399
Link Here
|
| 393 |
} |
310 |
} |
| 394 |
|
311 |
|
| 395 |
private void dumpEntry(StringBuffer buffer, Entry entry) { |
312 |
private void dumpEntry(StringBuffer buffer, Entry entry) { |
| 396 |
buffer.append(NLS.bind(Messages.deltaReportTask_entry, entry.getDisplayKind(), entry.getDisplayString())); |
313 |
if (entry.getCompatible()) { |
|
|
314 |
buffer.append(NLS.bind(Messages.deltaReportTask_entry, entry.getDisplayKind(), entry.getDisplayString())); |
| 315 |
} else { |
| 316 |
buffer.append(NLS.bind(Messages.deltaReportTask_entry_incompatible, entry.getDisplayKind(), entry.getDisplayString())); |
| 317 |
} |
| 397 |
} |
318 |
} |
| 398 |
|
319 |
|
| 399 |
private void dumpEntryForComponent(StringBuffer buffer, String componentID) { |
320 |
private void dumpEntryForComponent(StringBuffer buffer, String componentID) { |