org.eclipse.jdt.apt.pluggable.core_1.0.400.v20110305-1450

16:44:59.409 INFO  jd.cli.Main - Decompiling org.eclipse.jdt.apt.pluggable.core_1.0.400.v20110305-1450.jar
package org.eclipse.jdt.internal.apt.pluggable.core;

import org.eclipse.jdt.core.compiler.CompilationParticipant;

public class Apt6CompilationParticipant
  extends CompilationParticipant
{}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.Apt6CompilationParticipant
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core;

import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;

public class Apt6Plugin
  extends Plugin
{
  private static final SimpleDateFormat TRACE_DATE_FORMAT = new SimpleDateFormat("HH:mm:ss.SSS");
  public static final String PLUGIN_ID = "org.eclipse.jdt.apt.pluggable.core";
  public static final int STATUS_EXCEPTION = 1;
  public static boolean DEBUG = false;
  public static final String APT_DEBUG_OPTION = "org.eclipse.jdt.apt.pluggable.core/debug";
  private static Apt6Plugin thePlugin = null;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    thePlugin = this;
    initDebugTracing();
  }
  
  private void initDebugTracing()
  {
    String option = Platform.getDebugOption("org.eclipse.jdt.apt.pluggable.core/debug");
    if (option != null) {
      DEBUG = option.equalsIgnoreCase("true");
    }
  }
  
  public static Apt6Plugin getPlugin()
  {
    return thePlugin;
  }
  
  public static void log(IStatus status)
  {
    thePlugin.getLog().log(status);
  }
  
  public static void log(Throwable e, String message)
  {
    log(new Status(4, "org.eclipse.jdt.apt.pluggable.core", 1, message, e));
  }
  
  public static void logWarning(Throwable e, String message)
  {
    log(createWarningStatus(e, message));
  }
  
  public static Status createStatus(Throwable e, String message)
  {
    return new Status(4, "org.eclipse.jdt.apt.pluggable.core", 1, message, e);
  }
  
  public static Status createWarningStatus(Throwable e, String message)
  {
    return new Status(2, "org.eclipse.jdt.apt.pluggable.core", 1, message, e);
  }
  
  public static Status createInfoStatus(Throwable e, String message)
  {
    return new Status(1, "org.eclipse.jdt.apt.pluggable.core", 1, message, e);
  }
  
  public static void trace(String msg)
  {
    if (DEBUG)
    {
      StringBuffer sb = new StringBuffer();
      sb.append('[');
      synchronized (TRACE_DATE_FORMAT)
      {
        sb.append(TRACE_DATE_FORMAT.format(new Date()));
      }
      sb.append('-');
      
      String threadName = Thread.currentThread().getName();
      int dot = threadName.lastIndexOf('.');
      if (dot < 0) {
        sb.append(threadName);
      } else {
        sb.append(threadName.substring(dot + 1));
      }
      sb.append(']');
      sb.append(msg);
      System.out.println(sb);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.dispatch;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.processing.Processor;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader;
import org.eclipse.jdt.apt.core.internal.IServiceFactory;
import org.eclipse.jdt.apt.core.internal.util.FactoryPath.Attributes;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager;
import org.eclipse.jdt.internal.compiler.apt.dispatch.ProcessorInfo;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.core.CompilationUnitProblemFinder;
import org.eclipse.jdt.internal.core.builder.ICompilationUnitLocator;

public class IdeAnnotationProcessorManager
  extends BaseAnnotationProcessorManager
{
  private IJavaProject _javaProject;
  private ICompilationUnitLocator _cuLocator;
  private Map<IServiceFactory, FactoryPath.Attributes> _processorFactories;
  private Iterator<Map.Entry<IServiceFactory, FactoryPath.Attributes>> _processorIter;
  
  public void configureFromPlatform(Compiler compiler, Object compilationUnitLocator, Object javaProject)
  {
    _javaProject = ((IJavaProject)javaProject);
    _cuLocator = ((ICompilationUnitLocator)compilationUnitLocator);
    if (_processingEnv != null) {
      throw new IllegalStateException(
        "Calling configure() more than once on an AnnotationProcessorManager is not supported");
    }
    if ((compiler instanceof CompilationUnitProblemFinder)) {
      _processingEnv = new IdeReconcileProcessingEnvImpl(this, _javaProject, compiler);
    } else {
      _processingEnv = new IdeBuildProcessingEnvImpl(this, _javaProject, compiler);
    }
    if (Apt6Plugin.DEBUG) {
      Apt6Plugin.trace(
        "Java 6 annotation processor manager initialized for compiler " + compiler.toString() + " on project " + _javaProject.getElementName());
    }
  }
  
  public ProcessorInfo discoverNextProcessor()
  {
    if (_processorIter.hasNext())
    {
      Map.Entry<IServiceFactory, FactoryPath.Attributes> entry = (Map.Entry)_processorIter.next();
      try
      {
        Processor p = (Processor)((IServiceFactory)entry.getKey()).newInstance();
        p.init(_processingEnv);
        ProcessorInfo pi = new ProcessorInfo(p);
        if (Apt6Plugin.DEBUG) {
          Apt6Plugin.trace("Discovered processor " + p.toString());
        }
        _processors.add(pi);
        return pi;
      }
      catch (CoreException e)
      {
        Apt6Plugin.log(e, "Unable to create instance of annotation processor " + entry.getKey());
      }
    }
    return null;
  }
  
  public void reportProcessorException(Processor p, Exception e)
  {
    Apt6Plugin.log(e, "Exception thrown by Java annotation processor " + p);
  }
  
  public ICompilationUnit findCompilationUnit(IFile file)
  {
    return _cuLocator.fromIFile(file);
  }
  
  public void processAnnotations(CompilationUnitDeclaration[] units, ReferenceBinding[] referenceBindings, boolean isLastRound)
  {
    if (_processorFactories == null)
    {
      _processorFactories = AnnotationProcessorFactoryLoader.getLoader().getJava6FactoriesAndAttributesForProject(_javaProject);
      _processorIter = _processorFactories.entrySet().iterator();
    }
    if (!_processorFactories.isEmpty()) {
      super.processAnnotations(units, referenceBindings, isLastRound);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.dispatch;

import org.eclipse.jdt.apt.core.env.Phase;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.internal.compiler.Compiler;

public class IdeBuildProcessingEnvImpl
  extends IdeProcessingEnvImpl
{
  public IdeBuildProcessingEnvImpl(IdeAnnotationProcessorManager dispatchManager, IJavaProject jproject, Compiler compiler)
  {
    super(dispatchManager, jproject, compiler);
  }
  
  public Phase getPhase()
  {
    return Phase.BUILD;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeBuildProcessingEnvImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.dispatch;

import javax.annotation.processing.Messager;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.tools.Diagnostic.Kind;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.apt.dispatch.AptProblem;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseMessagerImpl;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;

public class IdeMessagerImpl
  implements Messager
{
  private final IdeAnnotationProcessorManager _manager;
  private final IdeProcessingEnvImpl _env;
  
  public IdeMessagerImpl(IdeAnnotationProcessorManager manager, IdeProcessingEnvImpl env)
  {
    _manager = manager;
    _env = env;
    if ((_manager == null) || (_env == null)) {
      throw new NullPointerException();
    }
  }
  
  public void printMessage(Diagnostic.Kind kind, CharSequence msg)
  {
    printMessage(kind, msg, null, null, null);
  }
  
  public void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e)
  {
    printMessage(kind, msg, e, null, null);
  }
  
  public void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a)
  {
    printMessage(kind, msg, e, a, null);
  }
  
  public void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a, AnnotationValue v)
  {
    AptProblem problem = BaseMessagerImpl.createProblem(kind, msg, e, a, v);
    if (kind == Diagnostic.Kind.NOTE)
    {
      Apt6Plugin.log(new Status(1, "org.eclipse.jdt.apt.pluggable.core", 1, problem.getMessage(), null));
    }
    else if (_referenceContext != null)
    {
      CompilationResult result = _referenceContext.compilationResult();
      result.record(problem, _referenceContext);
    }
    else
    {
      Apt6Plugin.log(new Status(1, "org.eclipse.jdt.apt.pluggable.core", 1, problem.getMessage(), null));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeMessagerImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.dispatch;

import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import javax.lang.model.element.Element;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.apt.core.env.Phase;
import org.eclipse.jdt.apt.core.internal.AptCompilationParticipant;
import org.eclipse.jdt.apt.core.internal.AptPlugin;
import org.eclipse.jdt.apt.core.internal.AptProject;
import org.eclipse.jdt.apt.core.internal.generatedfile.FileGenerationResult;
import org.eclipse.jdt.apt.core.util.AptConfig;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.apt.model.IElementInfo;

public abstract class IdeProcessingEnvImpl
  extends BaseProcessingEnvImpl
{
  private final IdeAnnotationProcessorManager _dispatchManager;
  private final IJavaProject _javaProject;
  protected final AptProject _aptProject;
  
  public IdeProcessingEnvImpl(IdeAnnotationProcessorManager dispatchManager, IJavaProject jproject, Compiler compiler)
  {
    _dispatchManager = dispatchManager;
    _javaProject = jproject;
    _compiler = compiler;
    _aptProject = AptPlugin.getAptProject(jproject);
    _filer = new IdeFilerImpl(_dispatchManager, this);
    _messager = new IdeMessagerImpl(_dispatchManager, this);
  }
  
  public Locale getLocale()
  {
    return Locale.getDefault();
  }
  
  public Map<String, String> getOptions()
  {
    if (_processorOptions == null)
    {
      Map<String, String> allOptions = AptConfig.getProcessorOptions(_javaProject);
      Map<String, String> procOptions = new HashMap();
      for (Map.Entry<String, String> entry : allOptions.entrySet()) {
        if (!((String)entry.getKey()).startsWith("-")) {
          procOptions.put((String)entry.getKey(), (String)entry.getValue());
        }
      }
      procOptions.put("phase", getPhase().toString());
      _processorOptions = Collections.unmodifiableMap(procOptions);
    }
    return _processorOptions;
  }
  
  public AptProject getAptProject()
  {
    return _aptProject;
  }
  
  public IJavaProject getJavaProject()
  {
    return _javaProject;
  }
  
  public IProject getProject()
  {
    return _javaProject.getProject();
  }
  
  public abstract Phase getPhase();
  
  public IFile getEnclosingIFile(Element elem)
  {
    IElementInfo impl = (IElementInfo)elem;
    String name = impl.getFileName();
    if (name == null) {
      return null;
    }
    IFile file = _javaProject.getProject().getParent().getFile(new Path(name));
    return file;
  }
  
  public void addNewUnit(FileGenerationResult result)
  {
    AptCompilationParticipant.getInstance().addJava6GeneratedFile(result.getFile());
    addNewUnit(_dispatchManager.findCompilationUnit(result.getFile()));
  }
  
  public void addNewResource(IFile file)
  {
    AptCompilationParticipant.getInstance().addJava6GeneratedFile(file);
  }
  
  public boolean currentProcessorSupportsRTTG()
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.dispatch;

import org.eclipse.jdt.apt.core.env.Phase;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.internal.compiler.Compiler;

public class IdeReconcileProcessingEnvImpl
  extends IdeProcessingEnvImpl
{
  public IdeReconcileProcessingEnvImpl(IdeAnnotationProcessorManager dispatchManager, IJavaProject jproject, Compiler compiler)
  {
    super(dispatchManager, jproject, compiler);
  }
  
  public Phase getPhase()
  {
    return Phase.RECONCILE;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeReconcileProcessingEnvImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.filer;

import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.processing.Filer;
import javax.annotation.processing.FilerException;
import javax.lang.model.element.Element;
import javax.tools.FileObject;
import javax.tools.JavaFileManager.Location;
import javax.tools.JavaFileObject;
import javax.tools.StandardLocation;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.apt.core.internal.AptCompilationParticipant;
import org.eclipse.jdt.apt.core.internal.AptProject;
import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager;
import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;

public class IdeFilerImpl
  implements Filer
{
  private final IdeProcessingEnvImpl _env;
  
  public IdeFilerImpl(IdeAnnotationProcessorManager dispatchManager, IdeProcessingEnvImpl env)
  {
    _env = env;
  }
  
  public JavaFileObject createClassFile(CharSequence name, Element... originatingElements)
    throws IOException
  {
    throw new UnsupportedOperationException("Creating class files is not yet implemented");
  }
  
  public FileObject createResource(JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName, Element... originatingElements)
    throws IOException
  {
    if (location == null) {
      throw new IllegalArgumentException("Location is null");
    }
    if (!location.isOutputLocation()) {
      throw new IllegalArgumentException("Location " + location.getName() + " is not an output location");
    }
    if (pkg == null) {
      throw new IllegalArgumentException("Package is null");
    }
    if (relativeName == null) {
      throw new IllegalArgumentException("Relative name is null");
    }
    if (relativeName.length() == 0) {
      throw new IllegalArgumentException("Relative name is zero length");
    }
    IFile file = getFileFromOutputLocation(location, pkg, relativeName);
    if (AptCompilationParticipant.getInstance().getJava6GeneratedFiles().contains(file)) {
      throw new FilerException("Source file already created: " + file.getFullPath());
    }
    Set<IFile> parentFiles;
    if ((originatingElements != null) && (originatingElements.length > 0))
    {
      Set<IFile> parentFiles = new HashSet(originatingElements.length);
      Element[] arrayOfElement;
      int j = (arrayOfElement = originatingElements).length;
      for (int i = 0; i < j; i++)
      {
        Element elem = arrayOfElement[i];
        IFile enclosing = _env.getEnclosingIFile(elem);
        if (enclosing != null) {
          parentFiles.add(enclosing);
        }
      }
    }
    else
    {
      parentFiles = Collections.emptySet();
    }
    return new IdeOutputNonSourceFileObject(_env, file, parentFiles);
  }
  
  public JavaFileObject createSourceFile(CharSequence name, Element... originatingElements)
    throws IOException
  {
    if (name == null) {
      throw new IllegalArgumentException("Name is null");
    }
    IFile file = _env.getAptProject().getGeneratedFileManager().getIFileForTypeName(name.toString());
    if (AptCompilationParticipant.getInstance().getJava6GeneratedFiles().contains(file)) {
      throw new FilerException("Source file already created: " + file.getFullPath());
    }
    Set<IFile> parentFiles = Collections.emptySet();
    if ((originatingElements != null) && (originatingElements.length > 0))
    {
      parentFiles = new HashSet(originatingElements.length);
      Element[] arrayOfElement;
      int j = (arrayOfElement = originatingElements).length;
      for (int i = 0; i < j; i++)
      {
        Element elem = arrayOfElement[i];
        IFile enclosing = _env.getEnclosingIFile(elem);
        if (enclosing != null) {
          parentFiles.add(enclosing);
        }
      }
    }
    return new IdeOutputJavaFileObject(_env, name, parentFiles);
  }
  
  public FileObject getResource(JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName)
    throws IOException
  {
    IFile file = getFileFromOutputLocation(location, pkg, relativeName);
    return new IdeInputFileObject(file);
  }
  
  protected IFile getFileFromOutputLocation(JavaFileManager.Location loc, CharSequence pkg, CharSequence relPath)
    throws IOException
  {
    GeneratedSourceFolderManager gsfm = _env.getAptProject().getGeneratedSourceFolderManager();
    IPath path = null;
    if (loc == StandardLocation.CLASS_OUTPUT) {
      try
      {
        path = gsfm.getBinaryOutputLocation();
      }
      catch (JavaModelException e)
      {
        Apt6Plugin.log(e, "Failure getting the binary output location");
        IOException ioe = new IOException();
        ioe.initCause(e);
        throw ioe;
      }
    } else if (loc == StandardLocation.SOURCE_OUTPUT) {
      path = gsfm.getFolder().getProjectRelativePath();
    } else {
      throw new IllegalArgumentException("Unsupported location: " + loc);
    }
    if (pkg.length() > 0) {
      path = path.append(pkg.toString().replace('.', File.separatorChar));
    }
    path = path.append(relPath.toString());
    
    IFile file = _env.getProject().getFile(path);
    
    validatePath(file);
    
    return file;
  }
  
  private void validatePath(IFile file)
    throws IOException
  {
    IStatus status = _env.getProject().getWorkspace().validatePath(file.getFullPath().toOSString(), 1);
    if (!status.isOK())
    {
      CoreException ce = new CoreException(status);
      IOException ioe = new IOException("Invalid path: " + file.toString());
      ioe.initCause(ce);
      throw ioe;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.filer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
import javax.tools.FileObject;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.internal.core.util.Util;

public class IdeInputFileObject
  implements FileObject
{
  private final IFile _file;
  
  public IdeInputFileObject(IFile file)
  {
    _file = file;
  }
  
  public boolean delete()
  {
    throw new IllegalStateException("An annotation processor is not permitted to delete resources");
  }
  
  public CharSequence getCharContent(boolean ignoreEncodingErrors)
    throws IOException
  {
    try
    {
      char[] chars = Util.getResourceContentsAsCharArray(_file);
      return new String(chars);
    }
    catch (CoreException e)
    {
      throw new IOException(e);
    }
  }
  
  public long getLastModified()
  {
    return _file.getModificationStamp();
  }
  
  public String getName()
  {
    return _file.getProjectRelativePath().toString();
  }
  
  public InputStream openInputStream()
    throws IOException
  {
    try
    {
      return _file.getContents();
    }
    catch (CoreException e)
    {
      throw new IOException(e);
    }
  }
  
  public OutputStream openOutputStream()
    throws IOException
  {
    throw new IllegalStateException("Writing to a non-generated file is not permitted");
  }
  
  public Reader openReader(boolean ignoreEncodingErrors)
    throws IOException
  {
    return new BufferedReader(new InputStreamReader(openInputStream()));
  }
  
  public Writer openWriter()
    throws IOException
  {
    throw new IllegalStateException("Writing to a non-generated file is not permitted");
  }
  
  public URI toUri()
  {
    return _file.getLocationURI();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeInputFileObject
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.filer;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Collection;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.apt.core.env.Phase;
import org.eclipse.jdt.apt.core.internal.AptProject;
import org.eclipse.jdt.apt.core.internal.generatedfile.FileGenerationResult;
import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;

public class IdeJavaSourceOutputStream
  extends ByteArrayOutputStream
{
  private final IdeProcessingEnvImpl _env;
  private final CharSequence _name;
  private final Collection<IFile> _parentFiles;
  private boolean _closed = false;
  
  public IdeJavaSourceOutputStream(IdeProcessingEnvImpl env, CharSequence name, Collection<IFile> parentFiles)
  {
    _env = env;
    _name = name;
    _parentFiles = parentFiles;
  }
  
  public void close()
    throws IOException
  {
    synchronized (this)
    {
      if (_closed) {
        return;
      }
      _closed = true;
    }
    try
    {
      GeneratedFileManager gfm = _env.getAptProject().getGeneratedFileManager();
      Phase phase = _env.getPhase();
      
      FileGenerationResult result = null;
      if (phase != Phase.RECONCILE) {
        if (phase == Phase.BUILD) {
          result = gfm.generateFileDuringBuild(
            _parentFiles, _name.toString(), toString(), 
            _env.currentProcessorSupportsRTTG(), null);
        }
      }
      if (result != null) {
        _env.addNewUnit(result);
      }
    }
    catch (CoreException ce)
    {
      Apt6Plugin.log(ce, "Unable to generate type when IdeJavaSourceOutputStream was closed");
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeJavaSourceOutputStream
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.filer;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.apt.core.internal.util.FileSystemUtil;
import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin;
import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;

public class IdeNonSourceOutputStream
  extends ByteArrayOutputStream
{
  private final IdeProcessingEnvImpl _env;
  private final IFile _file;
  private final Collection<IFile> _parentFiles;
  
  public IdeNonSourceOutputStream(IdeProcessingEnvImpl env, IFile file, Collection<IFile> parentFiles)
  {
    _env = env;
    _file = file;
    _parentFiles = parentFiles;
  }
  
  /* Error */
  public void close()
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 140	java/io/ByteArrayOutputStream:close	()V
    //   4: new 63	java/io/ByteArrayInputStream
    //   7: dup
    //   8: aload_0
    //   9: invokevirtual 155	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:toByteArray	()[B
    //   12: invokespecial 138	java/io/ByteArrayInputStream:<init>	([B)V
    //   15: astore_1
    //   16: iconst_1
    //   17: istore_2
    //   18: aload_0
    //   19: getfield 135	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:_file	Lorg/eclipse/core/resources/IFile;
    //   22: invokeinterface 159 1 0
    //   27: ifne +12 -> 39
    //   30: aload_0
    //   31: aload_1
    //   32: iconst_1
    //   33: invokespecial 157	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:saveToDisk	(Ljava/io/InputStream;Z)V
    //   36: goto +123 -> 159
    //   39: aconst_null
    //   40: astore_3
    //   41: aconst_null
    //   42: astore 4
    //   44: new 63	java/io/ByteArrayInputStream
    //   47: dup
    //   48: aload_0
    //   49: invokevirtual 155	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:toByteArray	()[B
    //   52: invokespecial 138	java/io/ByteArrayInputStream:<init>	([B)V
    //   55: astore_3
    //   56: new 62	java/io/BufferedInputStream
    //   59: dup
    //   60: aload_0
    //   61: getfield 135	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:_file	Lorg/eclipse/core/resources/IFile;
    //   64: invokeinterface 160 1 0
    //   69: invokespecial 137	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   72: astore 4
    //   74: aload_3
    //   75: aload 4
    //   77: invokestatic 151	org/eclipse/jdt/apt/core/internal/util/FileSystemUtil:compareStreams	(Ljava/io/InputStream;Ljava/io/InputStream;)Z
    //   80: ifeq +41 -> 121
    //   83: iconst_0
    //   84: istore_2
    //   85: goto +36 -> 121
    //   88: pop
    //   89: iconst_1
    //   90: istore_2
    //   91: aload_0
    //   92: aload_3
    //   93: invokespecial 156	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:closeInputStream	(Ljava/io/InputStream;)V
    //   96: aload_0
    //   97: aload 4
    //   99: invokespecial 156	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:closeInputStream	(Ljava/io/InputStream;)V
    //   102: goto +30 -> 132
    //   105: astore 5
    //   107: aload_0
    //   108: aload_3
    //   109: invokespecial 156	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:closeInputStream	(Ljava/io/InputStream;)V
    //   112: aload_0
    //   113: aload 4
    //   115: invokespecial 156	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:closeInputStream	(Ljava/io/InputStream;)V
    //   118: aload 5
    //   120: athrow
    //   121: aload_0
    //   122: aload_3
    //   123: invokespecial 156	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:closeInputStream	(Ljava/io/InputStream;)V
    //   126: aload_0
    //   127: aload 4
    //   129: invokespecial 156	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:closeInputStream	(Ljava/io/InputStream;)V
    //   132: iload_2
    //   133: ifeq +26 -> 159
    //   136: aload_1
    //   137: invokevirtual 144	java/io/InputStream:reset	()V
    //   140: aload_0
    //   141: aload_1
    //   142: iconst_0
    //   143: invokespecial 157	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:saveToDisk	(Ljava/io/InputStream;Z)V
    //   146: goto +13 -> 159
    //   149: astore 6
    //   151: aload_0
    //   152: aload_1
    //   153: invokespecial 156	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:closeInputStream	(Ljava/io/InputStream;)V
    //   156: aload 6
    //   158: athrow
    //   159: aload_0
    //   160: aload_1
    //   161: invokespecial 156	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:closeInputStream	(Ljava/io/InputStream;)V
    //   164: aload_0
    //   165: getfield 134	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:_parentFiles	Ljava/util/Collection;
    //   168: ifnull +47 -> 215
    //   171: aload_0
    //   172: getfield 134	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:_parentFiles	Ljava/util/Collection;
    //   175: invokeinterface 158 1 0
    //   180: ifne +35 -> 215
    //   183: aload_0
    //   184: getfield 136	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:_env	Lorg/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl;
    //   187: invokevirtual 154	org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl:getAptProject	()Lorg/eclipse/jdt/apt/core/internal/AptProject;
    //   190: invokevirtual 148	org/eclipse/jdt/apt/core/internal/AptProject:getGeneratedFileManager	()Lorg/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager;
    //   193: aload_0
    //   194: getfield 134	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:_parentFiles	Ljava/util/Collection;
    //   197: aload_0
    //   198: getfield 135	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:_file	Lorg/eclipse/core/resources/IFile;
    //   201: invokevirtual 149	org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager:addGeneratedFileDependency	(Ljava/util/Collection;Lorg/eclipse/core/resources/IFile;)V
    //   204: aload_0
    //   205: getfield 136	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:_env	Lorg/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl;
    //   208: aload_0
    //   209: getfield 135	org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeNonSourceOutputStream:_file	Lorg/eclipse/core/resources/IFile;
    //   212: invokevirtual 153	org/eclipse/jdt/internal/apt/pluggable/core/dispatch/IdeProcessingEnvImpl:addNewResource	(Lorg/eclipse/core/resources/IFile;)V
    //   215: return
    // Line number table:
    //   Java source line #46	-> byte code offset #0
    //   Java source line #48	-> byte code offset #4
    //   Java source line #51	-> byte code offset #16
    //   Java source line #52	-> byte code offset #18
    //   Java source line #53	-> byte code offset #30
    //   Java source line #56	-> byte code offset #39
    //   Java source line #57	-> byte code offset #41
    //   Java source line #60	-> byte code offset #44
    //   Java source line #61	-> byte code offset #56
    //   Java source line #62	-> byte code offset #74
    //   Java source line #63	-> byte code offset #83
    //   Java source line #66	-> byte code offset #88
    //   Java source line #68	-> byte code offset #89
    //   Java source line #71	-> byte code offset #91
    //   Java source line #72	-> byte code offset #96
    //   Java source line #70	-> byte code offset #105
    //   Java source line #71	-> byte code offset #107
    //   Java source line #72	-> byte code offset #112
    //   Java source line #73	-> byte code offset #118
    //   Java source line #71	-> byte code offset #121
    //   Java source line #72	-> byte code offset #126
    //   Java source line #74	-> byte code offset #132
    //   Java source line #75	-> byte code offset #136
    //   Java source line #76	-> byte code offset #140
    //   Java source line #80	-> byte code offset #149
    //   Java source line #81	-> byte code offset #151
    //   Java source line #82	-> byte code offset #156
    //   Java source line #81	-> byte code offset #159
    //   Java source line #85	-> byte code offset #164
    //   Java source line #86	-> byte code offset #183
    //   Java source line #87	-> byte code offset #204
    //   Java source line #89	-> byte code offset #215
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	216	0	this	IdeNonSourceOutputStream
    //   15	146	1	contents	InputStream
    //   17	116	2	contentsChanged	boolean
    //   40	83	3	in	InputStream
    //   42	86	4	oldData	InputStream
    //   105	14	5	localObject1	Object
    //   149	8	6	localObject2	Object
    //   88	1	7	localCoreException	CoreException
    // Exception table:
    //   from	to	target	type
    //   44	85	88	org/eclipse/core/runtime/CoreException
    //   44	91	105	finally
    //   16	149	149	finally
  }
  
  private void closeInputStream(InputStream stream)
  {
    if (stream != null) {
      try
      {
        stream.close();
      }
      catch (IOException localIOException) {}
    }
  }
  
  private void saveToDisk(InputStream toSave, boolean create)
    throws IOException
  {
    try
    {
      FileSystemUtil.makeDerivedParentFolders(_file.getParent());
      if (create) {
        _file.create(toSave, 1025, null);
      } else {
        _file.setContents(toSave, true, false, null);
      }
    }
    catch (CoreException ce)
    {
      if (!_file.exists())
      {
        Apt6Plugin.log(ce, "Could not create generated non-Java file " + _file.getName());
        IOException ioe = new IOException();
        ioe.initCause(ce);
        throw ioe;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeNonSourceOutputStream
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.filer;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import javax.tools.FileObject;

public abstract class IdeOutputFileObject
  implements FileObject
{
  public boolean delete()
  {
    throw new IllegalStateException("Deleting a file is not permitted from within an annotation processor");
  }
  
  public CharSequence getCharContent(boolean ignoreEncodingErrors)
    throws IOException
  {
    throw new IllegalStateException("Generated files are write-only");
  }
  
  public long getLastModified()
  {
    throw new UnsupportedOperationException("Not yet implemented");
  }
  
  public InputStream openInputStream()
    throws IOException
  {
    throw new IllegalStateException("Opening an input stream on a generated file is not permitted");
  }
  
  public Reader openReader(boolean ignoreEncodingErrors)
    throws IOException
  {
    throw new IllegalStateException("Opening a reader on a generated file is not permitted");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeOutputFileObject
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.filer;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.URI;
import java.util.Collection;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.NestingKind;
import javax.tools.JavaFileObject;
import javax.tools.JavaFileObject.Kind;
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.apt.core.internal.AptProject;
import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedFileManager;
import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;

public class IdeOutputJavaFileObject
  extends IdeOutputFileObject
  implements JavaFileObject
{
  private final IdeProcessingEnvImpl _env;
  private final CharSequence _name;
  private final Collection<IFile> _parentFiles;
  
  public IdeOutputJavaFileObject(IdeProcessingEnvImpl env, CharSequence name, Collection<IFile> parentFiles)
  {
    _env = env;
    _parentFiles = parentFiles;
    _name = name;
  }
  
  public Modifier getAccessLevel()
  {
    throw new UnsupportedOperationException("Not yet implemented");
  }
  
  public JavaFileObject.Kind getKind()
  {
    throw new UnsupportedOperationException("Not yet implemented");
  }
  
  public String getName()
  {
    return _name.toString();
  }
  
  public NestingKind getNestingKind()
  {
    throw new UnsupportedOperationException("Not yet implemented");
  }
  
  public boolean isNameCompatible(String simpleName, JavaFileObject.Kind kind)
  {
    throw new UnsupportedOperationException("Not yet implemented");
  }
  
  public OutputStream openOutputStream()
    throws IOException
  {
    return new IdeJavaSourceOutputStream(_env, _name, _parentFiles);
  }
  
  public Writer openWriter()
    throws IOException
  {
    return new PrintWriter(openOutputStream());
  }
  
  public URI toUri()
  {
    IFile file = _env.getAptProject().getGeneratedFileManager().getIFileForTypeName(_name.toString());
    return file.getLocationURI();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeOutputJavaFileObject
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.apt.pluggable.core.filer;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.URI;
import java.util.Collection;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl;

public class IdeOutputNonSourceFileObject
  extends IdeOutputFileObject
{
  private final IdeProcessingEnvImpl _env;
  private final IFile _file;
  private final Collection<IFile> _parentFiles;
  
  public IdeOutputNonSourceFileObject(IdeProcessingEnvImpl env, IFile file, Set<IFile> parentFiles)
  {
    _env = env;
    _file = file;
    _parentFiles = parentFiles;
  }
  
  public String getName()
  {
    return _file.getLocation().toOSString();
  }
  
  public OutputStream openOutputStream()
    throws IOException
  {
    return new IdeNonSourceOutputStream(_env, _file, _parentFiles);
  }
  
  public Writer openWriter()
    throws IOException
  {
    return new PrintWriter(openOutputStream(
1 2

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-2017. Infinite Loop Ltd