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

 (!pathname.isHidden());
  }
}

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

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

class UseScanParser$ReferenceHandler
  extends DefaultHandler
{
  private int type;
  final UseScanParser this$0;
  
  public UseScanParser$ReferenceHandler(UseScanParser paramUseScanParser, int type)
  {
    this$0 = paramUseScanParser;this.type = 0;
    this.type = type;
  }
  
  public void startElement(String uri, String localName, String name, Attributes attributes)
    throws SAXException
  {
    this$0.processElement(uri, localName, name, attributes, type);
  }
}

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

import java.io.File;
import java.io.FileFilter;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.provisional.Factory;
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.util.Util;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class UseScanParser
{
  private UseScanVisitor visitor;
  private IComponentDescriptor targetComponent;
  private IComponentDescriptor referencingComponent;
  private IMemberDescriptor targetMember;
  private int referenceKind;
  private int visibility;
  private boolean visitReferencingComponent = true;
  private boolean visitMembers = true;
  private boolean visitReferences = true;
  
  class ReferenceHandler
    extends DefaultHandler
  {
    private int type = 0;
    
    public ReferenceHandler(int type)
    {
      this.type = type;
    }
    
    public void startElement(String uri, String localName, String name, Attributes attributes)
      throws SAXException
    {
      processElement(uri, localName, name, attributes, type);
    }
  }
  
  protected String[] getIdVersion(String value)
  {
    int index = value.indexOf(' ');
    if (index > 0)
    {
      String id = value.substring(0, index);
      String version = value.substring(index + 1);
      if (version.startsWith("("))
      {
        version = version.substring(1);
        if (version.endsWith(")")) {
          version = version.substring(0, version.length() - 1);
        }
      }
      return new String[] { id, version };
    }
    return new String[] { value };
  }
  
  protected void processElement(String uri, String localName, String name, Attributes attributes, int type)
    throws SAXException
  {
    if ("references".equals(name))
    {
      String target = attributes.getValue("referee");
      String[] idv = getIdVersion(target);
      IComponentDescriptor targetComponent = Factory.componentDescriptor(idv[0], idv[1]);
      if (!targetComponent.equals(this.targetComponent)) {
        System.out.println("WARNING: The referee in the xml file (" + targetComponent + ") does not match the directory name (" + this.targetComponent + ")");
      }
      String source = attributes.getValue("origin");
      idv = getIdVersion(source);
      IComponentDescriptor sourceComponent = Factory.componentDescriptor(idv[0], idv[1]);
      if (!sourceComponent.equals(referencingComponent)) {
        System.out.println("WARNING: The origin in the xml file (" + sourceComponent + ") does not match the directory name (" + referencingComponent + ")");
      }
      String visString = attributes.getValue("reference_visibility");
      try
      {
        int vis = Integer.parseInt(visString);
        enterVisibility(vis);
      }
      catch (NumberFormatException localNumberFormatException1)
      {
        enterVisibility(-1);
        System.out.println("Internal error: invalid visibility: " + visString);
      }
    }
    else if ("target".equals(name))
    {
      String qName = attributes.getValue("type");
      String memberName = attributes.getValue("member");
      String signature = attributes.getValue("signature");
      IMemberDescriptor member = null;
      switch (type)
      {
      case 1: 
        member = Factory.typeDescriptor(qName);
        break;
      case 3: 
        member = Factory.methodDescriptor(qName, memberName, signature);
        break;
      case 2: 
        member = Factory.fieldDescriptor(qName, memberName);
      }
      enterTargetMember(member);
    }
    else if ("reference_kind".equals(name))
    {
      String value = attributes.getValue("kind");
      if (value != null) {
        try
        {
          enterReferenceKind(Integer.parseInt(value));
        }
        catch (NumberFormatException localNumberFormatException2)
        {
          System.out.println(NLS.bind("Internal error: invalid reference kind: {0}", value));
        }
      }
    }
    else if ("reference".equals(name))
    {
      String qName = attributes.getValue("type");
      if (qName != null)
      {
        String memberName = attributes.getValue("member");
        String signature = attributes.getValue("signature");
        IMemberDescriptor origin = null;
        if (signature != null) {
          origin = Factory.methodDescriptor(qName, memberName, signature);
        } else if (memberName != null) {
          origin = Factory.fieldDescriptor(qName, memberName);
        } else {
          origin = Factory.typeDescriptor(qName);
        }
        String line = attributes.getValue("linenumber");
        String flags = attributes.getValue("flags");
        try
        {
          int num = Integer.parseInt(line);
          int flgs = 0;
          if (flags != null) {
            flgs = Integer.parseInt(flags);
          }
          setReference(Factory.referenceDescriptor(
            referencingComponent, 
            origin, 
            num, 
            this.targetComponent, 
            targetMember, 
            referenceKind, 
            flgs, 
            visibility, 
            parseMessages(attributes)));
        }
        catch (NumberFormatException localNumberFormatException3)
        {
          System.out.println("Internal error: invalid line number: " + line);
        }
      }
      else
      {
        System.out.println(NLS.bind("Element {0} is missing type attribute and will be skipped", targetMember.getName()));
      }
    }
  }
  
  protected String[] parseMessages(Attributes attribs)
  {
    String msgs = attribs.getValue("message_arguments");
    String[] messages = (String[])null;
    if (msgs != null) {
      messages = msgs.split("\\,");
    }
    return messages;
  }
  
  /* Error */
  public void parse(String xmlLocation, org.eclipse.core.runtime.IProgressMonitor monitor, UseScanVisitor usv)
    throws Exception
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnonnull +14 -> 15
    //   4: new 224	java/lang/Exception
    //   7: dup
    //   8: getstatic 406	org/eclipse/pde/api/tools/internal/search/SearchMessages:missing_xml_files_location	Ljava/lang/String;
    //   11: invokespecial 423	java/lang/Exception:<init>	(Ljava/lang/String;)V
    //   14: athrow
    //   15: aload_0
    //   16: aload_3
    //   17: putfield 415	org/eclipse/pde/api/tools/internal/search/UseScanParser:visitor	Lorg/eclipse/pde/api/tools/internal/search/UseScanVisitor;
    //   20: new 221	java/io/File
    //   23: dup
    //   24: aload_1
    //   25: invokespecial 420	java/io/File:<init>	(Ljava/lang/String;)V
    //   28: astore 4
    //   30: aload 4
    //   32: invokevirtual 417	java/io/File:exists	()Z
    //   35: ifeq +11 -> 46
    //   38: aload 4
    //   40: invokevirtual 418	java/io/File:isDirectory	()Z
    //   43: ifne +18 -> 61
    //   46: new 224	java/lang/Exception
    //   49: dup
    //   50: getstatic 405	org/eclipse/pde/api/tools/internal/search/SearchMessages:invalid_directory_name	Ljava/lang/String;
    //   53: aload_1
    //   54: invokestatic 450	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   57: invokespecial 423	java/lang/Exception:<init>	(Ljava/lang/String;)V
    //   60: athrow
    //   61: aload_2
    //   62: getstatic 404	org/eclipse/pde/api/tools/internal/search/SearchMessages:UseScanParser_parsing	Ljava/lang/String;
    //   65: bipush 8
    //   67: invokestatic 449	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;Ljava/lang/String;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   70: astore 5
    //   72: aload 5
    //   74: getstatic 400	org/eclipse/pde/api/tools/internal/search/SearchMessages:UseReportConverter_collecting_dir_info	Ljava/lang/String;
    //   77: invokevirtual 447	org/eclipse/core/runtime/SubMonitor:subTask	(Ljava/lang/String;)V
    //   80: aload_0
    //   81: aload 4
    //   83: invokevirtual 468	org/eclipse/pde/api/tools/internal/search/UseScanParser:getDirectories	(Ljava/io/File;)[Ljava/io/File;
    //   86: astore 6
    //   88: aload 5
    //   90: iconst_1
    //   91: invokestatic 484	org/eclipse/pde/api/tools/internal/util/Util:updateMonitor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   94: aconst_null
    //   95: checkcast 219	[Ljava/io/File;
    //   98: astore 7
    //   100: aconst_null
    //   101: checkcast 219	[Ljava/io/File;
    //   104: astore 8
    //   106: aload 5
    //   108: aload 6
    //   110: arraylength
    //   111: invokevirtual 448	org/eclipse/core/runtime/SubMonitor:setWorkRemaining	(I)Lorg/eclipse/core/runtime/SubMonitor;
    //   114: pop
    //   115: aload_0
    //   116: getfield 415	org/eclipse/pde/api/tools/internal/search/UseScanParser:visitor	Lorg/eclipse/pde/api/tools/internal/search/UseScanVisitor;
    //   119: invokevirtual 476	org/eclipse/pde/api/tools/internal/search/UseScanVisitor:visitScan	()V
    //   122: aload_0
    //   123: invokevirtual 463	org/eclipse/pde/api/tools/internal/search/UseScanParser:getParser	()Ljavax/xml/parsers/SAXParser;
    //   126: astore 9
    //   128: iconst_0
    //   129: istore 10
    //   131: goto +281 -> 412
    //   134: aload 6
    //   136: iload 10
    //   138: aaload
    //   139: invokevirtual 418	java/io/File:isDirectory	()Z
    //   142: ifeq +267 -> 409
    //   145: aload_0
    //   146: aload 6
    //   148: iload 10
    //   150: aaload
    //   151: invokevirtual 419	java/io/File:getName	()Ljava/lang/String;
    //   154: invokevirtual 470	org/eclipse/pde/api/tools/internal/search/UseScanParser:getIdVersion	(Ljava/lang/String;)[Ljava/lang/String;
    //   157: astore 11
    //   159: aload 11
    //   161: iconst_0
    //   162: aaload
    //   163: aload 11
    //   165: iconst_1
    //   166: aaload
    //   167: invokestatic 453	org/eclipse/pde/api/tools/internal/provisional/Factory:componentDescriptor	(Ljava/lang/String;Ljava/lang/String;)Lorg/eclipse/pde/api/tools/internal/provisional/descriptors/IComponentDescriptor;
    //   170: astore 12
    //   172: aload_0
    //   173: aload 12
    //   175: invokevirtual 465	org/eclipse/pde/api/tools/internal/search/UseScanParser:enterTargetComponent	(Lorg/eclipse/pde/api/tools/internal/provisional/descriptors/IComponentDescriptor;)V
    //   178: aload_0
    //   179: getfield 411	org/eclipse/pde/api/tools/internal/search/UseScanParser:visitReferencingComponent	Z
    //   182: ifeq +217 -> 399
    //   185: aload_0
    //   186: aload 6
    //   188: iload 10
    //   190: aaload
    //   191: invokevirtual 468	org/eclipse/pde/api/tools/internal/search/UseScanParser:getDirectories	(Ljava/io/File;)[Ljava/io/File;
    //   194: astore 7
    //   196: aload_0
    //   197: aload 7
    //   199: invokevirtual 469	org/eclipse/pde/api/tools/internal/search/UseScanParser:sort	([Ljava/io/File;)[Ljava/io/File;
    //   202: astore 7
    //   204: iconst_0
    //   205: istore 13
    //   207: goto +184 -> 391
    //   210: aload 7
    //   212: iload 13
    //   214: aaload
    //   215: invokevirtual 418	java/io/File:isDirectory	()Z
    //   218: ifeq +170 -> 388
    //   221: aload_0
    //   222: aload 7
    //   224: iload 13
    //   226: aaload
    //   227: invokevirtual 419	java/io/File:getName	()Ljava/lang/String;
    //   230: invokevirtual 470	org/eclipse/pde/api/tools/internal/search/UseScanParser:getIdVersion	(Ljava/lang/String;)[Ljava/lang/String;
    //   233: astore 11
    //   235: aload 11
    //   237: iconst_0
    //   238: aaload
    //   239: aload 11
    //   241: iconst_1
    //   242: aaload
    //   243: invokestatic 453	org/eclipse/pde/api/tools/internal/provisional/Factory:componentDescriptor	(Ljava/lang/String;Ljava/lang/String;)Lorg/eclipse/pde/api/tools/internal/provisional/descriptors/IComponentDescriptor;
    //   246: astore 14
    //   248: aload_0
    //   249: aload 14
    //   251: invokevirtual 464	org/eclipse/pde/api/tools/internal/search/UseScanParser:enterReferencingComponent	(Lorg/eclipse/pde/api/tools/internal/provisional/descriptors/IComponentDescriptor;)V
    //   254: aload_0
    //   255: getfield 409	org/eclipse/pde/api/tools/internal/search/UseScanParser:visitMembers	Z
    //   258: ifeq +126 -> 384
    //   261: aload 5
    //   263: getstatic 403	org/eclipse/pde/api/tools/internal/search/SearchMessages:UseScanParser_analyzing_references	Ljava/lang/String;
    //   266: iconst_1
    //   267: anewarray 228	java/lang/String
    //   270: dup
    //   271: iconst_0
    //   272: aload 7
    //   274: iload 13
    //   276: aaload
    //   277: invokevirtual 419	java/io/File:getName	()Ljava/lang/String;
    //   280: aastore
    //   281: invokestatic 451	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   284: invokevirtual 447	org/eclipse/core/runtime/SubMonitor:subTask	(Ljava/lang/String;)V
    //   287: aload 7
    //   289: iload 13
    //   291: aaload
    //   292: new 243	org/eclipse/pde/api/tools/internal/search/UseScanParser$1
    //   295: dup
    //   296: aload_0
    //   297: invokespecial 472	org/eclipse/pde/api/tools/internal/search/UseScanParser$1:<init>	(Lorg/eclipse/pde/api/tools/internal/search/UseScanParser;)V
    //   300: invokestatic 485	org/eclipse/pde/api/tools/internal/util/Util:getAllFiles	(Ljava/io/File;Ljava/io/FileFilter;)[Ljava/io/File;
    //   303: astore 8
    //   305: aload 8
    //   307: ifnull +73 -> 380
    //   310: aload 8
    //   312: arraylength
    //   313: ifle +67 -> 380
    //   316: aload_0
    //   317: aload 8
    //   319: invokevirtual 469	org/eclipse/pde/api/tools/internal/search/UseScanParser:sort	([Ljava/io/File;)[Ljava/io/File;
    //   322: astore 8
    //   324: iconst_0
    //   325: istore 15
    //   327: goto +45 -> 372
    //   330: new 245	org/eclipse/pde/api/tools/internal/search/UseScanParser$ReferenceHandler
    //   333: dup
    //   334: aload_0
    //   335: aload_0
    //   336: aload 8
    //   338: iload 15
    //   340: aaload
    //   341: invokespecial 462	org/eclipse/pde/api/tools/internal/search/UseScanParser:getTypeFromFileName	(Ljava/io/File;)I
    //   344: invokespecial 474	org/eclipse/pde/api/tools/internal/search/UseScanParser$ReferenceHandler:<init>	(Lorg/eclipse/pde/api/tools/internal/search/UseScanParser;I)V
    //   347: astore 16
    //   349: aload 9
    //   351: aload 8
    //   353: iload 15
    //   355: aaload
    //   356: aload 16
    //   358: invokevirtual 443	javax/xml/parsers/SAXParser:parse	(Ljava/io/File;Lorg/xml/sax/helpers/DefaultHandler;)V
    //   361: goto +8 -> 369
    //   364: pop
    //   365: goto +4 -> 369
    //   368: pop
    //   369: iinc 15 1
    //   372: iload 15
    //   374: aload 8
    //   376: arraylength
    //   377: if_icmplt -47 -> 330
    //   380: aload_0
    //   381: invokespecial 458	org/eclipse/pde/api/tools/internal/search/UseScanParser:endMember	()V
    //   384: aload_0
    //   385: invokespecial 459	org/eclipse/pde/api/tools/internal/search/UseScanParser:endReferencingComponent	()V
    //   388: iinc 13 1
    //   391: iload 13
    //   393: aload 7
    //   395: arraylength
    //   396: if_icmplt -186 -> 210
    //   399: aload 5
    //   401: iconst_1
    //   402: invokestatic 484	org/eclipse/pde/api/tools/internal/util/Util:updateMonitor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   405: aload_0
    //   406: invokespecial 457	org/eclipse/pde/api/tools/internal/search/UseScanParser:endComponent	()V
    //   409: iinc 10 1
    //   412: iload 10
    //   414: aload 6
    //   416: arraylength
    //   417: if_icmplt -283 -> 134
    //   420: goto +20 -> 440
    //   423: astore 17
    //   425: aload_0
    //   426: getfield 415	org/eclipse/pde/api/tools/internal/search/UseScanParser:visitor	Lorg/eclipse/pde/api/tools/internal/search/UseScanVisitor;
    //   429: invokevirtual 475	org/eclipse/pde/api/tools/internal/search/UseScanVisitor:endVisitScan	()V
    //   432: aload 5
    //   434: invokevirtual 446	org/eclipse/core/runtime/SubMonitor:done	()V
    //   437: aload 17
    //   439: athrow
    //   440: aload_0
    //   441: getfield 415	org/eclipse/pde/api/tools/internal/search/UseScanParser:visitor	Lorg/eclipse/pde/api/tools/internal/search/UseScanVisitor;
    //   444: invokevirtual 475	org/eclipse/pde/api/tools/internal/search/UseScanVisitor:endVisitScan	()V
    //   447: aload 5
    //   449: invokevirtual 446	org/eclipse/core/runtime/SubMonitor:done	()V
    //   452: return
    // Line number table:
    //   Java source line #229	-> byte code offset #0
    //   Java source line #230	-> byte code offset #4
    //   Java source line #232	-> byte code offset #15
    //   Java source line #233	-> byte code offset #20
    //   Java source line #234	-> byte code offset #30
    //   Java source line #235	-> byte code offset #46
    //   Java source line #237	-> byte code offset #61
    //   Java source line #238	-> byte code offset #72
    //   Java source line #239	-> byte code offset #80
    //   Java source line #240	-> byte code offset #88
    //   Java source line #241	-> byte code offset #94
    //   Java source line #242	-> byte code offset #100
    //   Java source line #243	-> byte code offset #106
    //   Java source line #244	-> byte code offset #115
    //   Java source line #246	-> byte code offset #122
    //   Java source line #248	-> byte code offset #128
    //   Java source line #249	-> byte code offset #134
    //   Java source line #250	-> byte code offset #145
    //   Java source line #251	-> byte code offset #159
    //   Java source line #252	-> byte code offset #172
    //   Java source line #253	-> byte code offset #178
    //   Java source line #256	-> byte code offset #185
    //   Java source line #257	-> byte code offset #196
    //   Java source line #258	-> byte code offset #204
    //   Java source line #259	-> byte code offset #210
    //   Java source line #260	-> byte code offset #221
    //   Java source line #261	-> byte code offset #235
    //   Java source line #262	-> byte code offset #248
    //   Java source line #263	-> byte code offset #254
    //   Java source line #266	-> byte code offset #261
    //   Java source line #267	-> byte code offset #287
    //   Java source line #272	-> byte code offset #305
    //   Java source line #273	-> byte code offset #316
    //   Java source line #274	-> byte code offset #324
    //   Java source line #276	-> byte code offset #330
    //   Java source line #277	-> byte code offset #349
    //   Java source line #279	-> byte code offset #364
    //   Java source line #280	-> byte code offset #368
    //   Java source line #274	-> byte code offset #369
    //   Java source line #283	-> byte code offset #380
    //   Java source line #285	-> byte code offset #384
    //   Java source line #258	-> byte code offset #388
    //   Java source line #289	-> byte code offset #399
    //   Java source line #290	-> byte code offset #405
    //   Java source line #248	-> byte code offset #409
    //   Java source line #294	-> byte code offset #423
    //   Java source line #295	-> byte code offset #425
    //   Java source line #296	-> byte code offset #432
    //   Java source line #297	-> byte code offset #437
    //   Java source line #295	-> byte code offset #440
    //   Java source line #296	-> byte code offset #447
    //   Java source line #298	-> byte code offset #452
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	453	0	this	UseScanParser
    //   0	453	1	xmlLocation	String
    //   0	453	2	monitor	org.eclipse.core.runtime.IProgressMonitor
    //   0	453	3	usv	UseScanVisitor
    //   28	54	4	reportsRoot	File
    //   70	378	5	localmonitor	org.eclipse.core.runtime.SubMonitor
    //   86	329	6	referees	File[]
    //   98	296	7	origins	File[]
    //   104	271	8	xmlfiles	File[]
    //   126	224	9	parser	SAXParser
    //   129	284	10	i	int
    //   157	83	11	idv	String[]
    //   170	4	12	targetComponent	IComponentDescriptor
    //   205	187	13	j	int
    //   246	4	14	referencingComponent	IComponentDescriptor
    //   325	48	15	k	int
    //   347	10	16	handler	ReferenceHandler
    //   423	15	17	localObject	Object
    //   364	1	18	localSAXException	SAXException
    //   368	1	19	localIOException	java.io.IOException
    // Exception table:
    //   from	to	target	type
    //   330	361	364	org/xml/sax/SAXException
    //   330	361	368	java/io/IOException
    //   122	423	423	finally
  }
  
  SAXParser getParser()
    throws Exception
  {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try
    {
      return factory.newSAXParser();
    }
    catch (ParserConfigurationException pce)
    {
      throw new Exception(SearchMessages.UseReportConverter_pce_error_getting_parser, pce);
    }
    catch (SAXException se)
    {
      throw new Exception(SearchMessages.UseReportConverter_se_error_parser_handle, se);
    }
  }
  
  protected IComponentDescriptor getReferencingComponent()
  {
    return referencingComponent;
  }
  
  protected IComponentDescriptor getTargetComponent()
  {
    return targetComponent;
  }
  
  protected IMemberDescriptor getTargetMember()
  {
    return targetMember;
  }
  
  protected int getReferenceKind()
  {
    return referenceKind;
  }
  
  protected int getVisibility()
  {
    return visibility;
  }
  
  File[] getDirectories(File file)
  {
    File[] directories = file.listFiles(new FileFilter()
    {
      public boolean accept(File pathname)
      {
        return (pathname.isDirectory()) && (!pathname.isHidden());
      }
    });
    return directories;
  }
  
  private int getTypeFromFileName(File xmlfile)
  {
    if (xmlfile.getName().indexOf("type_references") > -1) {
      return 1;
    }
    if (xmlfile.getName().indexOf("method_references") > -1) {
      return 3;
    }
    return 2;
  }
  
  public void enterTargetComponent(IComponentDescriptor component)
  {
    boolean different = false;
    if (targetComponent == null) {
      different = true;
    } else if (!targetComponent.equals(component)) {
      different = true;
    }
    if (different)
    {
      endMember();
      endReferencingComponent();
      endComponent();
      
      targetComponent = component;
      visitReferencingComponent = visitor.visitComponent(targetComponent);
    }
  }
  
  public void enterReferencingComponent(IComponentDescriptor component)
  {
    boolean different = false;
    if (referencingComponent == null) {
      different = true;
    } else if (!referencingComponent.equals(component)) {
      different = true;
    }
    if (different)
    {
      endMember();
      endReferencingComponent();
      
      referencingComponent = component;
      if (visitReferencingComponent) {
        visitMembers = visitor.visitReferencingComponent(referencingComponent);
      }
    }
  }
  
  public void enterVisibility(int vis)
  {
    visibility = vis;
  }
  
  public void enterTargetMember(IMemberDescriptor member)
  {
    if ((targetMember == null) || (!targetMember.equals(member)))
    {
      endMember();
      targetMember = member;
      if ((visitReferencingComponent) && (visitMembers)) {
        visitReferences = visitor.visitMember(targetMember);
      }
    }
  }
  
  public void enterReferenceKind(int refKind)
  {
    referenceKind = refKind;
  }
  
  public void setReference(IReferenceDescriptor reference)
  {
    if ((visitReferencingComponent) && (visitMembers) && (visitReferences)) {
      visitor.visitReference(reference);
    }
  }
  
  private void endMember()
  {
    if (targetMember != null)
    {
      if ((visitReferencingComponent) && (visitMembers)) {
        visitor.endVisitMember(targetMember);
      }
      targetMember = null;
    }
  }
  
  private void endReferencingComponent()
  {
    if (referencingComponent != null)
    {
      if (visitReferencingComponent) {
        visitor.endVisitReferencingComponent(referencingComponent);
      }
      referencingComponent = null;
    }
  }
  
  private void endComponent()
  {
    if (targetComponent != null)
    {
      visitor.endVisitComponent(targetComponent);
      targetComponent = null;
    }
  }
  
  File[] sort(File[] files)
  {
    List sorted = new ArrayList(files.length + 2);
    for (int i = 0; i < files.length; i++) {
      sorted.add(files[i]);
    }
    Collections.sort(sorted, Util.filesorter);
    return (File[])sorted.toArray(new File[sorted.size()]);
  }
}

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

