1 11 package org.eclipse.pde.internal.core.builders; 12 13 import java.io.File ; 14 import java.util.ArrayList ; 15 import java.util.HashSet ; 16 import java.util.Iterator ; 17 import java.util.StringTokenizer ; 18 19 import org.eclipse.core.resources.IFile; 20 import org.eclipse.core.resources.IResource; 21 import org.eclipse.core.runtime.CoreException; 22 import org.eclipse.core.runtime.IPath; 23 import org.eclipse.core.runtime.IProgressMonitor; 24 import org.eclipse.core.runtime.Path; 25 import org.eclipse.jdt.core.IJavaProject; 26 import org.eclipse.jdt.core.JavaCore; 27 import org.eclipse.osgi.util.NLS; 28 import org.eclipse.pde.core.build.IBuild; 29 import org.eclipse.pde.core.plugin.IPluginExtensionPoint; 30 import org.eclipse.pde.core.plugin.IPluginModelBase; 31 import org.eclipse.pde.core.plugin.PluginRegistry; 32 import org.eclipse.pde.core.plugin.TargetPlatform; 33 import org.eclipse.pde.internal.core.AbstractNLModel; 34 import org.eclipse.pde.internal.core.ClasspathUtilCore; 35 import org.eclipse.pde.internal.core.NLResourceHelper; 36 import org.eclipse.pde.internal.core.PDECore; 37 import org.eclipse.pde.internal.core.PDECoreMessages; 38 import org.eclipse.pde.internal.core.PDEStateHelper; 39 import org.eclipse.pde.internal.core.ischema.IMetaAttribute; 40 import org.eclipse.pde.internal.core.ischema.ISchema; 41 import org.eclipse.pde.internal.core.ischema.ISchemaAttribute; 42 import org.eclipse.pde.internal.core.ischema.ISchemaComplexType; 43 import org.eclipse.pde.internal.core.ischema.ISchemaCompositor; 44 import org.eclipse.pde.internal.core.ischema.ISchemaElement; 45 import org.eclipse.pde.internal.core.ischema.ISchemaEnumeration; 46 import org.eclipse.pde.internal.core.ischema.ISchemaObject; 47 import org.eclipse.pde.internal.core.ischema.ISchemaObjectReference; 48 import org.eclipse.pde.internal.core.ischema.ISchemaRestriction; 49 import org.eclipse.pde.internal.core.ischema.ISchemaRootElement; 50 import org.eclipse.pde.internal.core.ischema.ISchemaSimpleType; 51 import org.eclipse.pde.internal.core.ischema.ISchemaType; 52 import org.eclipse.pde.internal.core.schema.SchemaRegistry; 53 import org.eclipse.pde.internal.core.util.CoreUtility; 54 import org.eclipse.pde.internal.core.util.IdUtil; 55 import org.eclipse.pde.internal.core.util.PDEJavaHelper; 56 import org.w3c.dom.Attr ; 57 import org.w3c.dom.Element ; 58 import org.w3c.dom.NamedNodeMap ; 59 import org.w3c.dom.Node ; 60 import org.w3c.dom.NodeList ; 61 import org.xml.sax.SAXException ; 62 63 public class ExtensionsErrorReporter extends ManifestErrorReporter { 64 65 private IPluginModelBase fModel; 66 private IBuild fBuildModel; 67 68 public ExtensionsErrorReporter(IFile file) { 69 super(file); 70 fModel = PluginRegistry.findModel(file.getProject()); 71 try { 72 if (fModel != null && fModel.getUnderlyingResource() != null) 73 fBuildModel = ClasspathUtilCore.getBuild(fModel); 74 } catch (CoreException e) { 75 } 76 } 77 78 81 public void characters(char[] characters, int start, int length) 82 throws SAXException { 83 } 84 85 public void validateContent(IProgressMonitor monitor) { 86 Element element = getDocumentRoot(); 87 if (element == null) 88 return; 89 String elementName = element.getNodeName(); 90 if (!"plugin".equals(elementName) && !"fragment".equals(elementName)) { reportIllegalElement(element, CompilerFlags.ERROR); 92 } else { 93 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_DEPRECATED); 94 if (severity != CompilerFlags.IGNORE) { 95 NamedNodeMap attrs = element.getAttributes(); 96 for (int i = 0; i < attrs.getLength(); i++) { 97 reportUnusedAttribute(element, attrs.item(i).getNodeName(), severity); 98 } 99 } 100 101 NodeList children = element.getChildNodes(); 102 for (int i = 0; i < children.getLength(); i++) { 103 if (monitor.isCanceled()) 104 break; 105 Element child = (Element)children.item(i); 106 String name = child.getNodeName(); 107 if (name.equals("extension")) { validateExtension(child); 109 } else if (name.equals("extension-point")) { validateExtensionPoint(child); 111 } else { 112 if (!name.equals("runtime") && !name.equals("requires")) { severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); 114 if (severity != CompilerFlags.IGNORE) 115 reportIllegalElement(child, severity); 116 } else { 117 severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_DEPRECATED); 118 if (severity != CompilerFlags.IGNORE) 119 reportUnusedElement(child, severity); 120 } 121 } 122 } 123 } 124 } 125 126 protected void validateExtension(Element element) { 127 if (!assertAttributeDefined(element, "point", CompilerFlags.ERROR)) return; 129 String pointID = element.getAttribute("point"); IPluginExtensionPoint point = PDEStateHelper.findExtensionPoint(pointID); 131 if (point == null) { 132 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNRESOLVED_EX_POINTS); 133 if (severity != CompilerFlags.IGNORE) { 134 report(NLS.bind(PDECoreMessages.Builders_Manifest_ex_point, pointID), 135 getLine(element, "point"), severity, PDEMarkerFactory.CAT_OTHER); } 137 } else { 138 SchemaRegistry registry = PDECore.getDefault().getSchemaRegistry(); 139 ISchema schema = registry.getSchema(pointID); 140 if (schema != null) { 141 validateElement(element, schema, true); 142 } 143 } 144 } 145 146 151 private void reportMaxOccurenceViolation(ElementOccurrenceResult result, 152 int severity) { 153 Element childElement = result.getElement(); 154 String allowedOccurrences = 155 new Integer (result.getAllowedOccurrences()).toString(); 156 String message = NLS.bind( 157 PDECoreMessages.ExtensionsErrorReporter_maxOccurrence, 158 new String [] { allowedOccurrences, childElement.getNodeName() }); 159 report(message, getLine(childElement), severity, 160 PDEMarkerFactory.P_ILLEGAL_XML_NODE, childElement, null, 161 PDEMarkerFactory.CAT_FATAL); 162 } 163 164 169 private void reportMinOccurenceViolation(Element parentElement, 170 ElementOccurrenceResult result, int severity) { 171 172 ISchemaElement childElement = result.getSchemaElement(); 173 String allowedOccurrences = 174 new Integer (result.getAllowedOccurrences()).toString(); 175 String message = NLS.bind( 176 PDECoreMessages.ExtensionsErrorReporter_minOccurrence, 177 new String [] { allowedOccurrences, childElement.getName()}); 178 report(message, getLine(parentElement), severity, 179 PDEMarkerFactory.CAT_FATAL); 180 } 181 182 protected void validateElement(Element element, ISchema schema, 183 boolean isTopLevel) { 184 String elementName = element.getNodeName(); 185 ISchemaElement schemaElement = schema.findElement(elementName); 186 187 if ((schemaElement != null) && 189 (schemaElement.getType() instanceof ISchemaComplexType)) { 190 validateMaxElementMult(element, schemaElement); 191 validateMinElementMult(element, schemaElement); 192 } 193 194 ISchemaElement parentSchema = null; 195 if (!"extension".equals(elementName)) { Node parent = element.getParentNode(); 197 parentSchema = schema.findElement(parent.getNodeName()); 198 } else if (isTopLevel == false) { 199 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); 206 reportIllegalElement(element, severity); 207 return; 208 } 209 210 if (parentSchema != null) { 211 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); 212 if (severity != CompilerFlags.IGNORE) { 213 HashSet allowedElements = new HashSet (); 214 computeAllowedElements(parentSchema.getType(), allowedElements); 215 if (!allowedElements.contains(elementName)) { 216 reportIllegalElement(element, severity); 217 return; 218 } 219 } 220 221 } 222 if (schemaElement == null && parentSchema != null) { 223 ISchemaAttribute attr = parentSchema.getAttribute(elementName); 224 if (attr != null && attr.getKind() == IMetaAttribute.JAVA) { 225 if (attr.isDeprecated()) 226 reportDeprecatedAttribute(element, element.getAttributeNode("class")); validateJavaAttribute(element, element.getAttributeNode("class")); } 229 } else { 230 if (schemaElement != null) { 231 validateRequiredExtensionAttributes(element, schemaElement); 232 validateExistingExtensionAttributes(element, element.getAttributes(), schemaElement); 233 if (schemaElement.isDeprecated()) { 234 if (schemaElement instanceof ISchemaRootElement) 235 reportDeprecatedRootElement(element, 236 ((ISchemaRootElement)schemaElement).getDeprecatedSuggestion()); 237 else 238 reportDeprecatedElement(element); 239 } 240 if (schemaElement.hasTranslatableContent()) 241 validateTranslatableElementContent(element); 242 } 243 NodeList children = element.getChildNodes(); 244 for (int i = 0; i < children.getLength(); i++) { 245 validateElement((Element)children.item(i), schema, false); 246 } 247 } 248 } 249 250 254 private void validateMinElementMult(Element element, 255 ISchemaElement schemaElement) { 256 int minSeverity = CompilerFlags.getFlag(fProject, 258 CompilerFlags.P_UNKNOWN_ELEMENT); 259 if (minSeverity != CompilerFlags.IGNORE) { 260 HashSet minElementSet = ElementOccurenceChecker 261 .findMinOccurenceViolations(schemaElement, element); 262 Iterator minIterator = minElementSet.iterator(); 263 264 while (minIterator.hasNext()) { 265 reportMinOccurenceViolation(element, 266 (ElementOccurrenceResult) minIterator.next(), minSeverity); 267 } 268 } 269 } 270 271 275 private void validateMaxElementMult(Element element, 276 ISchemaElement schemaElement) { 277 int maxSeverity = CompilerFlags.getFlag(fProject, 279 CompilerFlags.P_UNKNOWN_ELEMENT); 280 if (maxSeverity != CompilerFlags.IGNORE) { 281 HashSet maxElementSet = ElementOccurenceChecker 282 .findMaxOccurenceViolations(schemaElement, element); 283 Iterator maxIterator = maxElementSet.iterator(); 284 while (maxIterator.hasNext()) { 285 reportMaxOccurenceViolation( 286 (ElementOccurrenceResult) maxIterator.next(), 287 maxSeverity); 288 } 289 } 290 } 291 292 private void computeAllowedElements(ISchemaType type, HashSet elementSet) { 293 if (type instanceof ISchemaComplexType) { 294 ISchemaComplexType complexType = (ISchemaComplexType) type; 295 ISchemaCompositor compositor = complexType.getCompositor(); 296 if (compositor != null) 297 computeAllowedElements(compositor, elementSet); 298 299 ISchemaAttribute[] attrs = complexType.getAttributes(); 300 for (int i = 0; i < attrs.length; i++) { 301 if (attrs[i].getKind() == IMetaAttribute.JAVA) 302 elementSet.add(attrs[i].getName()); 303 } 304 } 305 } 306 307 private void computeAllowedElements(ISchemaCompositor compositor, 308 HashSet elementSet) { 309 ISchemaObject[] children = compositor.getChildren(); 310 for (int i = 0; i < children.length; i++) { 311 ISchemaObject child = children[i]; 312 if (child instanceof ISchemaObjectReference) { 313 ISchemaObjectReference ref = (ISchemaObjectReference) child; 314 ISchemaElement refElement = (ISchemaElement) ref 315 .getReferencedObject(); 316 if (refElement != null) 317 elementSet.add(refElement.getName()); 318 } else if (child instanceof ISchemaCompositor) { 319 computeAllowedElements((ISchemaCompositor) child, elementSet); 320 } 321 } 322 } 323 324 325 326 private void validateRequiredExtensionAttributes(Element element, ISchemaElement schemaElement) { 327 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_NO_REQUIRED_ATT); 328 if (severity == CompilerFlags.IGNORE) 329 return; 330 331 ISchemaAttribute[] attInfos = schemaElement.getAttributes(); 332 for (int i = 0; i < attInfos.length; i++) { 333 ISchemaAttribute attInfo = attInfos[i]; 334 if (attInfo.getUse() == ISchemaAttribute.REQUIRED) { 335 boolean found = element.getAttributeNode(attInfo.getName()) != null; 336 if (!found && attInfo.getKind() == IMetaAttribute.JAVA) { 337 NodeList children = element.getChildNodes(); 338 for (int j = 0; j < children.getLength(); j++) { 339 if (attInfo.getName().equals(children.item(j).getNodeName())) { 340 found = true; 341 break; 342 } 343 } 344 } 345 if (!found) { 346 reportMissingRequiredAttribute(element, attInfo.getName(), severity); 347 } 348 } 349 } 350 } 351 352 private void validateExistingExtensionAttributes(Element element, NamedNodeMap attrs, 353 ISchemaElement schemaElement) { 354 for (int i = 0; i < attrs.getLength(); i++) { 355 Attr attr = (Attr )attrs.item(i); 356 ISchemaAttribute attInfo = schemaElement.getAttribute(attr.getName()); 357 if (attInfo == null) { 358 HashSet allowedElements = new HashSet (); 359 computeAllowedElements(schemaElement.getType(), allowedElements); 360 if (allowedElements.contains(attr.getName())) { 361 validateJavaAttribute(element, attr); 362 } else { 363 int flag = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ATTRIBUTE); 364 if (flag != CompilerFlags.IGNORE) 365 reportUnknownAttribute(element, attr.getName(), flag); 366 } 367 } else { 368 validateExtensionAttribute(element, attr, attInfo); 369 } 370 } 371 } 372 373 private void validateExtensionAttribute(Element element, Attr attr, ISchemaAttribute attInfo) { 374 ISchemaSimpleType type = attInfo.getType(); 375 ISchemaRestriction restriction = type.getRestriction(); 376 if (restriction != null) { 377 validateRestrictionAttribute(element, attr, restriction); 378 } 379 380 int kind = attInfo.getKind(); 381 if (kind == IMetaAttribute.JAVA) { 382 validateJavaAttribute(element, attr); 383 } else if (kind == IMetaAttribute.RESOURCE) { 384 validateResourceAttribute(element, attr); 385 } else if (type.getName().equals("boolean")) { validateBoolean(element, attr); 387 } 388 389 validateTranslatableString(element, attr, attInfo.isTranslatable()); 390 391 if (attInfo.isDeprecated()) { 392 reportDeprecatedAttribute(element, attr); 393 } 394 } 395 396 protected void validateExtensionPoint(Element element) { 397 if (assertAttributeDefined(element, "id", CompilerFlags.ERROR)) { Attr idAttr = element.getAttributeNode("id"); double schemaVersion = getSchemaVersion(); 400 String message = null; 401 if (schemaVersion < 3.2 && !IdUtil.isValidSimpleID(idAttr.getValue())) 402 message = NLS.bind(PDECoreMessages.Builders_Manifest_simpleID, idAttr.getValue()); 403 else if (schemaVersion >= 3.2) { 404 if (!IdUtil.isValidCompositeID(idAttr.getValue())) { 405 message = NLS.bind(PDECoreMessages.Builders_Manifest_compositeID, idAttr.getValue()); 406 } 407 } 408 409 if (message != null) 410 report(message, getLine(element, idAttr.getName()), CompilerFlags.WARNING, PDEMarkerFactory.CAT_OTHER); 411 } 412 413 assertAttributeDefined(element, "name", CompilerFlags.ERROR); 415 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ATTRIBUTE); 416 NamedNodeMap attrs = element.getAttributes(); 417 for (int i = 0; i < attrs.getLength(); i++) { 418 Attr attr = (Attr )attrs.item(i); 419 String name = attr.getName(); 420 if ("name".equals(name)) { validateTranslatableString(element, attr, true); 422 } else if (!"id".equals(name) && !"schema".equals(name) && severity != CompilerFlags.IGNORE) { reportUnknownAttribute(element, name, severity); 424 } 425 } 426 427 severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT); 428 if (severity != CompilerFlags.IGNORE) { 429 NodeList children = element.getChildNodes(); 430 for (int i = 0; i < children.getLength(); i++) 431 reportIllegalElement((Element)children.item(i), severity); 432 } 433 434 Attr attr = element.getAttributeNode(IPluginExtensionPoint.P_SCHEMA); 436 if (attr != null) { 438 String schemaValue = attr.getValue(); 439 IResource res = getFile().getProject().findMember(schemaValue); 440 String errorMessage = null; 441 if (!(res instanceof IFile && 443 (res.getName().endsWith(".exsd") || res.getName().endsWith(".mxsd")))) errorMessage = PDECoreMessages.ExtensionsErrorReporter_InvalidSchema; 446 if (errorMessage != null) { 448 severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_RESOURCE); 449 if (severity != CompilerFlags.IGNORE) 450 report(NLS.bind(errorMessage, schemaValue), getLine(element), severity, 451 PDEMarkerFactory.CAT_OTHER); 452 } 453 } 454 } 455 456 protected void validateTranslatableString(Element element, Attr attr, boolean shouldTranslate) { 457 if (!shouldTranslate) 458 return; 459 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_NOT_EXTERNALIZED); 460 if (severity == CompilerFlags.IGNORE) 461 return; 462 String value = attr.getValue(); 463 if (!value.startsWith("%")) { report(NLS.bind(PDECoreMessages.Builders_Manifest_non_ext_attribute, attr.getName()), 465 getLine(element, attr.getName()), 466 severity, 467 PDEMarkerFactory.P_UNTRANSLATED_NODE, 468 element, attr.getName(), 469 PDEMarkerFactory.CAT_NLS); 470 } else if (fModel instanceof AbstractNLModel) { 471 NLResourceHelper helper = ((AbstractNLModel)fModel).getNLResourceHelper(); 472 if (helper == null || !helper.resourceExists(value)) { 473 report(NLS.bind(PDECoreMessages.Builders_Manifest_key_not_found, value.substring(1)), getLine(element, attr.getName()), severity, 474 PDEMarkerFactory.CAT_NLS); 475 } 476 } 477 } 478 479 protected void validateTranslatableElementContent(Element element) { 480 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_NOT_EXTERNALIZED); 481 if (severity == CompilerFlags.IGNORE) 482 return; 483 String value = getTextContent(element); 484 if (value == null) 485 return; 486 if (!value.startsWith("%")) { report(NLS.bind(PDECoreMessages.Builders_Manifest_non_ext_element, element.getNodeName()), 488 getLine(element), 489 severity, 490 PDEMarkerFactory.P_UNTRANSLATED_NODE, 491 element, null, PDEMarkerFactory.CAT_NLS); 492 } else if (fModel instanceof AbstractNLModel) { 493 NLResourceHelper helper = ((AbstractNLModel)fModel).getNLResourceHelper(); 494 if (helper == null || !helper.resourceExists(value)) { 495 report(NLS.bind(PDECoreMessages.Builders_Manifest_key_not_found, value.substring(1)), getLine(element), severity, PDEMarkerFactory.CAT_NLS); 496 } 497 } 498 } 499 500 protected void validateResourceAttribute(Element element, Attr attr) { 501 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_RESOURCE); 502 if (severity != CompilerFlags.IGNORE && !resourceExists(attr.getValue())) { 503 report(NLS.bind(PDECoreMessages.Builders_Manifest_resource, (new String [] { attr.getValue(), attr.getName() })), 504 getLine(element, 505 attr.getName()), 506 severity, 507 PDEMarkerFactory.CAT_OTHER); 508 } 509 } 510 511 private boolean resourceExists(String location) { 512 String bundleJar=null; 513 IPath path = new Path(location); 514 if ("platform:".equals(path.getDevice()) && path.segmentCount() > 2) { if ("plugin".equals(path.segment(0))) { String id = path.segment(1); 517 IPluginModelBase model = PluginRegistry.findModel(id); 518 if (model != null && model.isEnabled()) { 519 path = path.setDevice(null).removeFirstSegments(2); 520 String bundleLocation = model.getInstallLocation(); 521 if(bundleLocation.endsWith(".jar")){ bundleJar=bundleLocation; 523 } else { 524 path = new Path(model.getInstallLocation()).append(path); 525 } 526 location = path.toString(); 527 } 528 } 529 } else if (path.getDevice()==null && path.segmentCount() > 3 && "platform:".equals(path.segment(0))){ if ("plugin".equals(path.segment(1))) { String id = path.segment(2); 532 IPluginModelBase model = PluginRegistry.findModel(id); 533 if (model != null && model.isEnabled()) { 534 path = path.removeFirstSegments(3); 535 String bundleLocation = model.getInstallLocation(); 536 if(bundleLocation.endsWith(".jar")){ bundleJar=bundleLocation; 538 } else { 539 path = new Path(model.getInstallLocation()).append(path); 540 } 541 location = path.toString(); 542 } 543 } 544 } 545 546 ArrayList paths = new ArrayList (); 547 if (location.indexOf("$nl$") != -1) { StringTokenizer tokenizer = new StringTokenizer (TargetPlatform.getNL(), "_"); String language = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null; 550 String country = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null; 551 if (language != null && country != null) 552 paths.add(location 553 .replaceAll( 554 "\\$nl\\$", "nl" + IPath.SEPARATOR + language + IPath.SEPARATOR + country)); if (language != null) 556 paths.add(location.replaceAll( 557 "\\$nl\\$", "nl" + IPath.SEPARATOR + language)); paths.add(location.replaceAll("\\$nl\\$", "")); } else { 560 paths.add(location); 561 } 562 563 for (int i = 0; i < paths.size(); i++) { 564 if (bundleJar == null) { 565 IPath currPath = new Path(paths.get(i).toString()); 566 if (currPath.isAbsolute() && currPath.toFile().exists()) 567 return true; 568 if (fFile.getProject().findMember(currPath) != null) 569 return true; 570 if (fBuildModel != null && fBuildModel.getEntry("source." + paths.get(i)) != null) return true; 572 } else { 573 if (CoreUtility.jarContainsResource(new File (bundleJar), paths.get(i).toString(), false)) 574 return true; 575 } 576 } 577 578 return false; 579 } 580 581 protected void validateJavaAttribute(Element element, Attr attr) { 582 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_CLASS); 583 if (severity == CompilerFlags.IGNORE) 584 return; 585 586 String value = attr.getValue(); 587 IJavaProject javaProject = JavaCore.create(fFile.getProject()); 588 589 int index = value.indexOf(":"); if (index != -1) 593 value = value.substring(0, index); 594 595 if (!PDEJavaHelper.isOnClasspath(value, javaProject)) { 596 report(NLS.bind(PDECoreMessages.Builders_Manifest_class, (new String [] { value, attr.getName() })), getLine( 597 element, attr.getName()), severity, 598 PDEMarkerFactory.P_UNKNOWN_CLASS, 599 element, 600 attr.getName() + F_ATT_VALUE_PREFIX + attr.getValue(), 601 PDEMarkerFactory.CAT_FATAL); 602 } 603 } 604 605 protected void validateRestrictionAttribute(Element element, Attr attr, ISchemaRestriction restriction) { 606 Object [] children = restriction.getChildren(); 607 String value = attr.getValue(); 608 for (int i = 0; i < children.length; i++) { 609 Object child = children[i]; 610 if (child instanceof ISchemaEnumeration) { 611 ISchemaEnumeration enumeration = (ISchemaEnumeration) child; 612 if (enumeration.getName().equals(value)) { 613 return; 614 } 615 } 616 } 617 reportIllegalAttributeValue(element, attr); 618 } 619 620 protected void reportUnusedAttribute(Element element, String attName, int severity) { 621 String message = NLS.bind(PDECoreMessages.Builders_Manifest_unused_attribute, attName); 622 report(message, getLine(element, attName), severity, PDEMarkerFactory.CAT_OTHER); 623 } 624 625 protected void reportUnusedElement(Element element, int severity) { 626 Node parent = element.getParentNode(); 627 report(NLS.bind(PDECoreMessages.Builders_Manifest_unused_element, (new String [] { 628 element.getNodeName(), parent.getNodeName() })), 629 getLine(element), severity, 630 PDEMarkerFactory.CAT_OTHER); 631 } 632 633 protected void reportDeprecatedElement(Element element) { 634 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_DEPRECATED); 635 if (severity != CompilerFlags.IGNORE) { 636 report(NLS.bind(PDECoreMessages.Builders_Manifest_deprecated_element, element.getNodeName()), getLine(element), severity, PDEMarkerFactory.CAT_DEPRECATION); 637 } 638 } 639 640 protected void reportDeprecatedRootElement(Element element, String suggestion) { 641 int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_DEPRECATED); 642 if (severity != CompilerFlags.IGNORE) { 643 String point = element.getAttribute("point"); if (point == null) return; String message; 646 if (suggestion != null) 647 message = NLS.bind(PDECoreMessages.Builders_Manifest_deprecated_rootElementSuggestion, point, suggestion); 648 else 649 message = NLS.bind(PDECoreMessages.Builders_Manifest_deprecated_rootElement, point); 650 report(message, getLine(element, "point"), severity, PDEMarkerFactory.CAT_DEPRECATION); } 652 } 653 } 654 | Popular Tags |