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

 Java source line #243	-> byte code offset #175
    //   Java source line #244	-> byte code offset #181
    //   Java source line #245	-> byte code offset #190
    //   Java source line #246	-> byte code offset #197
    //   Java source line #247	-> byte code offset #203
    //   Java source line #251	-> byte code offset #206
    //   Java source line #252	-> byte code offset #214
    //   Java source line #254	-> byte code offset #224
    //   Java source line #255	-> byte code offset #230
    //   Java source line #256	-> byte code offset #239
    //   Java source line #257	-> byte code offset #244
    //   Java source line #258	-> byte code offset #246
    //   Java source line #259	-> byte code offset #248
    //   Java source line #260	-> byte code offset #261
    //   Java source line #257	-> byte code offset #267
    //   Java source line #262	-> byte code offset #272
    //   Java source line #263	-> byte code offset #277
    //   Java source line #268	-> byte code offset #304
    //   Java source line #270	-> byte code offset #313
    //   Java source line #271	-> byte code offset #315
    //   Java source line #272	-> byte code offset #320
    //   Java source line #271	-> byte code offset #323
    //   Java source line #273	-> byte code offset #328
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	329	0	this	ApiSearchEngine
    //   0	329	1	requestor	IApiSearchRequestor
    //   0	329	2	element	IApiElement
    //   0	329	3	reporter	IApiSearchReporter
    //   0	329	4	monitor	IProgressMonitor
    //   1	281	5	refs	List
    //   9	315	6	localmonitor	SubMonitor
    //   78	9	7	type	IApiType
    //   173	11	7	visitor	ReferenceExtractor
    //   228	3	7	member	IApiMember
    //   179	12	8	comp	IApiComponent
    //   237	14	8	type	IApiType
    //   313	8	9	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   11	313	313	finally
  }
  
  public void search(IApiBaseline baseline, IApiSearchRequestor requestor, IApiSearchReporter reporter, IProgressMonitor monitor)
    throws CoreException
  {
    if ((baseline == null) || (reporter == null) || (requestor == null)) {
      return;
    }
    IApiScope scope = requestor.getScope();
    if (scope == null) {
      return;
    }
    fRequestorContext = computeContext(requestor);
    IApiElement[] scopeelements = scope.getApiElements();
    SubMonitor localmonitor = SubMonitor.convert(monitor, 
      MessageFormat.format(SearchMessages.ApiSearchEngine_searching_projects, new String[] { fRequestorContext }), scopeelements.length * 2 + 1);
    try
    {
      long start = System.currentTimeMillis();
      long loopstart = 0L;
      String taskname = null;
      MultiStatus mstatus = null;
      for (int i = 0; i < scopeelements.length; i++) {
        try
        {
          taskname = MessageFormat.format(SearchMessages.ApiSearchEngine_searching_project, new String[] { scopeelements[i].getApiComponent().getSymbolicName(), fRequestorContext });
          localmonitor.setTaskName(taskname);
          if (DEBUG)
          {
            loopstart = System.currentTimeMillis();
            System.out.println("Searching " + scopeelements[i].getApiComponent().getSymbolicName() + "...");
          }
          searchReferences(requestor, scopeelements[i], reporter, localmonitor.newChild(1));
          localmonitor.setTaskName(taskname);
          if (localmonitor.isCanceled())
          {
            reporter.reportResults(scopeelements[i], NO_REFERENCES);
            return;
          }
          localmonitor.worked(1);
          if (DEBUG) {
            System.out.println(Math.round((i + 1) / scopeelements.length * 100.0F) + "% done in " + (System.currentTimeMillis() - loopstart) + " ms");
          }
        }
        catch (CoreException ce)
        {
          if (mstatus == null) {
            mstatus = new MultiStatus("org.eclipse.pde.api.tools", 4, null, null);
          }
          mstatus.add(new Status(4, "org.eclipse.pde.api.tools", ce.getMessage(), ce));
        }
      }
      if (DEBUG) {
        System.out.println("Total Search Time: " + (System.currentTimeMillis() - start) / 1000L + " seconds");
      }
      if (mstatus != null) {
        throw new CoreException(mstatus);
      }
    }
    finally
    {
      localmonitor.done();
    }
    localmonitor.done();
  }
  
  String computeContext(IApiSearchRequestor requestor)
  {
    String context = SearchMessages.ApiSearchEngine_api_internal;
    if (requestor.includesAPI())
    {
      if (requestor.includesInternal())
      {
        if (requestor.includesIllegalUse()) {
          return context;
        }
        context = SearchMessages.ApiSearchEngine_api_and_internal;
      }
      else if (!requestor.includesIllegalUse())
      {
        context = SearchMessages.ApiSearchEngine_api;
      }
      else
      {
        context = SearchMessages.ApiSearchEngine_api_and_illegal;
      }
    }
    else if (requestor.includesInternal())
    {
      if (requestor.includesIllegalUse()) {
        context = SearchMessages.ApiSearchEngine_internal_and_illegal;
      } else {
        context = SearchMessages.ApiSearchEngine_internal;
      }
    }
    else if (requestor.includesIllegalUse()) {
      context = SearchMessages.ApiSearchEngine_illegal;
    }
    return context;
  }
}

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

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