import java.util.Arrays;
import java.util.List;
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.IReferenceTypeDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;

public class UseScanReferenceVisitor
  extends UseScanVisitor
{
  private IApiComponent fLookupAPIComponent;
  private List fLookupMemberTypes;
  private String fCurrentReferencedMemberRootType;
  private IComponentDescriptor fCurrentComponent;
  private IComponentDescriptor fReferencingComponent;
  private IReferenceCollection fReferences;
  private IMemberDescriptor fCurrentReferencedMember;
  
  public UseScanReferenceVisitor(IApiComponent component, String[] lookupTypes, IReferenceCollection references)
  {
    fLookupAPIComponent = component;
    if ((lookupTypes == null) || (lookupTypes.length == 0)) {
      fLookupMemberTypes = null;
    } else {
      fLookupMemberTypes = Arrays.asList(lookupTypes);
    }
    fReferences = references;
  }
  
  public boolean visitComponent(IComponentDescriptor target)
  {
    if ((fLookupAPIComponent == null) || (fLookupAPIComponent.getSymbolicName().equals(target.getId())))
    {
      fCurrentComponent = target;
      return true;
    }
    return false;
  }
  
  public boolean visitMember(IMemberDescriptor referencedMember)
  {
    boolean found = false;
    String referencedMemberRootType;
    String referencedMemberRootType;
    if ((referencedMember instanceof IReferenceTypeDescriptor)) {
      referencedMemberRootType = ((IReferenceTypeDescriptor)referencedMember).getQualifiedName();
    } else {
      referencedMemberRootType = referencedMember.getEnclosingType().getQualifiedName();
    }
    if (referencedMemberRootType.indexOf('$') > -1) {
      referencedMemberRootType = referencedMemberRootType.substring(0, referencedMemberRootType.indexOf('$'));
    }
    found = (fLookupMemberTypes == null) || (fLookupMemberTypes.contains(referencedMemberRootType));
    fCurrentReferencedMemberRootType = referencedMemberRootType;
    fCurrentReferencedMember = referencedMember;
    
    return found;
  }
  
  public void visitReference(IReferenceDescriptor reference)
  {
    ReferenceDescriptor refDesc = new ReferenceDescriptor(fReferencingComponent, reference.getMember(), reference.getLineNumber(), fCurrentComponent, fCurrentReferencedMember, reference.getReferenceKind(), reference.getReferenceFlags(), reference.getVisibility(), null);
    fReferences.add(fCurrentReferencedMemberRootType, refDesc);
  }
  
  public boolean visitReferencingComponent(IComponentDescriptor component)
  {
    fReferencingComponent = component;
    return true;
  }
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.jdt.internal.core.util.ILRUCacheable;

public class UseScanReferences
  implements ILRUCacheable, IReferenceCollection
{
  Map fReferencesMap;
  
  public UseScanReferences()
  {
    fReferencesMap = new HashMap();
  }
  
  public void add(String type, IReferenceDescriptor refDesc)
  {
    List refDescList = (List)fReferencesMap.get(type);
    if (refDescList == null)
    {
      refDescList = new ArrayList();
      fReferencesMap.put(type, refDescList);
    }
    if (!refDescList.contains(refDesc)) {
      refDescList.add(refDesc);
    }
  }
  
  public boolean hasReferencesTo(String type)
  {
    List refDescList = (List)fReferencesMap.get(type);
    if ((refDescList == null) || (refDescList.size() == 0)) {
      return false;
    }
    return true;
  }
  
  public IReferenceDescriptor[] getExternalDependenciesTo(String[] types)
  {
    if ((types == null) || (types.length == 0)) {
      return new IReferenceDescriptor[0];
    }
    List referenceDescriptorList = new ArrayList();
    for (int i = 0; i < types.length; i++)
    {
      List refDescs = (List)fReferencesMap.get(types[i]);
      if ((refDescs != null) && (refDescs.size() != 0)) {
        referenceDescriptorList.addAll(refDescs);
      }
    }
    return (IReferenceDescriptor[])referenceDescriptorList.toArray(new IReferenceDescriptor[referenceDescriptorList.size()]);
  }
  
  public IReferenceDescriptor[] getAllExternalDependencies()
  {
    List allRefDescs = new ArrayList();
    for (Iterator iterator = fReferencesMap.values().iterator(); iterator.hasNext();)
    {
      List refDescList = (List)iterator.next();
      allRefDescs.addAll(refDescList);
    }
    return (IReferenceDescriptor[])allRefDescs.toArray(new IReferenceDescriptor[allRefDescs.size()]);
  }
  
  public int getCacheFootprint()
  {
    return fReferencesMap.size();
  }
  
  public void clear()
  {
    fReferencesMap.clear();
  }
}

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

import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;

public abstract class UseScanVisitor
{
  public void visitScan() {}
  
  public void endVisitScan() {}
  
  public boolean visitComponent(IComponentDescriptor target)
  {
    return true;
  }
  
  public void endVisitComponent(IComponentDescriptor target) {}
  
  public boolean visitReferencingComponent(IComponentDescriptor component)
  {
    return true;
  }
  
  public void endVisitReferencingComponent(IComponentDescriptor component) {}
  
  public boolean visitMember(IMemberDescriptor referencedMember)
  {
    return true;
  }
  
  public void endVisitMember(IMemberDescriptor referencedMember) {}
  
  public void visitReference(IReferenceDescriptor reference) {}
}

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

import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.builder.AbstractProblemDetector;
import org.eclipse.pde.api.tools.internal.builder.ProblemDetectorBuilder;
import org.eclipse.pde.api.tools.internal.builder.Reference;
import org.eclipse.pde.api.tools.internal.builder.ReferenceAnalyzer;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.builder.IApiProblemDetector;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.comparator.ApiScope;
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.search.IApiSearchRequestor;

public class UseSearchRequestor
  implements IApiSearchRequestor
{
  private Set fComponentIds = null;
  private int fSearchMask = 0;
  private IApiScope fScope = null;
  private String[] jarPatterns = null;
  ReferenceAnalyzer fAnalyzer = null;
  
  public UseSearchRequestor(Set elementnames, IApiElement[] scope, int searchkinds)
  {
    fSearchMask = searchkinds;
    fComponentIds = elementnames;
    fAnalyzer = new ReferenceAnalyzer();
    prepareScope(scope);
  }
  
  public boolean acceptComponent(IApiComponent component)
  {
    try
    {
      if ((!component.isSystemComponent()) && (getScope().encloses(component)))
      {
        if (includesIllegalUse()) {
          fAnalyzer.buildProblemDetectors(component, ProblemDetectorBuilder.K_USE, null);
        }
        return true;
      }
    }
    catch (CoreException localCoreException) {}
    return false;
  }
  
  public boolean acceptContainer(IApiTypeContainer container)
  {
    return considerTypeContainer(container);
  }
  
  public boolean acceptMember(IApiMember member)
  {
    switch (member.getType())
    {
    case 2: 
      IApiType type = (IApiType)member;
      return (!type.isMemberType()) && (!type.isLocal());
    }
    return true;
  }
  
  boolean considerTypeContainer(IApiTypeContainer container)
  {
    if ((jarPatterns != null) && (container != null) && 
      (container.getContainerType() == 1))
    {
      String[] pparts = (String[])null;
      for (int i = 0; i < jarPatterns.length; i++)
      {
        pparts = jarPatterns[i].split(":");
        if (pparts.length == 2) {
          if ((container.getApiComponent().getSymbolicName().equals(pparts[0])) && 
            (container.getName().endsWith(pparts[1]))) {
            return false;
          }
        }
      }
    }
    return true;
  }
  
  public boolean acceptReference(IReference reference)
  {
    try
    {
      IApiMember member = reference.getResolvedReference();
      if (member != null)
      {
        IApiComponent component = member.getApiComponent();
        if ((!fComponentIds.contains(component.getSymbolicName())) || (component.equals(reference.getMember().getApiComponent()))) {
          return false;
        }
        if ((isIllegalUse(reference)) || ((includesAPI()) && (includesInternal()))) {
          return true;
        }
        IApiAnnotations annots = component.getApiDescription().resolveAnnotations(member.getHandle());
        if (annots != null)
        {
          int vis = annots.getVisibility();
          if ((VisibilityModifiers.isAPI(vis)) && (includesAPI())) {
            return true;
          }
          if ((VisibilityModifiers.isPrivate(vis)) && (includesInternal())) {
            return true;
          }
        }
      }
    }
    catch (CoreException ce)
    {
      ApiPlugin.log(ce);
    }
    return false;
  }
  
  boolean isIllegalUse(IReference reference)
  {
    IApiProblemDetector[] detectors = fAnalyzer.getProblemDetectors(reference.getReferenceKind());
    for (int i = 0; i < detectors.length; i++) {
      if (detectors[i].considerReference(reference))
      {
        Reference ref = (Reference)reference;
        ref.setFlags(1);
        try
        {
          ref.addProblems(((AbstractProblemDetector)detectors[i]).createProblem(reference));
        }
        catch (CoreException e)
        {
          ApiPlugin.log(e);
        }
        return true;
      }
    }
    return false;
  }
  
  public int getReferenceKinds()
  {
    return 2080374783;
  }
  
  private void prepareScope(IApiElement[] elements)
  {
    if (elements != null)
    {
      fScope = new ApiScope();
      for (int i = 0; i < elements.length; i++) {
        fScope.addElement(elements[i].getApiComponent());
      }
    }
  }
  
  public IApiScope getScope()
  {
    return fScope;
  }
  
  public boolean includesAPI()
  {
    return (fSearchMask & 0x1) > 0;
  }
  
  public boolean includesInternal()
  {
    return (fSearchMask & 0x2) > 0;
  }
  
  public boolean includesIllegalUse()
  {
    return (fSearchMask & 0x4) > 0;
  }
  
  public void setJarPatterns(String[] patterns)
  {
    jarPatterns = patterns;
  }
}

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

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.core.runtime.CoreException;
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.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IFieldDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMethodDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
import org.eclipse.pde.api.tools.internal.util.Signatures;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.helpers.DefaultHandler;

public class XmlReferenceDescriptorWriter
{
  public static final String TYPE_REFERENCES = "type_references";
  public static final String METHOD_REFERENCES = "method_references";
  public static final String FIELD_REFERENCES = "field_references";
  private static final Integer V_ILLEGAL = new Integer(22);
  private String fLocation = null;
  private HashMap fReferenceMap = null;
  private DocumentBuilder parser = null;
  private IComponentDescriptor alternate;
  
  public XmlReferenceDescriptorWri
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