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

yte code offset #237
    //   Java source line #605	-> byte code offset #238
    //   Java source line #608	-> byte code offset #248
    //   Java source line #609	-> byte code offset #250
    //   Java source line #610	-> byte code offset #255
    //   Java source line #609	-> byte code offset #258
    //   Java source line #612	-> byte code offset #263
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	264	0	this	ProjectApiDescription
    //   20	27	1	buffer	StringBuffer
    //   99	20	1	iterator	Iterator
    //   112	2	2	node	PackageNode
    //   164	37	2	fragments	IPackageFragment[]
    //   237	2	2	e	CoreException
    //   172	46	3	names	java.util.Set
    //   174	25	4	i	int
    //   209	4	4	component	ProjectComponent
    //   248	8	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   160	234	237	org/eclipse/core/runtime/CoreException
    //   78	248	248	finally
  }
  
  private IElementDescriptor getElementDescriptor(IJavaElement element)
  {
    switch (element.getElementType())
    {
    case 4: 
      return Factory.packageDescriptor(element.getElementName());
    case 7: 
      return Factory.typeDescriptor(((IType)element).getFullyQualifiedName('$'));
    }
    return null;
  }
  
  private IJavaProject getJavaProject()
  {
    return fProject;
  }
  
  synchronized IApiTypeContainer getApiTypeContainer(IPackageFragmentRoot root)
    throws CoreException
  {
    IApiTypeContainer container = getApiComponent().getTypeContainer(root);
    if (container == null) {
      throw new CoreException(new Status(4, "org.eclipse.pde.api.tools", "Unable to resolve type conatiner for package fragment root"));
    }
    return container;
  }
  
  private IPackageFragment[] getLocalPackageFragments()
  {
    List local = new ArrayList();
    try
    {
      IPackageFragmentRoot[] roots = getJavaProject().getPackageFragmentRoots();
      for (int i = 0; i < roots.length; i++)
      {
        IPackageFragmentRoot root = roots[i];
        
        IResource resource = root.getCorrespondingResource();
        if ((resource != null) && (resource.getProject().equals(getJavaProject().getProject())))
        {
          IJavaElement[] children = root.getChildren();
          for (int j = 0; j < children.length; j++) {
            local.add(children[j]);
          }
        }
      }
    }
    catch (JavaModelException localJavaModelException) {}
    return (IPackageFragment[])local.toArray(new IPackageFragment[local.size()]);
  }
  
  public synchronized String getXML()
    throws CoreException
  {
    Document document = Util.newDocument();
    Element component = document.createElement("component");
    component.setAttribute("id", getJavaProject().getElementName());
    component.setAttribute("modificationStamp", Long.toString(fPackageTimeStamp));
    component.setAttribute("version", "1.2");
    document.appendChild(component);
    persistChildren(document, component, fPackageMap);
    return Util.serializeDocument(document);
  }
  
  void persistChildren(Document document, Element xmlElement, Map elementMap)
  {
    Iterator iterator = elementMap.values().iterator();
    while (iterator.hasNext())
    {
      ApiDescription.ManifestNode node = (ApiDescription.ManifestNode)iterator.next();
      node.persistXML(document, xmlElement);
    }
  }
  
  public synchronized void clean()
  {
    fPackageMap.clear();
    fPackageTimeStamp = -1L;
    fInSynch = false;
    modified();
  }
  
  public synchronized void projectChanged()
  {
    fInSynch = false;
  }
  
  public synchronized void projectClasspathChanged()
  {
    fInSynch = false;
    
    fPackageTimeStamp = -1L;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("Project API description for: ").append(getJavaProject().getElementName());
    return buffer.toString();
  }
  
  private ProjectComponent getApiComponent()
    throws CoreException
  {
    IApiBaseline baseline = ApiBaselineManager.getManager().getWorkspaceBaseline();
    ProjectComponent component = (ProjectComponent)baseline.getApiComponent(getJavaProject().getProject());
    if (component == null) {
      throw new CoreException(new Status(4, "org.eclipse.pde.api.tools", "Unable to resolve project API component for API description"));
    }
    return component;
  }
  
  protected IApiAnnotations resolveAnnotations(ApiDescription.ManifestNode node, IElementDescriptor element)
  {
    IApiAnnotations ann = super.resolveAnnotations(node, element);
    if ((node instanceof TypeNode)) {
      return new TypeAnnotations(ann, fBuildStamp);
    }
    return ann;
  }
}

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