public abstract interface IApiSearchReporter
{
  public abstract void reportResults(IApiElement paramIApiElement, IReference[] paramArrayOfIReference);
  
  public abstract void reportNotSearched(IApiElement[] paramArrayOfIApiElement);
  
  public abstract void reportMetadata(IMetadata paramIMetadata);
  
  public abstract void reportCounts();
}

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

import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
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.IApiScope;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;

public abstract interface IApiSearchRequestor
{
  public static final int INCLUDE_API = 1;
  public static final int INCLUDE_INTERNAL = 2;
  public static final int INCLUDE_ILLEGAL_USE = 4;
  
  public abstract IApiScope getScope();
  
  public abstract boolean acceptComponent(IApiComponent paramIApiComponent);
  
  public abstract boolean acceptContainer(IApiTypeContainer paramIApiTypeContainer);
  
  public abstract boolean acceptMember(IApiMember paramIApiMember);
  
  public abstract boolean acceptReference(IReference paramIReference);
  
  public abstract int getReferenceKinds();
  
  public abstract boolean includesAPI();
  
  public abstract boolean includesInternal();
  
  public abstract boolean includesIllegalUse();
}

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

import java.io.File;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;

public abstract interface IMetadata
{
  public abstract void serializeToFile(File paramFile)
    throws IOException, CoreException;
}

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

import java.util.regex.Matcher;
import java.util.regex.Pattern;
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.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;

public class ApiDescriptionModifier
  extends ApiDescriptionVisitor
{
  private Pattern[] fInternalPackages;
  private Pattern[] fApiPackages;
  private IApiDescription fDescription;
  
  public ApiDescriptionModifier(String[] internal, String[] api)
  {
    setInternalPatterns(internal);
    setApiPatterns(api);
  }
  
  public void setApiDescription(IApiDescription description)
  {
    fDescription = description;
  }
  
  private void setInternalPatterns(String[] patterns)
  {
    if ((patterns == null) || (patterns.length == 0))
    {
      fInternalPackages = null;
    }
    else
    {
      fInternalPackages = new Pattern[patterns.length];
      for (int i = 0; i < patterns.length; i++) {
        fInternalPackages[i] = Pattern.compile(patterns[i]);
      }
    }
  }
  
  private void setApiPatterns(String[] patterns)
  {
    if ((patterns == null) || (patterns.length == 0))
    {
      fApiPackages = null;
    }
    else
    {
      fApiPackages = new Pattern[patterns.length];
      for (int i = 0; i < patterns.length; i++) {
        fApiPackages[i] = Pattern.compile(patterns[i]);
      }
    }
  }
  
  public boolean visitElement(IElementDescriptor element, IApiAnnotations description)
  {
    switch (element.getElementType())
    {
    case 8: 
      return true;
    case 1: 
      IPackageDescriptor pkg = (IPackageDescriptor)element;
      if ((fInternalPackages != null) && 
        (matchesPattern(pkg.getName(), fInternalPackages))) {
        fDescription.setVisibility(element, 2);
      }
      if ((fApiPackages != null) && 
        (matchesPattern(pkg.getName(), fApiPackages))) {
        fDescription.setVisibility(element, 1);
      }
      return false;
    }
    return false;
  }
  
  private boolean matchesPattern(String name, Pattern[] patterns)
  {
    for (int i = 0; i < patterns.length; i++) {
      if (patterns[i].matcher(name).find()) {
        return true;
      }
    }
    return false;
  }
}

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

