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

    {
    case 2: 
    case 4: 
    case 8: 
      return true;
    case 1: 
      IFile resource = (IFile)delta.getResource();
      String fileName = resource.getName();
      if (Util.isClassFile(fileName))
      {
        if (delta.getKind() == 2)
        {
          String typename = this$0.resolveTypeName(resource, 1);
          if (typename != null)
          {
            if (ApiAnalysisBuilder.DEBUG) {
              System.out.println("Found removed class file " + typename);
            }
            changes.add(new IncrementalApiBuilder.Change(this$0, 1, delta.getKind(), resource, typename, 1));
          }
        }
        else if ((buildpathChanged) && (delta.getKind() == 4) && 
          ((delta.getFlags() & 0x100) > 0))
        {
          String typename = this$0.resolveTypeName(resource, 1);
          if (typename != null) {
            changes.add(new IncrementalApiBuilder.Change(this$0, 1, delta.getKind(), resource, typename, 1));
          }
        }
      }
      else if (Util.isJavaFileName(fileName))
      {
        String type = this$0.resolveTypeName(resource, 2);
        if (type != null)
        {
          IncrementalApiBuilder.Change change = new IncrementalApiBuilder.Change(this$0, 1, delta.getKind(), resource, type, 2);
          changes.add(change);
          
          IApiComponent component = this$0.workspaceBaseline.getApiComponent(resource.getProject());
          if (component != null) {
            try
            {
              IApiAnnotations annotations = component.getApiDescription().resolveAnnotations(Factory.typeDescriptor(type.replace('/', '.')));
              if ((annotations instanceof TypeAnnotations))
              {
                TypeAnnotations ta = (TypeAnnotations)annotations;
                if (ta.getBuildStamp() == BuildStamps.getBuildStamp(resource.getProject())) {
                  changeKind |= 0x2;
                }
              }
            }
            catch (CoreException e)
            {
              ApiPlugin.log(e);
            }
          }
        }
      }
      break;
    }
    return false;
  }
}

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

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
import org.eclipse.jdt.internal.core.builder.ReferenceCollection;
import org.eclipse.jdt.internal.core.builder.State;
import org.eclipse.jdt.internal.core.builder.StringSet;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.TypeAnnotations;
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.IApiAnnotations;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.builder.IApiAnalyzer;
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.util.Util;
import org.eclipse.pde.core.plugin.IPluginModelBase;

public class IncrementalApiBuilder
{
  private static final int UNKNOWN = 0;
  private static final int CLASS_FILE = 1;
  private static final int JAVA__FILE = 2;
  private static final int STRUCTURAL = 1;
  private static final int DESCRIPTION = 2;
  
  class Change
  {
    int changeKind;
    int fileKind;
    int deltaKind;
    IProject project;
    IFile resource;
    String typeName;
    
    Change(int kind, int deltaKind, IFile resource, String typeName, int fileKind)
    {
      changeKind = kind;
      this.deltaKind = deltaKind;
      this.resource = resource;
      project = resource.getProject();
      this.typeName = typeName;
      this.fileKind = fileKind;
    }
    
    boolean isContained(IProject project, HashSet others)
    {
      return (this.project.equals(project)) || ((others != null) && (others.contains(this.project)));
    }
  }
  