import org.eclipse.pde.api.tools.internal.provisional.IRequiredComponentDescription;
import org.eclipse.pde.api.tools.internal.provisional.IVersionRange;

public class RequiredComponentDescription
  implements IRequiredComponentDescription
{
  private String fId;
  private boolean fIsOptional;
  private boolean fIsExprted;
  private IVersionRange fRange;
  
  public RequiredComponentDescription(String id, IVersionRange range)
  {
    this(id, range, false, false);
  }
  
  public RequiredComponentDescription(String id, IVersionRange range, boolean isOptional, boolean isExported)
  {
    fId = id;
    fRange = range;
    fIsOptional = isOptional;
    fIsExprted = isExported;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof RequiredComponentDescription))
    {
      RequiredComponentDescription desc = (RequiredComponentDescription)obj;
      return (fId.equals(fId)) && (fRange.equals(fRange));
    }
    return super.equals(obj);
  }
  
  public String getId()
  {
    return fId;
  }
  
  public IVersionRange getVersionRange()
  {
    return fRange;
  }
  
  public int hashCode()
  {
    return fId.hashCode() + fRange.hashCode();
  }
  
  public boolean isOptional()
  {
    return fIsOptional;
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer();
    buf.append(fId);
    buf.append(' ');
    buf.append(fRange.toString());
    return buf.toString();
  }
  
  public boolean isExported()
  {
    return fIsExprted;
  }
}

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

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.pde.api.tools.internal.provisional.ISession;
import org.eclipse.pde.api.tools.internal.provisional.ISessionListener;
import org.eclipse.pde.api.tools.internal.provisional.ISessionManager;

