| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2008, 2009 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | package org.eclipse.pde.api.tools.internal.problems; |
| 12 | |
| 13 | import org.eclipse.core.runtime.Path; |
| 14 | import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; |
| 15 | import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor; |
| 16 | import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem; |
| 17 | import org.eclipse.pde.api.tools.internal.util.Util; |
| 18 | |
| 19 | /** |
| 20 | * A description of an api problem |
| 21 | * |
| 22 | * @since 1.0.0 |
| 23 | */ |
| 24 | public class ApiProblem implements IApiProblem { |
| 25 | |
| 26 | /** |
| 27 | * Human readable message for the problem |
| 28 | * TODO should not be passed in by user, should be derived (lazily loaded) |
| 29 | */ |
| 30 | private String fMessage = null; |
| 31 | /** |
| 32 | * The resource path for this problem |
| 33 | */ |
| 34 | private String fResourcePath = null; |
| 35 | /** |
| 36 | * The qualified type name for this problem |
| 37 | */ |
| 38 | private String fTypeName = null; |
| 39 | /** |
| 40 | * The composite id of the problem. Contains the category, |
| 41 | * element kind, kind, and flags for a specific problem |
| 42 | */ |
| 43 | private int fId = 0; |
| 44 | /** |
| 45 | * The listing of extra argument ids for the problem |
| 46 | */ |
| 47 | private String[] fExtraArgumentIds = null; |
| 48 | /** |
| 49 | * The listing of corresponding arguments for the problem |
| 50 | */ |
| 51 | private Object[] fExtraArguments = null; |
| 52 | /** |
| 53 | * The listing of arguments used to fill localized messages |
| 54 | */ |
| 55 | private String[] fMessageArguments = null; |
| 56 | /** |
| 57 | * The line number the problem occurred on |
| 58 | */ |
| 59 | private int fLineNumber = -1; |
| 60 | /** |
| 61 | * The start of a character selection range |
| 62 | */ |
| 63 | private int fCharStart = -1; |
| 64 | /** |
| 65 | * The end of a character selection range |
| 66 | */ |
| 67 | private int fCharEnd = -1; |
| 68 | |
| 69 | /** |
| 70 | * Masks to get the original bits out of the id |
| 71 | */ |
| 72 | public static final int CATEGORY_MASK = 0xF0000000; |
| 73 | public static final int ELEMENT_KIND_MASK = 0x0F000000; |
| 74 | public static final int KIND_MASK = 0x00F00000; |
| 75 | public static final int FLAGS_MASK = 0x000FF000; |
| 76 | public static final int MESSAGE_MASK = 0x00000FFF; |
| 77 | |
| 78 | /** |
| 79 | * Constant representing the name of the 'compatibilityStatus' attribute on API problem |
| 80 | * for the compatibility category. |
| 81 | * Value is: <code>compatibilityStatus</code> |
| 82 | */ |
| 83 | public static final String COMPATIBILITY_STATUS = "compatibilityStatus"; //$NON-NLS-1$ |
| 84 | |
| 85 | /** |
| 86 | * Constructor |
| 87 | * @param resource the resource this problem occurs on / in |
| 88 | * @param typeName the qualified type name this problem occurs on / in |
| 89 | * @param messageargs arguments to be passed into a localized message for the problem |
| 90 | * @param argumentids the ids of arguments passed into the problem |
| 91 | * @param arguments the arguments that correspond to the listing of ids |
| 92 | * @param linenumber the line this problem occurred on |
| 93 | * @param charstart the char selection start position |
| 94 | * @param charend the char selection end position |
| 95 | * @param severity the severity level of the problem |
| 96 | * @param id the id of the problem |
| 97 | */ |
| 98 | public ApiProblem(String path, String typeName, String[] messageargs, String[] argumentids, Object[] arguments, int linenumber, int charstart, int charend, int id) { |
| 99 | this.fResourcePath = path; |
| 100 | this.fTypeName = typeName; |
| 101 | this.fId = id; |
| 102 | this.fExtraArgumentIds = argumentids; |
| 103 | this.fExtraArguments = arguments; |
| 104 | this.fLineNumber = linenumber; |
| 105 | this.fCharStart = charstart; |
| 106 | this.fCharEnd = charend; |
| 107 | this.fMessageArguments = messageargs; |
| 108 | } |
| 109 | |
| 110 | /* (non-Javadoc) |
| 111 | * @see org.eclipse.pde.api.tools.internal.provisional.IApiProblem#getId() |
| 112 | */ |
| 113 | public int getId() { |
| 114 | return fId; |
| 115 | } |
| 116 | |
| 117 | /* (non-Javadoc) |
| 118 | * @see org.eclipse.pde.api.tools.internal.provisional.IApiProblem#getCategory() |
| 119 | */ |
| 120 | public int getCategory() { |
| 121 | return (fId & CATEGORY_MASK); |
| 122 | } |
| 123 | |
| 124 | /* (non-Javadoc) |
| 125 | * @see org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem#getMessageid() |
| 126 | */ |
| 127 | public int getMessageid() { |
| 128 | return (fId & MESSAGE_MASK) >> OFFSET_MESSAGE; |
| 129 | } |
| 130 | |
| 131 | /* (non-Javadoc) |
| 132 | * @see org.eclipse.pde.api.tools.internal.provisional.IApiProblem#getFlags() |
| 133 | */ |
| 134 | public int getFlags() { |
| 135 | return (fId & FLAGS_MASK) >> OFFSET_FLAGS; |
| 136 | } |
| 137 | |
| 138 | /* (non-Javadoc) |
| 139 | * @see org.eclipse.pde.api.tools.internal.provisional.IApiProblem#getKind() |
| 140 | */ |
| 141 | public int getKind() { |
| 142 | return (fId & KIND_MASK) >> OFFSET_KINDS; |
| 143 | } |
| 144 | |
| 145 | /* (non-Javadoc) |
| 146 | * @see org.eclipse.pde.api.tools.internal.provisional.IApiProblem#getMessage() |
| 147 | */ |
| 148 | public String getMessage() { |
| 149 | if(fMessage == null) { |
| 150 | fMessage = ApiProblemFactory.getLocalizedMessage(this); |
| 151 | } |
| 152 | return fMessage; |
| 153 | } |
| 154 | |
| 155 | /* (non-Javadoc) |
| 156 | * @see org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem#getResourcePath() |
| 157 | */ |
| 158 | public String getResourcePath() { |
| 159 | return fResourcePath; |
| 160 | } |
| 161 | |
| 162 | /* (non-Javadoc) |
| 163 | * @see org.eclipse.pde.api.tools.internal.provisional.IApiProblem#getSeverity() |
| 164 | */ |
| 165 | public int getSeverity() { |
| 166 | if(ApiPlugin.isRunningInFramework()) { |
| 167 | return ApiPlugin.getDefault().getSeverityLevel(ApiProblemFactory.getProblemSeverityId(this), null); |
| 168 | } |
| 169 | return ApiPlugin.SEVERITY_WARNING; |
| 170 | } |
| 171 | |
| 172 | /* (non-Javadoc) |
| 173 | * @see org.eclipse.pde.api.tools.internal.provisional.IApiProblem#getElementKind() |
| 174 | */ |
| 175 | public int getElementKind() { |
| 176 | return (fId & ELEMENT_KIND_MASK) >> OFFSET_ELEMENT; |
| 177 | } |
| 178 | |
| 179 | /* (non-Javadoc) |
| 180 | * @see org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem#getLineNumber() |
| 181 | */ |
| 182 | public int getLineNumber() { |
| 183 | return fLineNumber; |
| 184 | } |
| 185 | |
| 186 | /* (non-Javadoc) |
| 187 | * @see org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem#getCharStart() |
| 188 | */ |
| 189 | public int getCharStart() { |
| 190 | return fCharStart; |
| 191 | } |
| 192 | |
| 193 | /* (non-Javadoc) |
| 194 | * @see org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem#getCharEnd() |
| 195 | */ |
| 196 | public int getCharEnd() { |
| 197 | return fCharEnd; |
| 198 | } |
| 199 | |
| 200 | /* (non-Javadoc) |
| 201 | * @see org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem#getExtraMarkerAttributeNames() |
| 202 | */ |
| 203 | public String[] getExtraMarkerAttributeIds() { |
| 204 | if(fExtraArguments == null || fExtraArgumentIds == null) { |
| 205 | return new String[0]; |
| 206 | } |
| 207 | if(fExtraArgumentIds.length != fExtraArguments.length) { |
| 208 | return new String[0]; |
| 209 | } |
| 210 | return fExtraArgumentIds; |
| 211 | } |
| 212 | |
| 213 | /* (non-Javadoc) |
| 214 | * @see org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem#getExtraMarkerAttributeValues() |
| 215 | */ |
| 216 | public Object[] getExtraMarkerAttributeValues() { |
| 217 | if(fExtraArguments == null || fExtraArgumentIds == null) { |
| 218 | return new String[0]; |
| 219 | } |
| 220 | if(fExtraArgumentIds.length != fExtraArguments.length) { |
| 221 | return new String[0]; |
| 222 | } |
| 223 | return fExtraArguments; |
| 224 | } |
| 225 | |
| 226 | /* (non-Javadoc) |
| 227 | * @see org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem#getMessageArguments() |
| 228 | */ |
| 229 | public String[] getMessageArguments() { |
| 230 | if(fMessageArguments == null) { |
| 231 | return new String[0]; |
| 232 | } |
| 233 | return fMessageArguments; |
| 234 | } |
| 235 | |
| 236 | public boolean equals(Object obj) { |
| 237 | if(obj instanceof IApiProblem) { |
| 238 | IApiProblem problem = (IApiProblem) obj; |
| 239 | if (problem.getId() == fId && argumentsEqual(problem.getMessageArguments())) { |
| 240 | String resourcePath = problem.getResourcePath(); |
| 241 | if (resourcePath == null) { |
| 242 | if (this.fResourcePath != null) { |
| 243 | return false; |
| 244 | } |
| 245 | } else if (this.fResourcePath == null) { |
| 246 | return false; |
| 247 | } else if (!new Path(resourcePath).equals(new Path(fResourcePath))) { |
| 248 | return false; |
| 249 | } |
| 250 | String typeName = problem.getTypeName(); |
| 251 | if (typeName == null) { |
| 252 | if (this.fTypeName != null) { |
| 253 | return false; |
| 254 | } |
| 255 | return true; |
| 256 | } else if (this.fTypeName == null) { |
| 257 | return false; |
| 258 | } |
| 259 | return typeName.equals(this.fTypeName); |
| 260 | } |
| 261 | return false; |
| 262 | } |
| 263 | return super.equals(obj); |
| 264 | } |
| 265 | /** |
| 266 | * Compares the complete list of message arguments |
| 267 | * @param arguments |
| 268 | * @return true if all of the arguments are equal, false otherwise |
| 269 | */ |
| 270 | private boolean argumentsEqual(String[] arguments) { |
| 271 | String[] currentArguments = getMessageArguments(); |
| 272 | if((currentArguments == null && arguments != null) || |
| 273 | (currentArguments != null && arguments == null)) { |
| 274 | return false; |
| 275 | } |
| 276 | boolean equal = true; |
| 277 | if(currentArguments.length != arguments.length) { |
| 278 | return false; |
| 279 | } |
| 280 | for(int i = 0; i < currentArguments.length; i++) { |
| 281 | equal &= currentArguments[i].equals(arguments[i]); |
| 282 | } |
| 283 | return equal; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Returns the deep hash code of the complete listing of message arguments |
| 288 | * @param arguments |
| 289 | * @return the hash code of the message arguments |
| 290 | */ |
| 291 | private int argumentsHashcode(String[] arguments) { |
| 292 | if(fMessageArguments == null) { |
| 293 | return 0; |
| 294 | } |
| 295 | int hashcode = 0; |
| 296 | for(int i = 0; i < fMessageArguments.length; i++) { |
| 297 | hashcode += fMessageArguments[i].hashCode(); |
| 298 | } |
| 299 | return hashcode; |
| 300 | } |
| 301 | |
| 302 | /* (non-Javadoc) |
| 303 | * @see java.lang.Object#toString() |
| 304 | */ |
| 305 | public String toString() { |
| 306 | StringBuffer buffer = new StringBuffer(); |
| 307 | buffer.append("Api problem: "); //$NON-NLS-1$ |
| 308 | buffer.append(fResourcePath != null ? fResourcePath : "no path").append("\n"); //$NON-NLS-1$//$NON-NLS-2$ |
| 309 | buffer.append("\tseverity: "); //$NON-NLS-1$ |
| 310 | buffer.append(Util.getSeverity(getSeverity())).append("\n"); //$NON-NLS-1$ |
| 311 | buffer.append("\tcategory: "); //$NON-NLS-1$ |
| 312 | buffer.append(ApiProblem.getProblemCategory(getCategory())).append("\n"); //$NON-NLS-1$ |
| 313 | buffer.append("\telement kind: "); //$NON-NLS-1$ |
| 314 | buffer.append(ApiProblem.getProblemElementKind(getCategory(), getElementKind())).append("\n"); //$NON-NLS-1$ |
| 315 | buffer.append("\tkind: "); //$NON-NLS-1$ |
| 316 | buffer.append(ApiProblem.getProblemKind(getCategory(), getKind())).append("\n"); //$NON-NLS-1$ |
| 317 | buffer.append("\tflags: "); //$NON-NLS-1$ |
| 318 | buffer.append(ApiProblem.getProblemFlagsName(getCategory(), getFlags())).append("\n"); //$NON-NLS-1$ |
| 319 | buffer.append("\tmessage id: "); //$NON-NLS-1$ |
| 320 | buffer.append(getMessageid()); |
| 321 | buffer.append("\n\tmessage:"); //$NON-NLS-1$ |
| 322 | buffer.append(getMessage()); |
| 323 | return buffer.toString(); |
| 324 | } |
| 325 | |
| 326 | /* (non-Javadoc) |
| 327 | * @see java.lang.Object#hashCode() |
| 328 | */ |
| 329 | public int hashCode() { |
| 330 | return getId() |
| 331 | + (fResourcePath != null ? fResourcePath.hashCode() : 0) |
| 332 | + argumentsHashcode(fMessageArguments) |
| 333 | + (fTypeName != null ? fTypeName.hashCode() : 0); |
| 334 | } |
| 335 | |
| 336 | public String getTypeName() { |
| 337 | return this.fTypeName; |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * Returns the string representation of an element descriptor type or <code>null</code> |
| 342 | * if the kind is unknown |
| 343 | * @param kind |
| 344 | * @return the string of the kind or <code>null</code> |
| 345 | */ |
| 346 | public static String getDescriptorKind(int kind) { |
| 347 | switch(kind) { |
| 348 | case IElementDescriptor.PACKAGE: { |
| 349 | return "PACKAGE"; //$NON-NLS-1$ |
| 350 | } |
| 351 | case IElementDescriptor.FIELD: { |
| 352 | return "FIELD"; //$NON-NLS-1$ |
| 353 | } |
| 354 | case IElementDescriptor.METHOD: { |
| 355 | return "METHOD"; //$NON-NLS-1$ |
| 356 | } |
| 357 | case IElementDescriptor.TYPE: { |
| 358 | return "REFERENCE_TYPE"; //$NON-NLS-1$ |
| 359 | } |
| 360 | case IElementDescriptor.RESOURCE: { |
| 361 | return "RESOURCE"; //$NON-NLS-1$ |
| 362 | } |
| 363 | } |
| 364 | return Util.UNKNOWN_ELEMENT_KIND; |
| 365 | } |
| 366 | |
| 367 | /** |
| 368 | * Returns the string representation of the kind of since tab |
| 369 | * api problem |
| 370 | * @param kind |
| 371 | * @return the string for the since tag api problem kind |
| 372 | */ |
| 373 | public static String getTagsProblemKindName(int kind) { |
| 374 | switch(kind) { |
| 375 | case IApiProblem.SINCE_TAG_INVALID: return "INVALID_SINCE_TAGS"; //$NON-NLS-1$ |
| 376 | case IApiProblem.SINCE_TAG_MALFORMED: return "MALFORMED_SINCE_TAGS"; //$NON-NLS-1$ |
| 377 | case IApiProblem.SINCE_TAG_MISSING: return "MISSING_SINCE_TAGS"; //$NON-NLS-1$ |
| 378 | } |
| 379 | return Util.UNKNOWN_KIND; |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * Returns the string representation of the kind of usage problem for |
| 384 | * an {@link IApiProblem} kind |
| 385 | * @param kind |
| 386 | * @return the string for the usage api problem kind |
| 387 | */ |
| 388 | public static String getUsageProblemKindName(int kind) { |
| 389 | switch(kind) { |
| 390 | case IApiProblem.ILLEGAL_EXTEND: return "ILLEGAL_EXTEND"; //$NON-NLS-1$ |
| 391 | case IApiProblem.ILLEGAL_IMPLEMENT: return "ILLEGAL_IMPLEMENT"; //$NON-NLS-1$ |
| 392 | case IApiProblem.ILLEGAL_INSTANTIATE: return "ILLEGAL_INSTANTIATE"; //$NON-NLS-1$ |
| 393 | case IApiProblem.ILLEGAL_REFERENCE: return "ILLEGAL_REFERENCE"; //$NON-NLS-1$ |
| 394 | case IApiProblem.ILLEGAL_OVERRIDE: return "ILLEGAL_OVERRIDE"; //$NON-NLS-1$ |
| 395 | case IApiProblem.API_LEAK: return "API_LEAK"; //$NON-NLS-1$ |
| 396 | case IApiProblem.UNSUPPORTED_TAG_USE: return "UNSUPPORTED_TAG_USE"; //$NON-NLS-1$ |
| 397 | case IApiProblem.INVALID_REFERENCE_IN_SYSTEM_LIBRARIES: return "INVALID_REFERENCE_IN_SYSTEM_LIBRARIES"; //$NON-NLS-1$ |
| 398 | case IApiProblem.UNUSED_PROBLEM_FILTERS: return "UNUSED_PROBLEM_FILTERS"; //$NON-NLS-1$ |
| 399 | } |
| 400 | return Util.UNKNOWN_KIND; |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Returns the string representation of the version problem kind. |
| 405 | * @param kind |
| 406 | * @return the string of the version API problem kind |
| 407 | */ |
| 408 | public static String getVersionProblemKindName(int kind) { |
| 409 | switch(kind) { |
| 410 | case IApiProblem.MINOR_VERSION_CHANGE: return "MINOR_VERSION_CHANGE"; //$NON-NLS-1$ |
| 411 | case IApiProblem.MAJOR_VERSION_CHANGE: return "MAJOR_VERSION_CHANGE"; //$NON-NLS-1$ |
| 412 | case IApiProblem.MAJOR_VERSION_CHANGE_NO_BREAKAGE: return "MAJOR_VERSION_CHANGE_NO_BREAKAGE"; //$NON-NLS-1$ |
| 413 | case IApiProblem.MINOR_VERSION_CHANGE_NO_NEW_API: return "MINOR_VERSION_CHANGE_NO_NEW_API"; //$NON-NLS-1$ |
| 414 | case IApiProblem.REEXPORTED_MAJOR_VERSION_CHANGE: return "REEXPORTED_MAJOR_VERSION_CHANGE"; //$NON-NLS-1$ |
| 415 | case IApiProblem.REEXPORTED_MINOR_VERSION_CHANGE: return "REEXPORTED_MINOR_VERSION_CHANGE"; //$NON-NLS-1$ |
| 416 | } |
| 417 | return Util.UNKNOWN_KIND; |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Returns the string representation of the API profile problem kind |
| 422 | * @param kind |
| 423 | * @return the string of the API profile problem kind |
| 424 | */ |
| 425 | public static String getApiComponentResolutionProblemKindName(int kind) { |
| 426 | switch(kind) { |
| 427 | case IApiProblem.API_COMPONENT_RESOLUTION: { |
| 428 | return "API_COMPONENT_RESOLUTION"; //$NON-NLS-1$ |
| 429 | } |
| 430 | } |
| 431 | return Util.UNKNOWN_KIND; |
| 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Returns the string representation of the API profile problem kind |
| 436 | * @param kind |
| 437 | * @return the string of the API profile problem kind |
| 438 | */ |
| 439 | public static String getApiBaselineProblemKindName(int kind) { |
| 440 | switch(kind) { |
| 441 | case IApiProblem.API_BASELINE_MISSING: return "API_BASELINE_MISSING"; //$NON-NLS-1$ |
| 442 | } |
| 443 | return Util.UNKNOWN_KIND; |
| 444 | } |
| 445 | |
| 446 | /** |
| 447 | * Returns the string representation of the kind of an |
| 448 | * {@link IApiProblem}, given its category |
| 449 | * @param category |
| 450 | * @param kind |
| 451 | * @return the string of the {@link IApiProblem} kind |
| 452 | */ |
| 453 | public static String getProblemKind(int category, int kind) { |
| 454 | switch(category) { |
| 455 | case IApiProblem.CATEGORY_COMPATIBILITY: { |
| 456 | return Util.getDeltaKindName(kind); |
| 457 | } |
| 458 | case IApiProblem.CATEGORY_SINCETAGS: { |
| 459 | return ApiProblem.getTagsProblemKindName(kind); |
| 460 | } |
| 461 | case IApiProblem.CATEGORY_USAGE: { |
| 462 | return ApiProblem.getUsageProblemKindName(kind); |
| 463 | } |
| 464 | case IApiProblem.CATEGORY_VERSION: { |
| 465 | return ApiProblem.getVersionProblemKindName(kind); |
| 466 | } |
| 467 | case IApiProblem.CATEGORY_API_BASELINE: { |
| 468 | return ApiProblem.getApiBaselineProblemKindName(kind); |
| 469 | } |
| 470 | case IApiProblem.CATEGORY_API_COMPONENT_RESOLUTION: { |
| 471 | return ApiProblem.getApiComponentResolutionProblemKindName(kind); |
| 472 | } |
| 473 | } |
| 474 | return Util.UNKNOWN_KIND; |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * Return the string representation of the flags for a problem |
| 479 | * @param category |
| 480 | * @param flags |
| 481 | * @return the string for the problem flags |
| 482 | */ |
| 483 | public static String getProblemFlagsName(int category, int flags) { |
| 484 | switch(category) { |
| 485 | case IApiProblem.CATEGORY_COMPATIBILITY: { |
| 486 | return Util.getDeltaFlagsName(flags); |
| 487 | } |
| 488 | case IApiProblem.CATEGORY_SINCETAGS: |
| 489 | case IApiProblem.CATEGORY_USAGE: |
| 490 | case IApiProblem.CATEGORY_VERSION: |
| 491 | case IApiProblem.CATEGORY_API_BASELINE: |
| 492 | case IApiProblem.CATEGORY_API_COMPONENT_RESOLUTION: { |
| 493 | switch(flags) { |
| 494 | case IApiProblem.LEAK_EXTENDS: { |
| 495 | return "LEAK_EXTENDS"; //$NON-NLS-1$ |
| 496 | } |
| 497 | case IApiProblem.LEAK_FIELD: { |
| 498 | return "LEAK_FIELD"; //$NON-NLS-1$ |
| 499 | } |
| 500 | case IApiProblem.LEAK_IMPLEMENTS: { |
| 501 | return "LEAK_IMPLEMENTS"; //$NON-NLS-1$ |
| 502 | } |
| 503 | case IApiProblem.LEAK_METHOD_PARAMETER: { |
| 504 | return "LEAK_METHOD_PARAMETER"; //$NON-NLS-1$ |
| 505 | } |
| 506 | case IApiProblem.LEAK_CONSTRUCTOR_PARAMETER: { |
| 507 | return "LEAK_CONSTRUCTOR_PARAMETER"; //$NON-NLS-1$ |
| 508 | } |
| 509 | case IApiProblem.LEAK_RETURN_TYPE: { |
| 510 | return "LEAK_RETURN_TYPE"; //$NON-NLS-1$ |
| 511 | } |
| 512 | case IApiProblem.CONSTRUCTOR_METHOD: { |
| 513 | return "CONSTRUCTOR_METHOD"; //$NON-NLS-1$ |
| 514 | } |
| 515 | case IApiProblem.NO_FLAGS: { |
| 516 | return "NO_FLAGS"; //$NON-NLS-1$ |
| 517 | } |
| 518 | case IApiProblem.INDIRECT_REFERENCE: { |
| 519 | return "INDIRECT_REFERENCE"; //$NON-NLS-1$ |
| 520 | } |
| 521 | case IApiProblem.METHOD: { |
| 522 | return "METHOD"; //$NON-NLS-1$ |
| 523 | } |
| 524 | case IApiProblem.FIELD: { |
| 525 | return "FIELD"; //$NON-NLS-1$ |
| 526 | } |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | return Util.UNKNOWN_FLAGS; |
| 531 | } |
| 532 | |
| 533 | /** |
| 534 | * Returns the string representation of the element kind of an |
| 535 | * {@link IApiProblem}, given its category |
| 536 | * @param category |
| 537 | * @param kind |
| 538 | * @return the string of the {@link IApiProblem} element kind |
| 539 | */ |
| 540 | public static String getProblemElementKind(int category, int kind) { |
| 541 | switch(category) { |
| 542 | case IApiProblem.CATEGORY_COMPATIBILITY: |
| 543 | case IApiProblem.CATEGORY_SINCETAGS: { |
| 544 | return Util.getDeltaElementType(kind); |
| 545 | } |
| 546 | case IApiProblem.CATEGORY_USAGE: |
| 547 | case IApiProblem.CATEGORY_VERSION: |
| 548 | case IApiProblem.CATEGORY_API_BASELINE: |
| 549 | case IApiProblem.CATEGORY_API_COMPONENT_RESOLUTION: { |
| 550 | return ApiProblem.getDescriptorKind(kind); |
| 551 | } |
| 552 | } |
| 553 | return Util.UNKNOWN_KIND; |
| 554 | } |
| 555 | |
| 556 | /** |
| 557 | * Returns a string representation of the category of an api problem |
| 558 | * @param category |
| 559 | * @return the string of the api problem category |
| 560 | */ |
| 561 | public static String getProblemCategory(int category) { |
| 562 | switch(category) { |
| 563 | case IApiProblem.CATEGORY_COMPATIBILITY : |
| 564 | return "COMPATIBILITY"; //$NON-NLS-1$ |
| 565 | case IApiProblem.CATEGORY_SINCETAGS : |
| 566 | return "SINCETAGS"; //$NON-NLS-1$ |
| 567 | case IApiProblem.CATEGORY_USAGE : |
| 568 | return "USAGE"; //$NON-NLS-1$ |
| 569 | case IApiProblem.CATEGORY_VERSION : |
| 570 | return "VERSION"; //$NON-NLS-1$ |
| 571 | case IApiProblem.CATEGORY_API_BASELINE : |
| 572 | return "API_BASELINE"; //$NON-NLS-1$ |
| 573 | case IApiProblem.CATEGORY_API_COMPONENT_RESOLUTION : |
| 574 | return "API_COMPONENT_RESOLUTION"; //$NON-NLS-1$ |
| 575 | default : |
| 576 | return "UNKNOWN_CATEGORY"; //$NON-NLS-1$ |
| 577 | } |
| 578 | } |
| 579 | } |