  class ResourceDeltaVisitor
    implements IResourceDeltaVisitor
  {
    List changes = new ArrayList();
    boolean buildpathChanged = false;
    
    ResourceDeltaVisitor(boolean pathChanged)
    {
      buildpathChanged = pathChanged;
    }
    
    public boolean visit(IResourceDelta delta)
      throws CoreException
    {
      switch (delta.getResource().getType())
      {
      case 2: 
      case 4: 
      case 8: 
        return true;
      case 1: 
        IFile resource = (IFile)delta.getResource();
        String fileName = resource.getName();
        if (Util.isClassFile(fileName))
        {
          if (delta.getKind() == 2)
          {
            String typename = resolveTypeName(resource, 1);
            if (typename != null)
            {
              if (ApiAnalysisBuilder.DEBUG) {
                System.out.println("Found removed class file " + typename);
              }
              changes.add(new IncrementalApiBuilder.Change(IncrementalApiBuilder.this, 1, delta.getKind(), resource, typename, 1));
            }
          }
          else if ((buildpathChanged) && (delta.getKind() == 4) && 
            ((delta.getFlags() & 0x100) > 0))
          {
            String typename = resolveTypeName(resource, 1);
            if (typename != null) {
              changes.add(new IncrementalApiBuilder.Change(IncrementalApiBuilder.this, 1, delta.getKind(), resource, typename, 1));
            }
          }
        }
        else if (Util.isJavaFileName(fileName))
        {
          String type = resolveTypeName(resource, 2);
          if (type != null)
          {
            IncrementalApiBuilder.Change change = new IncrementalApiBuilder.Change(IncrementalApiBuilder.this, 1, delta.getKind(), resource, type, 2);
            changes.add(change);
            
            IApiComponent component = workspaceBaseline.getApiComponent(resource.getProject());
            if (component != null) {
              try
              {
                IApiAnnotations annotations = component.getApiDescription().resolveAnnotations(Factory.typeDescriptor(type.replace('/', '.')));
                if ((annotations instanceof TypeAnnotations))
                {
                  TypeAnnotations ta = (TypeAnnotations)annotations;
                  if (ta.getBuildStamp() == BuildStamps.getBuildStamp(resource.getProject())) {
                    changeKind |= 0x2;
                  }
                }
              }
              catch (CoreException e)
              {
                ApiPlugin.log(e);
              }
            }
          }
        }
        break;
      }
      return false;
    }
  }
  
  ApiAnalysisBuilder builder = null;
  BuildContext context = null;
  IApiBaseline workspaceBaseline = null;
  
  public IncrementalApiBuilder(ApiAnalysisBuilder builder)
  {
    this.builder = builder;
  }
  