import java.util.Comparator;

class ConsumerReportConvertor$1
  implements Comparator
{
  final ConsumerReportConvertor this$0;
  
  ConsumerReportConvertor$1(ConsumerReportConvertor paramConsumerReportConvertor)
  {
    this$0 = paramConsumerReportConvertor;
  }
  
  public int compare(Object o1, Object o2)
  {
    return name.compareTo(name);
  }
}

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

class ConsumerReportConvertor$Consumer
{
  String name;
  UseReportConverter.CountGroup counts;
  final ConsumerReportConvertor this$0;
  
  ConsumerReportConvertor$Consumer(ConsumerReportConvertor paramConsumerReportConvertor)
  {
    this$0 = paramConsumerReportConvertor;
    
    counts = new UseReportConverter.CountGroup();
  }
}

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

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.pde.api.tools.internal.builder.Reference;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
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.descriptors.IPackageDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;

class ConsumerReportConvertor$ConsumerReportVisitor
  extends UseScanVisitor
{
  ConsumerReportConvertor.Consumer consumer;
  Map producers;
  private IComponentDescriptor consumerDescriptor;
  private ConsumerReportConvertor.Producer currentProducer;
  private ConsumerReportConvertor.Type2 currenttype;
  private UseReportConverter.Member currentmember;
  HashMap keys;
  final ConsumerReportConvertor this$0;
  
  public ConsumerReportConvertor$ConsumerReportVisitor(ConsumerReportConvertor paramConsumerReportConvertor, IComponentDescriptor consumerDescriptor)
  {
    this$0 = paramConsumerReportConvertor;producers = new HashMap();currenttype = null;currentmember = null;keys = new HashMap();
    this.consumerDescriptor = consumerDescriptor;
    consumer = new ConsumerReportConvertor.Consumer(paramConsumerReportConvertor);
    consumer.name = paramConsumerReportConvertor.composeName(consumerDescriptor.getId(), consumerDescriptor.getVersion());
  }
  
  public void endVisitScan()
  {
    try
    {
      long start = 0L;
      if (ConsumerReportConvertor.DEBUG)
      {
        System.out.println("Writing consumer report for bundle: " + consumer.name);
        start = System.currentTimeMillis();
      }
      if (consumer.counts.getTotalRefCount() > 0)
      {
        this$0.writeConsumerReport(consumer, producers);
        producers.clear();
      }
      if (ConsumerReportConvertor.DEBUG) {
        System.out.println("Done in: " + (System.currentTimeMillis() - start) + " ms");
      }
    }
    catch (Exception e)
    {
      ApiPlugin.log(e);
    }
  }
  
  public boolean visitComponent(IComponentDescriptor target)
  {
    currentProducer = new ConsumerReportConvertor.Producer(this$0);
    currentProducer.name = this$0.composeName(target.getId(), target.getVersion());
    return true;
  }
  
  public void endVisitComponent(IComponentDescriptor target)
  {
    if (currentProducer.counts.getTotalRefCount() > 0) {
      try
      {
        if (!producers.containsKey(currentProducer.name)) {
          producers.put(currentProducer.name, currentProducer);
        }
        long start = 0L;
        if (ConsumerReportConvertor.DEBUG)
        {
          System.out.println("Writing producer report for bundle: " + currentProducer.name);
          start = System.currentTimeMillis();
        }
        if (consumer.counts.getTotalRefCount() > 0) {
          this$0.writeProducerReport(consumer, currentProducer);
        }
        if (ConsumerReportConvertor.DEBUG) {
          System.out.println("Done in: " + (System.currentTimeMillis() - start) + " ms");
        }
      }
      catch (Exception e)
      {
        ApiPlugin.log(e);
      }
    }
  }
  
  public boolean visitReferencingComponent(IComponentDescriptor component)
  {
    return component.equals(consumerDescriptor);
  }
  
  public void endVisitReferencingComponent(IComponentDescriptor component) {}
  
  public boolean visitMember(IMemberDescriptor referencedMember)
  {
    IReferenceTypeDescriptor desc = getEnclosingDescriptor(referencedMember);
    if (desc == null) {
      return false;
    }
    currenttype = ((ConsumerReportConvertor.Type2)keys.get(desc));
    if (currenttype == null)
    {
      currenttype = new ConsumerReportConvertor.Type2(this$0, desc);
      keys.put(desc, currenttype);
    }
    currentProducer.types.put(desc, currenttype);
    
    currentmember = new UseReportConverter.Member(referencedMember);
    currenttype.referencingMembers.put(referencedMember, currentmember);
    
    return true;
  }
  
  public void endVisitMember(IMemberDescriptor referencedMember)
  {
    if (currenttype.counts.getTotalRefCount() == 0)
    {
      IReferenceTypeDescriptor desc = getEnclosingDescriptor(referencedMember);
      if (desc != null)
      {
        keys.remove(desc);
        currentProducer.types.remove(currenttype);
      }
    }
  }
  
  public void visitReference(IReferenceDescriptor reference)
  {
    IMemberDescriptor fromMember = reference.getMember();
    if ((!acceptReference(reference.getReferencedMember(), this$0.topatterns)) || 
      (!acceptReference(fromMember, this$0.frompatterns))) {
      return;
    }
    int lineNumber = reference.getLineNumber();
    int refKind = reference.getReferenceKind();
    int visibility = reference.getVisibility();
    String refname = Reference.getReferenceText(refKind);
    ArrayList refs = (ArrayList)currentmember.children.get(refname);
    if (refs == null)
    {
      refs = new ArrayList();
      currentmember.children.put(refname, refs);
    }
    refs.add(new UseReportConverter.Reference(fromMember, lineNumber, visibility, formatMessages(reference.getProblemMessages())));
    switch (fromMember.getElementType())
    {
    case 2: 
      switch (visibility)
      {
      case 1: 
        consumer.counts.total_api_type_count += 1;
        currentProducer.counts.total_api_type_count += 1;
        currentmember.counts.total_api_type_count += 1;
        currenttype.counts.total_api_type_count += 1;
        break;
      case 2: 
        consumer.counts.total_private_type_count += 1;
        currentProducer.counts.total_private_type_count += 1;
        currentmember.counts.total_private_type_count += 1;
        currenttype.counts.total_private_type_count += 1;
        break;
      case 8: 
        consumer.counts.total_permissable_type_count += 1;
        currentProducer.counts.total_permissable_type_count += 1;
        currentmember.counts.total_permissable_type_count += 1;
        currenttype.counts.total_permissable_type_count += 1;
        break;
      case 5: 
        consumer.counts.total_fragment_permissible_type_count += 1;
        currentProducer.counts.total_fragment_permissible_type_count += 1;
        currentmember.counts.total_fragment_permissible_type_count += 1;
        currenttype.counts.total_fragment_permissible_type_count += 1;
        break;
      case 22: 
        consumer.counts.total_illegal_type_count += 1;
        currentProducer.counts.total_illegal_type_count += 1;
        currentmember.counts.total_illegal_type_count += 1;
        currenttype.counts.total_illegal_type_count += 1;
      }
      break;
    case 6: 
      switch (visibility)
      {
      case 1: 
        consumer.counts.total_api_method_count += 1;
        currentProducer.counts.total_api_method_count += 1;
        currentmember.counts.total_api_method_count += 1;
        currenttype.counts.total_api_method_count += 1;
        break;
      case 2: 
        consumer.counts.total_private_method_count += 1;
        currentProducer.counts.total_private_method_count += 1;
        currentmember.counts.total_private_method_count += 1;
        currenttype.counts.total_private_method_count += 1;
        break;
      case 8: 
        consumer.counts.total_permissable_method_count += 1;
        currentProducer.counts.total_permissable_method_count += 1;
        currentmember.counts.total_permissable_method_count += 1;
        currenttype.counts.total_permissable_method_count += 1;
        break;
      case 5: 
        consumer.counts.total_fragment_permissible_method_count += 1;
        currentProducer.counts.total_fragment_permissible_method_count += 1;
        currentmember.counts.total_fragment_permissible_method_count += 1;
        currenttype.counts.total_fragment_permissible_method_count += 1;
        break;
      case 22: 
        consumer.counts.total_illegal_method_count += 1;
        currentProducer.counts.total_illegal_method_count += 1;
        currentmember.counts.total_illegal_method_count += 1;
        currenttype.counts.total_illegal_method_count += 1;
      }
      break;
    case 5: 
      switch (visibility)
      {
      case 1: 
        consumer.counts.total_api_field_count += 1;
        currentProducer.counts.total_api_field_count += 1;
        currentmember.counts.total_api_field_count += 1;
        currenttype.counts.total_api_field_count += 1;
        break;
      case 2: 
        consumer.counts.total_private_field_count += 1;
        currentProducer.counts.total_private_field_count += 1;
        currentmember.counts.total_private_field_count += 1;
        currenttype.counts.total_private_field_count += 1;
        break;
      case 8: 
        consumer.counts.total_permissable_field_count += 1;
        currentProducer.counts.total_permissable_field_count += 1;
        currentmember.counts.total_permissable_field_count += 1;
        currenttype.counts.total_permissable_field_count += 1;
        break;
      case 5: 
        consumer.counts.total_fragment_permissible_field_count += 1;
        currentProducer.counts.total_fragment_permissible_field_count += 1;
        currentmember.counts.total_fragment_permissible_field_count += 1;
        currenttype.counts.total_fragment_permissible_field_count += 1;
        break;
      case 22: 
        consumer.counts.total_illegal_field_count += 1;
        currentProducer.counts.total_illegal_field_count += 1;
        currentmember.counts.total_illegal_field_count += 1;
        currenttype.counts.total_illegal_field_count += 1;
      }
      break;
    }
  }
  
  private boolean acceptReference(IMemberDescriptor desc, Pattern[] patterns)
  {
    if (patterns != null) {
      for (int i = 0; i < patterns.length; i++) {
        if (patterns[i].matcher(desc.getPackage().getName()).find()) {
          return false;
        }
      }
    }
    return true;
  }
  
  private IReferenceTypeDescriptor getEnclosingDescriptor(IMemberDescriptor member)
  {
    switch (member.getElementType())
    {
    case 2: 
      return (IReferenceTypeDescriptor)member;
    case 5: 
    case 6: 
      return member.getEnclosingType();
    }
    return null;
  }
  
  private String formatMessages(String[] messages)
  {
    if (messages != null)
    {
      StringBuffer buffer = new StringBuffer();
      for (int i = 0; i < messages.length; i++)
      {
        buffer.append(messages[i]);
        if (i < messages.length - 1) {
          buffer.append("\n");
        }
      }
      return buffer.toString();
    }
    return null;
  }
}

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

