org.eclipse.pde.api.tools_1.0.301.v20111129-2053

);
            String referencedTypeName = reference.getReferencedTypeName();
            int index = referencedTypeName.lastIndexOf('.');
            String packageName = referencedTypeName.substring(0, index);
            int j = 0;
            for (int max2 = importPackages.length; j < max2; j++)
            {
              ImportPackageSpecification importPackageSpecification = importPackages[j];
              
              String importPackageName = importPackageSpecification.getName();
              if (importPackageName.equals(packageName)) {
                break;
              }
            }
          }
          if (referenceEEs == null) {
            referenceEEs = new HashMap(3);
          }
          referenceEEs.put(reference, new Integer(eeValue));
          return true;
        }
      }
    }
    catch (CoreException e)
    {
      ApiPlugin.log(e);
    }
    return false;
  }
  
  public boolean considerReference(IReference reference)
  {
    try
    {
      IApiComponent apiComponent = reference.getMember().getApiComponent();
      IApiBaseline baseline = apiComponent.getBaseline();
      if (baseline == null) {
        return false;
      }
      String referencedTypeName = reference.getReferencedTypeName();
      
      int index = referencedTypeName.lastIndexOf('.');
      if (index == -1) {
        return false;
      }
      String substring = referencedTypeName.substring(0, index);
      IApiComponent[] resolvePackages = baseline.resolvePackage(apiComponent, substring);
      switch (resolvePackages.length)
      {
      case 1: 
        if (resolvePackages[0].isSystemComponent())
        {
          switch (reference.getReferenceKind())
          {
          case 67108864: 
          case 268435456: 
            return false;
          }
          ((Reference)reference).setResolveStatus(false);
          retainReference(reference);
          return true;
        }
        break;
      }
    }
    catch (CoreException e)
    {
      ApiPlugin.log(e);
    }
    return false;
  }
  
  public int getReferenceKinds()
  {
    return 1879048191;
  }
  
  public List createProblems()
  {
    List references = getRetainedReferences();
    List problems = new LinkedList();
    Iterator iterator = references.iterator();
    while (iterator.hasNext())
    {
      IReference reference = (IReference)iterator.next();
      if (isProblem(reference)) {
        try
        {
          IApiProblem problem = null;
          IApiComponent component = reference.getMember().getApiComponent();
          if ((component instanceof ProjectComponent))
          {
            ProjectComponent ppac = (ProjectComponent)component;
            IJavaProject project = ppac.getJavaProject();
            problem = createProblem(reference, project);
          }
          else
          {
            problem = createProblem(reference);
          }
          if (problem != null) {
            problems.add(problem);
          }
        }
        catch (CoreException e)
        {
          ApiPlugin.log(e.getStatus());
        }
      }
    }
    return problems;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.SystemApiDetector
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.builder;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.Javadoc;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.TagElement;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.pde.api.tools.internal.JavadocTagManager;
import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiJavadocTag;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
import org.eclipse.pde.api.tools.internal.util.Util;

public class TagValidator
  extends ASTVisitor
{
  private ArrayList fTagProblems = null;
  private ICompilationUnit fCompilationUnit = null;
  private static final IApiJavadocTag[] NO_TAGS = new IApiJavadocTag[0];
  
  public TagValidator(ICompilationUnit parent)
  {
    fCompilationUnit = parent;
  }
  
  public boolean visit(Javadoc node)
  {
    ASTNode parent = node.getParent();
    if (parent != null)
    {
      List tags = node.tags();
      validateTags(parent, tags);
    }
    return false;
  }
  
  private void validateTags(ASTNode node, List tags)
  {
    if (tags.size() == 0) {
      return;
    }
    JavadocTagManager jtm = ApiPlugin.getJavadocTagManager();
    switch (node.getNodeType())
    {
    case 55: 
      TypeDeclaration type = (TypeDeclaration)node;
      IApiJavadocTag[] validtags = jtm.getTagsForType(type.isInterface() ? 2 : 1, 16);
      HashSet invalidtags = new HashSet(validtags.length);
      String context = BuilderMessages.TagValidator_an_interface;
      if (!type.isInterface())
      {
        context = BuilderMessages.TagValidator_a_class;
        if (Flags.isAbstract(type.getModifiers()))
        {
          context = BuilderMessages.TagValidator_an_abstract_class;
          invalidtags.add("@noinstantiate");
        }
        if (Flags.isFinal(type.getModifiers()))
        {
          context = BuilderMessages.TagValidator_a_final_class;
          invalidtags.add("@noextend");
        }
      }
      if (invalidtags.size() > 0)
      {
        ArrayList vtags = new ArrayList(validtags.length);
        for (int i = 0; i < validtags.length; i++) {
          if (!invalidtags.contains(validtags[i].getTagName())) {
            vtags.add(validtags[i]);
          }
        }
        validtags = (IApiJavadocTag[])vtags.toArray(new IApiJavadocTag[vtags.size()]);
      }
      processTags(getTypeName(type), tags, validtags, 2, context);
      break;
    case 71: 
      EnumDeclaration enumm = (EnumDeclaration)node;
      IApiJavadocTag[] validtags = jtm.getTagsForType(64, 16);
      processTags(getTypeName(enumm), tags, validtags, 2, BuilderMessages.TagValidator_an_enum);
      break;
    case 72: 
      EnumConstantDeclaration decl = (EnumConstantDeclaration)node;
      processTags(getTypeName(decl), tags, new IApiJavadocTag[0], 5, BuilderMessages.TagValidator_an_enum_constant);
      break;
    case 81: 
      AnnotationTypeDeclaration annot = (AnnotationTypeDeclaration)node;
      IApiJavadocTag[] validtags = jtm.getTagsForType(128, 16);
      processTags(getTypeName(annot), tags, validtags, 2, BuilderMessages.TagValidator_an_annotation);
      break;
    case 31: 
      MethodDeclaration method = (MethodDeclaration)node;
      int pkind = getParentKind(node);
      String context = null;
      int mods = method.getModifiers();
      boolean isprivate = Flags.isPrivate(mods);
      boolean isconstructor = method.isConstructor();
      boolean isfinal = Flags.isFinal(mods);
      boolean isstatic = Flags.isStatic(mods);
      boolean pfinal = false;
      switch (pkind)
      {
      case 64: 
        context = isprivate ? BuilderMessages.TagValidator_private_enum_method : BuilderMessages.TagValidator_an_enum_method;
        break;
      case 2: 
        context = BuilderMessages.TagValidator_an_interface_method;
        break;
      default: 
        pfinal = Flags.isFinal(getParentModifiers(method));
        if (isprivate) {
          context = isconstructor ? BuilderMessages.TagValidator_private_constructor : BuilderMessages.TagValidator_private_method;
        } else if ((isstatic) && (isfinal)) {
          context = BuilderMessages.TagValidator_a_static_final_method;
        } else if (isfinal) {
          context = BuilderMessages.TagValidator_a_final_method;
        } else if (isstatic) {
          context = BuilderMessages.TagValidator_a_static_method;
        } else if (pfinal) {
          context = BuilderMessages.TagValidator_a_method_in_a_final_class;
        } else {
          context = isconstructor ? BuilderMessages.TagValidator_a_constructor : BuilderMessages.TagValidator_a_method;
        }
        break;
      }
      IApiJavadocTag[] validtags = NO_TAGS;
      if (!isprivate) {
        validtags = jtm.getTagsForType(pkind, isconstructor ? 32 : 4);
      }
      if ((isfinal) || (isstatic) || (pfinal))
      {
        ArrayList ttags = new ArrayList(validtags.length);
        for (int i = 0; i < validtags.length; i++) {
          if (!validtags[i].getTagName().equals("@nooverride")) {
            ttags.add(validtags[i]);
          }
        }
        validtags = (IApiJavadocTag[])ttags.toArray(new IApiJavadocTag[ttags.size()]);
      }
      processTags(getTypeName(method), tags, validtags, 6, context);
      break;
    case 82: 
      AnnotationTypeMemberDeclaration decl = (AnnotationTypeMemberDeclaration)node;
      IApiJavadocTag[] validtags = jtm.getTagsForType(128, 4);
      processTags(getTypeName(decl), tags, validtags, 6, BuilderMessages.TagValidator_an_annotation_method);
      break;
    case 23: 
      FieldDeclaration field = (FieldDeclaration)node;
      int pkind = getParentKind(node);
      String context = null;
      boolean isfinal = Flags.isFinal(field.getModifiers());
      boolean isprivate = Flags.isPrivate(field.getModifiers());
      switch (pkind)
      {
      case 128: 
        context = BuilderMessages.TagValidator_annotation_field;
        if (isfinal) {
          context = BuilderMessages.TagValidator_a_final_annotation_field;
        }
        break;
      case 64: 
        context = isprivate ? BuilderMessages.TagValidator_private_enum_field : BuilderMessages.TagValidator_enum_field;
        break;
      default: 
        if (isprivate) {
          context = BuilderMessages.TagValidator_private_field;
        } else {
          context = isfinal ? BuilderMessages.TagValidator_a_final_field : BuilderMessages.TagValidator_a_field;
        }
        break;
      }
      IApiJavadocTag[] validtags = NO_TAGS;
      if ((!isprivate) && (!isfinal)) {
        validtags = jtm.getTagsForType(pkind, 8);
      }
      processTags(getTypeName(field), tags, validtags, 5, context);
    }
  }
  
  private int getParentModifiers(ASTNode node)
  {
    if (node == null) {
      return 0;
    }
    if ((node instanceof AbstractTypeDeclaration))
    {
      AbstractTypeDeclaration type = (AbstractTypeDeclaration)node;
      return type.getModifiers();
    }
    return getParentModifiers(node.getParent());
  }
  
  private String getTypeName(ASTNode node)
  {
    return getTypeName(node, new StringBuffer());
  }
  
  private String getTypeName(ASTNode node, StringBuffer buffer)
  {
    switch (node.getNodeType())
    {
    case 15: 
      CompilationUnit unit = (CompilationUnit)node;
      PackageDeclaration packageDeclaration = unit.getPackage();
      if (packageDeclaration != null)
      {
        buffer.insert(0, '.');
        buffer.insert(0, packageDeclaration.getName().getFullyQualifiedName());
      }
      return String.valueOf(buffer);
    }
    if ((node instanceof AbstractTypeDeclaration))
    {
      AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration)node;
      if (typeDeclaration.isPackageMemberTypeDeclaration())
      {
        buffer.insert(0, typeDeclaration.getName().getIdentifier());
      }
      else
      {
        buffer.insert(0, typeDeclaration.getName().getFullyQualifiedName());
        buffer.insert(0, '$');
      }
    }
    return getTypeName(node.getParent(), buffer);
  }
  
  private void processTags(String typeName, List tags, IApiJavadocTag[] validtags, int element, String context)
  {
    IApiJavadocTag[] alltags = ApiPlugin.getJavadocTagManager().getAllTags();
    Set tagnames = ApiPlugin.getJavadocTagManager().getAllTagNames();
    HashSet invalidtags = new HashSet(alltags.length);
    for (int i = 0; i < alltags.length; i++) {
      invalidtags.add(alltags[i].getTagName());
    }
    for (int i = 0; i < validtags.length; i++) {
      invalidtags.remove(validtags[i]);
    }
    if (invalidtags.size() == 0) {
      return;
    }
    TagElement tag = null;
    HashSet tagz = new HashSet(tags.size());
    String tagname = null;
    for (Iterator iter = tags.iterator(); iter.hasNext();)
    {
      tag = (TagElement)iter.next();
      tagname = tag.getTagName();
      if (invalidtags.contains(tag.getTagName())) {
        processTagProblem(typeName, tag, element, 7, 6, context);
      }
      if ((tagnames.contains(tag.getTagName())) && (!tagz.add(tagname))) {
        processTagProblem(typeName, tag, element, 8, 7, null);
      }
    }
  }
  
  private void processTagProblem(String typeName, TagElement tag, int element, int kind, int markerid, String context)
  {
    if (fTagProblems == null) {
      fTagProblems = new ArrayList(10);
    }
    int charstart = tag.getStartPosition();
    int charend = charstart + tag.getTagName().length();
    int linenumber = -1;
    try
    {
      IDocument document = Util.getDocument(fCompilationUnit);
      linenumber = document.getLineOfOffset(charstart);
    }
    catch (BadLocationException localBadLocationException) {}catch (CoreException localCoreException) {}
    try
    {
      IApiProblem problem = ApiProblemFactory.newApiProblem(fCompilationUnit.getCorrespondingResource().getProjectRelativePath().toPortableString(), 
        typeName, 
        new String[] { tag.getTagName(), context }, 
        new String[] { "apiMarkerID", "org.eclipse.jdt.internal.core.JavaModelManager.handleId" }, 
        new Object[] { new Integer(markerid), fCompilationUnit.getHandleIdentifier() }, 
        linenumber, 
        charstart, 
        charend, 
        536870912, 
        element, 
        kind, 
        0);
      
      fTagProblems.add(problem);
    }
    catch (JavaModelException localJavaModelException) {}
  }
  
  private int getParentKind(ASTNode node)
  {
    if (node == null) {
      return -1;
    }
    if ((node instanceof TypeDeclaration)) {
      return ((TypeDeclaration)node).isInterface() ? 2 : 1;
    }
    if ((node instanceof AnnotationTypeDeclaration)) {
      return 128;
    }
    if ((node instanceof EnumDeclaration)) {
      return 64;
    }
    return getParentKind(node.getParent());
  }
  
  public IApiProblem[] getTagProblems()
  {
    if (fTagProblems == null) {
      return new IApiProblem[0];
    }
    return (IApiProblem[])fTagProblems.toArray(new IApiProblem[fTagProblems.size()]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.TagValidator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.builder;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.model.ApiElement;
import org.eclipse.pde.api.tools.internal.provisional.Factory;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;

public class TypeScope
  extends ApiElement
  implements IApiTypeContainer
{
  private IApiComponent fComponent;
  private Map fPackageToTypes;
  
  public TypeScope(IApiComponent component, IReferenceTypeDescriptor[] types)
  {
    super(component, 3, null);
    fComponent = component;
    fPackageToTypes = new HashMap();
    for (int i = 0; i < types.length; i++)
    {
      IReferenceTypeDescriptor type = types[i];
      String name = type.getPackage().getName();
      Set set = (Set)fPackageToTypes.get(name);
      if (set == null)
      {
        set = new HashSet();
        fPackageToTypes.put(name, set);
      }
      set.add(type);
    }
  }
  
  public String[] getPackageNames()
    throws CoreException
  {
    Set pkgs = fPackageToTypes.keySet();
    String[] result = new String[pkgs.size()];
    pkgs.toArray(result);
    Arrays.sort(result);
    return result;
  }
  
  public void accept(ApiTypeContainerVisitor visitor)
    throws CoreException
  {
    if (visitor.visit(fComponent))
    {
      Set entrySet = fPackageToTypes.entrySet();
      Iterator iterator = entrySet.iterator();
      while (iterator.hasNext())
      {
        Map.Entry entry = (Map.Entry)iterator.next();
        String pkg = (String)entry.getKey();
        if (visitor.visitPackage(pkg))
        {
          Set types = (Set)entry.getValue();
          Iterator typeIter = types.iterator();
          while (typeIter.hasNext())
          {
            IReferenceTypeDescriptor type = (IReferenceTypeDescriptor)typeIter.next();
            IApiTypeRoot classFile = fComponent.findTypeRoot(type.getQualifiedName());
            if (classFile != null)
            {
              visitor.visit(pkg, classFile);
              visitor.end(pkg, classFile);
            }
          }
        }
        visitor.endVisitPackage(pkg);
      }
    }
    visitor.end(fComponent);
  }
  
  public void close()
    throws CoreException
  {}
  
  public IApiTypeRoot findTypeRoot(String qualifiedName)
    throws CoreException
  {
    IReferenceTypeDescriptor descriptor = Factory.typeDescriptor(qualifiedName);
    Set types = (Set)fPackageToTypes.get(descriptor.getPackage().getName());
    if ((types != null) && (types.contains(descriptor))) {
      return fComponent.findTypeRoot(qualifiedName);
    }
    return null;
  }
  
  public IApiTypeRoot findTypeRoot(String qualifiedName, String id)
    throws CoreException
  {
    if (fComponent.getSymbolicName().equals(id)) {
      return findTypeRoot(qualifiedName);
    }
    return null;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("*** Type Search Scope ***\n");
    buffer.append("Component: ").append(fComponent);
    if (fPackageToTypes != null)
    {
      String pack = null;
      for (Iterator iter = fPackageToTypes.keySet().iterator(); iter.hasNext();)
      {
        pack = (String)iter.next();
        buffer.append("Package: ").append(pack).append("\n");
        buffer.append("Types: ").append(fPackageToTypes.get(pack).toString()).append("\n");
      }
    }
    return buffer.toString();
  }
  
  public int getContainerType()
  {
    return 4;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.TypeScope
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.comparator;

import com.ibm.icu.text.MessageFormat;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.Signature;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiComparator;
import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMethodDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiField;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
import org.eclipse.pde.api.tools.internal.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.objectweb.asm.signature.SignatureReader;

public class ClassFileComparator
{
  private static boolean Debug = Util.DEBUG;
  
  public static void setDebug(boolean debugValue)
  {
    Debug = (debugValue) || (Util.DEBUG);
  }
  
  private boolean isCheckedException(IApiBaseline baseline, IApiComponent apiComponent, String exceptionName)
  {
    if (baseline == null) {
      return true;
    }
    try
    {
      if (Util.isJavaLangRuntimeException(exceptionName)) {
        return false;
      }
      String packageName = Signatures.getPackageName(exceptionName);
      IApiTypeRoot result = Util.getClassFile(
        baseline.resolvePackage(apiComponent, packageName), 
        exceptionName);
      if (result != null)
      {
        IApiType exception = result.getStructure();
        if (exception == null) {
          return false;
        }
        while (!Util.isJavaLangObject(exception.getName()))
        {
          String superName = exception.getSuperclassName();
          packageName = Signatures.getPackageName(superName);
          result = Util.getClassFile(
            baseline.resolvePackage(apiComponent, packageName), 
            superName);
          if (result == null)
          {
            if (!Debug) {
              break;
            }
            System.err.println("CHECKED EXCEPTION LOOKUP: Could not find " + superName + " in baseline " + baseline.getName() + " from component " + apiComponent.getSymbolicName());
            
            break;
          }
          exception = result.getStructure();
          if (Util.isJavaLangRuntimeException(exception.getName())) {
            return false;
          }
        }
      }
    }
    catch (CoreException e)
    {
      reportStatus(e);
    }
    return true;
  }
  
  private IApiBaseline apiBaseline1 = null;
  private IApiBaseline apiBaseline2 = null;
  private IApiComponent component = null;
  private IApiComponent component2 = null;
  private Delta delta = null;
  private IApiType type1 = null;
  private IApiType type2 = null;
  private int visibilityModifiers;
  private int currentDescriptorRestrictions;
  private int initialDescriptorRestrictions;
  private MultiStatus status = null;
  
  public ClassFileComparator(IApiTypeRoot classFile, IApiTypeRoot classFile2, IApiComponent component, IApiComponent component2, IApiBaseline apiState, IApiBaseline apiState2, int visibilityModifiers)
    throws CoreException
  {
    this.component = component;
    this.component2 = component2;
    type1 = classFile.getStructure();
    type2 = classFile2.getStructure();
    apiBaseline1 = apiState;
    apiBaseline2 = apiState2;
    this.visibilityModifiers = visibilityModifiers;
  }
  
  public ClassFileComparator(IApiType type, IApiTypeRoot classFile2, IApiComponent component, IApiComponent component2, IApiBaseline apiState, IApiBaseline apiState2, int visibilityModifiers)
    throws CoreException
  {
    this.component = component;
    this.component2 = component2;
    type1 = type;
    type2 = classFile2.getStructure();
    apiBaseline1 = apiState;
    apiBaseline2 = apiState2;
    this.visibilityModifiers = visibilityModifiers;
  }
  
  private void addDelta(IDelta delta)
  {
    this.delta.add(delta);
  }
  
  private void addDelta(int elementType, int kind, int flags, int restrictions, int oldModifiers, int newModifiers, IApiType type, String key, String data)
  {
    addDelta(new Delta(Util.getDeltaComponentVersionsId(component2), elementType, kind, flags, restrictions, oldModifiers, newModifiers, type.getName(), key, data));
  }
  
  private void addDelta(int elementType, int kind, int flags, int restrictions, int oldModifiers, int newModifiers, IApiType type, String key, String[] datas)
  {
    addDelta(new Delta(Util.getDeltaComponentVersionsId(component2), elementType, kind, flags, restrictions, 0, oldModifiers, newModifiers, type.getName(), key, datas));
  }
  
  private void addDelta(int elementType, int kind, int flags, int currentRestrictions, int previousRestrictions, int oldModifiers, int newModifiers, IApiType type, String key, String[] datas)
  {
    addDelta(new Delta(Util.getDeltaComponentVersionsId(component2), elementType, kind, flags, currentRestrictions, previousRestrictions, oldModifiers, newModifiers, type.getName(), key, datas));
  }
  
  private void checkSuperclass()
    throws CoreException
  {
    List superclassList1 = getSuperclassList(type1);
    if (!isStatusOk()) {
      return;
    }
    Set superclassNames2 = null;
    List superclassList2 = getSuperclassList(type2);
    if (!isStatusOk()) {
      return;
    }
    if (superclassList2 != null)
    {
      superclassNames2 = new HashSet();
      Iterator iterator = superclassList2.iterator();
      while (iterator.hasNext()) {
        superclassNames2.add(((IApiType)iterator.next()).getName());
      }
    }
    if (superclassList1 == null)
    {
      if (superclassList2 != null) {
        addDelta(
          getElementType(type1), 
          1, 
          39, 
          currentDescriptorRestrictions, 
          type1.getModifiers(), 
          type2.getModifiers(), 
          type1, 
          type1.getName(), 
          Util.getDescriptorName(type1));
      }
    }
    else if (superclassList2 == null) {
      addDelta(
        getElementType(type1), 
        3, 
        39, 
        currentDescriptorRestrictions, 
        type1.getModifiers(), 
        type2.getModifiers(), 
        type1, 
        type1.getName(), 
        Util.getDescriptorName(type1));
    }
    if ((superclassList1 != null) && (superclassList2 != null))
    {
      IApiType superclassType2 = (IApiType)superclassList2.get(0);
      IApiType superclassType = (IApiType)superclassList1.get(0);
      if (!superclassType.getName().equals(superclassType2.getName())) {
        if (!superclassNames2.contains(superclassType.getName())) {
          addDelta(
            getElementType(type1), 
            3, 
            39, 
            currentDescriptorRestrictions, 
            type1.getModifiers(), 
            type2.getModifiers(), 
            type1, 
            type1.getName(), 
            Util.getDescriptorName(type1));
        } else {
          addDelta(
            getElementType(type1), 
            1, 
            39, 
            currentDescriptorRestrictions, 
            type1.getModifiers(), 
            type2.getModifiers(), 
            type1, 
            type1.getName(), 
            Util.getDescriptorName(type1));
        }
      }
    }
  }
  
  protected void reportStatus(IStatus newstatus)
  {
    if (status == null)
    {
      String msg = MessageFormat.format(ComparatorMessages.ClassFileComparator_0, new String[] { type1.getName() });
      status = new MultiStatus("org.eclipse.pde.api.tools", 4, msg, null);
    }
    status.add(newstatus);
  }
  
  private void reportStatus(CoreException e)
  {
    reportStatus(e.getStatus());
  }
  
  private boolean isStatusOk()
  {
    return status == null;
  }
  
  public IStatus getStatus()
  {
    return status;
  }
  
  private void checkSuperInterfaces()
  {
    Set superinterfacesSet1 = getInterfacesSet(type1);
    if (!isStatusOk()) {
      return;
    }
    Set superinterfacesSet2 = getInterfacesSet(type2);
    if (!isStatusOk()) {
      return;
    }
    if (superinterfacesSet1 == null)
    {
      if (superinterfacesSet2 != null)
      {
        addDelta(
          getElementType(type1), 
          2, 
          15, 
          currentDescriptorRestrictions, 
          type1.getModifiers(), 
          type2.getModifiers(), 
          type1, 
          type1.getName(), 
          Util.getDescriptorName(type1));
        if (type1.isInterface()) {
          for (Iterator iterator = superinterfacesSet2.iterator(); iterator.hasNext();)
          {
            IApiType type = (IApiType)iterator.next();
            IApiMethod[] methods = type.getMethods();
            int length = methods.length;
            if (length != 0) {
              for (int j = 0; j < length; j++)
              {
                IApiMethod method = methods[j];
                IApiMethod method3 = type1.getMethod(method.getName(), method.getSignature());
                if (method3 == null)
                {
                  addDelta(
                    getElementType(type1), 
                    1, 
                    69, 
                    currentDescriptorRestrictions, 
                    initialDescriptorRestrictions, 
                    type1.getModifiers(), 
                    type2.getModifiers(), 
                    type1, 
                    type1.getName(), 
                    new String[] {
                    Util.getDescriptorName(type1), 
                    type.getName(), 
                    getMethodDisplayName(method, type) });
                  
                  break;
                }
              }
            }
          }
        }
      }
    }
    else if (superinterfacesSet2 == null)
    {
      addDelta(
        getElementType(type1), 
        2, 
        10, 
        currentDescriptorRestrictions, 
        type1.getModifiers(), 
        type2.getModifiers(), 
        type1, 
        type1.getName(), 
        Util.getDescriptorName(type1));
    }
    else
    {
      Set names2 = new HashSet();
      for (Iterator iterator = superinterfacesSet2.iterator(); iterator.hasNext();) {
        names2.add(((IApiType)iterator.next()).getName());
      }
      boolean contracted = false;
      for (Iterator iterator = superinterfacesSet1.iterator(); iterator.hasNext();)
      {
        IApiType superInterfaceType = (IApiType)iterator.next();
        if (!names2.remove(superInterfaceType.getName())) {
          contracted = true;
        }
      }
      if (contracted)
      {
        addDelta(
          getElementType(type1), 
          2, 
          10, 
          currentDescriptorRestrictions, 
          type1.getModifiers(), 
          type2.getModifiers(), 
          type1, 
          type1.getName(), 
          Util.getDescriptorName(type1));
        return;
      }
      if (names2.size() > 0)
      {
        addDelta(
          getElementType(type1), 
          2, 
          15, 
          currentDescriptorRestrictions, 
          type1.getModifiers(), 
          type2.getModifiers(), 
          type1, 
          type1.getName(), 
          Util.getDescriptorName(type1));
        if (type1.isInterface()) {
          for (Iterator iterator = names2.iterator(); iterator.hasNext();)
          {
            String interfaceName = (String)iterator.next();
            try
            {
              IApiTypeRoot interfaceClassFile = getType(interfaceName, component2, apiBaseline2);
              if (interfaceClassFile != null)
              {
                IApiType type = interfaceClassFile.getStructure();
                if (type != null)
                {
                  IApiMethod[] methods = type.getMethods();
                  int length = methods.length;
                  if (length > 0) {
                    for (int j = 0; j < length; j++)
                    {
                      IApiMethod method = methods[j];
                      boolean found = false;
                      for (Iterator iterator2 = superinterfacesSet1.iterator(); iterator2.hasNext();)
                      {
                        IApiType superTypeDescriptor = (IApiType)iterator2.next();
                        IApiMethod method3 = superTypeDescriptor.getMethod(method.getName(), method.getSignature());
                        if (method3 != null)
                        {
                          found = true;
                          break;
                        }
                      }
                      if (!found)
                      {
                        addDelta(
                          getElementType(type1), 
                          1, 
                          69, 
                          currentDescriptorRestrictions, 
                          initialDescriptorRestrictions, 
                          type1.getModifiers(), 
                          type2.getModifiers(), 
                          type1, 
                          type1.getName(), 
                          new String[] {
                          Util.getDescriptorName(type1), 
                          type.getName(), 
                          getMethodDisplayName(method, type) });
                        
                        break;
                      }
                    }
                  }
                }
              }
            }
            catch (CoreException e)
            {
              ApiPlugin.log(e);
            }
          }
        }
      }
    }
  }
  
  private void checkTypeMembers()
    throws CoreException
  {
    IApiType[] typeMembers = type1.getMemberTypes();
    IApiType[] typeMembers2 = type2.getMemberTypes();
    List added = new ArrayList(typeMembers2.length);
    for (int i = 0; i < typeMembers2.length; i++) {
      added.add(typeMembers2[i].getName());
    }
    if (typeMembers.length > 0)
    {
      if (typeMembers2.length == 0)
      {
        for (int i = 0; i < typeMembers.length; i++) {
          try
          {
            IApiType typeMember = typeMembers[i];
            
            IApiDescription apiDescription = component.getApiDescription();
            IApiAnnotations memberTypeElementDescription = apiDescription.resolveAnnotations(typeMember.getHandle());
            int memberTypeVisibility = 0;
            if (memberTypeElementDescription != null) {
              memberTypeVisibility = memberTypeElementDescription.getVisibility();
            }
            if ((memberTypeVisibility & visibilityModifiers) != 0) {
              if ((visibilityModifiers != 1) || (
              
                (!Util.isDefault(typeMember.getModifiers())) && 
                (!Flags.isPrivate(typeMember.getModifiers())))) {
                addDelta(
                  getElementType(type1), 
                  3, 
                  48, 
                  currentDescriptorRestrictions, 
                  typeMember.getModifiers(), 
                  0, 
                  type1, 
                  typeMember.getName(), 
                  new String[] { typeMember.getName().replace('$', '.'), Util.getComponentVersionsId(component2) });
              }
            }
          }
          catch (CoreException e)
          {
            reportStatus(e);
          }
        }
        return;
      }
      List removedTypeMembers = new ArrayList();
      for (int i = 0; i < typeMembers.length; i++)
      {
        IApiType typeMember = typeMembers[i];
        IApiType typeMember2 = type2.getMemberType(typeMember.getSimpleName());
        if (typeMember2 == null)
        {
          removedTypeMembers.add(typeMember);
        }
        else
        {
          added.remove(typeMember2.getName());
          try
          {
            IApiDescription apiDescription = component.getApiDescription();
            IApiAnnotations memberTypeElementDescription = apiDescription.resolveAnnotations(typeMember.getHandle());
            int memberTypeVisibility = 0;
            if (memberTypeElementDescription != null) {
              memberTypeVisibility = memberTypeElementDescription.getVisibility();
            }
            if ((memberTypeVisibility & visibilityModifiers) != 0)
            {
              IApiDescription apiDescription2 = component2.getApiDescription();
              IApiAnnotations memberTypeElementDescription2 = apiDescription2.resolveAnnotations(typeMember2.getHandle());
              int memberTypeVisibility2 = 0;
              if (memberTypeElementDescription2 != null) {
                memberTypeVisibility2 = memberTypeElementDescription2.getVisibility();
              }
              String deltaComponentID = Util.getDeltaComponentVersionsId(component2);
              int restrictions = memberTypeElementDescription2 != null ? memberTypeElementDescription2.getRestrictions() : 0;
              if (Flags.isFinal(type2.getModifiers())) {
                restrictions |= 0x2;
              }
              if ((isAPI(memberTypeVisibility, typeMember)) && (!isAPI(memberTypeVisibility2, typeMember2)))
              {
                addDelta(
                  new Delta(
                  deltaComponentID, 
                  getElementType(typeMember), 
                  2, 
                  11, 
                  restrictions | currentDescriptorRestrictions, 
                  0, 
                  typeMember.getModifiers(), 
                  typeMember2.getModifiers(), 
                  typeMember.getName(), 
                  typeMember.getName(), 
                  new String[] { typeMember.getName().replace('$', '.') }));
              }
              else
              {
                if ((memberTypeVisibility2 & visibilityModifiers) == 0) {
                  addDelta(
                    new Delta(
                    deltaComponentID, 
                    getElementType(typeMember), 
                    2, 
                    52, 
                    restrictions | currentDescriptorRestrictions, 
                    0, 
                    typeMember.getModifiers(), 
                    typeMember2.getModifiers(), 
                    typeMember.getName(), 
                    typeMember.getName(), 
                    new String[] { typeMember.getName().replace('$', '.') }));
                }
                if ((visibilityModifiers != 1) || (
                
                  (!Util.isDefault(typeMember2.getModifiers())) && 
                  (!Flags.isPrivate(typeMember2.getModifiers()))))
                {
                  IApiTypeRoot memberType2 = component2.findTypeRoot(typeMember.getName());
                  ClassFileComparator comparator = new ClassFileComparator(typeMember, memberType2, component, component2, apiBaseline1, apiBaseline2, visibilityModifiers);
                  IDelta delta2 = comparator.getDelta(null);
                  if ((delta2 != null) && (delta2 != ApiComparator.NO_DELTA)) {
                    addDelta(delta2);
                  }
                }
              }
            }
          }
          catch (CoreException e)
          {
            reportStatus(e);
          }
        }
      }
      for (Iterator iterator = removedTypeMembers.iter
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

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-2019. Infinite Loop Ltd