  /* Error */
  public void build(IApiBaseline baseline, IApiBaseline wbaseline, IResourceDelta[] deltas, State state, BuildState buildstate, IProgressMonitor monitor)
    throws CoreException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 486	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder:builder	Lorg/eclipse/pde/api/tools/internal/builder/ApiAnalysisBuilder;
    //   4: invokevirtual 524	org/eclipse/pde/api/tools/internal/builder/ApiAnalysisBuilder:getProject	()Lorg/eclipse/core/resources/IProject;
    //   7: astore 7
    //   9: aload_0
    //   10: aload_2
    //   11: putfield 488	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder:workspaceBaseline	Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiBaseline;
    //   14: aload 6
    //   16: getstatic 484	org/eclipse/pde/api/tools/internal/builder/BuilderMessages:IncrementalBuilder_builder_for_project	Ljava/lang/String;
    //   19: aload 7
    //   21: invokeinterface 569 1 0
    //   26: invokestatic 522	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   29: iconst_1
    //   30: invokestatic 513	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;Ljava/lang/String;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   33: astore 8
    //   35: aload_0
    //   36: new 269	org/eclipse/pde/api/tools/internal/builder/BuildContext
    //   39: dup
    //   40: invokespecial 531	org/eclipse/pde/api/tools/internal/builder/BuildContext:<init>	()V
    //   43: putfield 487	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder:context	Lorg/eclipse/pde/api/tools/internal/builder/BuildContext;
    //   46: aload 5
    //   48: invokevirtual 543	org/eclipse/pde/api/tools/internal/builder/BuildState:getReexportedComponents	()[Ljava/lang/String;
    //   51: astore 9
    //   53: aconst_null
    //   54: astore 10
    //   56: aload 9
    //   58: arraylength
    //   59: ifeq +96 -> 155
    //   62: new 243	java/util/HashSet
    //   65: dup
    //   66: invokespecial 505	java/util/HashSet:<init>	()V
    //   69: astore 10
    //   71: invokestatic 508	org/eclipse/core/resources/ResourcesPlugin:getWorkspace	()Lorg/eclipse/core/resources/IWorkspace;
    //   74: invokeinterface 579 1 0
    //   79: astore 11
    //   81: aconst_null
    //   82: astore 12
    //   84: iconst_0
    //   85: istore 13
    //   87: aload 9
    //   89: arraylength
    //   90: istore 14
    //   92: goto +56 -> 148
    //   95: aload 11
    //   97: aload 9
    //   99: iload 13
    //   101: aaload
    //   102: invokeinterface 580 2 0
    //   107: astore 12
    //   109: aload 12
    //   111: invokeinterface 568 1 0
    //   116: ifeq +29 -> 145
    //   119: aload_1
    //   120: ifnull +25 -> 145
    //   123: aload_1
    //   124: aload 9
    //   126: iload 13
    //   128: aaload
    //   129: invokeinterface 590 2 0
    //   134: ifnonnull +11 -> 145
    //   137: aload 10
    //   139: aload 12
    //   141: invokevirtual 506	java/util/HashSet:add	(Ljava/lang/Object;)Z
    //   144: pop
    //   145: iinc 13 1
    //   148: iload 13
    //   150: iload 14
    //   152: if_icmplt -57 -> 95
    //   155: aload 5
    //   157: invokevirtual 542	org/eclipse/pde/api/tools/internal/builder/BuildState:getBuildPathCRC	()J
    //   160: lstore 11
    //   162: aload 7
    //   164: invokestatic 545	org/eclipse/pde/api/tools/internal/builder/BuildState:computeBuildPathCRC	(Lorg/eclipse/core/resources/IProject;)J
    //   167: lstore 13
    //   169: new 274	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder$ResourceDeltaVisitor
    //   172: dup
    //   173: aload_0
    //   174: lload 13
    //   176: lload 11
    //   178: lcmp
    //   179: ifeq +7 -> 186
    //   182: iconst_1
    //   183: goto +4 -> 187
    //   186: iconst_0
    //   187: invokespecial 556	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder$ResourceDeltaVisitor:<init>	(Lorg/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder;Z)V
    //   190: astore 15
    //   192: iconst_0
    //   193: istore 16
    //   195: goto +17 -> 212
    //   198: aload_3
    //   199: iload 16
    //   201: aaload
    //   202: aload 15
    //   204: invokeinterface 578 2 0
    //   209: iinc 16 1
    //   212: iload 16
    //   214: aload_3
    //   215: arraylength
    //   216: if_icmplt -18 -> 198
    //   219: aload_0
    //   220: aload 7
    //   222: aload 4
    //   224: aload 15
    //   226: getfield 494	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder$ResourceDeltaVisitor:changes	Ljava/util/List;
    //   229: aload 10
    //   231: invokevirtual 553	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder:buildContext	(Lorg/eclipse/core/resources/IProject;Lorg/eclipse/jdt/internal/core/builder/State;Ljava/util/List;Ljava/util/HashSet;)V
    //   234: aload_0
    //   235: aload 7
    //   237: aload_1
    //   238: aload_2
    //   239: aload 4
    //   241: aload 5
    //   243: aload 8
    //   245: iconst_1
    //   246: invokevirtual 512	org/eclipse/core/runtime/SubMonitor:newChild	(I)Lorg/eclipse/core/runtime/SubMonitor;
    //   249: invokevirtual 554	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder:build	(Lorg/eclipse/core/resources/IProject;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiBaseline;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiBaseline;Lorg/eclipse/jdt/internal/core/builder/State;Lorg/eclipse/pde/api/tools/internal/builder/BuildState;Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   252: goto +66 -> 318
    //   255: pop
    //   256: getstatic 479	org/eclipse/pde/api/tools/internal/builder/ApiAnalysisBuilder:DEBUG	Z
    //   259: ifeq +11 -> 270
    //   262: getstatic 473	java/lang/System:out	Ljava/io/PrintStream;
    //   265: ldc 1
    //   267: invokevirtual 495	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   270: aload 8
    //   272: invokevirtual 510	org/eclipse/core/runtime/SubMonitor:isCanceled	()Z
    //   275: ifne +8 -> 283
    //   278: aload 8
    //   280: invokevirtual 509	org/eclipse/core/runtime/SubMonitor:done	()V
    //   283: aload_0
    //   284: getfield 487	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder:context	Lorg/eclipse/pde/api/tools/internal/builder/BuildContext;
    //   287: invokevirtual 532	org/eclipse/pde/api/tools/internal/builder/BuildContext:dispose	()V
    //   290: goto +48 -> 338
    //   293: astore 17
    //   295: aload 8
    //   297: invokevirtual 510	org/eclipse/core/runtime/SubMonitor:isCanceled	()Z
    //   300: ifne +8 -> 308
    //   303: aload 8
    //   305: invokevirtual 509	org/eclipse/core/runtime/SubMonitor:done	()V
    //   308: aload_0
    //   309: getfield 487	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder:context	Lorg/eclipse/pde/api/tools/internal/builder/BuildContext;
    //   312: invokevirtual 532	org/eclipse/pde/api/tools/internal/builder/BuildContext:dispose	()V
    //   315: aload 17
    //   317: athrow
    //   318: aload 8
    //   320: invokevirtual 510	org/eclipse/core/runtime/SubMonitor:isCanceled	()Z
    //   323: ifne +8 -> 331
    //   326: aload 8
    //   328: invokevirtual 509	org/eclipse/core/runtime/SubMonitor:done	()V
    //   331: aload_0
    //   332: getfield 487	org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder:context	Lorg/eclipse/pde/api/tools/internal/builder/BuildContext;
    //   335: invokevirtual 532	org/eclipse/pde/api/tools/internal/builder/BuildContext:dispose	()V
    //   338: return
    // Line number table:
    //   Java source line #201	-> byte code offset #0
    //   Java source line #202	-> byte code offset #9
    //   Java source line #203	-> byte code offset #14
    //   Java source line #204	-> byte code offset #35
    //   Java source line #206	-> byte code offset #46
    //   Java source line #207	-> byte code offset #53
    //   Java source line #208	-> byte code offset #56
    //   Java source line #209	-> byte code offset #62
    //   Java source line #210	-> byte code offset #71
    //   Java source line #211	-> byte code offset #81
    //   Java source line #212	-> byte code offset #84
    //   Java source line #213	-> byte code offset #95
    //   Java source line #214	-> byte code offset #109
    //   Java source line #216	-> byte code offset #119
    //   Java source line #217	-> byte code offset #137
    //   Java source line #212	-> byte code offset #145
    //   Java source line #223	-> byte code offset #155
    //   Java source line #224	-> byte code offset #162
    //   Java source line #225	-> byte code offset #169
    //   Java source line #226	-> byte code offset #192
    //   Java source line #227	-> byte code offset #198
    //   Java source line #226	-> byte code offset #209
    //   Java source line #229	-> byte code offset #219
    //   Java source line #230	-> byte code offset #234
    //   Java source line #232	-> byte code offset #255
    //   Java source line #235	-> byte code offset #256
    //   Java source line #236	-> byte code offset #262
    //   Java source line #240	-> byte code offset #270
    //   Java source line #241	-> byte code offset #278
    //   Java source line #243	-> byte code offset #283
    //   Java source line #239	-> byte code offset #293
    //   Java source line #240	-> byte code offset #295
    //   Java source line #241	-> byte code offset #303
    //   Java source line #243	-> byte code offset #308
    //   Java source line #244	-> byte code offset #315
    //   Java source line #240	-> byte code offset #318
    //   Java source line #241	-> byte code offset #326
    //   Java source line #243	-> byte code offset #331
    //   Java source line #245	-> byte code offset #338
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	339	0	this	IncrementalApiBuilder
    //   0	339	1	baseline	IApiBaseline
    //   0	339	2	wbaseline	IApiBaseline
    //   0	339	3	deltas	IResourceDelta[]
    //   0	339	4	state	State
    //   0	339	5	buildstate	BuildState
    //   0	339	6	monitor	IProgressMonitor
    //   7	229	7	project	IProject
    //   33	294	8	localmonitor	SubMonitor
    //   51	74	9	projectNames	String[]
    //   54	176	10	depprojects	HashSet
    //   79	17	11	root	org.eclipse.core.resources.IWorkspaceRoot
    //   160	17	11	prev	long
    //   82	58	12	pj	IProject
    //   85	64	13	i	int
    //   167	8	13	curr	long
    //   90	61	14	max	int
    //   190	35	15	visitor	ResourceDeltaVisitor
    //   193	20	16	i	int
    //   293	23	17	localObject	Object
    //   255	1	20	localOperationCanceledException	org.eclipse.core.runtime.OperationCanceledException
    // Exception table:
    //   from	to	target	type
    //   46	252	255	org/eclipse/core/runtime/OperationCanceledException
    //   46	270	293	finally
  }
  
  void build(IProject project, IApiBaseline baseline, IApiBaseline wbaseline, State state, BuildState buildstate, IProgressMonitor monitor)
    throws CoreException
  {
    SubMonitor localmonitor = SubMonitor.convert(monitor, BuilderMessages.api_analysis_on_0, 6);
    try
    {
      Util.updateMonitor(localmonitor, 1);
      localmonitor.subTask(NLS.bind(BuilderMessages.ApiAnalysisBuilder_finding_affected_source_files, project.getName()));
      Util.updateMonitor(localmonitor, 0);
      if (context.hasTypes())
      {
        IPluginModelBase currentModel = builder.getCurrentModel();
        if (currentModel != null)
        {
          String id = currentModel.getBundleDescription().getSymbolicName();
          IApiComponent comp = wbaseline.getApiComponent(id);
          if (comp == null) {
            return;
          }
          IApiComponent comp;
          String id;
          IPluginModelBase currentModel;
          extClean(project, buildstate, localmonitor.newChild(1));
          Util.updateMonitor(localmonitor, 1);
          builder.getAnalyzer().analyzeComponent(buildstate, 
            null, 
            null, 
            baseline, 
            comp, 
            context, 
            localmonitor.newChild(1));
          Util.updateMonitor(localmonitor, 1);
          builder.createMarkers();
          Util.updateMonitor(localmonitor, 1);
        }
      }
    }
    finally
    {
      if (localmonitor != null) {
        localmonitor.done();
      }
    }
    if (localmonitor != null) {
      localmonitor.done();
    }
  }
  
  private void addDependentTypeToContext(IFile file, int kind)
  {
    String type = resolveTypeName(file, 2);
    if (type == null) {
      return;
    }
    if (((0x1 & kind) > 0) && 
      (!context.containsStructuralChange(type))) {
      builder.cleanupCompatibilityMarkers(file);
    }
    if (((0x2 & kind) > 0) && 
      (!context.containsDescriptionChange(type)) && (!context.containsDescriptionDependent(type)))
    {
      builder.cleanupUsageMarkers(file);
      builder.cleanUnusedFilterMarkers(file);
      context.recordDescriptionDependent(type);
    }
    addInnerTypesToDependents(file, kind);
  }
  
  private void addInnerTypesToDependents(IFile file, int kind)
  {
    ICompilationUnit unit = (ICompilationUnit)JavaCore.create(file);
    IType[] types = (IType[])null;
    try
    {
      types = unit.getAllTypes();
      String typename = null;
      for (int i = 0; i < types.length; i++)
      {
        typename = types[i].getFullyQualifiedName('$');
        if (((0x2 & kind) > 0) && 
          (!context.containsDescriptionChange(typename)) && (!context.containsDescriptionDependent(typename))) {
          context.recordDescriptionDependent(typename);
        }
      }
    }
    catch (JavaModelException localJavaModelException) {}
  }
  
  private void addInnerTypes(IFile file, int kind)
  {
    ICompilationUnit unit = (ICompilationUnit)JavaCore.create(file);
    IType[] types = (IType[])null;
    try
    {
      types = unit.getAllTypes();
      String typename = null;
      for (int i = 0; i < types.length; i++)
      {
        typename = types[i].getFullyQualifiedName('$');
        if (((0x1 & kind) > 0) && 
          (!context.containsStructuralChange(typename))) {
          context.recordStructuralChange(typename);
        }
        if (((0x2 & kind) > 0) && 
          (!context.containsDescriptionChange(typename))) {
          context.recordDescriptionChanged(typename);
        }
      }
    }
    catch (JavaModelException localJavaModelException) {}
  }
  
  void buildContext(IProject project, State state, List changes, HashSet depprojects)
  {
    StringSet structural = null;
    StringSet description = null;
    Iterator iterator = changes.iterator();
    while (iterator.hasNext())
    {
      Change change = (Change)iterator.next();
      boolean contained = change.isContained(project, depprojects);
      if ((changeKind & 0x1) > 0)
      {
        if (deltaKind != 2)
        {
          if (structural == null) {
            structural = new StringSet(16);
          }
          structural.add(typeName);
        }
        if (contained)
        {
          context.recordStructuralChange(typeName);
          if (deltaKind == 2) {
            context.recordRemovedType(typeName);
          }
        }
      }
      if ((changeKind & 0x2) > 0)
      {
        if (description == null) {
          description = new StringSet(16);
        }
        description.add(typeName);
        if (contained) {
          context.recordDescriptionChanged(typeName);
        }
      }
      if (contained) {
        if (fileKind == 2)
        {
          builder.cleanupMarkers(resource);
          addInnerTypes(resource, changeKind);
        }
        else
        {
          String path = (String)typeLocators.get(typeName);
          if (path != null)
          {
            IResource member = builder.getProject().findMember(path);
            if ((member != null) && (member.getType() == 1))
            {
              IFile source = (IFile)member;
              builder.cleanupMarkers(source);
              addInnerTypes(source, changeKind);
            }
          }
        }
      }
    }
    if ((changes.size() == 1) && (structural != null) && (description != null))
    {
      String[] types = values;
      if (types.length > 0) {
        addDependents(project, state, types, 3);
      }
    }
    else
    {
      if (structural != null)
      {
        String[] types = values;
        if (types.length > 0) {
          addDependents(project, state, types, 1);
        }
      }
      if (description != null)
      {
        String[] types = values;
        if (types.length > 0) {
          addDependents(project, state, types, 2);
        }
      }
    }
  }
  
  private void addDependents(IProject project, State state, String[] types, int kind)
  {
    StringSet packages = new StringSet(16);
    StringSet typenames = new StringSet(16);
    for (int i = 0; i < types.length; i++) {
      if (types[i] != null) {
        splitName(types[i], packages, typenames);
      }
    }
    char[][][] internedQualifiedNames = ReferenceCollection.internQualifiedNames(packages);
    if (internedQualifiedNames.length < elementSize) {
      internedQualifiedNames = (char[][][])null;
    }
    char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(typenames, true);
    if (internedSimpleNames.length < elementSize) {
      internedSimpleNames = (char[][])null;
    }
    Object[] keyTable = getReferenceskeyTable;
    Object[] valueTable = getReferencesvalueTable;
    IFile file = null;
    String typeLocator = null;
    for (int i = 0; i < valueTable.length; i++)
    {
      typeLocator = (String)keyTable[i];
      if (typeLocator != null)
      {
        ReferenceCollection refs = (ReferenceCollection)valueTable[i];
        if (refs.includes(internedQualifiedNames, internedSimpleNames, null))
        {
          file = project.getFile(typeLocator);
          if (file != null)
          {
            if (ApiAnalysisBuilder.DEBUG) {
              System.out.println("  adding affected source file " + file.getName());
            }
            addDependentTypeToContext(file, kind);
          }
        }
      }
    }
  }
  
  void splitName(String typename, StringSet packages, StringSet simpleTypes)
  {
    int idx = typename.lastIndexOf('/');
    String packageName = idx < 0 ? "" : typename.substring(0, idx);
    String typeName = idx < 0 ? typename : typename.substring(idx + 1, typename.length());
    idx = typeName.indexOf('$');
    if (idx > 0) {
      typeName = typeName.substring(0, idx);
    }
    if ((simpleTypes.add(typeName)) && (packages.add(packageName)) && (ApiAnalysisBuilder.DEBUG)) {
      System.out.println("  will look for dependents of " + typeName + " in " + packageName);
    }
  }
  
  void extClean(IProject project, BuildState state, IProgressMonitor monitor)
    throws CoreException
  {
    String[] types = context.getRemovedTypes();
    for (int i = 0; i < types.length; i++) {
      state.cleanup(types[i]);
    }
    Util.updateMonitor(monitor, 0);
    IResource resource = project.findMember(ApiAnalysisBuilder.MANIFEST_PATH);
    if (resource != null) {
      try
      {
        IMarker[] markers = resource.findMarkers("org.eclipse.pde.api.tools.compatibility", false, 0);
        String tname = null;
        for (int i = 0; i < markers.length; i++)
        {
          tname = Util.getTypeNameFromMarker(markers[i]);
          if (context.containsStructuralChange(tname)) {
            markers[i].delete();
          }
        }
        Util.updateMonitor(monitor, 0);
        
        markers = resource.findMarkers("org.eclipse.pde.api.tools.unused_filters", false, 0);
        for (int i = 0; i < markers.length; i++)
        {
          tname = Util.getTypeNameFromMarker(markers[i]);
          if (context.containsStructuralChange(tname)) {
            markers[i].delete();
          }
        }
        Util.updateMonitor(monitor, 0);
      }
      catch (CoreException e)
      {
        ApiPlugin.log(e);
      }
    }
  }
  
  String resolveTypeName(IResource resource, int kind)
  {
    IPath typepath = resource.getFullPath();
    int type = kind;
    if (kind == 0) {
      if (Util.isClassFile(resource.getName())) {
        type = 1;
      } else if (Util.isJavaFileName(resource.getName())) {
        type = 2;
      }
    }
    HashSet paths = null;
    switch (type)
    {
    case 2: 
      paths = (HashSet)builder.src_locs.get(resource.getProject());
      break;
    case 1: 
      paths = (HashSet)builder.output_locs.get(resource.getProject());
      break;
    }
    if (paths != null)
    {
      IPath path = null;
      for (Iterator iterator = paths.iterator(); iterator.hasNext();)
      {
        path = (IPath)iterator.next();
        if (path.isPrefixOf(typepath))
        {
          typepath = typepath.removeFirstSegments(path.segmentCount()).removeFileExtension();
          return typepath.toString();
        }
      }
    }
    return null;
  }
}

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

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.Flags;
import org.eclipse.pde.api.tools.internal.model.MethodKey;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiField;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;