public class SessionManager
  implements ISessionManager
{
  private List sessions = new ArrayList();
  private Set listeners = new HashSet();
  private ISession activeSession;
  
  public synchronized void addSession(ISession session, boolean activate)
  {
    if (session == null) {
      throw new IllegalArgumentException("The given session cannot be null");
    }
    if (!sessions.contains(session))
    {
      sessions.add(session);
      fireSessionAdded(session);
    }
    if (activate)
    {
      activeSession = session;
      fireSessionActivated(session);
    }
  }
  
  public synchronized void removeSession(ISession session)
  {
    if (sessions.remove(session))
    {
      if (session.equals(activeSession))
      {
        activeSession = null;
        fireSessionActivated(null);
      }
      fireSessionRemoved(session);
    }
  }
  
  public synchronized void removeAllSessions()
  {
    ISession[] allSessions = (ISession[])sessions.toArray(new ISession[sessions.size()]);
    sessions.clear();
    activeSession = null;
    fireSessionActivated(null);
    for (int i = 0; i < allSessions.length; i++)
    {
      ISession session = allSessions[i];
      fireSessionRemoved(session);
    }
  }
  
  public synchronized ISession[] getSessions()
  {
    return (ISession[])sessions.toArray(new ISession[sessions.size()]);
  }
  
  public synchronized void addSessionListener(ISessionListener listener)
  {
    if (listener == null) {
      throw new IllegalArgumentException("The given listener cannot be null");
    }
    listeners.add(listener);
  }
  
  public synchronized void removeSessionListener(ISessionListener listener)
  {
    listeners.remove(listener);
  }
  
  protected synchronized void fireSessionAdded(ISession session)
  {
    Iterator i = listeners.iterator();
    while (i.hasNext()) {
      ((ISessionListener)i.next()).sessionAdded(session);
    }
  }
  
  protected synchronized void fireSessionRemoved(ISession session)
  {
    Iterator i = listeners.iterator();
    while (i.hasNext()) {
      ((ISessionListener)i.next()).sessionRemoved(session);
    }
  }
  
  public ISession getActiveSession()
  {
    return activeSession;
  }
  
  protected synchronized void fireSessionActivated(ISession session)
  {
    Iterator i = listeners.iterator();
    while (i.hasNext()) {
      ((ISessionListener)i.next()).sessionActivated(session);
    }
  }
  
  public void activateSession(ISession session)
  {
    if ((sessions.contains(session)) && (!session.equals(activeSession)))
    {
      activeSession = session;
      fireSessionActivated(session);
    }
  }
}

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

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
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.IFieldDescriptor;
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.scanner.ScannerMessages;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class SystemApiDescriptionProcessor
{
  public static String serializeComponentXml(File location)
  {
    if (location.exists())
    {
      ZipFile jarFile = null;
      InputStream stream = null;
      try
      {
        String extension = new Path(location.getName()).getFileExtension();
        if ((extension != null) && (extension.equals("jar")) && (location.isFile()))
        {
          jarFile = new ZipFile(location, 1);
          ZipEntry manifestEntry = jarFile.getEntry("system.api_description");
          if (manifestEntry != null) {
            stream = jarFile.getInputStream(manifestEntry);
          }
        }
        else if (location.isDirectory())
        {
          File file = new File(location, "system.api_description");
          if (file.exists()) {
            stream = new FileInputStream(file);
          }
        }
        else if ((location.isFile()) && 
          (location.getName().equals("system.api_description")))
        {
          stream = new FileInputStream(location);
        }
        if (stream != null) {
          return new String(Util.getInputStreamAsCharArray(stream, -1, "UTF-8"));
        }
      }
      catch (IOException e)
      {
        ApiPlugin.log(e);
      }
      finally
      {
        try
        {
          if (stream != null) {
            stream.close();
          }
        }
        catch (IOException e)
        {
          ApiPlugin.log(e);
        }
        try
        {
          if (jarFile != null) {
            jarFile.close();
          }
        }
        catch (IOException e)
        {
          ApiPlugin.log(e);
        }
      }
      try
      {
        if (stream != null) {
          stream.close();
        }
      }
      catch (IOException e)
      {
        ApiPlugin.log(e);
      }
      try
      {
        if (jarFile != null) {
          jarFile.close();
        }
      }
      catch (IOException e)
      {
        ApiPlugin.log(e);
      }
    }
    return null;
  }
  
  private static void abort(String message, Throwable exception)
    throws CoreException
  {
    IStatus status = new Status(4, "org.eclipse.pde.api.tools", message, exception);
    throw new CoreException(status);
  }
  
  public static void annotateApiSettings(IApiDescription settings, String xml)
    throws CoreException
  {
    Element root = null;
    try
    {
      root = Util.parseDocument(xml);
    }
    catch (CoreException ce)
    {
      abort("Failed to parse API description xml file", ce);
    }
    if (!root.getNodeName().equals("component")) {
      abort(ScannerMessages.ComponentXMLScanner_0, null);
    }
    NodeList packages = root.getElementsByTagName("package");
    NodeList types = null;
    IPackageDescriptor packdesc = null;
    Element type = null;
    for (int i = 0; i < packages.getLength(); i++)
    {
      Element pkg = (Element)packages.item(i);
      
      String pkgName = pkg.getAttribute("name");
      packdesc = Factory.packageDescriptor(pkgName);
      annotateDescriptor(settings, packdesc, pkg);
      types = pkg.getElementsByTagName("type");
      for (int j = 0; j < types.getLength(); j++)
      {
        type = (Element)types.item(j);
        String name = type.getAttribute("name");
        if (name.length() == 0) {
          abort("Missing type name", null);
        }
        IReferenceTypeDescriptor typedesc = packdesc.getType(name);
        annotateDescriptor(settings, typedesc, type);
        annotateMethodSettings(settings, typedesc, type);
        annotateFieldSettings(settings, typedesc, type);
      }
    }
  }
  
  private static void annotateDescriptor(IApiDescription settings, IElementDescriptor descriptor, Element element)
  {
    settings.setVisibility(descriptor, 1);
    settings.setRestrictions(descriptor, 0);
    settings.setAddedProfile(descriptor, retrieveElementAttribute(element, "addedprofile"));
    settings.setRemovedProfile(descriptor, retrieveElementAttribute(element, "removedprofile"));
    settings.setSuperclass(descriptor, retrieveStringElementAttribute(element, "sc"));
    settings.setSuperinterfaces(descriptor, retrieveStringElementAttribute(element, "sis"));
    settings.setInterface(descriptor, retrieveBooleanElementAttribute(element, "int"));
  }
  
  private static int retrieveElementAttribute(Element element, String name)
  {
    String value = element.getAttribute(name);
    if (value.length() > 0) {
      return Integer.parseInt(value);
    }
    return 0;
  }
  
  private static String retrieveStringElementAttribute(Element element, String name)
  {
    String value = element.getAttribute(name);
    if (value.length() > 0) {
      return value;
    }
    return null;
  }
  
  private static boolean retrieveBooleanElementAttribute(Element element, String name)
  {
    String value = element.getAttribute(name);
    if (value.length() > 0) {
      return Boolean.toString(true).equals(value);
    }
    return false;
  }
  
  private static void annotateFieldSettings(IApiDescription settings, IReferenceTypeDescriptor typedesc, Element type)
    throws CoreException
  {
    NodeList fields = type.getElementsByTagName("field");
    Element field = null;
    IFieldDescriptor fielddesc = null;
    String name = null;
    for (int i = 0; i < fields.getLength(); i++)
    {
      field = (Element)fields.item(i);
      name = field.getAttribute("name");
      if (name == null) {
        abort(ScannerMessages.ComponentXMLScanner_1, null);
      }
      fielddesc = typedesc.getField(name);
      annotateDescriptor(settings, fielddesc, field);
    }
  }
  
  private static void annotateMethodSettings(IApiDescription settings, IReferenceTypeDescriptor typedesc, Element type)
    throws CoreException
  {
    NodeList methods = type.getElementsByTagName("method");
    Element method = null;
    IMethodDescriptor methoddesc = null;
    for (int i = 0; i < methods.getLength(); i++)
    {
      method = (Element)methods.item(i);
      String name = method.getAttribute("name");
      if (name == null) {
        abort(ScannerMessages.ComponentXMLScanner_2, null);
      }
      String signature = method.getAttribute("signature");
      if (signature == null) {
        abort(ScannerMessages.ComponentXMLScanner_3, null);
      }
      methoddesc = typedesc.getMethod(name, signature);
      annotateDescriptor(settings, methoddesc, method);
    }
  }
}

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

