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

ructure != null)
        {
          IApiMethod[] methods = structure.getMethods();
          for (int i = 0; i < methods.length; i++)
          {
            IApiMethod method = methods[i];
            if (descriptor.getName().equals(method.getName()))
            {
              String signature = method.getSignature();
              String descriptorSignature = descriptor.getSignature().replace('/', '.');
              if (Signatures.matchesSignatures(descriptorSignature, signature.replace('/', '.'))) {
                return descriptor.getEnclosingType().getMethod(method.getName(), signature);
              }
              String genericSignature = method.getGenericSignature();
              if ((genericSignature != null) && 
                (Signatures.matchesSignatures(descriptorSignature, genericSignature.replace('/', '.')))) {
                return descriptor.getEnclosingType().getMethod(method.getName(), signature);
              }
            }
          }
        }
      }
      throw new CoreException(new Status(4, "org.eclipse.pde.api.tools", 
        MessageFormat.format("Unable to resolve method signature: {0}", new String[] { descriptor.toString() }), null));
    }
    return descriptor;
  }
}

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

import java.text.MessageFormat;
import java.util.ArrayList;
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.Status;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.Javadoc;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.TagElement;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.pde.api.tools.internal.CompilationUnit;
import org.eclipse.pde.api.tools.internal.JavadocTagManager;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.Factory;
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.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.IApiMethod;
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.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;

public class TagScanner
{
  private static boolean DEBUG = Util.DEBUG;
  
  public static void setDebug(boolean debugValue)
  {
    DEBUG = (debugValue) || (Util.DEBUG);
  }
  