public class LeakExtendsProblemDetector
  extends AbstractTypeLeakDetector
{
  public LeakExtendsProblemDetector(Set nonApiPackageNames)
  {
    super(nonApiPackageNames);
  }
  
  public int getReferenceKinds()
  {
    return 1;
  }
  
  protected String getSeverityKey()
  {
    return "LEAK_EXTEND";
  }
  
  protected int getProblemFlags(IReference reference)
  {
    return 1;
  }
  
  public boolean isProblem(IReference reference)
  {
    if (super.isProblem(reference))
    {
      IApiType type = (IApiType)reference.getMember();
      IApiComponent component = type.getApiComponent();
      try
      {
        if (type.isClass())
        {
          int modifiers = 0;
          IApiAnnotations annotations = component.getApiDescription().resolveAnnotations(type.getHandle());
          if (annotations != null)
          {
            if (RestrictionModifiers.isExtendRestriction(annotations.getRestrictions())) {
              modifiers = 1;
            } else if (Flags.isFinal(type.getModifiers())) {
              modifiers = 1;
            } else {
              modifiers = 5;
            }
            IApiType nonApiSuper = type.getSuperclass();
            
            Set methods = new HashSet();
            while (!isAPIType(nonApiSuper))
            {
              if (hasVisibleField(nonApiSuper, modifiers)) {
                return true;
              }
              gatherVisibleMethods(nonApiSuper, methods, modifiers);
              nonApiSuper = nonApiSuper.getSuperclass();
            }
            if (methods.size() > 0)
            {
              List apiTypes = new LinkedList();
              apiTypes.add(type);
              gatherAPISuperTypes(apiTypes, type);
              Iterator iterator2 = apiTypes.iterator();
              while (iterator2.hasNext())
              {
                IApiType t2 = (IApiType)iterator2.next();
                Set apiMembers = new HashSet();
                gatherVisibleMethods(t2, apiMembers, modifiers);
                methods.removeAll(apiMembers);
                if (methods.size() == 0) {
                  return false;
                }
              }
              if (methods.size() > 0) {
                return true;
              }
            }
          }
        }
        else
        {
          return true;
        }
      }
      catch (CoreException ce)
      {
        if (DEBUG) {
          ApiPlugin.log(ce);
        }
        return true;
      }
    }
    return false;
  }
  
  private void gatherVisibleMethods(IApiType type, Set members, int modifiers)
  {
    IApiMethod[] methods = type.getMethods();
    for (int i = 0; i < methods.length; i++)
    {
      IApiMethod method = methods[i];
      if (((method.getModifiers() & modifiers) > 0) && (!method.isConstructor()) && (!method.isSynthetic())) {
        members.add(new MethodKey(type.getName(), method.getName(), method.getSignature(), false));
      }
    }
  }
  
  private boolean hasVisibleField(IApiType type, int modifiers)
  {
    IApiField[] fields = type.getFields();
    for (int i = 0; i < fields.length; i++)
    {
      IApiField field = fields[i];
      if ((field.getModifiers() & modifiers) > 0) {
        return true;
      }
    }
    return false;
  }
  
  private void gatherAPISuperTypes(List superTypes, IApiType type)
    throws CoreException
  {
    if (type != null)
    {
      if (isAPIType(type)) {
        superTypes.add(0, type);
      }
      gatherAPISuperTypes(superTypes, type.getSuperclass());
      IApiType[] interfaces = type.getSuperInterfaces();
      if (interfaces != null) {
        for (int i = 0; i < interfaces.length; i++) {
          if (isAPIType(interfaces[i]))
          {
            superTypes.add(interfaces[i]);
            gatherAPISuperTypes(superTypes, interfaces[i]);
          }
        }
      }
    }
  }
  
  private boolean isAPIType(IApiType type)
    throws CoreException
  {
    IApiDescription description = type.getApiComponent().getApiDescription();
    IApiAnnotations annotations = description.resolveAnnotations(type.getHandle());
    if (annotations == null) {
      return false;
    }
    return VisibilityModifiers.isAPI(annotations.getVisibility());
  }
}

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