import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;

public class TypeAnnotations
  implements IApiAnnotations
{
  private IApiAnnotations fAnnotations;
  private long fBuildStamp;
  
  public TypeAnnotations(IApiAnnotations annotations, long stamp)
  {
    fAnnotations = annotations;
    fBuildStamp = stamp;
  }
  
  public long getBuildStamp()
  {
    return fBuildStamp;
  }
  
  public int getVisibility()
  {
    return fAnnotations.getVisibility();
  }
  
  public int getRestrictions()
  {
    return fAnnotations.getRestrictions();
  }
}

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

import java.io.PrintStream;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.pde.api.tools.internal.builder.BuildState;
import org.eclipse.pde.api.tools.internal.model.ApiBaseline;
import org.eclipse.pde.api.tools.internal.util.Util;

public class WorkspaceDeltaProcessor
  implements IElementChangedListener, IResourceChangeListener
{
  private static boolean DEBUG = Util.DEBUG;
  
  public static void setDebug(boolean debugValue)
  {
    DEBUG = (debugValue) || (Util.DEBUG);
  }
  
  ApiBaselineManager bmanager = ApiBaselineManager.getManager();
  ApiDescriptionManager dmanager = ApiDescriptionManager.getManager();
  
  public void elementChanged(ElementChangedEvent event)
  {
    processJavaElementDeltas(event.getDelta().getAffectedChildren(), null);
  }
  
  void processJavaElementDeltas(IJavaElementDelta[] deltas, IJavaProject project)
  {
    for (int i = 0; i < deltas.length; i++)
    {
      IJavaElementDelta delta = deltas[i];
      switch (delta.getElement().getElementType())
      {
      case 2: 
        IJavaProject proj = (IJavaProject)delta.getElement();
        int flags = delta.getFlags();
        switch (delta.getKind())
        {
        case 4: 
          if (!Util.isApiProject(proj))
          {
            if (DEBUG) {
              System.out.println("--> skipped processing CHANGED delta for project: " + proj.getElementName());
            }
          }
          else if ((flags & 0x200) != 0)
          {
            if (DEBUG) {
              System.out.println("--> processing OPEN project: [" + proj.getElementName() + "]");
            }
            bmanager.disposeWorkspaceBaseline();
          }
          else if (((flags & 0x200000) != 0) || 
            ((flags & 0x20000) != 0))
          {
            if (DEBUG) {
              System.out.println("--> processing CLASSPATH CHANGE project: [" + proj.getElementName() + "]");
            }
            bmanager.disposeWorkspaceBaseline();
            dmanager.projectClasspathChanged(proj);
            try
            {
              BuildState.setLastBuiltState(proj.getProject(), null);
            }
            catch (CoreException localCoreException) {}
            dmanager.flushElementCache(delta.getElement());
          }
          else if ((flags & 0x8) != 0)
          {
            if (DEBUG) {
              System.out.println("--> processing CHILDREN delta of project: [" + proj.getElementName() + "]");
            }
            processJavaElementDeltas(delta.getAffectedChildren(), proj);
          }
          else if ((flags & 0x1) != 0)
          {
            if (proj != null)
            {
              if (DEBUG) {
                System.out.println("--> processing child CONTENT of project: [" + proj.getElementName() + "]");
              }
              IResourceDelta[] resourcedeltas = delta.getResourceDeltas();
              if (resourcedeltas != null)
              {
                IResourceDelta rdelta = null;
                for (int j = 0; j < resourcedeltas.length; j++)
                {
                  rdelta = resourcedeltas[j].findMember(new Path("MANIFEST.MF"));
                  if ((rdelta != null) && (rdelta.getKind() == 4) && ((rdelta.getFlags() & 0x100) > 0))
                  {
                    if (DEBUG) {
                      System.out.println("--> processing manifest delta");
                    }
                    bmanager.disposeWorkspaceBaseline();
                    break;
                  }
                }
              }
            }
            else if (DEBUG)
            {
              System.out.println("--> ignoring child CONTENT project context is null");
            }
          }
          break;
        case 1: 
          if (!Util.isApiProject(proj))
          {
            if (DEBUG) {
              System.out.println("--> skipped processing ADDED delta for project: " + proj.getElementName());
            }
          }
          else if ((flags & 0x10) != 0)
          {
            if (DEBUG) {
              System.out.println("--> processing PROJECT RENAME from: [" + delta.getMovedFromElement().getJavaProject().getElementName() + "] to: [" + proj.getElementName() + "]");
            }
            bmanager.disposeWorkspaceBaseline();
          }
          break;
        }
        break;
      case 3: 
        IPackageFragmentRoot root = (IPackageFragmentRoot)delta.getElement();
        int flags = delta.getFlags();
        if ((flags & 0x80C0) != 0)
        {
          if (DEBUG) {
            System.out.println("processed CLASSPATH CHANGED for package fragment root: [" + root.getElementName() + "]");
          }
          dmanager.projectClasspathChanged(project);
        }
        if ((flags & 0x8) != 0)
        {
          if (DEBUG) {
            System.out.println("processed CHILDREN for package fragment root: [" + root.getElementName() + "]");
          }
          processJavaElementDeltas(delta.getAffectedChildren(), project);
        }
        break;
      case 4: 
        IPackageFragment fragment = (IPackageFragment)delta.getElement();
        if (delta.getKind() == 2)
        {
          if (DEBUG) {
            System.out.println("processed REMOVED delta for package fragment: [" + fragment.getElementName() + "]");
          }
          ((ApiBaseline)bmanager.getWorkspaceBaseline()).clearPackage(fragment.getElementName());
        }
        int flags = delta.getFlags();
        if ((flags & 0x8) != 0)
        {
          if (DEBUG) {
            System.out.println("processed CHILDREN delta for package fragment: [" + fragment.getElementName() + "]");
          }
          processJavaElementDeltas(delta.getAffectedChildren(), project);
        }
        break;
      case 5: 
        int flags = delta.getFlags();
        switch (delta.getKind())
        {
        case 4: 
          if ((flags & 0x44001) != 0) {
            if (project != null)
            {
              if (DEBUG) {
                System.out.println("processed CONTENT / FINE_GRAINED / PRIMARY_RESOURCE delta for: [" + delta.getElement().getElementName() + "]");
              }
              dmanager.projectChanged(project);
              dmanager.flushElementCache(delta.getElement());
            }
          }
          break;
        case 1: 
        case 2: 
          if (project != null)
          {
            if (DEBUG) {
              if (delta.getKind() == 1) {
                System.out.println("processed ADDED delta for: [" + delta.getElement().getElementName() + "]");
              } else {
                System.out.println("processed REMOVED delta for: [" + delta.getElement().getElementName() + "]");
              }
            }
            dmanager.projectChanged(project);
            dmanager.flushElementCache(delta.getElement());
          }
          break;
        }
        break;
      }
    }
  }
  
  public void resourceChanged(IResourceChangeEvent event)
  {
    IResource resource = event.getResource();
    switch (event.getType())
    {
    case 8: 
      if (DEBUG) {
        if (resource == null) {
          System.out.println("processed PRE_BUILD delta for workspace.");
        } else {
          System.out.println("processed PRE_BUILD delta for project: [" + resource.getName() + "]");
        }
      }
      IResourceDelta delta = event.getDelta();
      if (delta != null)
      {
        IResourceDelta[] children = delta.getAffectedChildren(4);
        for (int i = 0; i < children.length; i++)
        {
          resource = children[i].getResource();
          if (children[i].getResource().getType() == 4)
          {
            IProject project = (IProject)resource;
            if (((Util.isApiProject(project)) || (Util.isJavaProject(project))) && 
              ((children[i].getFlags() & 0x80000) != 0))
            {
              IJavaProject jp = (IJavaProject)JavaCore.create(resource);
              dmanager.clean(jp, true, true);
              bmanager.disposeWorkspaceBaseline();
              break;
            }
          }
        }
      }
      break;
    case 2: 
    case 4: 
      if ((goto 404) && 
      
        (resource.getType() == 4))
      {
        IProject project = (IProject)resource;
        if ((Util.isApiProject(project)) || (Util.isJavaProject(project)))
        {
          if (DEBUG) {
            if (event.getType() == 2) {
              System.out.println("processed PRE_CLOSE delta for project: [" + resource.getName() + "]");
            } else if (DEBUG) {
              System.out.println("processed PRE_DELETE delta for project: [" + resource.getName() + "]");
            }
          }
          bmanager.disposeWorkspaceBaseline();
          IJavaProject javaProject = (IJavaProject)JavaCore.create(resource);
          dmanager.clean(javaProject, false, true);
          dmanager.flushElementCache(javaProject);
        }
      }
      break;
    }
  }
}

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

import java.util.HashMap;
import java.util.Map;
import org.eclipse.pde.api.tools.internal.model.MethodKey;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
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.provisional.model.IApiMember;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;

public abstract class AbstractIllegalMethodReference
  extends AbstractProblemDetector
{
  private Map fIllegalMethods = new HashMap();
  private Map fMethodComponents = new HashMap();
  
  void addIllegalMethod(IMethodDescriptor method, String componentId)
  {
    fIllegalMethods.put(new MethodKey(method.getEnclosingType().getQualifiedName(), method.getName(), method.getSignature(), true), method);
    fMethodComponents.put(method, componentId);
  }
  
  public boolean considerReference(IReference reference)
  {
    if ((super.considerReference(reference)) && (fIllegalMethods.containsKey(new MethodKey(reference.getReferencedTypeName(), reference.getReferencedMemberName(), reference.getReferencedSignature(), true))))
    {
      retainReference(reference);
      return true;
    }
    return false;
  }
  
  protected boolean isProblem(IReference reference)
  {
    if (!super.isProblem(reference)) {
      return false;
    }
    IApiMember method = reference.getResolvedReference();
    String componentId = (String)fMethodComponents.get(method.getHandle());
    
    return isReferenceFromComponent(reference, componentId);
  }
  
  protected int getElementType(IReference reference)
  {
    return 6;
  }
  
  protected int getProblemFlags(IReference reference)
  {
    IApiMethod method = (IApiMethod)reference.getResolvedReference();
    if (method.isConstructor()) {
      return 7;
    }
    return 8;
  }
}

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

