org.eclipse.pde.core_3.7.1.v20120103_r372

nt.getNodeName()), getLine(element), severity, "deprecation");
    }
  }
  
  protected void reportDeprecatedRootElement(Element element, String suggestion)
  {
    int severity = CompilerFlags.getFlag(fProject, "compilers.p.deprecated");
    if (severity != 2)
    {
      String point = element.getAttribute("point");
      if (point == null) {
        return;
      }
      String message;
      String message;
      if (suggestion != null) {
        message = NLS.bind(PDECoreMessages.Builders_Manifest_deprecated_rootElementSuggestion, point, suggestion);
      } else {
        message = NLS.bind(PDECoreMessages.Builders_Manifest_deprecated_rootElement, point);
      }
      report(message, getLine(element, "point"), severity, "deprecation");
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.builders.ExtensionsErrorReporter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.builders;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.pde.internal.core.PDECore;

class FeatureConsistencyChecker$DeltaVisitor
  implements IResourceDeltaVisitor
{
  private IProgressMonitor monitor;
  final FeatureConsistencyChecker this$0;
  
  public FeatureConsistencyChecker$DeltaVisitor(FeatureConsistencyChecker paramFeatureConsistencyChecker, IProgressMonitor monitor)
  {
    this$0 = paramFeatureConsistencyChecker;
    this.monitor = monitor;
  }
  
  public boolean visit(IResourceDelta delta)
  {
    IResource resource = delta.getResource();
    if ((resource instanceof IProject))
    {
      IProject project = (IProject)resource;
      try
      {
        return project.hasNature("org.eclipse.pde.FeatureNature");
      }
      catch (CoreException e)
      {
        PDECore.logException(e);
        return false;
      }
    }
    if ((resource instanceof IFile))
    {
      IFile candidate = (IFile)resource;
      if (FeatureConsistencyChecker.access$0(this$0, candidate)) {
        if (delta.getKind() != 2)
        {
          FeatureConsistencyChecker.access$1(this$0, candidate, monitor);
          return true;
        }
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.builders.FeatureConsistencyChecker.DeltaVisitor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.builders;

import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PDECoreMessages;
import org.eclipse.pde.internal.core.WorkspaceModelManager;
import org.eclipse.pde.internal.core.project.PDEProject;
import org.osgi.framework.Bundle;

public class FeatureConsistencyChecker
  extends IncrementalProjectBuilder
{
  class DeltaVisitor
    implements IResourceDeltaVisitor
  {
    private IProgressMonitor monitor;
    
    public DeltaVisitor(IProgressMonitor monitor)
    {
      this.monitor = monitor;
    }
    
    public boolean visit(IResourceDelta delta)
    {
      IResource resource = delta.getResource();
      if ((resource instanceof IProject))
      {
        IProject project = (IProject)resource;
        try
        {
          return project.hasNature("org.eclipse.pde.FeatureNature");
        }
        catch (CoreException e)
        {
          PDECore.logException(e);
          return false;
        }
      }
      if ((resource instanceof IFile))
      {
        IFile candidate = (IFile)resource;
        if (FeatureConsistencyChecker.this.isManifestFile(candidate)) {
          if (delta.getKind() != 2)
          {
            FeatureConsistencyChecker.this.checkFile(candidate, monitor);
            return true;
          }
        }
      }
      return false;
    }
  }
  
  protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
    throws CoreException
  {
    if ((PDECore.getDefault().getBundle().getState() != 32) || (monitor.isCanceled())) {
      return new IProject[0];
    }
    if (WorkspaceModelManager.isBinaryProject(getProject())) {
      return new IProject[0];
    }
    IResourceDelta delta = null;
    if (kind != 6) {
      delta = getDelta(getProject());
    }
    if ((delta == null) || (kind == 6)) {
      checkProject(monitor);
    } else {
      delta.accept(new DeltaVisitor(monitor));
    }
    return new IProject[0];
  }
  
  private void checkProject(IProgressMonitor monitor)
  {
    IFile file = PDEProject.getFeatureXml(getProject());
    if (file.exists()) {
      checkFile(file, monitor);
    }
  }
  
  private void checkFile(IFile file, IProgressMonitor monitor)
  {
    String message = NLS.bind(PDECoreMessages.Builders_verifying, file.getFullPath().toString());
    monitor.subTask(message);
    FeatureErrorReporter reporter = new FeatureErrorReporter(file);
    DefaultSAXParser.parse(file, reporter);
    if (reporter.getErrorCount() == 0) {
      reporter.validateContent(monitor);
    }
    monitor.subTask(PDECoreMessages.Builders_updating);
    monitor.done();
  }
  
  private boolean isManifestFile(IFile file)
  {
    return file.equals(PDEProject.getFeatureXml(file.getProject()));
  }
  
  /* Error */
  protected void clean(IProgressMonitor monitor)
    throws CoreException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 164	org/eclipse/pde/internal/core/builders/FeatureConsistencyChecker:getProject	()Lorg/eclipse/core/resources/IProject;
    //   4: invokestatic 172	org/eclipse/pde/internal/core/project/PDEProject:getFeatureXml	(Lorg/eclipse/core/resources/IProject;)Lorg/eclipse/core/resources/IFile;
    //   7: astore_2
    //   8: aload_2
    //   9: invokeinterface 173 1 0
    //   14: ifeq +52 -> 66
    //   17: aload_1
    //   18: getstatic 153	org/eclipse/pde/internal/core/PDECoreMessages:FeatureConsistencyChecker_0	Ljava/lang/String;
    //   21: aload_2
    //   22: invokeinterface 175 1 0
    //   27: invokestatic 158	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   30: iconst_1
    //   31: invokestatic 157	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;Ljava/lang/String;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   34: astore_3
    //   35: aload_2
    //   36: ldc 1
    //   38: iconst_1
    //   39: iconst_0
    //   40: invokeinterface 176 4 0
    //   45: aload_3
    //   46: iconst_1
    //   47: invokevirtual 156	org/eclipse/core/runtime/SubMonitor:worked	(I)V
    //   50: goto +12 -> 62
    //   53: astore 4
    //   55: aload_3
    //   56: invokevirtual 155	org/eclipse/core/runtime/SubMonitor:done	()V
    //   59: aload 4
    //   61: athrow
    //   62: aload_3
    //   63: invokevirtual 155	org/eclipse/core/runtime/SubMonitor:done	()V
    //   66: return
    // Line number table:
    //   Java source line #107	-> byte code offset #0
    //   Java source line #108	-> byte code offset #8
    //   Java source line #109	-> byte code offset #17
    //   Java source line #112	-> byte code offset #35
    //   Java source line #113	-> byte code offset #45
    //   Java source line #114	-> byte code offset #53
    //   Java source line #115	-> byte code offset #55
    //   Java source line #116	-> byte code offset #59
    //   Java source line #115	-> byte code offset #62
    //   Java source line #118	-> byte code offset #66
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	67	0	this	FeatureConsistencyChecker
    //   0	67	1	monitor	IProgressMonitor
    //   7	29	2	file	IFile
    //   34	29	3	localmonitor	org.eclipse.core.runtime.SubMonitor
    //   53	7	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   35	53	53	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.builders.FeatureConsistencyChecker
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.builders;

import java.util.Arrays;
import java.util.HashSet;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.ModelEntry;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.internal.core.FeatureModelManager;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PDECoreMessages;
import org.eclipse.pde.internal.core.ibundle.IBundle;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModel;
import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.pde.internal.core.util.CoreUtility;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class FeatureErrorReporter
  extends ManifestErrorReporter
{
  static HashSet attrs = new HashSet();
  static String[] attrNames = { "id", "version", "label", "provider-name", "image", "os", 
    "ws", "arch", "nl", "colocation-affinity", "primary", "exclusive", 
    "plugin", "application", "license-feature", "license-feature-version" };
  private IProgressMonitor fMonitor;
  
  public FeatureErrorReporter(IFile file)
  {
    super(file);
    if (attrs.isEmpty()) {
      attrs.addAll(Arrays.asList(attrNames));
    }
  }
  
  public void validateContent(IProgressMonitor monitor)
  {
    fMonitor = monitor;
    Element element = getDocumentRoot();
    if (element == null) {
      return;
    }
    String elementName = element.getNodeName();
    if (!"feature".equals(elementName))
    {
      reportIllegalElement(element, 0);
    }
    else
    {
      validateFeatureAttributes(element);
      validateInstallHandler(element);
      validateDescription(element);
      validateLicense(element);
      validateCopyright(element);
      validateURLElement(element);
      validateIncludes(element);
      validateRequires(element);
      validatePlugins(element);
      validateData(element);
    }
  }
  
  private void validateData(Element parent)
  {
    NodeList list = getChildrenByName(parent, "data");
    for (int i = 0; i < list.getLength(); i++)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element data = (Element)list.item(i);
      assertAttributeDefined(data, "id", 0);
      NamedNodeMap attributes = data.getAttributes();
      for (int j = 0; j < attributes.getLength(); j++)
      {
        Attr attr = (Attr)attributes.item(j);
        String name = attr.getName();
        if ((!name.equals("id")) && (!name.equals("os")) && (!name.equals("ws")) && 
          (!name.equals("nl")) && (!name.equals("arch")) && 
          (!name.equals("download-size")) && (!name.equals("install-size"))) {
          reportUnknownAttribute(data, name, 0);
        }
      }
    }
  }
  
  private void validatePlugins(Element parent)
  {
    NodeList list = getChildrenByName(parent, "plugin");
    for (int i = 0; i < list.getLength(); i++)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element plugin = (Element)list.item(i);
      assertAttributeDefined(plugin, "id", 0);
      assertAttributeDefined(plugin, "version", 0);
      NamedNodeMap attributes = plugin.getAttributes();
      boolean isFragment = plugin.getAttribute("fragment").equals("true");
      for (int j = 0; j < attributes.getLength(); j++)
      {
        Attr attr = (Attr)attributes.item(j);
        String name = attr.getName();
        if (name.equals("id"))
        {
          validatePluginID(plugin, attr, isFragment);
        }
        else if (name.equals("version"))
        {
          validateVersionAttribute(plugin, attr);
          validateVersion(plugin, attr);
        }
        else if ((name.equals("fragment")) || (name.equals("unpack")))
        {
          validateBoolean(plugin, attr);
        }
        else if ((!name.equals("os")) && (!name.equals("ws")) && (!name.equals("nl")) && 
          (!name.equals("arch")) && (!name.equals("download-size")) && 
          (!name.equals("install-size")) && (!name.equals("filter")))
        {
          reportUnknownAttribute(plugin, name, 0);
        }
      }
      validateUnpack(plugin);
    }
  }
  
  private void validateRequires(Element parent)
  {
    NodeList list = getChildrenByName(parent, "requires");
    if (list.getLength() > 0)
    {
      validateImports((Element)list.item(0));
      reportExtraneousElements(list, 1);
    }
  }
  
  private void validateImports(Element parent)
  {
    NodeList list = getChildrenByName(parent, "import");
    for (int i = 0; i < list.getLength(); i++)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element element = (Element)list.item(i);
      Attr plugin = element.getAttributeNode("plugin");
      Attr feature = element.getAttributeNode("feature");
      if ((plugin == null) && (feature == null)) {
        assertAttributeDefined(element, "plugin", 0);
      } else if ((plugin != null) && (feature != null)) {
        reportExclusiveAttributes(element, "plugin", "feature", 0);
      } else if (plugin != null) {
        validatePluginID(element, plugin, false);
      } else if (feature != null) {
        validateFeatureID(element, feature);
      }
      NamedNodeMap attributes = element.getAttributes();
      for (int j = 0; j < attributes.getLength(); j++)
      {
        Attr attr = (Attr)attributes.item(j);
        String name = attr.getName();
        if (name.equals("version")) {
          validateVersionAttribute(element, attr);
        } else if (name.equals("match"))
        {
          if (element.getAttributeNode("patch") != null) {
            report(NLS.bind(PDECoreMessages.Builders_Feature_patchedMatch, attr.getValue()), getLine(element, attr.getValue()), 0, "fatal");
          } else {
            validateMatch(element, attr);
          }
        }
        else if (name.equals("patch"))
        {
          if (("true".equalsIgnoreCase(attr.getValue())) && (feature == null)) {
            report(NLS.bind(PDECoreMessages.Builders_Feature_patchPlugin, attr.getValue()), getLine(element, attr.getValue()), 0, "fatal");
          } else if (("true".equalsIgnoreCase(attr.getValue())) && (element.getAttributeNode("version") == null)) {
            report(NLS.bind(PDECoreMessages.Builders_Feature_patchedVersion, attr.getValue()), getLine(element, attr.getValue()), 0, "fatal");
          } else {
            validateBoolean(element, attr);
          }
        }
        else if ((!name.equals("plugin")) && (!name.equals("feature")) && (!name.equals("filter"))) {
          reportUnknownAttribute(element, name, 0);
        }
      }
    }
  }
  
  private void validateIncludes(Element parent)
  {
    NodeList list = getChildrenByName(parent, "includes");
    for (int i = 0; i < list.getLength(); i++)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element include = (Element)list.item(i);
      if ((assertAttributeDefined(include, "id", 0)) && 
        (assertAttributeDefined(include, "version", 
        0))) {
        validateFeatureID(include, include.getAttributeNode("id"));
      }
      NamedNodeMap attributes = include.getAttributes();
      for (int j = 0; j < attributes.getLength(); j++)
      {
        Attr attr = (Attr)attributes.item(j);
        String name = attr.getName();
        if (name.equals("version"))
        {
          validateVersionAttribute(include, attr);
        }
        else if (name.equals("optional"))
        {
          validateBoolean(include, attr);
        }
        else if (name.equals("search-location"))
        {
          String value = include.getAttribute("search-location");
          if ((!value.equals("root")) && (!value.equals("self")) && (!value.equals("both"))) {
            reportIllegalAttributeValue(include, attr);
          }
        }
        else if ((!name.equals("id")) && (!name.equals("name")) && (!name.equals("os")) && (!name.equals("ws")) && 
          (!name.equals("nl")) && (!name.equals("arch")) && (!name.equals("filter")))
        {
          reportUnknownAttribute(include, name, 0);
        }
      }
    }
  }
  
  private void validateURLElement(Element parent)
  {
    NodeList list = getChildrenByName(parent, "url");
    if (list.getLength() > 0)
    {
      Element url = (Element)list.item(0);
      validateUpdateURL(url);
      validateDiscoveryURL(url);
      reportExtraneousElements(list, 1);
    }
  }
  
  private void validateUpdateURL(Element parent)
  {
    NodeList list = getChildrenByName(parent, "update");
    if (list.getLength() > 0)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element update = (Element)list.item(0);
      assertAttributeDefined(update, "url", 0);
      NamedNodeMap attributes = update.getAttributes();
      for (int i = 0; i < attributes.getLength(); i++)
      {
        String name = attributes.item(i).getNodeName();
        if (name.equals("url")) {
          validateURL(update, "url");
        } else if (!name.equals("label")) {
          reportUnknownAttribute(update, name, 0);
        }
      }
      reportExtraneousElements(list, 1);
    }
  }
  
  private void validateDiscoveryURL(Element parent)
  {
    NodeList list = getChildrenByName(parent, "discovery");
    if (list.getLength() > 0)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element discovery = (Element)list.item(0);
      assertAttributeDefined(discovery, "url", 0);
      NamedNodeMap attributes = discovery.getAttributes();
      for (int i = 0; i < attributes.getLength(); i++)
      {
        String name = attributes.item(i).getNodeName();
        if (name.equals("url"))
        {
          validateURL(discovery, "url");
        }
        else if (name.equals("type"))
        {
          String value = discovery.getAttribute("type");
          if ((!value.equals("web")) && (!value.equals("update"))) {
            reportIllegalAttributeValue(discovery, (Attr)attributes.item(i));
          }
          reportDeprecatedAttribute(discovery, discovery.getAttributeNode("type"));
        }
        else if (!name.equals("label"))
        {
          reportUnknownAttribute(discovery, name, 0);
        }
      }
    }
  }
  
  private void validateCopyright(Element parent)
  {
    NodeList list = getChildrenByName(parent, "copyright");
    if (list.getLength() > 0)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element element = (Element)list.item(0);
      validateElementWithContent((Element)list.item(0), true);
      NamedNodeMap attributes = element.getAttributes();
      for (int i = 0; i < attributes.getLength(); i++)
      {
        Attr attr = (Attr)attributes.item(i);
        String name = attr.getName();
        if (name.equals("url")) {
          validateURL(element, name);
        } else {
          reportUnknownAttribute(element, name, 0);
        }
      }
      reportExtraneousElements(list, 1);
    }
  }
  
  private void validateLicense(Element parent)
  {
    NodeList list = getChildrenByName(parent, "license");
    if (list.getLength() > 0)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element element = (Element)list.item(0);
      validateElementWithContent((Element)list.item(0), true);
      NamedNodeMap attributes = element.getAttributes();
      for (int i = 0; i < attributes.getLength(); i++)
      {
        Attr attr = (Attr)attributes.item(i);
        String name = attr.getName();
        if (name.equals("url")) {
          validateURL(element, name);
        } else {
          reportUnknownAttribute(element, name, 0);
        }
      }
      reportExtraneousElements(list, 1);
    }
  }
  
  private void validateDescription(Element parent)
  {
    NodeList list = getChildrenByName(parent, "description");
    if (list.getLength() > 0)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element element = (Element)list.item(0);
      validateElementWithContent((Element)list.item(0), true);
      NamedNodeMap attributes = element.getAttributes();
      for (int i = 0; i < attributes.getLength(); i++)
      {
        Attr attr = (Attr)attributes.item(i);
        String name = attr.getName();
        if (name.equals("url")) {
          validateURL(element, name);
        } else {
          reportUnknownAttribute(element, name, 0);
        }
      }
      reportExtraneousElements(list, 1);
    }
  }
  
  private void validateInstallHandler(Element element)
  {
    NodeList elements = getChildrenByName(element, "install-handler");
    if (elements.getLength() > 0)
    {
      if (fMonitor.isCanceled()) {
        return;
      }
      Element handler = (Element)elements.item(0);
      NamedNodeMap attributes = handler.getAttributes();
      for (int i = 0; i < attributes.getLength(); i++)
      {
        String name = attributes.item(i).getNodeName();
        if ((!name.equals("library")) && (!name.equals("handler"))) {
          reportUnknownAttribute(handler, name, 0);
        }
      }
      reportExtraneousElements(elements, 1);
    }
  }
  
  private void validateFeatureAttributes(Element element)
  {
    if (fMonitor.isCanceled()) {
      return;
    }
    assertAttributeDefined(element, "id", 0);
    assertAttributeDefined(element, "version", 0);
    NamedNodeMap attributes = element.getAttributes();
    for (int i = 0; i < attributes.getLength(); i++)
    {
      String name = attributes.item(i).getNodeName();
      if (!attrs.contains(name)) {
        reportUnknownAttribute(element, name, 0);
      } else if (name.equals("id")) {
        validatePluginID(element, (Attr)attributes.item(i));
      } else if ((name.equals("primary")) || (name.equals("exclusive"))) {
        validateBoolean(element, (Attr)attributes.item(i));
      } else if (name.equals("version")) {
        validateVersionAttribute(element, (Attr)attributes.item(i));
      }
      if (name.equals("primary")) {
        reportDeprecatedAttribute(element, (Attr)attributes.item(i));
      } else if (name.equals("plugin")) {
        validatePluginID(element, (Attr)attributes.item(i), false);
      }
    }
  }
  
  private void validatePluginID(Element element, Attr attr, boolean isFragment)
  {
    String id = attr.getValue();
    if (!validatePluginID(element, attr)) {
      return;
    }
    int severity = CompilerFlags.getFlag(fProject, "compilers.f.unresolved-plugins");
    if (severity != 2)
    {
      IPluginModelBase model = PluginRegistry.findModel(id);
      if ((model == null) || (!model.isEnabled()) || ((isFragment) && (!model.isFragmentModel())) || ((!isFragment) && (model.isFragmentModel()))) {
        report(NLS.bind(PDECoreMessages.Builders_Feature_reference, id), getLine(element, attr.getName()), severity, "");
      }
    }
  }
  
  private void validateFeatureID(Element element, Attr attr)
  {
    int severity = CompilerFlags.getFlag(fProject, "compilers.f.unresolved-features");
    if (severity != 2)
    {
      IFeatureModel[] models = PDECore.getDefault().getFeatureModelManager().findFeatureModels(attr.getValue());
      if (models.length == 0) {
        report(NLS.bind(PDECoreMessages.Builders_Feature_freference, attr.getValue()), getLine(element, attr.getName()), severity, "");
      }
    }
  }
  
  protected void reportExclusiveAttributes(Element element, String attName1, String attName2, int severity)
  {
    String message = NLS.bind(PDECoreMessages.Builders_Feature_exclusiveAttributes, new String[] { attName1, attName2 });
    report(message, getLine(element, attName2), severity, "");
  }
  
  private void validateUnpack(Element parent)
  {
    int severity = CompilerFlags.getFlag(fProject, "compilers.f.unresolved-plugins");
    if (severity == 2) {
      return;
    }
    if (severity == 0) {
      severity = 1;
    }
    String unpack = parent.getAttribute("unpack");
    IPluginModelBase pModel = PluginRegistry.findModel(parent.getAttribute("id"));
    if (pModel == null) {
      return;
    }
    if ((pModel instanceof IBundlePluginModel))
    {
      IBundlePluginModel bModel = (IBundlePluginModel)pModel;
      IManifestHeader header = bModel.getBundleModel().getBundle().getManifestHeader("Eclipse-BundleShape");
      if (header != null)
      {
        String value = header.getValue();
        String unpackValue = "true".equals(unpack) ? "jar" : "dir";
        if ((value != null) && (!value.equalsIgnoreCase(unpackValue)))
        {
          String message = NLS.bind(PDECoreMessages.Builders_Feature_mismatchUnpackBundleShape, new String[] { "unpack=" + unpack, parent.getAttribute("id"), "Eclipse-BundleShape: " + value });
          report(message, getLine(parent), severity, "");
        }
      }
    }
    if (("true".equals(unpack)) && (!CoreUtility.guessUnpack(pModel.getBundleDescription())))
    {
      String message = NLS.bind(PDECoreMessages.Builders_Feature_missingUnpackFalse, new String[] { parent.getAttribute("id"), "unpack=\"false\"" });
      report(message, getLine(parent), severity, "");
    }
  }
  
  private void validateVersion(Element plugin, Attr attr)
  {
    String id = plugin.getAttribute("id");
    String version = plugin.getAttribute("version");
    if ((id.trim().length() == 0) || (version.trim().length() == 0) || (version.equals("0.0.0"))) {
      return;
    }
    ModelEntry entry = PluginRegistry.findEntry(id);
    if (entry != null)
    {
      IPluginModelBase[] allModels = entry.getActiveModels();
      for (int i = 0; i < allModels.length; i++)
      {
        IPluginModelBase availablePlugin = allModels[i];
        if ((id.equals(availablePlugin.getPluginBase().getId())) && 
          (version.equals(availablePlugin.getPluginBase().getVersion()))) {
          return;
        }
      }
    }
    report(NLS.bind(PDECoreMessages.Builders_Feature_mismatchPluginVersion, new String[] { version, id }), getLine(plugin, attr.getName()), 1, "");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.builders.FeatureErrorReporter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.builders;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.pde.core.plugin.ModelEntry;
import org.eclipse.pde.internal.core.FeatureModelManager;
import org.eclipse.pde.internal.core.IFeatureModelDelta;
import org.eclipse.pde.internal.core.IFeatureModelListener;
import org.eclipse.pde.internal.core.IPluginModelListener;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PluginModelDelta;
import org.eclipse.pde.internal.core.PluginModelManager;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;

public class FeatureRebuilder
  implements IFeatureModelListener, IPluginModelListener, IResourceChangeListener
{
  private boolean fTouchFeatures;
  
  public void start()
  {
    PDECore.getDefault().getFeatureModelManager().addFeatureModelListener(this);
    PDECore.getDefault().getModelManager().addPluginModelListener(this);
    JavaCore.addPreProcessingResourceChangedListener(this, 8);
  }
  
  public void stop()
  {
    PDECore.getDefault().getFeatureModelManager().removeFeatureModelListener(this);
    PDECore.getDefault().getModelManager().removePluginModelListener(this);
    JavaCore.removePreProcessingResourceChangedListener(this);
  }
  
  public void modelsChanged(IFeatureModelDelta delta)
  {
    if (((0x1 & delta.getKind()) != 0) || ((0x2 & delta.getKind()) != 0)) {
      fTouchFeatures = true;
    }
  }
  
  public void modelsChanged(PluginModelDelta delta)
  {
    if (((0x1 & delta.getKind()) != 0) || ((0x2 & delta.getKind()) != 0))
    {
      fTouchFeatures = true;
    }
    else
    {
      ModelEntry[] changed = delta.getChangedEntries();
      if ((changed.length > 0) && 
        (!changed[0].hasWorkspaceModels())) {
        touchFeatures();
      }
    }
  }
  
  public void resourceChanged(IResourceChangeEvent event)
  {
    if ((event.getType() == 8) && (fTouchFeatures)) {
      touchFeatures();
    }
  }
  
  private void touchFeatures()
  {
    FeatureModelManager manager = PDECore.getDefault().getFeatureModelManager();
    IFeatureModel[] workspaceFeatures = manager.getWorkspaceModels();
    if (workspaceFeatures.length > 0)
    {
      IProgressMonitor monitor = new NullProgressMonitor();
      monitor.beginTask("", workspaceFeatures.length);
      for (int i = 0; i < workspaceFeatures.length; i++) {
        try
        {
          IResource resource = workspaceFeatures[i].getUnderlyingResource();
          if (resource != null) {
            resource.touch(new SubProgressMonitor(monitor, 1));
          } else {
            monitor.worked(1);
          }
        }
        catch (CoreException localCoreException) {}
      }
    }
    fTouchFeatures = false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.builders.FeatureRebuilder
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.builders;

import org.eclipse.core.resources.IFile;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;

public class FragmentErrorReporter
  extends PluginBaseErrorReporter
{
  public FragmentErrorReporter(IFile file)
  {
    super(file);
  }
  
  protected void validateTopLevelAttributes(Element element)
  {
    super.validateTopLevelAttributes(element);
    if (assertAttributeDefined(element, "plugin-id", 0)) {
      validatePluginIDRef(element, element.getAttributeNode("plugin-id"));
    }
    if (assertAttributeDefined(element, "plugin-version", 0)) {
      validateVersionAttribute(element, element.getAttributeNode("plugin-version"));
    }
    Attr attr = element.getAttributeNode("match");
    if (attr != null) {
      validateMatch(element, attr);
    }
  }
  
  protected String getRootElementName()
  {
    return "fragment";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.builders.FragmentErrorReporter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.builders;

import org.eclipse.osgi.util.ManifestElement;

public abstract interface IHeader
{
  public abstract ManifestElement[] getElements();
  
  public abstract int getLineNumber();
  
  public abstract int getLinesSpan();
  
  public abstract String getName();
  
  public abstract String getValue();
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.builders.IHeader
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.builders;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PDECoreMessages;

public class JarManifestErrorReporter
  extends ErrorReporter
{
  protected Map fHeaders;
  protected IDocument fTextDocument;
  
  public JarManifestErrorReporter(IFile file)
  {
    super(file);
    fTextDocument = createDocument(file);
  }
  
  private String getHeaderName(String line)
  {
    for (int i = 0; i < line.length(); i++)
    {
      char c = line.charAt(i);
      if (c == ':') {
        return line.substring(0, i);
      }
      if (((c < 'A') || ('Z' < c)) && ((c < 'a') || ('z' < c)) && ((c < '0') || ('9' < c)))
      {
        if (i == 0) {
          return null;
        }
        if ((c != '-') && (c != '_')) {
          return null;
        }
      }
    }
    return null;
  }
  
  protected int getPackageLine(IHeader header, ManifestElement element)
  {
    String packageName = element.getValue();
    if ((element.getDirectiveKeys() != null) || (element.getKeys() != null)) {
      return getLine(header, packageName + ";");
    }
    try
    {
      IRegion lineRegion = fTextDocument.getLineInformation(header.getLineNumber() + header.getLinesSpan() - 1);
      String lineStr = fTextDocument.get(lineRegion.getOffset(), lineRegion.getLength());
      if (lineStr.endsWith(packageName)) {
        return header.getLineNumber() + header.getLinesSpan();
      }
    }
    catch (BadLocationException ble)
    {
      PDECore.logException(ble);
    }
    return getLine(header, packageName + ",");
  }
  
  protected int getLine(IHeader header, String valueSubstring)
  {
    for (int l = header.getLineNumber(); l < header.getLineNumber() + header.getLinesSpan(); l++) {
      try
      {
        IRegion lineRegion = fTextDocument.getLineInformation(l);
        String lineStr = fTextDocument.get(lineRegion.getOffset(), lineRegion.getLength());
        if (lineStr.indexOf(valueSubstring) >= 0) {
          return l + 1;
        }
      }
      catch (BadLocationException ble)
      {
        PDECore.logException(ble);
      }
    }
    try
    {
      IRegion lineRegion = fTextDocument.getLineInformation(header.getLineNumber());
      String lineStr = fTextDocument.get(lineRegion.getOffset(), lineRegion.getLength());
      for (int l = header.getLineNumber() + 1; l < header.getLineNumber() + header.getLinesSpan(); l++)
      {
        lineRegion = fTextDocument.getLineInformation(l);
        lineStr = lineStr + fTextDocument.get(lineRegion.getOffset() + 1, lineRegion.getLength());
        if (lineStr.indexOf(valueSubstring) >= 0) {
          return l;
        }
      }
    }
    catch (BadLocationException ble)
    {
      PDECore.logException(ble);
    }
    return header.getLineNumber() + 1;
  }
  
  protected void parseManifest(IDocument document, IProgressMonitor monitor)
  {
    try
    {
      fHeaders = new HashMap();
      JarManifestHeader header = null;
      for (int l = 0; l < document.getNumberOfLines(); l++)
      {
        if (l % 100 == 0) {
          checkCanceled(monitor);
        }
        IRegion lineInfo = document.getLineInformation(l);
        String line = document.get(lineInfo.getOffset(), lineInfo.getLength());
        
        Charset charset = Charset.forName("UTF-8");
        String lineDelimiter = document.getLineDelimiter(l);
        if (lineDelimiter == null) {
          lineDelimiter = "";
        }
        ByteBuffer byteBuf = charset.encode(line);
        if (byteBuf.limit() + lineDelimiter.length() > 512)
        {
          report(PDECoreMessages.BundleErrorReporter_lineTooLong, l + 1, 0, "fatal");
          return;
        }
        if (line.length() == 0)
        {
          if (l == 0)
          {
            report(PDECoreMessages.BundleErrorReporter_noMainSection, 1, 0, "fatal");
            return;
          }
          if (header == null) {
            break;
          }
          fHeaders.put(header.getName().toLowerCase(), header);
          header = null;
          
          break;
        }
        if (line.charAt(0) == ' ')
        {
          if (l == 0)
          {
            report(PDECoreMessages.BundleErrorReporter_noMainSection, 1, 0, "fatal");
            return;
          }
          if (header != null) {
            header.append(line.substring(1));
          }
        }
        else
        {
          if (header != null)
          {
            fHeaders.put(header.getName().toLowerCase(), header);
            header = null;
          }
          int colon = line.indexOf(':');
          if (colon == -1)
          {
            report(PDECoreMessages.BundleErrorReporter_noColon, l + 1, 0, "fatal");
            return;
          }
          String headerName = getHeaderName(line);
          if (headerName == null)
          {
            report(PDECoreMessages.BundleErrorReporter_invalidHeaderName, l + 1, 0, "fatal");
            return;
          }
          if ((line.length() < colon + 2) || (line.charAt(colon + 1) != ' '))
          {
            report(PDECoreMessages.BundleErrorReporter_noSpaceValue, l + 1, 0, "fatal");
            return;
          }
          if ("Name".equals(headerName))
          {
            report(PDECoreMessages.BundleErrorReporter_nameHeaderInMain, l + 1, 0, "fatal");
            return;
          }
          header = new JarManifestHeader(headerName, line.substring(colon + 2), l, this);
          if (fHeaders.containsKey(header.getName().toLowerCase())) {
            report(PDECoreMessages.BundleErrorReporter_duplicateHeader, l + 1, 1, "");
          }
        }
      }
      if (header != null)
      {
        report(PDECoreMessages.BundleErrorReporter_noLineTermination, l, 0, "fatal");
        return;
      }
      for (; l < document.getNumberOfLines(); l++)
      {
        IRegion lineInfo = document.getLineInformation(l);
        String line = document.get(lineInfo.getOffset(), lineInfo.getLength());
        if (line.length() != 0)
        {
          if (line.startsWith("Name:")) {
            break;
          }
          report(PDECoreMessages.BundleErrorReporter_noNameHeader, l, 0, "fatal");
          
          break;
        }
      }
      return;
    }
    catch (BadLocationException ble)
    {
      PDECore.logException(ble);
    }
  }
  
  protected void reportIllegalAttributeValue(IHeader header, String key, String value)
  {
    String msg = NLS.bind(PDECoreMessages.BundleErrorReporter_att_value, new String[] { value, key });
    report(msg, getLine(header, key + "="), 0, 
      "fatal");
  }
  
  protected void reportIllegalValue(IHeader header, String value)
  {
    String msg = NLS.bind(PDECoreMessages.BundleErrorReporter_illegal_value, value);
    report(msg, getLine(header, value), 0, "fatal");
  }
  
  protected void reportIllegalDirectiveValue(IHeader header, String key, String value)
  {
    String msg = NLS.bind(PDECoreMessages.BundleErrorReporter_dir_value, new String[] { value, key });
    report(msg, getLine(header, key + ":="), 0, "fatal");
  }
  
  protected void validateAttributeValue(IHeader header, ManifestElement element, String key, String[] allowedValues)
  {
    String value = element.getAttribute(key);
    if (value == null) {
      return;
    }
    for (int i = 0; i < allowedValues.length; i++) {
      if (allowedValues[i].equals(value)) {
        return;
      }
    }
    reportIllegalAttributeValue(header, key, value);
  }
  
  protected void validateBooleanAttributeValue(IHeader header, ManifestElement element, String key)
  {
    validateAttributeValue(header, element, key, BOOLEAN_VALUES);
  }
  
  protected void validateBooleanDirectiveValue(IHeader header, ManifestElement element, St
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd