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

kageName)
    {
      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(fAllReferenceKinds, null);
          
          Iterator iterator = references.iterator();
          while (iterator.hasNext())
          {
            IReference ref = (IReference)iterator.next();
            
            int index = getLog2(ref.getReferenceKind());
            IApiProblemDetector[] detectors = 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))
                {
                  fReferences.add(ref);
                  added = true;
                }
              }
            }
          }
        }
        catch (CoreException e)
        {
          fStatus.add(e.getStatus());
        }
      }
    }
  }
  
  int fAllReferenceKinds = 0;
  List fReferences = new LinkedList();
  IApiProblemDetector[][] fIndexedDetectors;
  
  public static void setDebug(boolean debugValue)
  {
    DEBUG = (debugValue) || (Util.DEBUG);
  }
  
  void indexProblemDetectors(IApiProblemDetector[] detectors)
  {
    fIndexedDetectors = new IApiProblemDetector[32][];
    for (int i = 0; i < detectors.length; i++)
    {
      IApiProblemDetector detector = detectors[i];
      int kinds = detector.getReferenceKinds();
      fAllReferenceKinds |= kinds;
      int mask = 1;
      for (int bit = 0; bit < 32; bit++)
      {
        if ((mask & kinds) > 0)
        {
          IApiProblemDetector[] indexed = fIndexedDetectors[bit];
          if (indexed == null)
          {
            fIndexedDetectors[bit] = { detector };
          }
          else
          {
            IApiProblemDetector[] next = new IApiProblemDetector[indexed.length + 1];
            System.arraycopy(indexed, 0, next, 0, indexed.length);
            next[indexed.length] = detector;
            fIndexedDetectors[bit] = next;
          }
        }
        mask <<= 1;
      }
    }
  }
  
  int getLog2(int bitConstant)
  {
    double logX = Math.log(bitConstant);
    double pow = logX / LOG2;
    return (int)Math.round(pow);
  }
  
  void extractReferences(IApiTypeContainer scope, IProgressMonitor monitor)
    throws CoreException
  {
    fStatus = new MultiStatus("org.eclipse.pde.api.tools", 0, BuilderMessages.ReferenceAnalyzer_api_analysis_error, null);
    String[] packageNames = scope.getPackageNames();
    SubMonitor localMonitor = SubMonitor.convert(monitor, packageNames.length);
    ApiTypeContainerVisitor visitor = new Visitor(localMonitor);
    long start = System.currentTimeMillis();
    try
    {
      scope.accept(visitor);
    }
    catch (CoreException e)
    {
      fStatus.add(e.getStatus());
    }
    long end = System.currentTimeMillis();
    if (!fStatus.isOK()) {
      throw new CoreException(fStatus);
    }
    localMonitor.done();
    if (DEBUG) {
      System.out.println("Reference Analyzer: extracted " + fReferences.size() + " references in " + (end - start) + "ms");
    }
  }
  
  public IApiProblem[] analyze(IApiComponent component, IApiTypeContainer scope, IProgressMonitor monitor)
    throws CoreException
  {
    IApiProblemDetector[] detectors = buildProblemDetectors(component, ProblemDetectorBuilder.K_ALL, monitor);
    try
    {
      SubMonitor localMonitor = SubMonitor.convert(monitor, BuilderMessages.ReferenceAnalyzer_analyzing_api, 3);
      localMonitor.subTask(BuilderMessages.ReferenceAnalyzer_analyzing_api_checking_use);
      extractReferences(scope, localMonitor);
      localMonitor.worked(1);
      IApiProblem[] arrayOfIApiProblem1;
      if (localMonitor.isCanceled()) {
        return EMPTY_RESULT;
      }
      localMonitor.subTask(BuilderMessages.ReferenceAnalyzer_analyzing_api_checking_use);
      if (fReferences.size() != 0) {
        ReferenceResolver.resolveReferences(fReferences, localMonitor);
      }
      localMonitor.worked(1);
      if (localMonitor.isCanceled()) {
        return EMPTY_RESULT;
      }
      List allProblems = new LinkedList();
      localMonitor.subTask(BuilderMessages.ReferenceAnalyzer_analyzing_api_checking_use);
      for (int i = 0; i < detectors.length; i++)
      {
        IApiProblemDetector detector = detectors[i];
        List problems = detector.createProblems();
        allProblems.addAll(problems);
        if (localMonitor.isCanceled()) {
          return EMPTY_RESULT;
        }
      }
      IApiProblem[] array = (IApiProblem[])allProblems.toArray(new IApiProblem[allProblems.size()]);
      localMonitor.worked(1);
      localMonitor.done();
      return array;
    }
    finally
    {
      fIndexedDetectors = null;
      fReferences.clear();
    }
  }
  
  public IApiProblemDetector[] getProblemDetectors(int referencekind)
  {
    if (fIndexedDetectors != null)
    {
      int index = getLog2(referencekind);
      if ((index > -1) && (index < fIndexedDetectors.length))
      {
        IApiProblemDetector[] detectors = fIndexedDetectors[index];
        if (detectors != null) {
          return detectors;
        }
      }
      return NO_PROBLEM_DETECTORS;
    }
    return NO_PROBLEM_DETECTORS;
  }
  
  public IApiProblemDetector[] buildProblemDetectors(IApiComponent component, int kindmask, IProgressMonitor monitor)
  {
    try
    {
      long start = System.currentTimeMillis();
      IApiComponent[] components = component.getBaseline().getPrerequisiteComponents(new IApiComponent[] { component });
      ProblemDetectorBuilder visitor = new ProblemDetectorBuilder(component, kindmask);
      for (int i = 0; i < components.length; i++)
      {
        Util.updateMonitor(monitor);
        IApiComponent prereq = components[i];
        if (!prereq.equals(component))
        {
          visitor.setOwningComponent(prereq);
          try
          {
            prereq.getApiDescription().accept(visitor, monitor);
          }
          catch (CoreException e)
          {
            ApiPlugin.log(e.getStatus());
          }
        }
      }
      long end = System.currentTimeMillis();
      if (DEBUG) {
        System.out.println("Time to build problem detectors: " + (end - start) + "ms");
      }
      ApiDescriptionVisitor nameVisitor = new ApiDescriptionVisitor()
      {
        private final ProblemDetectorBuilder val$visitor;
        
        public boolean visitElement(IElementDescriptor element, IApiAnnotations description)
        {
          if ((element.getElementType() == 1) && 
            (VisibilityModifiers.isPrivate(description.getVisibility()))) {
            val$visitor.addNonApiPackageName(((IPackageDescriptor)element).getName());
          }
          return false;
        }
      };
      component.getApiDescription().accept(nameVisitor, null);
      List detectors = visitor.getProblemDetectors();
      int size = detectors.size();
      if (size == 0) {
        return NO_PROBLEM_DETECTORS;
      }
      IApiProblemDetector[] array = (IApiProblemDetector[])detectors.toArray(new IApiProblemDetector[size]);
      indexProblemDetectors(array);
      return array;
    }
    catch (CoreException e)
    {
      ApiPlugin.log(e);
    }
    return NO_PROBLEM_DETECTORS;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.ReferenceAnalyzer
 * 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.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodAdapter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Type;

class ReferenceExtractor$ClassFileMethodVisitor
  extends MethodAdapter
{
  int argumentcount;
  ReferenceExtractor.LinePositionTracker linePositionTracker;
  String stringLiteral;
  String methodName;
  int lastLineNumber;
  boolean implicitConstructor;
  ReferenceExtractor.LocalLineNumberMarker localVariableMarker;
  HashMap labelsToLocalMarkers;
  final ReferenceExtractor this$0;
  
  public ReferenceExtractor$ClassFileMethodVisitor(ReferenceExtractor paramReferenceExtractor, MethodVisitor mv, String name, int argumentcount)
  {
    super(mv);this$0 = paramReferenceExtractor;this.argumentcount = 0;implicitConstructor = false;
    this.argumentcount = argumentcount;
    linePositionTracker = new ReferenceExtractor.LinePositionTracker();
    lastLineNumber = -1;
    labelsToLocalMarkers = new HashMap();
    methodName = name;
  }
  
  public void visitEnd()
  {
    implicitConstructor = false;
    argumentcount = 0;
    this$0.exitMember();
    linePositionTracker.computeLineNumbers();
    labelsToLocalMarkers = null;
  }
  
  public void visitVarInsn(int opcode, int var)
  {
    switch (opcode)
    {
    case 58: 
      if (lastLineNumber != -1) {
        localVariableMarker = new ReferenceExtractor.LocalLineNumberMarker(lastLineNumber, var);
      }
      break;
    }
  }
  
  public void visitFieldInsn(int opcode, String owner, String name, String desc)
  {
    int refType = -1;
    switch (opcode)
    {
    case 179: 
      refType = 4096;
      break;
    case 181: 
      refType = 16384;
      break;
    case 178: 
      refType = 2048;
      break;
    case 180: 
      refType = 8192;
    }
    if (refType != -1)
    {
      Reference reference = this$0.addFieldReference(Type.getObjectType(owner), name, refType);
      if (reference != null)
      {
        linePositionTracker.addLocation(reference);
        if ((refType == 8192) || (refType == 16384)) {
          this$0.fieldtracker.addField(reference);
        }
      }
    }
  }
  
  public void visitTryCatchBlock(Label start, Label end, Label handler, String type)
  {
    if (type != null)
    {
      Type ctype = Type.getObjectType(type);
      Reference reference = this$0.addTypeReference(ctype, 131072);
      if (reference != null)
      {
        linePositionTracker.addCatchLabelInfos(reference, handler);
        linePositionTracker.addLocation(reference);
      }
    }
  }
  
  public void visitLabel(Label label)
  {
    linePositionTracker.addLabel(label);
    if (localVariableMarker != null)
    {
      Object object = labelsToLocalMarkers.get(label);
      if (object != null)
      {
        if ((object instanceof List))
        {
          ((List)object).add(localVariableMarker);
        }
        else
        {
          List list = new ArrayList();
          list.add(object);
          list.add(localVariableMarker);
          labelsToLocalMarkers.put(label, list);
        }
      }
      else {
        labelsToLocalMarkers.put(label, localVariableMarker);
      }
      localVariableMarker = null;
    }
  }
  
  public void visitMethodInsn(int opcode, String owner, String name, String desc)
  {
    Type declaringType = Type.getObjectType(owner);
    int kind = -1;
    switch (opcode)
    {
    case 183: 
      kind = "<init>".equals(name) ? 64 : 1048576;
      if (kind == 64) {
        if ((!implicitConstructor) && (methodName.equals("<init>")) && (!this$0.fSuperStack.isEmpty()) && (this$0.fSuperStack.peek().equals(declaringType.getClassName())))
        {
          implicitConstructor = true;
          kind = 536870912;
        }
        else
        {
          Reference reference = this$0.addTypeReference(declaringType, 134217728);
          if (reference != null) {
            linePositionTracker.addLocation(reference);
          }
        }
      }
      break;
    case 184: 
      kind = 128;
      if ((name.equals("forName")) && 
        (this$0.processName(owner).equals("java.lang.Class")) && 
        (stringLiteral != null))
      {
        Type classLiteral = Type.getObjectType(stringLiteral);
        Reference reference = this$0.addTypeReference(classLiteral, 67108864);
        if (reference != null) {
          linePositionTracker.addLocation(reference);
        }
      }
      break;
    case 182: 
      kind = 256;
      break;
    case 185: 
      kind = 512;
    }
    if (kind != -1)
    {
      Reference reference = this$0.addMethodReference(declaringType, name, desc, kind);
      if (reference != null)
      {
        linePositionTracker.addLocation(reference);
        if (kind == 128) {
          this$0.fieldtracker.addAccessor(reference);
        }
      }
    }
    stringLiteral = null;
  }
  
  public void visitMultiANewArrayInsn(String desc, int dims)
  {
    Type type = getTypeFromDescription(desc);
    Reference reference = this$0.addTypeReference(type, 32768);
    if (reference != null) {
      linePositionTracker.addLocation(reference);
    }
  }
  
  public void visitLineNumber(int line, Label start)
  {
    lastLineNumber = line;
    linePositionTracker.addLineInfo(line, start);
  }
  
  public void visitCode()
  {
    super.visitCode();
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("Method visitor for: ");
    buffer.append(methodName);
    buffer.append("\nCurrent line number: ");
    buffer.append(lastLineNumber);
    return buffer.toString();
  }
  
  private Type getTypeFromDescription(String desc)
  {
    String ldesc = desc;
    while (ldesc.charAt(0) == '[') {
      ldesc = ldesc.substring(1);
    }
    Type type = null;
    if (ldesc.endsWith(";")) {
      type = Type.getType(ldesc);
    } else {
      type = Type.getObjectType(ldesc);
    }
    return type;
  }
  
  public void visitTypeInsn(int opcode, String desc)
  {
    Type type = getTypeFromDescription(desc);
    int kind = -1;
    switch (opcode)
    {
    case 189: 
      kind = 32768;
      break;
    case 192: 
      kind = 262144;
      break;
    case 193: 
      kind = 524288;
      break;
    case 187: 
      List refs = (List)this$0.fAnonymousTypes.get(this$0.processName(type.getInternalName()));
      if (refs != null) {
        for (Iterator iterator = refs.iterator(); iterator.hasNext();) {
          linePositionTracker.addLocation((Reference)iterator.next());
        }
      }
      break;
    }
    if (kind != -1)
    {
      Reference reference = this$0.addTypeReference(type, kind);
      if (reference != null) {
        linePositionTracker.addLocation(reference);
      }
    }
  }
  
  public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index)
  {
    if (desc.length() == 1) {
      return;
    }
    if (index > argumentcount)
    {
      Object object = labelsToLocalMarkers.get(start);
      int lineNumber = -1;
      if (object != null) {
        if ((object instanceof List))
        {
          List markersList = (List)object;
          ReferenceExtractor.LocalLineNumberMarker removeMarker = null;
          for (Iterator iterator = markersList.iterator(); iterator.hasNext();)
          {
            ReferenceExtractor.LocalLineNumberMarker marker = (ReferenceExtractor.LocalLineNumberMarker)iterator.next();
            if (varIndex == index)
            {
              lineNumber = lineNumber;
              removeMarker = marker;
              break;
            }
          }
          if (removeMarker != null)
          {
            markersList.remove(removeMarker);
            if (markersList.isEmpty()) {
              labelsToLocalMarkers.remove(start);
            }
          }
        }
        else
        {
          ReferenceExtractor.LocalLineNumberMarker marker = (ReferenceExtractor.LocalLineNumberMarker)object;
          if (varIndex == index)
          {
            lineNumber = lineNumber;
            labelsToLocalMarkers.remove(start);
          }
        }
      }
      if (lineNumber == -1) {
        return;
      }
      if (signature != null)
      {
        List references = this$0.processSignature(name, signature, 16777216, ReferenceExtractor.METHOD);
        for (Iterator iterator = references.iterator(); iterator.hasNext();)
        {
          Reference reference = (Reference)iterator.next();
          reference.setLineNumber(lineNumber);
        }
      }
      else
      {
        Type type = Type.getType(desc);
        if (type.getSort() == 10)
        {
          Reference reference = this$0.addTypeReference(type, 33554432);
          if (reference != null) {
            reference.setLineNumber(lineNumber);
          }
        }
      }
    }
  }
  
  public void visitLdcInsn(Object cst)
  {
    if ((cst instanceof Type))
    {
      Type type = (Type)cst;
      Reference reference = this$0.addTypeReference(type, 67108864);
      if (reference != null) {
        linePositionTracker.addLocation(reference);
      }
    }
    else if ((cst instanceof String))
    {
      String str = (String)cst;
      stringLiteral = ("".equals(str) ? null : str);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.ReferenceExtractor.ClassFileMethodVisitor
 * 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.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureVisitor;

class ReferenceExtractor$ClassFileSignatureVisitor
  implements SignatureVisitor
{
  protected int kind;
  protected int originalkind;
  protected int argumentcount;
  protected int type;
  protected String signature;
  protected String name;
  protected List references;
  final ReferenceExtractor this$0;
  
  public ReferenceExtractor$ClassFileSignatureVisitor(ReferenceExtractor paramReferenceExtractor)
  {
    this$0 = paramReferenceExtractor;kind = -1;originalkind = -1;argumentcount = 0;type = 0;signature = null;name = null;
    references = new ArrayList();
  }
  
  protected void reset()
  {
    kind = -1;
    originalkind = -1;
    name = null;
    signature = null;
    type = 0;
    references.clear();
  }
  
  protected void processType(String name)
  {
    Type type = this$0.resolveType(Type.getObjectType(name).getDescriptor());
    if (type != null)
    {
      String tname = type.getClassName();
      if ((tname.equals("E")) || (tname.equals("T")))
      {
        type = Type.getObjectType("java.lang.Object");
        tname = type.getClassName();
      }
      if ((this$0.consider(tname)) && (kind != -1) && 
        (this.name != null) && (signature != null)) {
        references.add(
          Reference.typeReference(this$0.getMember(), tname, signature, kind));
      }
    }
    kind = originalkind;
  }
  
  public void visitClassType(String name)
  {
    processType(name);
  }
  
  public void visitFormalTypeParameter(String name)
  {
    if (type != ReferenceExtractor.TYPE) {
      processType(name);
    }
  }
  
  public void visitTypeVariable(String name) {}
  
  public void visitInnerClassType(String name)
  {
    processType(name);
  }
  
  public SignatureVisitor visitParameterType()
  {
    argumentcount += 1;
    kind = 16;
    return this;
  }
  
  public SignatureVisitor visitInterface()
  {
    kind = 2;
    return this;
  }
  
  public SignatureVisitor visitExceptionType()
  {
    kind = 32;
    return this;
  }
  
  public SignatureVisitor visitArrayType()
  {
    return this;
  }
  
  public SignatureVisitor visitReturnType()
  {
    kind = 8;
    return this;
  }
  
  public SignatureVisitor visitClassBound()
  {
    kind = 2097152;
    return this;
  }
  
  public SignatureVisitor visitInterfaceBound()
  {
    kind = 2097152;
    return this;
  }
  
  public SignatureVisitor visitSuperclass()
  {
    kind = 1;
    return this;
  }
  
  public SignatureVisitor visitTypeArgument(char wildcard)
  {
    return this;
  }
  
  public void visitEnd() {}
  
  public void visitBaseType(char descriptor)
  {
    switch (descriptor)
    {
    case 'D': 
    case 'J': 
      argumentcount += 2;
      break;
    default: 
      argumentcount += 1;
    }
  }
  
  public void visitTypeArgument() {}
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.ReferenceExtractor.ClassFileSignatureVisitor
 * 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.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;

class ReferenceExtractor$FieldTracker
{
  HashMap accessors = new HashMap();
  ArrayList fields = new ArrayList();
  ReferenceExtractor extractor = null;
  
  public ReferenceExtractor$FieldTracker(ReferenceExtractor extractor)
  {
    this.extractor = extractor;
  }
  
  public void addField(Reference ref)
  {
    if (ref != null) {
      fields.add(ref);
    }
  }
  
  public void addAccessor(Reference ref)
  {
    if (ref != null)
    {
      String key = ref.getReferencedMemberName();
      List refs = (List)accessors.get(key);
      if (refs == null)
      {
        refs = new ArrayList();
        accessors.put(key, refs);
      }
      refs.add(ref);
    }
  }
  
  public void resolveSyntheticFields()
  {
    Reference accessor = null;Reference field = null;
    List refs = null;
    for (int i = 0; i < fields.size(); i++)
    {
      field = (Reference)fields.get(i);
      refs = (List)accessors.get(field.getMember().getName());
      if (refs != null)
      {
        for (Iterator iter = refs.iterator(); iter.hasNext();)
        {
          accessor = (Reference)iter.next();
          Reference refer = Reference.fieldReference(accessor.getMember(), 
            field.getReferencedTypeName(), 
            field.getReferencedMemberName(), 
            field.getReferenceKind());
          refer.setLineNumber(accessor.getLineNumber());
          extractor.collector.add(refer);
        }
        extractor.collector.remove(field);
      }
    }
  }
}

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

import org.objectweb.asm.Label;

class ReferenceExtractor$LabelInfo
{
  public Reference location;
  public Label label;
  
  public ReferenceExtractor$LabelInfo(Reference location, Label label)
  {
    this.location = location;
    this.label = label;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append('(').append(label).append(',').append(location).append(')');
    return String.valueOf(buffer);
  }
}

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

import org.objectweb.asm.Label;

class ReferenceExtractor$LineInfo
  implements Comparable
{
  int line;
  Label label;
  
  ReferenceExtractor$LineInfo(int line, Label label)
  {
    this.line = line;
    this.label = label;
  }
  
  public int compareTo(Object o)
  {
    return line - line;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof LineInfo))
    {
      LineInfo lineInfo2 = (LineInfo)obj;
      
      return (line == line) && (label.equals(label));
    }
    return super.equals(obj);
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append('(').append(line).append(',').append(label).append(')');
    return String.valueOf(buffer);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.ReferenceExtractor.LineInfo
 * 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.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import org.objectweb.asm.Label;

class ReferenceExtractor$LinePositionTracker
{
  List labelsAndLocations;
  SortedSet lineInfos;
  List catchLabelInfos;
  HashMap lineMap;
  
  public ReferenceExtractor$LinePositionTracker()
  {
    labelsAndLocations = new ArrayList();
    lineInfos = new TreeSet();
    catchLabelInfos = new ArrayList();
    lineMap = new HashMap();
  }
  
  void addLocation(Reference location)
  {
    labelsAndLocations.add(location);
  }
  
  void addLineInfo(int line, Label label)
  {
    lineInfos.add(new ReferenceExtractor.LineInfo(line, label));
    lineMap.put(label, new Integer(line));
  }
  
  void addCatchLabelInfos(Reference location, Label label)
  {
    catchLabelInfos.add(new ReferenceExtractor.LabelInfo(location, label));
  }
  
  void addLabel(Label label)
  {
    labelsAndLocations.add(label);
  }
  
  public void computeLineNumbers()
  {
    if ((lineInfos.size() < 1) || (labelsAndLocations.size() < 1)) {
      return;
    }
    Iterator lineInfosIterator = lineInfos.iterator();
    ReferenceExtractor.LineInfo firstLineInfo = (ReferenceExtractor.LineInfo)lineInfosIterator.next();
    int currentLineNumber = line;
    
    List remainingCatchLabelInfos = new ArrayList();
    for (Iterator iterator = catchLabelInfos.iterator(); iterator.hasNext();)
    {
      ReferenceExtractor.LabelInfo catchLabelInfo = (ReferenceExtractor.LabelInfo)iterator.next();
      Integer lineValue = (Integer)lineMap.get(label);
      if (lineValue != null) {
        location.setLineNumber(lineValue.intValue());
      } else {
        remainingCatchLabelInfos.add(catchLabelInfo);
      }
    }
    List computedEntries = new ArrayList();
    for (Iterator iterator = labelsAndLocations.iterator(); iterator.hasNext();)
    {
      Object current = iterator.next();
      if ((current instanceof Label))
      {
        Integer lineValue = (Integer)lineMap.get(current);
        if (lineValue != null) {
          computedEntries.add(new ReferenceExtractor.LineInfo(lineValue.intValue(), (Label)current));
        } else {
          computedEntries.add(current);
        }
      }
      else
      {
        computedEntries.add(current);
      }
    }
    for (Iterator iterator = computedEntries.iterator(); iterator.hasNext();)
    {
      Object current = iterator.next();
      if ((current instanceof Label))
      {
        if (remainingCatchLabelInfos != null)
        {
          List remaingEntriesTemp = new ArrayList();
          for (Iterator catchLabelInfosIterator = remainingCatchLabelInfos.iterator(); catchLabelInfosIterator.hasNext();)
          {
            ReferenceExtractor.LabelInfo catchLabelInfo = (ReferenceExtractor.LabelInfo)catchLabelInfosIterator.next();
            if (!current.equals(label)) {
              remaingEntriesTemp.add(catchLabelInfo);
            } else {
              location.setLineNumber(currentLineNumber);
            }
          }
          if (remaingEntriesTemp.size() == 0) {
            remainingCatchLabelInfos = null;
          } else {
            remainingCatchLabelInfos = remaingEntriesTemp;
          }
        }
      }
      else if ((current instanceof Reference))
      {
        Reference ref = (Reference)current;
        if (ref.getLineNumber() == -1) {
          ref.setLineNumber(currentLineNumber);
        } else {
          currentLineNumber = ref.getLineNumber();
        }
      }
      else if ((current instanceof ReferenceExtractor.LineInfo))
      {
        ReferenceExtractor.LineInfo lineInfo = (ReferenceExtractor.LineInfo)current;
        currentLineNumber = line;
      }
    }
  }
}

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

class ReferenceExtractor$LocalLineNumberMarker
{
  int lineNumber;
  int varIndex;
  
  public ReferenceExtractor$LocalLineNumberMarker(int line, int varIndex)
  {
    lineNumber = line;
    this.varIndex = varIndex;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof LocalLineNumberMarker))
    {
      LocalLineNumberMarker marker = (LocalLineNumberMarker)obj;
      return (lineNumber == lineNumber) && (varIndex == varIndex);
    }
    return false;
  }
  
  public int hashCode()
  {
    return varIndex;
  }
}

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

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.Stack;
import java.util.TreeSet;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.model.AbstractApiTypeRoot;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
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.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodAdapter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureReader;
import org.objectweb.asm.signature.SignatureVisitor;
import org.objectweb.asm.tree.ClassNode;

public class ReferenceExtractor
  extends ClassAdapter
{
  private static boolean DEBUG = Util.DEBUG;
  
  public static void setDebug(boolean debugValue)
  {
    DEBUG = (debugValue) || (Util.DEBUG);
  }
  
  class ClassFileSignatureVisitor
    implements SignatureVisitor
  {
    protected int kind = -1;
    protected int originalkind = -1;
    protected int argumentcount = 0;
    protected int type = 0;
    protected String signature = null;
    protected String name = null;
    protected List references;
    
    public ClassFileSignatureVisitor()
    {
      references = new ArrayList();
    }
    
    protected void reset()
    {
      kind = -1;
      originalkind = -1;
      name = null;
      signature = null;
      type = 0;
      references.clear();
    }
    
    protected void processType(String name)
    {
      Type type = resolveType(Type.getObjectType(name).getDescriptor());
      if (type != null)
      {
        String tname = type.getClassName();
        if ((tname.equals("E")) || (tname.equals("T")))
        {
          type = Type.getObjectType("java.lang.Object");
          tname = type.getClassName();
        }
        if ((consider(tname)) && (kind != -1) && 
          (this.name != null) && (signature != null)) {
          references.add(
            Reference.typeReference(getMember(), tname, signature, kind));
        }
      }
      kind = originalkind;
    }
    
    public void visitClassType(String name)
    {
      processType(name);
    }
    
    public void visitFormalTypeParameter(String name)
    {
      if (type != ReferenceExtractor.TYPE) {
        processType(name);
      }
    }
    
    public void visitTypeVariable(String name) {}
    
    public void visitInnerClassType(String name)
    {
      processType(name);
    }
    
    public SignatureVisitor visitParameterType()
    {
      argumentcount += 1;
      kind = 16;
      return this;
    }
    
    public SignatureVisitor visitInterface()
    {
      kind = 2;
      return this;
    }
    
    public SignatureVisitor visitExceptionType()
    {
      kind = 32;
      return this;
    }
    
    public SignatureVisitor visitArrayType()
    {
      return this;
    }
    
    public SignatureVisitor visitReturnType()
    {
      kind = 8;
      return this;
    }
    
    public SignatureVisitor visitClassBound()
    {
      kind = 2097152;
      return this;
    }
    
    public SignatureVisitor visitInterfaceBound()
    {
      kind = 2097152;
      return this;
    }
    
    public SignatureVisitor visitSuperclass()
    {
      kind = 1;
      return this;
    }
    
    public SignatureVisitor visitTypeArgument(char wildcard)
    {
      return this;
    }
    
    public void visitEnd() {}
    
    public void visitBaseType(char descriptor)
    {
      switch (descriptor)
      {
      case 'D': 
      case 'J': 
        argumentcount += 2;
        break;
      default: 
        argumentcount += 1;
      }
    }
    
    public void visitTypeArgument() {}
  }
  
  class ClassFileMethodVisitor
    extends MethodAdapter
  {
    int argumentcount = 0;
    ReferenceExtractor.LinePositionTracker linePositionTracker;
    String stringLiteral;
    String methodName;
    int lastLineNumber;
    boolean implicitConstructor = false;
    ReferenceExtractor.LocalLineNumberMarker localVariableMarker;
    HashMap labelsToLocalMarkers;
    
    public ClassFileMethodVisitor(MethodVisitor mv, String name, int argumentcount)
    {
      super();
      this.argumentcount = argumentcount;
      linePositionTracker = new ReferenceExtractor.LinePositionTracker();
      lastLineNumber = -1;
      labelsToLocalMarkers = new HashMap();
      methodName = name;
    }
    
    public void visitEnd()
    {
      implicitConstructor = false;
      argumentcount = 0;
      exitMember();
      linePositionTracker.computeLineNumbers();
      labelsToLocalMarkers = null;
    }
    
    public void visitVarInsn(int opcode, int var)
    {
      switch (opcode)
      {
      case 58: 
        if (lastLineNumber != -1) {
          localVariableMarker = new ReferenceExtractor.LocalLineNumberMarker(lastLineNumber, var);
        }
        break;
      }
    }
    
    public void visitFieldInsn(int opcode, String owner, String name, String desc)
    {
      int refType = -1;
      switch (opcode)
      {
      case 179: 
        refType = 4096;
        break;
      case 181: 
        refType = 16384;
        break;
      case 178: 
        refType = 2048;
        break;
      case 180: 
        refType = 8192;
      }
      if (refType != -1)
      {
        Reference reference = addFieldReference(Type.getObjectType(owner), name, refType);
        if (reference != null)
        {
          linePositionTracker.addLocation(reference);
          if ((refType == 8192) || (refType == 16384)) {
            fieldtracker.addField(reference);
          }
        }
      }
    }
    
    public void visitTryCatchBlock(Label start, Label end, Label handler, String type)
    {
      if (type != null)
      {
        Type ctype = Type.getObjectType(type);
        Reference reference = addTypeReference(ctype, 131072);
        if (reference != null)
        {
          linePositionTracker.addCatchLabelInfos(reference, handler);
          linePositionTracker.addLocation(reference);
        }
      }
    }
    
    public void visitLabel(Label label)
    {
      linePositionTracker.addLabel(label);
      if (localVariableMarker != null)
      {
        Object object = labelsToLocalMarkers.get(label);
        if (object != null)
        {
          if ((object instanceof List))
          {
            ((List)object).add(localVariableMarker);
          }
          else
          {
            List list = new ArrayList();
            list.add(object);
            list.add(localVariableMarker);
            labelsToLocalMarkers.put(label, list);
          }
        }
        else {
          labelsToLocalMarkers.put(label, localVariableMarker);
        }
        localVariableMarker = null;
      }
    }
    
    public void visitMethodInsn(int opcode, String owner, String name, String desc)
    {
      Type declaringType = Type.getObjectType(owner);
      int kind = -1;
      switch (opcode)
      {
      case 183: 
        kind = "<init>".equals(name) ? 64 : 1048576;
        if (kind == 64) {
          if ((!implicitConstructor) && (methodName.equals("<init>")) && (!fSuperStack.isEmpty()) && (fSuperStack.peek().equals(declaringType.getClassName())))
          {
            implicitConstructor = true;
            kind = 536870912;
          }
          else
          {
            Reference reference = addTypeReference(declaringType, 134217728);
            if (reference != null) {
              linePositionTracker.addLocation(reference);
            }
          }
        }
        break;
      case 184: 
        kind = 128;
        if ((name.equals("forName")) && 
          (processName(owner).equals("java.lang.Class")) && 
          (stringLiteral != null))
        {
          Type classLiteral = Type.getObjectType(stringLiteral);
          Reference reference = addTypeReference(classLiteral, 67108864);
          if (reference != null) {
            linePositionTracker.addLocation(reference);
          }
        }
        break;
      case 182: 
        kind = 256;
        break;
      case 185: 
        kind = 512;
      }
      if (kind != -1)
      {
        Reference reference = addMethodReference(declaringType, name, desc, kind);
        if (reference != null)
        {
          linePositionTracker.addLocation(reference);
          if (kind == 128) {
            fieldtracker.addAccessor(reference);
          }
        }
      }
      stringLiteral = null;
    }
    
    public void visitMultiANewArrayInsn(String desc, int dims)
    {
      Type type = getTypeFromDescription(desc);
      Reference reference = addTypeReference(type, 32768);
      if (reference != null) {
        linePositionTracker.addLocation(reference);
      }
    }
    
    public void visitLineNumber(int line, Label start)
    {
      lastLineNumber = line;
      linePositionTracker.addLineInfo(line, start);
    }
    
    public void visitCode()
    {
      super.visitCode();
    }
    
    public String toString()
    {
      StringBuffer buffer = new StringBuffer();
      buffer.append("Method visitor for: ");
      buffer.append(methodName);
      buffer.append("\nCurrent line number: ");
      buffer.append(lastLineNumber);
      return buffer.toString();
    }
    
    private Type getTypeFromDescription(String desc)
    {
      String ldesc = desc;
      while (ldesc.charAt(0) == '[') {
        ldesc = ldesc.substring(1);
      }
      Type type = null;
      if (ldesc.endsWith(";")) {
        type = Type.getType(ldesc);
      } else {
        type = Type.getObjectType(ldesc);
      }
      return type;
    }
    
    public void visitTypeInsn(int opcode, String desc)
    {
      Type type = getTypeFromDescription(desc);
      int kind = -1;
      switch (opcode)
      {
      case 189: 
        kind = 32768;
        break;
      case 192: 
        kind = 262144;
        break;
      case 193: 
        kind = 524288;
        break;
      case 187: 
        List refs = (List)fAnonymousTypes.get(processName(type.getInternalName()));
        if (refs != null) {
          for (Iterator iterator = refs.iterator(); iterator.hasNext();) {
         
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-2017. Infinite Loop Ltd