import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
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.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;

public abstract class AbstractIllegalTypeReference
  extends AbstractProblemDetector
{
  private Map fIllegalTypes = new HashMap();
  
  void addIllegalType(IReferenceTypeDescriptor type, String componentId)
  {
    fIllegalTypes.put(type.getQualifiedName(), componentId);
  }
  
  public boolean considerReference(IReference reference)
  {
    if ((super.considerReference(reference)) && (fIllegalTypes.containsKey(reference.getReferencedTypeName())))
    {
      retainReference(reference);
      return true;
    }
    return false;
  }
  
  protected boolean isIllegalType(IReference reference)
  {
    return fIllegalTypes.containsKey(reference.getReferencedTypeName());
  }
  
  protected boolean isProblem(IReference reference)
  {
    if (!super.isProblem(reference)) {
      return false;
    }
    IApiMember type = reference.getResolvedReference();
    Object componentId = fIllegalTypes.get(type.getName());
    return isReferenceFromComponent(reference, componentId);
  }
  
  protected Position getSourceRange(IType type, IDocument doc, IReference reference)
    throws CoreException, BadLocationException
  {
    ISourceRange range = type.getNameRange();
    Position pos = null;
    if (range != null) {
      pos = new Position(range.getOffset(), range.getLength());
    }
    if (pos == null) {
      return defaultSourcePosition(type, reference);
    }
    return pos;
  }
  
  protected int getElementType(IReference reference)
  {
    return 2;
  }
  
  protected String[] getMessageArgs(IReference reference)
    throws CoreException
  {
    return new String[] {
      getSimpleTypeName(reference.getResolvedReference()), 
      getSimpleTypeName(reference.getMember()) };
  }
  
  protected String[] getQualifiedMessageArgs(IReference reference)
    throws CoreException
  {
    return new String[] {
      getQualifiedTypeName(reference.getResolvedReference()), 
      getQualifiedTypeName(reference.getMember()) };
  }
  
  protected int getProblemFlags(IReference reference)
  {
    return 0;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.builder.AbstractIllegalTypeReference
 * 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.pde.api.tools.internal.provisional.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.util.Signatures;

public abstract class AbstractLeakProblemDetector
  extends AbstractProblemDetector
{
  private Set fNonApiPackageNames;
  
  public AbstractLeakProblemDetector(Set nonApiPackageNames)
  {
    fNonApiPackageNames = nonApiPackageNames;
  }
  
  protected boolean isNonAPIReference(IReference reference)
  {
    String packageName = Signatures.getPackageName(reference.getReferencedTypeName());
    if (fNonApiPackageNames.contains(packageName)) {
      return true;
    }
    IApiMember member = reference.getMember();
    IApiType type = null;
    if (member.getType() == 2) {
      type = (IApiType)member;
    } else {
      type = (IApiType)member.getAncestor(2);
    }
    String origin = Signatures.getPackageName(type.getName());
    if (packageName.equals(origin)) {
      return true;
    }
    return false;
  }
  
  protected boolean isEnclosingTypeVisible(IApiMember member)
    throws CoreException
  {
    IApiType type = null;
    if (member.getType() == 2) {
      type = (IApiType)member;
    } else {
      type = member.getEnclosingType();
    }
    while (type != null)
    {
      if ((0x5 & type.getModifiers()) == 0) {
        return false;
      }
      type = type.getEnclosingType();
    }
    return true;
  }
}

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

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.problems.ApiProblemFactory;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
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.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiField;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
import org.eclipse.pde.api.tools.internal.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;

public abstract class AbstractProblemDetector
  implements IApiProblemDetector
{
  protected static boolean DEBUG = Util.DEBUG;
  
  public static void setDebug(boolean debugValue)
  {
    DEBUG = (debugValue) || (Util.DEBUG);
  }
  
  private List fPotentialProblems = new LinkedList();
  
  protected void retainReference(IReference reference)
  {
    fPotentialProblems.add(reference);
  }
  
  protected List getRetainedReferences()
  {
    return fPotentialProblems;
  }
  
  public boolean considerReference(IReference reference)
  {
    return (reference != null) && ((reference.getReferenceKind() & getReferenceKinds()) > 0);
  }
  
  protected IApiProblem createProblem(IReference reference, IJavaProject javaProject)
  {
    IProject project = javaProject.getProject();
    if (ApiPlugin.getDefault().getSeverityLevel(getSeverityKey(), project) == 0) {
      return null;
    }
    try
    {
      IApiMember member = reference.getMember();
      String lookupName = getTypeName(member).replace('$', '.');
      IType type = javaProject.findType(lookupName, new NullProgressMonitor());
      if (type == null) {
        return null;
      }
      ICompilationUnit compilationUnit = type.getCompilationUnit();
      if (compilationUnit == null) {
        return null;
      }
      IResource resource = Util.getResource(project, type);
      if (resource == null) {
        return null;
      }
      int charStart = -1;
      int charEnd = -1;
      int lineNumber = reference.getLineNumber();
      IJavaElement element = compilationUnit;
      if ((!Util.isManifest(resource.getProjectRelativePath())) && (!type.isBinary()))
      {
        IDocument document = Util.getDocument(compilationUnit);
        if (lineNumber > 0) {
          lineNumber--;
        }
        if ((reference.getReferenceKind() & 
          0x1000003B) != 0)
        {
          IApiType enclosingType = member.getEnclosingType();
          if ((lineNumber > 0) && (enclosingType != null) && (enclosingType.isAnonymous()))
          {
            String superclass = enclosingType.getSuperclassName();
            String name = null;
            if ("java.lang.Object".equals(superclass))
            {
              String[] superinterfaces = enclosingType.getSuperInterfaceNames();
              if (superinterfaces != null)
              {
                String superinterface = superinterfaces[0];
                name = superinterface.substring(superinterface.lastIndexOf('.') + 1);
              }
              else
              {
                name = superclass.substring(superclass.lastIndexOf('.') + 1);
              }
            }
            else if (superclass != null)
            {
              name = superclass.substring(superclass.lastIndexOf('.') + 1);
            }
            if (name != null) {
              try
              {
                IRegion lineInformation = document.getLineInformation(lineNumber);
                String lineContents = document.get(lineInformation.getOffset(), lineInformation.getLength());
                charStart = lineInformation.getOffset() + lineContents.indexOf(name);
                charEnd = charStart + name.length();
              }
              catch (BadLocationException e)
              {
                ApiPlugin.log(e);
                return null;
              }
            }
          }
        }
        if (charStart == -1) {
          try
         
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