import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiField;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;

public class LeakFieldProblemDetector
  extends AbstractTypeLeakDetector
{
  public LeakFieldProblemDetector(Set nonApiPackageNames)
  {
    super(nonApiPackageNames);
  }
  
  protected boolean isApplicable(IApiAnnotations annotations)
  {
    return (super.isApplicable(annotations)) && (!RestrictionModifiers.isReferenceRestriction(annotations.getRestrictions()));
  }
  
  public int getReferenceKinds()
  {
    return 4;
  }
  
  protected int getElementType(IReference reference)
  {
    return 5;
  }
  
  protected String getSeverityKey()
  {
    return "LEAK_FIELD_DECL";
  }
  
  protected int getProblemFlags(IReference reference)
  {
    return 3;
  }
  
  protected boolean isProblem(IReference reference)
  {
    if (super.isProblem(reference))
    {
      IApiField field = (IApiField)reference.getMember();
      if ((0x4 & field.getModifiers()) > 0) {
        try
        {
          IApiDescription description = field.getApiComponent().getApiDescription();
          IApiAnnotations annotations = description.resolveAnnotations(field.getHandle().getEnclosingType());
          if ((annotations == null) || (RestrictionModifiers.isExtendRestriction(annotations.getRestrictions()))) {
            return false;
          }
        }
        catch (CoreException e)
        {
          ApiPlugin.log(e);
        }
      }
      return true;
    }
    return false;
  }
  
  protected String[] getMessageArgs(IReference reference)
    throws CoreException
  {
    IApiField field = (IApiField)reference.getMember();
    IApiType type = (IApiType)reference.getResolvedReference();
    return new String[] {
      getSimpleTypeName(type), 
      getSimpleTypeName(field), 
      field.getName() };
  }
  
  protected String[] getQualifiedMessageArgs(IReference reference)
    throws CoreException
  {
    IApiField field = (IApiField)reference.getMember();
    IApiType type = (IApiType)reference.getResolvedReference();
    return new String[] {
      getQualifiedTypeName(type), 
      getQualifiedTypeName(field), 
      field.getName() };
  }
  
  protected Position getSourceRange(IType type, IDocument doc, IReference reference)
    throws CoreException, BadLocationException
  {
    IApiField field = (IApiField)reference.getMember();
    IField javaField = type.getField(field.getName());
    Position pos = null;
    if (javaField.exists())
    {
      ISourceRange range = javaField.getNameRange();
      if (range != null) {
        pos = new Position(range.getOffset(), range.getLength());
      }
    }
    if (pos == null) {
      return defaultSourcePosition(type, reference);
    }
    return pos;
  }
}

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

import java.util.Set;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;

public class LeakImplementsProblemDetector
  extends AbstractTypeLeakDetector
{
  public LeakImplementsProblemDetector(Set nonApiPackageNames)
  {
    super(nonApiPackageNames);
  }
  
  public int getReferenceKinds()
  {
    return 2;
  }
  
  protected String getSeverityKey()
  {
    return "LEAK_IMPLEMENT";
  }
  
  protected int getProblemFlags(IReference reference)
  {
    return 2;
  }
}

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

import java.util.Set;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;

public class LeakParameterTypeDetector
  extends MethodLeakDetector
{
  public LeakParameterTypeDetector(Set nonApiPackageNames)
  {
    super(nonApiPackageNames);
  }
  
  protected String getSeverityKey()
  {
    return "LEAK_METHOD_PARAM";
  }
  
  public int getReferenceKinds()
  {
    return 16;
  }
  
  protected int getProblemFlags(IReference reference)
  {
    IApiMethod method = (IApiMethod)reference.getMember();
    if (method.isConstructor()) {
      return 6;
    }
    return 5;
  }
}

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

import java.util.Se
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