import java.util.HashSet;
import java.util.Set;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;

class ConsumerReportConvertor$ListConsumersVisitor
  extends UseScanVisitor
{
  Set consumers;
  final ConsumerReportConvertor this$0;
  
  ConsumerReportConvertor$ListConsumersVisitor(ConsumerReportConvertor paramConsumerReportConvertor)
  {
    this$0 = paramConsumerReportConvertor;
    
    consumers = new HashSet();
  }
  
  public boolean visitComponent(IComponentDescriptor target)
  {
    return true;
  }
  
  public boolean visitReferencingComponent(IComponentDescriptor component)
  {
    consumers.add(component);
    return false;
  }
  
  public boolean visitMember(IMemberDescriptor referencedMember)
  {
    return false;
  }
  
  public void visitReference(IReferenceDescriptor reference) {}
}

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

import java.util.HashMap;
import java.util.Map;

class ConsumerReportConvertor$Producer
{
  String name;
  Map types;
  UseReportConverter.CountGroup counts;
  final ConsumerReportConvertor this$0;
  
  ConsumerReportConvertor$Producer(ConsumerReportConvertor paramConsumerReportConvertor)
  {
    this$0 = paramConsumerReportConvertor;
    
    types = new HashMap();
    counts = new UseReportConverter.CountGroup();
  }
}

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

