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

t;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;

public class LeakReturnTypeDetector
  extends MethodLeakDetector
{
  public LeakReturnTypeDetector(Set nonApiPackageNames)
  {
    super(nonApiPackageNames);
  }
  
  protected String getSeverityKey()
  {
    return "LEAK_METHOD_RETURN_TYPE";
  }
  
  public int getReferenceKinds()
  {
    return 8;
  }
  
  protected int getProblemFlags(IReference reference)
  {
    return 4;
  }
}

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

import com.ibm.icu.text.MessageFormat;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IType;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
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.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
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.util.Signatures;

public abstract class MethodLeakDetector
  extends AbstractLeakProblemDetector
{
  public MethodLeakDetector(Set nonApiPackageNames)
  {
    super(nonApiPackageNames);
  }
  
  protected int getElementType(IReference reference)
  {
    return 6;
  }
  
  protected int getProblemKind()
  {
    return 6;
  }
  
  protected String getSeverityKey()
  {
    return "LEAK_METHOD_RETURN_TYPE";
  }
  
  protected boolean isProblem(IReference reference)
  {
    IApiMethod method = (IApiMethod)reference.getMember();
    IApiType type = (IApiType)reference.getResolvedReference();
    try
    {
      IApiAnnotations annotations = type.getApiComponent().getApiDescription().resolveAnnotations(type.getHandle());
      if (annotations != null)
      {
        if (VisibilityModifiers.isPrivate(annotations.getVisibility()))
        {
          if ((0x4 & method.getModifiers()) > 0)
          {
            IApiDescription description = method.getApiComponent().getApiDescription();
            annotations = description.resolveAnnotations(method.getHandle().getEnclosingType());
            if ((annotations == null) || (RestrictionModifiers.isExtendRestriction(annotations.getRestrictions()))) {
              return false;
            }
          }
          return true;
        }
      }
      else if (isEnclosingTypeVisible(type)) {
        ApiPlugin.log(
          new Status(
          1, "org.eclipse.pde.api.tools", 
          MessageFormat.format(BuilderMessages.AbstractTypeLeakDetector_vis_type_has_no_api_description, new String[] { type.getName() })));
      } else {
        return true;
      }
    }
    catch (CoreException e)
    {
      ApiPlugin.log(e);
    }
    return false;
  }
  
  protected String[] getMessageArgs(IReference reference)
    throws CoreException
  {
    IApiMethod method = (IApiMethod)reference.getMember();
    IApiType type = (IApiType)reference.getResolvedReference();
    return new String[] {
      getSimpleTypeName(type), 
      getSimpleTypeName(method), 
      Signatures.getMethodSignature(method) };
  }
  
  protected String[] getQualifiedMessageArgs(IReference reference)
    throws CoreException
  {
    IApiMethod method = (IApiMethod)reference.getMember();
    IApiType type = (IApiType)reference.getResolvedReference();
    return new String[] {
      getQualifiedTypeName(type), 
      getQualifiedTypeName(method), 
      Signatures.getMethodSignature(method) };
  }
  
  protected Position getSourceRange(IType type, IDocument doc, IReference reference)
    throws CoreException, BadLocationException
  {
    return getSourceRangeForMethod(type, reference, (IApiMethod)reference.getMember());
  }
  
  public boolean considerReference(IReference reference)
  {
    if ((super.considerReference(reference)) && (isNonAPIReference(reference)))
    {
      IApiMember member = reference.getMember();
      if ((member != null) && (matchesSourceModifiers(member)) && (matchesSourceApiRestrictions(member)))
      {
        retainReference(reference);
        return true;
      }
    }
    return false;
  }
  
  protected boolean matchesSourceApiRestrictions(IApiMember member)
  {
    IApiComponent apiComponent = member.getApiComponent();
    try
    {
      IApiMethod method = (IApiMethod)member;
      IApiAnnotations annotations = apiComponent.getApiDescription().resolveAnnotations(method.getHandle());
      if (annotations != null)
      {
        if (VisibilityModifiers.isAPI(annotations.getVisibility()))
        {
          int ares = annotations.getRestrictions();
          if (ares != 0)
          {
            if (method.isConstructor()) {
              return (ares & 0x8) == 0;
            }
            if ((ares & 0x10) == 0)
            {
              IApiAnnotations annot = apiComponent.getApiDescription().resolveAnnotations(method.getEnclosingType().getHandle());
              int pres = 0;
              if (annot != null) {
                pres = annot.getRestrictions();
              }
              return ((ares & 0x8) != 0) && (!Flags.isFinal(method.getModifiers())) && (!Flags.isStatic(method.getModifiers())) && (!Flags.isFinal(method.getEnclosingType().getModifiers())) && ((pres & 0x2) == 0);
            }
            return (ares & 0x8) == 0;
          }
          return (!Flags.isProtected(method.getModifiers())) || (!Flags.isFinal(method.getEnclosingType().getModifiers()));
        }
      }
      else {
        return true;
      }
    }
    catch (CoreException e)
    {
      ApiPlugin.log(e);
    }
    return false;
  }
  
  protected boolean matchesSourceModifiers(IApiMember member)
  {
    IApiMember lmember = member;
    while (lmember != null)
    {
      int modifiers = lmember.getModifiers();
      if ((Flags.isPublic(modifiers)) || (Flags.isProtected(modifiers))) {
        try
        {
          lmember = lmember.getEnclosingType();
        }
        catch (CoreException e)
        {
          ApiPlugin.log(e.getStatus());
          return false;
        }
      } else {
        return false;
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.MethodLeakDetector
 * 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.List;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.provisional.ApiDescriptionVisitor;
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.RestrictionModifiers;
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IFieldDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMethodDescriptor;
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.IApiComponent;

public class ProblemDetectorBuilder
  extends ApiDescriptionVisitor
{
  public static int K_ALL = -1;
  public static int K_USE = 1;
  public static int K_LEAK = 2;
  public static int K_SYSTEM = 4;
  private IllegalExtendsProblemDetector fIllegalExtends = null;
  private IllegalImplementsProblemDetector fIllegalImplements = null;
  private IllegalInstantiateProblemDetector fIllegalInstantiate = null;
  private IllegalOverrideProblemDetector fIllegalOverride = null;
  private IllegalMethodReferenceDetector fIllegalMethodRef = null;
  private IllegalFieldReferenceDetector fIllegalFieldRef = null;
  private SystemApiDetector fSystemApiDetector = null;
  private Set fNonApiPackageNames = new HashSet();
  private IApiComponent fComponent = null;
  private List fDetectors;
  private int fKindMask = 0;
  
  public ProblemDetectorBuilder(IApiComponent component, int kinds)
  {
    fKindMask = kinds;
    initializeDetectors(component);
  }
  
  public boolean visitElement(IElementDescriptor element, IApiAnnotations description)
  {
    int mask = description.getRestrictions();
    switch (element.getElementType())
    {
    case 1: 
      if (VisibilityModifiers.isPrivate(description.getVisibility()))
      {
        fNonApiPackageNames.add(((IPackageDescriptor)element).getName());
        return false;
      }
      break;
    default: 
      if (((fKindMask & K_USE) > 0) && 
        (!RestrictionModifiers.isUnrestricted(mask)))
      {
        if ((RestrictionModifiers.isOverrideRestriction(mask)) && (fIllegalOverride != null)) {
          fIllegalOverride.addIllegalMethod((IMethodDescriptor)element, fComponent.getSymbolicName());
        }
        if ((RestrictionModifiers.isExtendRestriction(mask)) && (fIllegalExtends != null)) {
          fIllegalExtends.addIllegalType((IReferenceTypeDescriptor)element, fComponent.getSymbolicName());
        }
        if ((RestrictionModifiers.isImplementRestriction(mask)) && (fIllegalImplements != null)) {
          fIllegalImplements.addIllegalType((IReferenceTypeDescriptor)element, fComponent.getSymbolicName());
        }
        if ((RestrictionModifiers.isInstantiateRestriction(mask)) && (fIllegalInstantiate != null)) {
          fIllegalInstantiate.addIllegalType((IReferenceTypeDescriptor)element, fComponent.getSymbolicName());
        }
        if (RestrictionModifiers.isReferenceRestriction(mask)) {
          if ((element.getElementType() == 6) && (fIllegalMethodRef != null)) {
            fIllegalMethodRef.addIllegalMethod((IMethodDescriptor)element, fComponent.getSymbolicName());
          } else if ((element.getElementType() == 5) && (fIllegalFieldRef != null)) {
            fIllegalFieldRef.addIllegalField((IFieldDescriptor)element, fComponent.getSymbolicName());
          }
        }
      }
      break;
    }
    return true;
  }
  
  public void setOwningComponent(IApiComponent component)
  {
    fComponent = component;
  }
  
  private IProject getProject(IApiComponent component)
  {
    if ((component instanceof ProjectComponent))
    {
      ProjectComponent comp = (ProjectComponent)component;
      return comp.getJavaProject().getProject();
    }
    return null;
  }
  
  private void initializeDetectors(IApiComponent component)
  {
    fDetectors = new ArrayList();
    IProject project = getProject(component);
    if ((fKindMask & K_USE) > 0) {
      addUseDetectors(fDetectors, project);
    }
    if ((fKindMask & K_SYSTEM) > 0) {
      addSystemDetector(fDetectors, project);
    }
    if ((fKindMask & K_LEAK) > 0) {
      addLeakDetectors(fDetectors, project);
    }
  }
  
  private boolean isIgnore(String problemKey, IProject project)
  {
    int severity = ApiPlugin.getDefault().getSeverityLevel(problemKey, project);
    return severity == 0;
  }
  
  Set getNonApiPackageNames()
  {
    return fNonApiPackageNames;
  }
  
  public boolean addNonApiPackageName(String packagee)
  {
    if (packagee != null) {
      return fNonApiPackageNames.add(packagee);
    }
    return false;
  }
  
  public List getProblemDetectors()
  {
    return fDetectors;
  }
  
  private void addSystemDetector(List detectors, IProject project)
  {
    if (project != null)
    {
      if ((!isIgnore("INVALID_REFERENCE_IN_SYSTEM_LIBRARIES", project)) && 
        (fSystemApiDetector == null))
      {
        fSystemApiDetector = new SystemApiDetector();
        fDetectors.add(fSystemApiDetector);
      }
    }
    else
    {
      fSystemApiDetector = new SystemApiDetector();
      fDetectors.add(fSystemApiDetector);
    }
  }
  
  private void addUseDetectors(List detectors, IProject project)
  {
    if (project != null)
    {
      if ((!isIgnore("ILLEGAL_EXTEND", project)) && (fIllegalExtends == null))
      {
        fIllegalExtends = new IllegalExtendsProblemDetector();
        detectors.add(fIllegalExtends);
      }
      if ((!isIgnore("ILLEGAL_IMPLEMENT", project)) && (fIllegalImplements == null))
      {
        fIllegalImplements = new IllegalImplementsProblemDetector();
        detectors.add(fIllegalImplements);
      }
      if ((!isIgnore("ILLEGAL_INSTANTIATE", project)) && (fIllegalInstantiate == null))
      {
        fIllegalInstantiate = new IllegalInstantiateProblemDetector();
        detectors.add(fIllegalInstantiate);
      }
      if ((!isIgnore("ILLEGAL_OVERRIDE", project)) && (fIllegalOverride == null))
      {
        fIllegalOverride = new IllegalOverrideProblemDetector();
        detectors.add(fIllegalOverride);
      }
      if ((!isIgnore("ILLEGAL_REFERENCE", project)) && (fIllegalMethodRef == null))
      {
        fIllegalMethodRef = new IllegalMethodReferenceDetector();
        detectors.add(fIllegalMethodRef);
        fIllegalFieldRef = new IllegalFieldReferenceDetector();
        detectors.add(fIllegalFieldRef);
      }
    }
    else
    {
      fIllegalExtends = new IllegalExtendsProblemDetector();
      detectors.add(fIllegalExtends);
      fIllegalImplements = new IllegalImplementsProblemDetector();
      detectors.add(fIllegalImplements);
      fIllegalInstantiate = new IllegalInstantiateProblemDetector();
      detectors.add(fIllegalInstantiate);
      fIllegalOverride = new IllegalOverrideProblemDetector();
      detectors.add(fIllegalOverride);
      fIllegalMethodRef = new IllegalMethodReferenceDetector();
      detectors.add(fIllegalMethodRef);
      fIllegalFieldRef = new IllegalFieldReferenceDetector();
      detectors.add(fIllegalFieldRef);
    }
  }
  
  private void addLeakDetectors(List detectors, IProject project)
  {
    if (project != null)
    {
      if (!isIgnore("LEAK_EXTEND", project)) {
        detectors.add(new LeakExtendsProblemDetector(fNonApiPackageNames));
      }
      if (!isIgnore("LEAK_IMPLEMENT", project)) {
        detectors.add(new LeakImplementsProblemDetector(fNonApiPackageNames));
      }
      if (!isIgnore("LEAK_FIELD_DECL", project)) {
        detectors.add(new LeakFieldProblemDetector(fNonApiPackageNames));
      }
      if (!isIgnore("LEAK_METHOD_PARAM", project)) {
        detectors.add(new LeakParameterTypeDetector(fNonApiPackageNames));
      }
      if (!isIgnore("LEAK_METHOD_RETURN_TYPE", project)) {
        detectors.add(new LeakReturnTypeDetector(fNonApiPackageNames));
      }
    }
    else
    {
      detectors.add(new LeakExtendsProblemDetector(fNonApiPackageNames));
      detectors.add(new LeakImplementsProblemDetector(fNonApiPackageNames));
      detectors.add(new LeakFieldProblemDetector(fNonApiPackageNames));
      detectors.add(new LeakReturnTypeDetector(fNonApiPackageNames));
      detectors.add(new LeakParameterTypeDetector(fNonApiPackageNames));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.ProblemDetectorBuilder
 * 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.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.Flags;
import org.eclipse.pde.api.tools.internal.model.StubApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.Factory;
import org.eclipse.pde.api.tools.internal.provisional.IApiAccess;
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.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
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.provisional.problems.IApiProblem;
import org.eclipse.pde.api.tools.internal.search.IReferenceDescriptor;
import org.eclipse.pde.api.tools.internal.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;

public class Reference
  implements IReference
{
  private int fSourceLine = -1;
  private IApiMember fSourceMember;
  private int fKind;
  private int fFlags = 0;
  private int fType;
  private String fTypeName;
  private String fMemberName;
  private String fSignature;
  private IApiMember fResolved;
  private boolean fStatus = true;
  private List fProblems = null;
  
  public boolean addProblems(IApiProblem problem)
  {
    if (problem == null) {
      return false;
    }
    if (fProblems == null) {
      fProblems = new ArrayList(2);
    }
    if (fProblems.contains(problem)) {
      return false;
    }
    return fProblems.add(problem);
  }
  
  public List getProblems()
  {
    return fProblems;
  }
  
  public int getLineNumber()
  {
    return fSourceLine;
  }
  
  public IApiMember getMember()
  {
    return fSourceMember;
  }
  
  public int getReferenceKind()
  {
    return fKind;
  }
  
  public int getReferenceFlags()
  {
    return fFlags;
  }
  
  public void setFlags(int newflags)
  {
    fFlags |= newflags;
  }
  
  public int getReferenceType()
  {
    return fType;
  }
  
  public IApiMember getResolvedReference()
  {
    return fResolved;
  }
  
  public String getReferencedMemberName()
  {
    return fMemberName;
  }
  
  public String getReferencedSignature()
  {
    return fSignature;
  }
  
  public String getReferencedTypeName()
  {
    return fTypeName;
  }
  
  public static Reference methodReference(IApiMember origin, String typeName, String methodName, String signature, int kind)
  {
    Reference ref = new Reference();
    fSourceMember = origin;
    fTypeName = typeName;
    fMemberName = methodName;
    fSignature = signature;
    fKind = kind;
    fType = 3;
    return ref;
  }
  
  public static Reference fieldReference(IApiMember origin, String typeName, String fieldName, int kind)
  {
    Reference ref = new Reference();
    fSourceMember = origin;
    fTypeName = typeName;
    fMemberName = fieldName;
    fKind = kind;
    fType = 2;
    return ref;
  }
  
  public static Reference typeReference(IApiMember origin, String typeName, int kind)
  {
    Reference ref = new Reference();
    fSourceMember = origin;
    fTypeName = typeName;
    fKind = kind;
    fType = 1;
    return ref;
  }
  
  public static Reference typeReference(IApiMember origin, String typeName, String signature, int kind)
  {
    Reference ref = typeReference(origin, typeName, kind);
    fSignature = signature;
    return ref;
  }
  
  void setLineNumber(int line)
  {
    fSourceLine = line;
  }
  
  public void resolve()
    throws CoreException
  {
    if (!fStatus) {
      return;
    }
    if (fResolved == null)
    {
      IApiComponent sourceComponent = getMember().getApiComponent();
      if (sourceComponent != null)
      {
        IApiTypeRoot result = Util.getClassFile(
          sourceComponent.getBaseline().resolvePackage(sourceComponent, Signatures.getPackageName(getReferencedTypeName())), 
          getReferencedTypeName());
        if (result != null)
        {
          IApiType type = result.getStructure();
          if (type == null) {
            return;
          }
          switch (getReferenceType())
          {
          case 1: 
            fResolved = type;
            break;
          case 2: 
            resolveField(type, getReferencedMemberName());
            break;
          case 3: 
            resolveVirtualMethod(type, getReferencedMemberName(), getReferencedSignature());
          }
        }
      }
    }
  }
  
  public boolean resolve(int eeValue)
    throws CoreException
  {
    IApiComponent sourceComponent = StubApiComponent.getStubApiComponent(eeValue);
    if (sourceComponent == null) {
      return true;
    }
    IApiTypeRoot result = Util.getClassFile(
      new IApiComponent[] { sourceComponent }, 
      getReferencedTypeName());
    if (result != null)
    {
      IApiType type = result.getStructure();
      if (type == null) {
        return false;
      }
      switch (getReferenceType())
      {
      case 1: 
        return true;
      case 2: 
        return resolveField(type, getReferencedMemberName());
      case 3: 
        return resolveMethod(sourceComponent, type, getReferencedMemberName(), getReferencedSignature());
      }
    }
    return false;
  }
  
  private boolean resolveField(IApiType type, String fieldame)
    throws CoreException
  {
    IApiField field = type.getField(fieldame);
    if (field != null)
    {
      fResolved = field;
      return true;
    }
    IApiType superT = type.getSuperclass();
    if (superT != null) {
      return resolveField(superT, fieldame);
    }
    return false;
  }
  
  private boolean resolveVirtualMethod(IApiType type, String methodName, String methodSignature)
    throws CoreException
  {
    IApiMethod target = type.getMethod(methodName, methodSignature);
    if (target != null)
    {
      if (target.isSynthetic()) {
        return false;
      }
      fResolved = target;
      return true;
    }
    if (getReferenceKind() == 512)
    {
      IApiType[] interfaces = type.getSuperInterfaces();
      if (interfaces != null) {
        for (int i = 0; i < interfaces.length; i++) {
          if (resolveVirtualMethod(interfaces[i], methodName, methodSignature)) {
            return true;
          }
        }
      }
    }
    else
    {
      IApiType superT = type.getSuperclass();
      if (superT != null) {
        return resolveVirtualMethod(superT, methodName, methodSignature);
      }
    }
    return false;
  }
  
  private boolean resolveMethod(IApiComponent sourceComponent, IApiType type, String methodName, String methodSignature)
    throws CoreException
  {
    IApiMethod target = type.getMethod(methodName, methodSignature);
    if (target != null)
    {
      if (target.isSynthetic()) {
        return false;
      }
      return true;
    }
    switch (fKind)
    {
    case 512: 
      String[] interfacesNames = type.getSuperInterfaceNames();
      if (interfacesNames != null)
      {
        int i = 0;
        for (int max = interfacesNames.length; i < max; i++)
        {
          IApiTypeRoot classFile = Util.getClassFile(
            new IApiComponent[] { sourceComponent }, 
            interfacesNames[i]);
          IApiType superinterface = classFile.getStructure();
          if ((superinterface != null) && (resolveMethod(sourceComponent, superinterface, methodName, methodSignature))) {
            return true;
          }
        }
      }
      break;
    case 128: 
      String superclassName = type.getSuperclassName();
      if (superclassName != null)
      {
        IApiTypeRoot classFile = Util.getClassFile(
          new IApiComponent[] { sourceComponent }, 
          superclassName);
        IApiType superclass = classFile.getStructure();
        boolean resolved = resolveMethod(sourceComponent, superclass, methodName, methodSignature);
        if (resolved) {
          return resolved;
        }
      }
      break;
    case 256: 
    case 1048576: 
      target = type.getMethod(methodName, "([Ljava/lang/Object;)Ljava/lang/Object;");
      if ((target != null) && 
        (methodName.equals(target.getName())) && (target.isPolymorphic())) {
        return true;
      }
      String superclassName = type.getSuperclassName();
      if (superclassName != null)
      {
        IApiTypeRoot classFile = Util.getClassFile(
          new IApiComponent[] { sourceComponent }, 
          superclassName);
        IApiType superclass = classFile.getStructure();
        boolean resolved = resolveMethod(sourceComponent, superclass, methodName, methodSignature);
        if (resolved) {
          return resolved;
        }
      }
      if (Flags.isAbstract(type.getModifiers()))
      {
        String[] interfacesNames = type.getSuperInterfaceNames();
        if (interfacesNames != null)
        {
          int i = 0;
          for (int max = interfacesNames.length; i < max; i++)
          {
            IApiTypeRoot classFile = Util.getClassFile(
              new IApiComponent[] { sourceComponent }, 
              interfacesNames[i]);
            IApiType superinterface = classFile.getStructure();
            if ((superinterface != null) && (resolveMethod(sourceComponent, superinterface, methodName, methodSignature))) {
              return true;
            }
          }
        }
      }
      break;
    }
    return false;
  }
  
  public void setResolution(IApiMember resolution)
  {
    fResolved = resolution;
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer();
    buf.append("From: ");
    IApiMember member = getMember();
    buf.append(member.getHandle().toString());
    buf.append(" [line: ").append(getLineNumber()).append("]");
    if (getResolvedReference() == null)
    {
      buf.append("\nUnresolved To: ");
      buf.append(getReferencedTypeName());
      if (getReferencedMemberName() != null)
      {
        buf.append('#');
        buf.append(getReferencedMemberName());
      }
      if (getReferencedSignature() != null)
      {
        buf.append('#');
        buf.append(getReferencedSignature());
      }
    }
    else
    {
      buf.append("\nResolved To: ");
      buf.append(getResolvedReference().getHandle().toString());
    }
    buf.append("\nKind: ");
    buf.append(getReferenceText(getReferenceKind()));
    return buf.toString();
  }
  
  public void setResolveStatus(boolean value)
  {
    fStatus = value;
  }
  
  public static final String getReferenceText(int kind)
  {
    StringBuffer buffer = new StringBuffer();
    if ((kind & 0x1) > 0) {
      buffer.append("EXTENDS");
    }
    if ((kind & 0x2) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("IMPLEMENTS");
    }
    if ((kind & 0x100000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("INVOKED_SPECIAL");
    }
    if ((kind & 0x80) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("INVOKED_STATIC");
    }
    if ((kind & 0x4000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("PUT_FIELD");
    }
    if ((kind & 0x1000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("PUT_STATIC_FIELD");
    }
    if ((kind & 0x4) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("DECLARED_FIELD");
    }
    if ((kind & 0x200000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("DECLARED_PARAMETERIZED_TYPE");
    }
    if ((kind & 0x400000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("DECLARED_PARAMETERIZED_FIELD");
    }
    if ((kind & 0x800000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("DECLARED_PARAMETERIZED_METHOD");
    }
    if ((kind & 0x10) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("PARAMETER");
    }
    if ((kind & 0x2000000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("LOCAL_VAR_DECLARED");
    }
    if ((kind & 0x1000000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("DECLARED_PARAMETERIZED_VARIABLE");
    }
    if ((kind & 0x20) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("THROWS");
    }
    if ((kind & 0x40000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("CASTS");
    }
    if ((kind & 0x8000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("ALLOCATES_ARRAY");
    }
    if ((kind & 0x20000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("CATCHES_EXCEPTION");
    }
    if ((kind & 0x2000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("GETS_FIELD");
    }
    if ((kind & 0x800) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("GETS_STATIC_FIELD");
    }
    if ((kind & 0x80000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("INSTANCEOF");
    }
    if ((kind & 0x200) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("INTERFACE_METHOD");
    }
    if ((kind & 0x40) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("CONSTRUCTOR_METHOD");
    }
    if ((kind & 0x10000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("LOCAL_VARIABLE");
    }
    if ((kind & 0x400) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("PASSED_PARAMETER");
    }
    if ((kind & 0x8) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("RETURN_TYPE");
    }
    if ((kind & 0x100) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("VIRTUAL_METHOD");
    }
    if ((kind & 0x4000000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("CONSTANT_POOL");
    }
    if ((kind & 0x8000000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("INSTANTIATION");
    }
    if ((kind & 0x10000000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("OVERRIDE");
    }
    if ((kind & 0x20000000) > 0)
    {
      if (buffer.length() != 0) {
        buffer.append(" | ");
      }
      buffer.append("SUPER_CONSTRUCTORMETHOD");
    }
    if (buffer.length() == 0) {
      buffer.append("UNKNOWN_KIND");
    }
    return buffer.toString();
  }
  
  public IReferenceDescriptor getReferenceDescriptor()
    throws CoreException
  {
    IApiMember res = getResolvedReference();
    if (res == null) {
      return null;
    }
    IApiComponent rcomponent = res.getApiComponent();
    IApiDescription description = rcomponent.getApiDescription();
    IApiAnnotations annot = description.resolveAnnotations(getResolvedReference().getHandle());
    int visibility = -1;
    IApiComponent mcomponent = getMember().getApiComponent();
    if (annot != null)
    {
      visibility = annot.getVisibility();
      if (annot.getVisibility() == 2)
      {
        IApiComponent host = mcomponent.getHost();
        if ((host != null) && (host.getSymbolicName().equals(rcomponent.getSymbolicName())))
        {
          visibility = 5;
        }
        else
        {
          IApiAccess access = description.resolveAccessLevel(
            Factory.componentDescriptor(mcomponent.getSymbolicName()), 
            getResolvedReference().getHandle().getPackage());
          if ((access != null) && (access.getAccessLevel() == 1)) {
            visibility = 8;
          }
        }
      }
    }
    else
    {
      visibility = 65535;
    }
    String[] messages = (String[])null;
    if (fProblems != null)
    {
      messages = new String[fProblems.size()];
      for (int i = 0; i < messages.length; i++) {
        messages[i] = ((IApiProblem)fProblems.get(i)).getMessage();
      }
    }
    return Factory.referenceDescriptor(
      (IComponentDescriptor)mcomponent.getHandle(), 
      getMember().getHandle(), 
      getLineNumber(), 
      (IComponentDescriptor)rcomponent.getHandle(), 
      res.getHandle(), 
      getReferenceKind(), 
      getReferenceFlags(), 
      visibility, 
      messages);
  }
}

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

import org.eclipse.pde.api.tools.internal.provisional.ApiDescriptionVisitor;
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;

class ReferenceAnalyzer$1
  extends ApiDescriptionVisitor
{
  final ReferenceAnalyzer this$0;
  private final ProblemDetectorBuilder val$visitor;
  
  ReferenceAnalyzer$1(ReferenceAnalyzer paramReferenceAnalyzer, ProblemDetectorBuilder paramProblemDetectorBuilder)
  {
    this$0 = paramReferenceAnalyzer;val$visitor = paramProblemDetectorBuilder;
  }
  
  public boolean visitElement(IElementDescriptor element, IApiAnnotations description)
  {
    if ((element.getElementType() == 1) && 
      (VisibilityModifiers.isPrivate(description.getVisibility()))) {
      val$visitor.addNonApiPackageName(((IPackageDescriptor)element).getName());
    }
    return false;
  }
}

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

import com.ibm.icu.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.pde.api.tools.internal.provisional.builder.IApiProblemDetector;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;

class ReferenceAnalyzer$Visitor
  extends ApiTypeContainerVisitor
{
  private IProgressMonitor fMonitor;
  final ReferenceAnalyzer this$0;
  
  public ReferenceAnalyzer$Visitor(ReferenceAnalyzer paramReferenceAnalyzer, IProgressMonitor monitor)
  {
    this$0 = paramReferenceAnalyzer;fMonitor = null;
    fMonitor = monitor;
  }
  
  public boolean visitPackage(String packageName)
  {
    fMonitor.subTask(MessageFormat.format(BuilderMessages.ReferenceAnalyzer_checking_api_used_by, new String[] { packageName }));
    return true;
  }
  
  public void endVisitPackage(String packageName)
  {
    fMonitor.worked(1);
  }
  
  public void visit(String packageName, IApiTypeRoot classFile)
  {
    if (!fMonitor.isCanceled()) {
      try
      {
        IApiType type = classFile.getStructure();
        if (type == null) {
          return;
        }
        if ((type.isMemberType()) || (type.isLocal()) || (type.isAnonymous())) {
          return;
        }
        List references = type.extractReferences(this$0.fAllReferenceKinds, null);
        
        Iterator iterator = references.iterator();
        while (iterator.hasNext())
        {
          IReference ref = (IReference)iterator.next();
          
          int index = this$0.getLog2(ref.getReferenceKind());
          IApiProblemDetector[] detectors = this$0.fIndexedDetectors[index];
          boolean added = false;
          if (detectors != null) {
            for (int i = 0; i < detectors.length; i++)
            {
              IApiProblemDetector detector = detectors[i];
              if ((detector.considerReference(ref)) && 
                (!added))
              {
                this$0.fReferences.add(ref);
                added = true;
              }
            }
          }
        }
      }
      catch (CoreException e)
      {
        this$0.fStatus.add(e.getStatus());
      }
    }
  }
}

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

import com.ibm.icu.text.MessageFormat;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.pde.api.tools.internal.provisional.ApiDescriptionVisitor;
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.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.builder.IApiProblemDetector;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
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.IApiType;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
import org.eclipse.pde.api.tools.internal.util.Util;

public class ReferenceAnalyzer
{
  private static final double LOG2 = Math.log(2.0D);
  private static boolean DEBUG = Util.DEBUG;
  private static final IApiProblem[] EMPTY_RESULT = new IApiProblem[0];
  private static final IApiProblemDetector[] NO_PROBLEM_DETECTORS = new IApiProblemDetector[0];
  MultiStatus fStatus;
  
  class Visitor
    extends ApiTypeContainerVisitor
  {
    private IProgressMonitor fMonitor = null;
    
    public Visitor(IProgressMonitor monitor)
    {
      fMonitor = monitor;
    }
    
    public boolean visitPackage(String pac
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