  static class Visitor
    extends ASTVisitor
  {
    private IApiDescription fDescription = null;
    private IPackageDescriptor fPackage = Factory.packageDescriptor("");
    private IReferenceTypeDescriptor fType = null;
    private IApiTypeContainer fContainer = null;
    private CoreException fException;
    
    public Visitor(IApiDescription description, IApiTypeContainer container)
    {
      fDescription = description;
      fContainer = container;
    }
    
    public boolean visit(Javadoc node)
    {
      List tags = node.tags();
      ASTNode parent = node.getParent();
      if (parent != null) {
        switch (parent.getNodeType())
        {
        case 55: 
          TypeDeclaration type = (TypeDeclaration)parent;
          if (type.isInterface()) {
            processTags(fType, pruneTags(tags, type), 2, 16);
          } else {
            processTags(fType, pruneTags(tags, type), 1, 16);
          }
          break;
        case 31: 
          MethodDeclaration method = (MethodDeclaration)parent;
          String signature = Signatures.getMethodSignatureFromNode(method);
          if (signature != null)
          {
            String methodname = method.getName().getFullyQualifiedName();
            int member = 4;
            if (method.isConstructor())
            {
              member = 32;
              methodname = "<init>";
            }
            IMethodDescriptor descriptor = fType.getMethod(methodname, signature);
            processTags(descriptor, pruneTags(tags, method), getEnclosingType(method), member);
          }
          break;
        case 23: 
          FieldDeclaration field = (FieldDeclaration)parent;
          List fields = field.fragments();
          VariableDeclarationFragment fragment = null;
          for (Iterator iter = fields.iterator(); iter.hasNext();)
          {
            fragment = (VariableDeclarationFragment)iter.next();
            processTags(fType.getField(fragment.getName().getFullyQualifiedName()), pruneTags(tags, field), getEnclosingType(field), 8);
          }
        }
      }
      return false;
    }
    
    private int getEnclosingType(ASTNode node)
    {
      ASTNode lnode = node;
      while (!(lnode instanceof AbstractTypeDeclaration)) {
        lnode = lnode.getParent();
      }
      if (((lnode instanceof TypeDeclaration)) && 
        (((TypeDeclaration)lnode).isInterface())) {
        return 2;
      }
      return 1;
    }
    
    private void enterType(SimpleName name)
    {
      if (fType == null) {
        fType = fPackage.getType(name.getFullyQualifiedName());
      } else {
        fType = fType.getType(name.getFullyQualifiedName());
      }
    }
    
    private void exitType()
    {
      fType = fType.getEnclosingType();
    }
    
    protected void processTags(IElementDescriptor descriptor, List tags, int type, int member)
    {
      JavadocTagManager jtm = ApiPlugin.getJavadocTagManager();
      TagElement tag = null;
      String tagname = null;
      int restrictions = 0;
      for (Iterator iter = tags.iterator(); iter.hasNext();)
      {
        tag = (TagElement)iter.next();
        tagname = tag.getTagName();
        restrictions |= jtm.getRestrictionsForTag(tagname, type, member);
      }
      if (restrictions != 0)
      {
        IElementDescriptor ldesc = descriptor;
        if (ldesc.getElementType() == 6) {
          try
          {
            ldesc = resolveMethod((IMethodDescriptor)ldesc);
          }
          catch (CoreException e)
          {
            fException = e;
          }
        }
        fDescription.setRestrictions(ldesc, restrictions);
      }
    }
    
    private List pruneTags(List tags, ASTNode node)
    {
      ArrayList pruned = new ArrayList(tags.size());
      TagElement tag = null;
      switch (node.getNodeType())
      {
      case 55: 
        TypeDeclaration type = (TypeDeclaration)node;
        int flags = type.getModifiers();
        for (Iterator iterator = tags.iterator(); iterator.hasNext();)
        {
          tag = (TagElement)iterator.next();
          String tagname = tag.getTagName();
          if ((type.isInterface()) && (
            ("@noextend".equals(tagname)) || 
            ("@noimplement".equals(tagname)))) {
            pruned.add(tag);
          } else if (("@noextend".equals(tagname)) && 
            (!Flags.isFinal(flags))) {
            pruned.add(tag);
          } else if (("@noinstantiate".equals(tagname)) && 
            (!Flags.isAbstract(flags))) {
            pruned.add(tag);
          }
        }
        break;
      case 31: 
        MethodDeclaration method = (MethodDeclaration)node;
        int flags = method.getModifiers();
        for (Iterator iterator = tags.iterator(); iterator.hasNext();)
        {
          tag = (TagElement)iterator.next();
          if ("@noreference".equals(tag.getTagName()))
          {
            pruned.add(tag);
          }
          else if ("@nooverride".equals(tag.getTagName()))
          {
            ASTNode parent = method.getParent();
            int pflags = 0;
            if ((parent instanceof BodyDeclaration)) {
              pflags = ((BodyDeclaration)parent).getModifiers();
            }
            if ((!Flags.isFinal(flags)) && 
              (!Flags.isStatic(flags)) && 
              (!Flags.isFinal(pflags))) {
              pruned.add(tag);
            }
          }
        }
        break;
      case 23: 
        FieldDeclaration field = (FieldDeclaration)node;
        for (Iterator iterator = tags.iterator(); iterator.hasNext();)
        {
          tag = (TagElement)iterator.next();
          boolean isfinal = Flags.isFinal(field.getModifiers());
          if ((isfinal) || ((isfinal) && (Flags.isStatic(field.getModifiers())))) {
            break;
          }
          if ("@noreference".equals(tag.getTagName()))
          {
            pruned.add(tag);
            break;
          }
        }
      }
      return pruned;
    }
    
    private boolean isContinue()
    {
      return fException == null;
    }
    
    CoreException getException()
    {
      return fException;
    }
    
    public boolean visit(TypeDeclaration node)
    {
      if (isPrivate(node.getModifiers())) {
        return false;
      }
      enterType(node.getName());
      return isContinue();
    }
    
    public void endVisit(TypeDeclaration node)
    {
      if (!isPrivate(node.getModifiers())) {
        exitType();
      }
    }
    
    public void endVisit(AnnotationTypeDeclaration node)
    {
      if (!isPrivate(node.getModifiers())) {
        exitType();
      }
    }
    
    public boolean visit(AnnotationTypeDeclaration node)
    {
      if (isPrivate(node.getModifiers())) {
        return false;
      }
      enterType(node.getName());
      return isContinue();
    }
    
    public boolean visit(EnumDeclaration node)
    {
      if (isPrivate(node.getModifiers())) {
        return false;
      }
      enterType(node.getName());
      return isContinue();
    }
    
    public void endVisit(EnumDeclaration node)
    {
      if (!isPrivate(node.getModifiers())) {
        exitType();
      }
    }
    
    public boolean visit(PackageDeclaration node)
    {
      Name name = node.getName();
      fPackage = Factory.packageDescriptor(name.getFullyQualifiedName());
      return false;
    }
    
    public boolean visit(MethodDeclaration node)
    {
      if (isPrivate(node.getModifiers())) {
        return false;
      }
      return isContinue();
    }
    
    public boolean visit(FieldDeclaration node)
    {
      if (isPrivate(node.getModifiers())) {
        return false;
      }
      return isContinue();
    }
    
    private boolean isPrivate(int flags)
    {
      return Flags.isPrivate(flags);
    }
    
    private IMethodDescriptor resolveMethod(IMethodDescriptor descriptor)
      throws CoreException
    {
      if (fContainer != null)
      {
        IReferenceTypeDescriptor type = descriptor.getEnclosingType();
        IApiTypeRoot classFile = fContainer.findTypeRoot(type.getQualifiedName());
        if (classFile != null)
        {
          IApiType structure = classFile.getStructure();
          if (structure != null)
          {
            IApiMethod[] methods = structure.getMethods();
            for (int i = 0; i < methods.length; i++)
            {
              IApiMethod method = methods[i];
              if (descriptor.getName().equals(method.getName()))
              {
                String signature = method.getSignature();
                String descriptorSignature = descriptor.getSignature().replace('/', '.');
                if (Signatures.matchesSignatures(descriptorSignature, signature.replace('/', '.'))) {
                  return descriptor.getEnclosingType().getMethod(method.getName(), signature);
                }
                String genericSignature = method.getGenericSignature();
                if ((genericSignature != null) && 
                  (Signatures.matchesSignatures(descriptorSignature, genericSignature.replace('/', '.')))) {
                  return descriptor.getEnclosingType().getMethod(method.getName(), signature);
                }
              }
            }
          }
        }
        throw new CoreException(new Status(4, "org.eclipse.pde.api.tools", 
          MessageFormat.format("Unable to resolve method signature: {0}", new String[] { descriptor.toString() }), null));
      }
      return descriptor;
    }
  }
  