import java.util.HashMap;
import java.util.Map;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;

class ConsumerReportConvertor$Type2
  extends UseReportConverter.Type
{
  Map referencingMembers;
  final ConsumerReportConvertor this$0;
  
  public ConsumerReportConvertor$Type2(ConsumerReportConvertor paramConsumerReportConvertor, IElementDescriptor desc)
  {
    super(desc);this$0 = paramConsumerReportConvertor;
    
    referencingMembers = new HashMap();
  }
}

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

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.builder.Reference;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;

public class ConsumerReportConvertor
  extends UseReportConverter
{
  class ListConsumersVisitor
    extends UseScanVisitor
  {
    Set consumers = new HashSet();
    
    ListConsumersVisitor() {}
    
    public boolean visitComponent(IComponentDescriptor target)
    {
      return true;
    }
    
    public boolean visitReferencingComponent(IComponentDescriptor component)
    {
      consumers.add(component);
      return false;
    }
    
    public boolean visitMember(IMemberDescriptor referencedMember)
    {
      return false;
    }
    
    public void visitReference(IReferenceDescriptor reference) {}
  }
  
  class ConsumerReportVisitor
    extends UseScanVisitor
  {
    ConsumerReportConvertor.Consumer consumer;
    Map producers = new HashMap();
    private IComponentDescriptor consumerDescriptor;
    private ConsumerReportConvertor.Producer currentProducer;
    private ConsumerReportConvertor.Type2 currenttype = null;
    private UseReportConverter.Member currentmember = null;
    HashMap keys = new HashMap();
    
    public ConsumerReportVisitor(IComponentDescriptor consumerDescriptor)
    {
      this.consumerDescriptor = consumerDescriptor;
      consumer = new ConsumerReportConvertor.Consumer(ConsumerReportConvertor.this);
      consumer.name = composeName(consumerDescriptor.getId(), consumerDescriptor.getVersion());
    }
    
    public void endVisitScan()
    {
      try
      {
        long start = 0L;
        if (ConsumerReportConvertor.DEBUG)
        {
          System.out.println("Writing consumer report for bundle: " + consumer.name);
          start = System.currentTimeMillis();
        }
        if (consumer.counts.getTotalRefCount() > 0)
        {
          writeConsumerReport(consumer, producers);
          producers.clear();
        }
        if (ConsumerReportConvertor.DEBUG) {
          System.out.println("Done in: " + (System.currentTimeMillis() - start) + " ms");
        }
      }
      catch (Exception e)
      {
        ApiPlugin.log(e);
      }
    }
    
    public boolean visitComponent(IComponentDescriptor target)
    {
      currentProducer = new ConsumerReportConvertor.Producer(ConsumerReportConvertor.this);
      currentProducer.name = composeName(target.getId(), target.getVersion());
      return true;
    }
    
    public void endVisitComponent(IComponentDescriptor target)
    {
      if (currentProducer.counts.getTotalRefCount() > 0) {
        try
        {
          if (!producers.containsKey(currentProducer.name)) {
            producers.put(currentProducer.name, currentProducer);
          }
          long start = 0L;
          if (ConsumerReportConvertor.DEBUG)
          {
            System.out.println("Writing producer report for bundle: " + currentProducer.name);
            start = System.currentTimeMillis();
          }
          if (consumer.counts.getTotalRefCount() > 0) {
            writeProducerReport(consumer, currentProducer);
          }
          if (ConsumerReportConvertor.DEBUG) {
            System.out.println("Done in: " + (System.currentTimeMillis() - start) + " ms");
          }
        }
        catch (Exception e)
        {
          ApiPlugin.log(e);
        }
      }
    }
    
    public boolean visitReferencingComponent(IComponentDescriptor component)
    {
      return component.equals(consumerDescriptor);
    }
    
    public void endVisitReferencingComponent(IComponentDescriptor component) {}
    
    public boolean visitMember(IMemberDescriptor referencedMember)
    {
      IReferenceTypeDescriptor desc = getEnclosingDescriptor(referencedMember);
      if (desc == null) {
        return false;
      }
      currenttype = ((ConsumerReportConvertor.Type2)keys.get(desc));
      if (currenttype == null)
      {
        currenttype = new ConsumerReportConvertor.Type2(ConsumerReportConvertor.this, desc);
        keys.put(desc, currenttype);
      }
      currentProducer.types.put(desc, currenttype);
      
      currentmember = new UseReportConverter.Member(referencedMember);
      currenttype.referencingMembers.put(referencedMember, currentmember);
      
      return true;
    }
    
    public void endVisitMember(IMemberDescriptor referencedMember)
    {
      if (currenttype.counts.getTotalRefCount() == 0)
      {
        IReferenceTypeDescriptor desc = getEnclosingDescriptor(referencedMember);
        if (desc != null)
        {
          keys.remove(desc);
          currentProducer.types.remove(currenttype);
        }
      }
    }
    
    public void visitReference(IReferenceDescriptor reference)
    {
      IMemberDescriptor fromMember = reference.getMember();
      if ((!acceptReference(reference.getReferencedMember(), topatterns)) || 
        (!acceptReference(fromMember, frompatterns))) {
        return;
      }
      int lineNumber = reference.getLineNumber();
      int refKind = reference.getReferenceKind();
      int visibility = reference.getVisibility();
      String refname = Reference.getReferenceText(refKind);
      ArrayList refs = (ArrayList)currentmember.children.get(refname);
      if (refs == null)
      {
        refs = new ArrayList();
        currentmember.children.put(refname, refs);
      }
      refs.add(new UseReportConverter.Reference(fromMember, lineNumber, visibility, formatMessages(reference.getProblemMessages())));
      switch (fromMember.getElementType())
      {
      case 2: 
        switch (visibility)
        {
        case 1: 
          consumer.counts.total_api_type_count += 1;
          currentProducer.counts.total_api_type_count += 1;
          currentmember.counts.total_api_type_count += 1;
          currenttype.counts.total_api_type_count += 1;
          break;
        case 2: 
          consumer.counts.total_private_type_count += 1;
          currentProducer.counts.total_private_type_count += 1;
          currentmember.counts.total_private_type_count += 1;
          currenttype.counts.total_private_type_count += 1;
          break;
        case 8: 
          consumer.counts.total_permissable_type_count += 1;
          currentProducer.counts.total_permissable_type_count += 1;
          currentmember.counts.total_permissable_type_count += 1;
          currenttype.counts.total_permissable_type_count += 1;
          break;
        case 5: 
          consumer.counts.total_fragment_permissible_type_count += 1;
          currentProducer.counts.total_fragment_permissible_type_count += 1;
          currentmember.counts.total_fragment_permissible_type_count += 1;
          currenttype.counts.total_fragment_permissible_type_count += 1;
          break;
        case 22: 
          consumer.counts.total_illegal_type_count += 1;
          currentProducer.counts.total_illegal_type_count += 1;
          currentmember.counts.total_illegal_type_count += 1;
          currenttype.counts.total_illegal_type_count += 1;
        }
        break;
      case 6: 
        switch (visibility)
        {
        case 1: 
          consumer.counts.total_api_method_count += 1;
          currentProducer.counts.total_api_method_count += 1;
          currentmember.counts.total_api_method_count += 1;
          currenttype.counts.total_api_method_count += 1;
          break;
        case 2: 
          consumer.counts.total_private_method_count += 1;
          currentProducer.counts.total_private_method_count += 1;
          currentmember.counts.total_private_method_count += 1;
          currenttype.counts.total_private_method_count += 1;
          break;
        case 8: 
          consumer.counts.total_permissable_method_count += 1;
          currentProducer.counts.total_permissable_method_count += 1;
          currentmember.counts.total_permissable_method_count += 1;
          currenttype.counts.total_permissable_method_count += 1;
          break;
        case 5: 
          consumer.counts.total_fragment_permissible_method_count += 1;
          currentProducer.counts.total_fragment_permissible_method_count += 1;
          currentmember.counts.total_fragment_permissible_method_count += 1;
          currenttype.counts.total_fragment_permissible_method_count += 1;
          break;
        case 22: 
          consumer.counts.total_illegal_method_count += 1;
          currentProducer.counts.total_illegal_method_count += 1;
          currentmember.counts.total_illegal_method_count += 1;
          currenttype.counts.total_illegal_method_count += 1;
        }
        break;
      case 5: 
        switch (visibility)
        {
        case 1: 
          consumer.counts.total_api_field_count += 1;
          currentProducer.counts.total_api_field_count += 1;
          currentmember.counts.total_api_field_count += 1;
          currenttype.counts.total_api_field_count += 1;
          break;
        case 2: 
          consumer.counts.total_private_field_count += 1;
          currentProducer.counts.total_private_field_count += 1;
          currentmember.counts.total_private_field_count += 1;
          currenttype.counts.total_private_field_count += 1;
          break;
        case 8: 
          consumer.counts.total_permissable_field_count += 1;
          currentProducer.counts.total_permissable_field_count += 1;
          currentmember.counts.total_permissable_field_count += 1;
          currenttype.counts.total_permissable_field_count += 1;
          break;
        case 5: 
          consumer.counts.total_fragment_permissible_field_count += 1;
          currentProducer.counts.total_fragment_permissible_field_count += 1;
          currentmember.counts.total_fragment_permissible_field_count += 1;
          currenttype.counts.total_fragment_permissible_field_count += 1;
          break;
        case 22: 
          consumer.counts.total_illegal_field_count += 1;
          currentProducer.counts.total_illegal_field_count += 1;
          currentmember.counts.total_illegal_field_count += 1;
          currenttype.counts.total_illegal_field_count += 1;
        }
        break;
      }
    }
    
    private boolean acceptReference(IMemberDescriptor desc, Pattern[] patterns)
    {
      if (patterns != null) {
        for (int i = 0; i < patterns.length; i++) {
          if (patterns[i].matcher(desc.getPackage().getName()).find()) {
            return false;
          }
        }
      }
      return true;
    }
    
    private IReferenceTypeDescriptor getEnclosingDescriptor(IMemberDescriptor member)
    {
      switch (member.getElementType())
      {
      case 2: 
        return (IReferenceTypeDescriptor)member;
      case 5: 
      case 6: 
        return member.getEnclosingType();
      }
      return null;
    }
    
    private String formatMessages(String[] messages)
    {
      if (messages != null)
      {
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < messages.length; i++)
        {
          buffer.append(messages[i]);
          if (i < messages.length - 1) {
            buffer.append("\n");
          }
        }
        return buffer.toString();
      }
      return null;
    }
  }
  
  class Consumer
  {
    String name;
    UseReportConverter.CountGroup counts = new UseReportConverter.CountGroup();
    
    Consumer() {}
  }
  
  class Producer
  {
    String name;
    Map types = new HashMap();
    UseReportConverter.CountGroup counts = new UseReportConverter.CountGroup();
    
    Producer() {}
  }
  
  class Type2
    extends UseReportConverter.Type
  {
    public Type2(IElementDescriptor desc)
    {
      super();
    }
    
    Map referencingMembers = new HashMap();
  }
  
  public ConsumerReportConvertor(String htmlroot, String xmlroot, String[] topatterns, String[] frompatterns)
  {
    super(htmlroot, xmlroot, topatterns, frompatterns);
  }
  
  protected List parse(IProgressMonitor monitor)
    throws Exception
  {
    SubMonitor subMon = SubMonitor.convert(monitor, 20);
    ListConsumersVisitor listVisitor = new ListConsumersVisitor();
    UseScanParser parser = new UseScanParser();
    parser.parse(getXmlLocation(), subMon.newChild(5), listVisitor);
    List consumerReports = new ArrayList();
    
    IComponentDescriptor currentConsumer = null;
    ConsumerReportVisitor visitor = null;
    for (Iterator iterator = consumers.iterator(); iterator.hasNext();)
    {
      currentConsumer = (IComponentDescriptor)iterator.next();
      visitor = new ConsumerReportVisitor(currentConsumer);
      parser.parse(getXmlLocation(), null, visitor);
      if (consumer.counts.getTotalRefCount() > 0) {
        consumerReports.add(consumer);
      }
    }
    return consumerReports;
  }
  
  protected String getConsumerTitle(String bundle)
  {
    return NLS.bind(SearchMessages.ConsumerReportConvertor_ConsumerTitle, bundle);
  }
  
  protected String getProducerTitle(String consumer, String producer)
  {
    return NLS.bind(SearchMessages.ConsumerReportConvertor_ProducerTitle, consumer, producer);
  }
  
  protected String getIndexTitle()
  {
    return SearchMessages.ConsumerReportConvertor_IndexTitle;
  }
  
  /* Error */
  void writeIndexPage(List scanResult)
    throws Exception
  {
    // Byte code:
    //   0: aload_1
    //   1: new 223	org/eclipse/pde/api/tools/internal/search/ConsumerReportConvertor$1
    //   4: dup
    //   5: aload_0
    //   6: invokespecial 464	org/eclipse/pde/api/tools/internal/search/ConsumerReportConvertor$1:<init>	(Lorg/eclipse/pde/api/tools/internal/search/ConsumerReportConvertor;)V
    //   9: invokestatic 436	java/util/Collections:sort	(Ljava/util/List;Ljava/util/Comparator;)V
    //   12: aconst_null
    //   13: astore_2
    //   14: new 202	java/io/File
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