  private static TagScanner fSingleton = null;
  
  public static final TagScanner newScanner()
  {
    if (fSingleton == null) {
      fSingleton = new TagScanner();
    }
    return fSingleton;
  }
  
  public void scan(ICompilationUnit unit, IApiDescription description, IApiTypeContainer container, IProgressMonitor monitor)
    throws CoreException
  {
    scan(new CompilationUnit(unit), description, container, unit.getJavaProject().getOptions(true), monitor);
  }
  
  /* Error */
  public void scan(CompilationUnit source, IApiDescription description, IApiTypeContainer container, java.util.Map options, IProgressMonitor monitor)
    throws CoreException
  {
    // Byte code:
    //   0: aload 5
    //   2: iconst_2
    //   3: invokestatic 187	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   6: astore 6
    //   8: iconst_4
    //   9: invokestatic 191	org/eclipse/jdt/core/dom/ASTParser:newParser	(I)Lorg/eclipse/jdt/core/dom/ASTParser;
    //   12: astore 7
    //   14: aconst_null
    //   15: astore 8
    //   17: aload_1
    //   18: invokevirtual 194	org/eclipse/pde/api/tools/internal/CompilationUnit:getInputStream	()Ljava/io/InputStream;
    //   21: astore 8
    //   23: aload 7
    //   25: aload 8
    //   27: iconst_m1
    //   28: ldc 4
    //   30: invokestatic 182	java/lang/System:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   33: invokestatic 203	org/eclipse/pde/api/tools/internal/util/Util:getInputStreamAsCharArray	(Ljava/io/InputStream;ILjava/lang/String;)[C
    //   36: invokevirtual 189	org/eclipse/jdt/core/dom/ASTParser:setSource	([C)V
    //   39: goto +120 -> 159
    //   42: astore 9
    //   44: new 91	org/eclipse/core/runtime/CoreException
    //   47: dup
    //   48: new 92	org/eclipse/core/runtime/Status
    //   51: dup
    //   52: iconst_4
    //   53: ldc 6
    //   55: ldc 1
    //   57: iconst_1
    //   58: anewarray 87	java/lang/String
    //   61: dup
    //   62: iconst_0
    //   63: aload_1
    //   64: invokevirtual 195	org/eclipse/pde/api/tools/internal/CompilationUnit:getName	()Ljava/lang/String;
    //   67: aastore
    //   68: invokestatic 183	java/text/MessageFormat:format	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   71: aload 9
    //   73: invokespecial 185	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   76: invokespecial 184	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   79: athrow
    //   80: astore 9
    //   82: getstatic 176	org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner:DEBUG	Z
    //   85: ifeq +13 -> 98
    //   88: getstatic 175	java/lang/System:err	Ljava/io/PrintStream;
    //   91: aload_1
    //   92: invokevirtual 195	org/eclipse/pde/api/tools/internal/CompilationUnit:getName	()Ljava/lang/String;
    //   95: invokevirtual 180	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   98: new 91	org/eclipse/core/runtime/CoreException
    //   101: dup
    //   102: new 92	org/eclipse/core/runtime/Status
    //   105: dup
    //   106: iconst_4
    //   107: ldc 6
    //   109: ldc 2
    //   111: iconst_1
    //   112: anewarray 87	java/lang/String
    //   115: dup
    //   116: iconst_0
    //   117: aload_1
    //   118: invokevirtual 195	org/eclipse/pde/api/tools/internal/CompilationUnit:getName	()Ljava/lang/String;
    //   121: aastore
    //   122: invokestatic 183	java/text/MessageFormat:format	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   125: aload 9
    //   127: invokespecial 185	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   130: invokespecial 184	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   133: athrow
    //   134: astore 10
    //   136: aload 8
    //   138: ifnull +18 -> 156
    //   141: aload 8
    //   143: invokevirtual 179	java/io/InputStream:close	()V
    //   146: goto +10 -> 156
    //   149: astore 11
    //   151: aload 11
    //   153: invokestatic 197	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   156: aload 10
    //   158: athrow
    //   159: aload 8
    //   161: ifnull +18 -> 179
    //   164: aload 8
    //   166: invokevirtual 179	java/io/InputStream:close	()V
    //   169: goto +10 -> 179
    //   172: astore 11
    //   174: aload 11
    //   176: invokestatic 197	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   179: aload 6
    //   181: invokestatic 202	org/eclipse/pde/api/tools/internal/util/Util:updateMonitor	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   184: aload 4
    //   186: astore 9
    //   188: aload 9
    //   190: ifnonnull +8 -> 198
    //   193: invokestatic 188	org/eclipse/jdt/core/JavaCore:getOptions	()Ljava/util/Hashtable;
    //   196: astore 9
    //   198: aload 9
    //   200: ldc 5
    //   202: ldc 3
    //   204: invokeinterface 204 3 0
    //   209: pop
    //   210: aload 7
    //   212: aload 9
    //   214: invokevirtual 190	org/eclipse/jdt/core/dom/ASTParser:setCompilerOptions	(Ljava/util/Map;)V
    //   217: aload 7
    //   219: aload 6
    //   221: iconst_1
    //   222: invokevirtual 186	org/eclipse/core/runtime/SubMonitor:newChild	(I)Lorg/eclipse/core/runtime/SubMonitor;
    //   225: invokevirtual 192	org/eclipse/jdt/core/dom/ASTParser:createAST	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/jdt/core/dom/ASTNode;
    //   228: checkcast 98	org/eclipse/jdt/core/dom/CompilationUnit
    //   231: astore 10
    //   233: new 102	org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner$Visitor
    //   236: dup
    //   237: aload_2
    //   238: aload_3
    //   239: invokespecial 201	org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner$Visitor:<init>	(Lorg/eclipse/pde/api/tools/internal/provisional/IApiDescription;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiTypeContainer;)V
    //   242: astore 11
    //   244: aload 10
    //   246: aload 11
    //   248: invokevirtual 193	org/eclipse/jdt/core/dom/CompilationUnit:accept	(Lorg/eclipse/jdt/core/dom/ASTVisitor;)V
    //   251: aload 11
    //   253: invokevirtual 200	org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner$Visitor:getException	()Lorg/eclipse/core/runtime/CoreException;
    //   256: ifnull +9 -> 265
    //   259: aload 11
    //   261: invokevirtual 200	org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner$Visitor:getException	()Lorg/eclipse/core/runtime/CoreException;
    //   264: athrow
    //   265: return
    // Line number table:
    //   Java source line #517	-> byte code offset #0
    //   Java source line #518	-> byte code offset #8
    //   Java source line #519	-> byte code offset #14
    //   Java source line #521	-> byte code offset #17
    //   Java source line #522	-> byte code offset #23
    //   Java source line #523	-> byte code offset #42
    //   Java source line #524	-> byte code offset #44
    //   Java source line #525	-> byte code offset #55
    //   Java source line #524	-> byte code offset #76
    //   Java source line #526	-> byte code offset #80
    //   Java source line #527	-> byte code offset #82
    //   Java source line #528	-> byte code offset #88
    //   Java source line #530	-> byte code offset #98
    //   Java source line #531	-> byte code offset #109
    //   Java source line #530	-> byte code offset #130
    //   Java source line #532	-> byte code offset #134
    //   Java source line #533	-> byte code offset #136
    //   Java source line #535	-> byte code offset #141
    //   Java source line #536	-> byte code offset #149
    //   Java source line #537	-> byte code offset #151
    //   Java source line #540	-> byte code offset #156
    //   Java source line #533	-> byte code offset #159
    //   Java source line #535	-> byte code offset #164
    //   Java source line #536	-> byte code offset #172
    //   Java source line #537	-> byte code offset #174
    //   Java source line #541	-> byte code offset #179
    //   Java source line #542	-> byte code offset #184
    //   Java source line #543	-> byte code offset #188
    //   Java source line #544	-> byte code offset #193
    //   Java source line #546	-> byte code offset #198
    //   Java source line #547	-> byte code offset #210
    //   Java source line #548	-> byte code offset #217
    //   Java source line #549	-> byte code offset #233
    //   Java source line #550	-> byte code offset #244
    //   Java source line #551	-> byte code offset #251
    //   Java source line #552	-> byte code offset #259
    //   Java source line #554	-> byte code offset #265
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	266	0	this	TagScanner
    //   0	266	1	source	CompilationUnit
    //   0	266	2	description	IApiDescription
    //   0	266	3	container	IApiTypeContainer
    //   0	266	4	options	java.util.Map
    //   0	266	5	monitor	IProgressMonitor
    //   6	214	6	localmonitor	org.eclipse.core.runtime.SubMonitor
    //   12	206	7	parser	org.eclipse.jdt.core.dom.ASTParser
    //   15	150	8	inputStream	java.io.InputStream
    //   42	30	9	e	java.io.FileNotFoundException
    //   80	46	9	e	java.io.IOException
    //   186	27	9	loptions	java.util.Map
    //   134	23	10	localObject	Object
    //   231	14	10	cunit	org.eclipse.jdt.core.dom.CompilationUnit
    //   149	3	11	e	java.io.IOException
    //   172	3	11	e	java.io.IOException
    //   242	18	11	visitor	Visitor
    // Exception table:
    //   from	to	target	type
    //   17	39	42	java/io/FileNotFoundException
    //   17	39	80	java/io/IOException
    //   17	134	134	finally
    //   141	146	149	java/io/IOException
    //   164	169	172	java/io/IOException
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
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.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
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;

class ApiSearchEngine$ReferenceExtractor
  extends ApiTypeContainerVisitor
{
  static final int COLLECTOR_MAX = 2500;
  private List collector;
  private IApiSearchRequestor requestor;
  private IApiSearchReporter reporter;
  IApiElement element;
  private SubMonitor monitor;
  final ApiSearchEngine this$0;
  
  public ApiSearchEngine$ReferenceExtractor(ApiSearchEngine paramApiSearchEngine, IApiSearchRequestor requestor, IApiSearchReporter reporter, IApiElement element, IProgressMonitor monitor)
  {
    this$0 = paramApiSearchEngine;collector = null;this.requestor = null;this.reporter = null;this.element = null;this.monitor = null;
    collector = new ArrayList();
    this.requestor = requestor;
    this.reporter = reporter;
    this.element = element;
    this.monitor = ((SubMonitor)monitor);
  }
  
  public boolean visit(IApiTypeContainer container)
  {
    return requestor.acceptContainer(container);
  }
  
  public void visit(String packageName, IApiTypeRoot typeroot)
  {
    if (monitor.isCanceled()) {
      return;
    }
    try
    {
      IApiType type = typeroot.getStructure();
      if ((type == null) || (!requestor.acceptMember(type))) {
        return;
      }
      collector.addAll(this$0.acceptReferences(
        requestor, 
        type, 
        this$0.getResolvedReferences(requestor, type, monitor.newChild(1)), 
        monitor.newChild(1)));
    }
    catch (CoreException ce)
    {
      ApiPlugin.log(ce);
    }
  }
  
  public void end(String packageName, IApiTypeRoot typeroot)
  {
    if (collector.size() >= 2500) {
      reportResults();
    }
  }
  
  public boolean visit(IApiComponent component)
  {
    return requestor.acceptComponent(component);
  }
  
  public void endVisitPackage(String packageName)
  {
    reportResults();
  }
  
  private void reportResults()
  {
    reporter.reportResults(element, (IReference[])collector.toArray(new IReference[collector.size()]));
    collector.clear();
  }
}

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

import com.ibm.icu.text.MessageFormat;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
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.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.pde.api.tools.internal.builder.Reference;
import org.eclipse.pde.api.tools.internal.builder.ReferenceResolver;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
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.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
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.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.search.SearchMessages;
import org.eclipse.pde.api.tools.internal.util.Util;

public final class ApiSearchEngine
{
  public static final IReference[] NO_REFERENCES = new IReference[0];
  private static boolean DEBUG = Util.DEBUG;
  
  class ReferenceExtractor
    extends ApiTypeContainerVisitor
  {
    static final int COLLECTOR_MAX = 2500;
    private List collector = null;
    private IApiSearchRequestor requestor = null;
    private IApiSearchReporter reporter = null;
    IApiElement element = null;
    private SubMonitor monitor = null;
    
    public ReferenceExtractor(IApiSearchRequestor requestor, IApiSearchReporter reporter, IApiElement element, IProgressMonitor monitor)
    {
      collector = new ArrayList();
      this.requestor = requestor;
      this.reporter = reporter;
      this.element = element;
      this.monitor = ((SubMonitor)monitor);
    }
    
    public boolean visit(IApiTypeContainer container)
    {
      return requestor.acceptContainer(container);
    }
    
    public void visit(String packageName, IApiTypeRoot typeroot)
    {
      if (monitor.isCanceled()) {
        return;
      }
      try
      {
        IApiType type = typeroot.getStructure();
        if ((type == null) || (!requestor.acceptMember(type))) {
          return;
        }
        collector.addAll(acceptReferences(
          requestor, 
          type, 
          getResolvedReferences(requestor, type, monitor.newChild(1)), 
          monitor.newChild(1)));
      }
      catch (CoreException ce)
      {
        ApiPlugin.log(ce);
      }
    }
    
    public void end(String packageName, IApiTypeRoot typeroot)
    {
      if (collector.size() >= 2500) {
        reportResults();
      }
    }
    
    public boolean visit(IApiComponent component)
    {
      return requestor.acceptComponent(component);
    }
    
    public void endVisitPackage(String packageName)
    {
      reportResults();
    }
    
    private void reportResults()
    {
      reporter.reportResults(element, (IReference[])collector.toArray(new IReference[collector.size()]));
      collector.clear();
    }
  }
  
  public static void setDebug(boolean debugValue)
  {
    DEBUG = (debugValue) || (Util.DEBUG);
  }
  
  private String fRequestorContext = null;
  
  List getResolvedReferences(IApiSearchRequestor requestor, IApiType type, IProgressMonitor monitor)
    throws CoreException
  {
    String name = type.getSimpleName();
    SubMonitor localmonitor = SubMonitor.convert(monitor, 
      MessageFormat.format(SearchMessages.ApiSearchEngine_extracting_refs_from, new String[] { name == null ? SearchMessages.ApiSearchEngine_anonymous_type : name }), 2);
    try
    {
      List refs = type.extractReferences(requestor.getReferenceKinds(), localmonitor.newChild(1));
      ReferenceResolver.resolveReferences(refs, localmonitor.newChild(1));
      return refs;
    }
    finally
    {
      localmonitor.done();
    }
  }
  
  List acceptReferences(IApiSearchRequestor requestor, IApiType type, List references, IProgressMonitor monitor)
    throws CoreException
  {
    ArrayList refs = new ArrayList();
    Reference ref = null;
    SubMonitor localmonitor = SubMonitor.convert(monitor, references.size());
    IApiMember member = null;
    try
    {
      for (Iterator iter = references.iterator(); iter.hasNext();)
      {
        if (localmonitor.isCanceled()) {
          return Collections.EMPTY_LIST;
        }
        ref = (Reference)iter.next();
        member = ref.getResolvedReference();
        if (member != null)
        {
          localmonitor.setTaskName(MessageFormat.format(SearchMessages.ApiSearchEngine_searching_for_use_from, new String[] { fRequestorContext, type.getName() }));
          if (requestor.acceptReference(ref)) {
            refs.add(ref);
          }
          localmonitor.worked(1);
        }
      }
    }
    finally
    {
      localmonitor.done();
    }
    localmonitor.done();
    
    return refs;
  }
  
  /* Error */
  private void searchReferences(IApiSearchRequestor requestor, IApiElement element, IApiSearchReporter reporter, IProgressMonitor monitor)
    throws CoreException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore 5
    //   3: aload 4
    //   5: iconst_3
    //   6: invokestatic 343	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   9: astore 6
    //   11: aload_2
    //   12: invokeinterface 361 1 0
    //   17: tableswitch	default:+287->304, 1:+121->138, 2:+39->56, 3:+287->304, 4:+287->304, 5:+189->206, 6:+189->206
    //   56: aload 6
    //   58: invokevirtual 339	org/eclipse/core/runtime/SubMonitor:isCanceled	()Z
    //   61: ifeq +13 -> 74
    //   64: aload_3
    //   65: aload_2
    //   66: getstatic 307	org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine:NO_REFERENCES	[Lorg/eclipse/pde/api/tools/internal/provisional/builder/IReference;
    //   69: invokeinterface 368 3 0
    //   74: aload_2
    //   75: checkcast 173	org/eclipse/pde/api/tools/internal/provisional/model/IApiType
    //   78: astore 7
    //   80: aload_0
    //   81: aload_1
    //   82: aload 7
    //   84: aload_0
    //   85: aload_1
    //   86: aload 7
    //   88: aload 6
    //   90: iconst_1
    //   91: invokevirtual 342	org/eclipse/core/runtime/SubMonitor:newChild	(I)Lorg/eclipse/core/runtime/SubMonitor;
    //   94: invokevirtual 348	org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine:getResolvedReferences	(Lorg/eclipse/pde/api/tools/internal/provisional/search/IApiSearchRequestor;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiType;Lorg/eclipse/core/runtime/IProgressMonitor;)Ljava/util/List;
    //   97: aload 6
    //   99: iconst_1
    //   100: invokevirtual 342	org/eclipse/core/runtime/SubMonitor:newChild	(I)Lorg/eclipse/core/runtime/SubMonitor;
    //   103: invokevirtual 350	org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine:acceptReferences	(Lorg/eclipse/pde/api/tools/internal/provisional/search/IApiSearchRequestor;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiType;Ljava/util/List;Lorg/eclipse/core/runtime/IProgressMonitor;)Ljava/util/List;
    //   106: astore 5
    //   108: aload_3
    //   109: aload_2
    //   110: aload 5
    //   112: aload 5
    //   114: invokeinterface 355 1 0
    //   119: anewarray 168	org/eclipse/pde/api/tools/internal/provisional/builder/IReference
    //   122: invokeinterface 357 2 0
    //   127: checkcast 150	[Lorg/eclipse/pde/api/tools/internal/provisional/builder/IReference;
    //   130: invokeinterface 368 3 0
    //   135: goto +169 -> 304
    //   138: aload 6
    //   140: invokevirtual 339	org/eclipse/core/runtime/SubMonitor:isCanceled	()Z
    //   143: ifeq +13 -> 156
    //   146: aload_3
    //   147: aload_2
    //   148: getstatic 307	org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine:NO_REFERENCES	[Lorg/eclipse/pde/api/tools/internal/provisional/builder/IReference;
    //   151: invokeinterface 368 3 0
    //   156: new 175	org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine$ReferenceExtractor
    //   159: dup
    //   160: aload_0
    //   161: aload_1
    //   162: aload_3
    //   163: aload_2
    //   164: aload 6
    //   166: iconst_1
    //   167: invokevirtual 342	org/eclipse/core/runtime/SubMonitor:newChild	(I)Lorg/eclipse/core/runtime/SubMonitor;
    //   170: invokespecial 351	org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine$ReferenceExtractor:<init>	(Lorg/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine;Lorg/eclipse/pde/api/tools/internal/provisional/search/IApiSearchRequestor;Lorg/eclipse/pde/api/tools/internal/provisional/search/IApiSearchReporter;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiElement;Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   173: astore 7
    //   175: aload_2
    //   176: checkcast 169	org/eclipse/pde/api/tools/internal/provisional/model/IApiComponent
    //   179: astore 8
    //   181: aload 8
    //   183: aload 7
    //   185: invokeinterface 360 2 0
    //   190: aload 8
    //   192: invokeinterface 358 1 0
    //   197: aload 6
    //   199: iconst_1
    //   200: invokestatic 352	org/eclipse/pde/api/tools/internal/util/Util:updateMonitor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   203: goto +101 -> 304
    //   206: aload 6
    //   208: invokevirtual 339	org/eclipse/core/runtime/SubMonitor:isCanceled	()Z
    //   211: ifeq +13 -> 224
    //   214: aload_3
    //   215: aload_2
    //   216: getstatic 307	org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine:NO_REFERENCES	[Lorg/eclipse/pde/api/tools/internal/provisional/builder/IReference;
    //   219: invokeinterface 368 3 0
    //   224: aload_2
    //   225: checkcast 171	org/eclipse/pde/api/tools/internal/provisional/model/IApiMember
    //   228: astore 7
    //   230: aload 7
    //   232: invokeinterface 363 1 0
    //   237: astore 8
    //   239: aload 8
    //   241: ifnull +31 -> 272
    //   244: aload_0
    //   245: aload_1
    //   246: aload 8
    //   248: aload_0
    //   249: aload_1
    //   250: aload 8
    //   252: aload 6
    //   254: iconst_1
    //   255: invokevirtual 342	org/eclipse/core/runtime/SubMonitor:newChild	(I)Lorg/eclipse/core/runtime/SubMonitor;
    //   258: invokevirtual 348	org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine:getResolvedReferences	(Lorg/eclipse/pde/api/tools/internal/provisional/search/IApiSearchRequestor;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiType;Lorg/eclipse/core/runtime/IProgressMonitor;)Ljava/util/List;
    //   261: aload 6
    //   263: iconst_1
    //   264: invokevirtual 342	org/eclipse/core/runtime/SubMonitor:newChild	(I)Lorg/eclipse/core/runtime/SubMonitor;
    //   267: invokevirtual 350	org/eclipse/pde/api/tools/internal/provisional/search/ApiSearchEngine:acceptReferences	(Lorg/eclipse/pde/api/tools/internal/provisional/search/IApiSearchRequestor;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiType;Ljava/util/List;Lorg/eclipse/core/runtime/IProgressMonitor;)Ljava/util/List;
    //   270: astore 5
    //   272: aload 5
    //   274: ifnull +30 -> 304
    //   277: aload_3
    //   278: aload_2
    //   279: aload 5
    //   281: aload 5
    //   283: invokeinterface 355 1 0
    //   288: anewarray 168	org/eclipse/pde/api/tools/internal/provisional/builder/IReference
    //   291: invokeinterface 357 2 0
    //   296: checkcast 150	[Lorg/eclipse/pde/api/tools/internal/provisional/builder/IReference;
    //   299: invokeinterface 368 3 0
    //   304: aload 6
    //   306: iconst_1
    //   307: invokestatic 352	org/eclipse/pde/api/tools/internal/util/Util:updateMonitor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   310: goto +13 -> 323
    //   313: astore 9
    //   315: aload 6
    //   317: invokevirtual 338	org/eclipse/core/runtime/SubMonitor:done	()V
    //   320: aload 9
    //   322: athrow
    //   323: aload 6
    //   325: invokevirtual 338	org/eclipse/core/runtime/SubMonitor:done	()V
    //   328: return
    // Line number table:
    //   Java source line #222	-> byte code offset #0
    //   Java source line #223	-> byte code offset #3
    //   Java source line #225	-> byte code offset #11
    //   Java source line #227	-> byte code offset #56
    //   Java source line #228	-> byte code offset #64
    //   Java source line #230	-> byte code offset #74
    //   Java source line #231	-> byte code offset #80
    //   Java source line #232	-> byte code offset #82
    //   Java source line #233	-> byte code offset #84
    //   Java source line #234	-> byte code offset #97
    //   Java source line #231	-> byte code offset #103
    //   Java source line #235	-> byte code offset #108
    //   Java source line #236	-> byte code offset #135
    //   Java source line #239	-> byte code offset #138
    //   Java source line #240	-> byte code offset #146
    //   Java source line #242	-> byte code offset #156
    //  
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