org.eclipse.jdt.compiler.apt_1.0.400.v0110816-0800

16:45:00.371 INFO  jd.cli.Main - Decompiling org.eclipse.jdt.compiler.apt_1.0.400.v0110816-0800.jar
package org.eclipse.jdt.internal.compiler.apt.dispatch;

import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.apt.model.Factory;
import org.eclipse.jdt.internal.compiler.apt.util.ManyToMany;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.AptSourceLocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;

public class AnnotationDiscoveryVisitor
  extends ASTVisitor
{
  final BaseProcessingEnvImpl _env;
  final Factory _factory;
  final ManyToMany<TypeElement, Element> _annoToElement;
  
  public AnnotationDiscoveryVisitor(BaseProcessingEnvImpl env)
  {
    _env = env;
    _factory = env.getFactory();
    _annoToElement = new ManyToMany();
  }
  
  public boolean visit(Argument argument, BlockScope scope)
  {
    Annotation[] annotations = annotations;
    ReferenceContext referenceContext = scope.referenceContext();
    if ((referenceContext instanceof AbstractMethodDeclaration))
    {
      MethodBinding binding = binding;
      if (binding != null)
      {
        TypeDeclaration typeDeclaration = scope.referenceType();
        binding.resolveTypesFor(binding);
        if (binding != null) {
          binding = new AptSourceLocalVariableBinding(binding, binding);
        }
      }
      if (annotations != null) {
        resolveAnnotations(
          scope, 
          annotations, 
          binding);
      }
    }
    return false;
  }
  
  public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope)
  {
    Annotation[] annotations = annotations;
    if (annotations != null)
    {
      MethodBinding constructorBinding = binding;
      if (constructorBinding == null) {
        return false;
      }
      ((SourceTypeBinding)declaringClass).resolveTypesFor(constructorBinding);
      resolveAnnotations(
        scope, 
        annotations, 
        constructorBinding);
    }
    Argument[] arguments = arguments;
    if (arguments != null)
    {
      int argumentLength = arguments.length;
      for (int i = 0; i < argumentLength; i++) {
        arguments[i].traverse(this, scope);
      }
    }
    return false;
  }
  
  public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope)
  {
    Annotation[] annotations = annotations;
    if (annotations != null)
    {
      FieldBinding fieldBinding = binding;
      if (fieldBinding == null) {
        return false;
      }
      ((SourceTypeBinding)declaringClass).resolveTypeFor(fieldBinding);
      resolveAnnotations(scope, annotations, fieldBinding);
    }
    return false;
  }
  
  public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope)
  {
    Annotation[] annotations = annotations;
    if (annotations != null)
    {
      MethodBinding methodBinding = binding;
      if (methodBinding == null) {
        return false;
      }
      ((SourceTypeBinding)declaringClass).resolveTypesFor(methodBinding);
      resolveAnnotations(
        scope, 
        annotations, 
        binding);
    }
    Argument[] arguments = arguments;
    if (arguments != null)
    {
      int argumentLength = arguments.length;
      for (int i = 0; i < argumentLength; i++) {
        arguments[i].traverse(this, scope);
      }
    }
    return false;
  }
  
  public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope)
  {
    SourceTypeBinding binding = binding;
    if (binding == null) {
      return false;
    }
    Annotation[] annotations = annotations;
    if (annotations != null) {
      resolveAnnotations(
        staticInitializerScope, 
        annotations, 
        binding);
    }
    return true;
  }
  
  public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope)
  {
    SourceTypeBinding binding = binding;
    if (binding == null) {
      return false;
    }
    Annotation[] annotations = annotations;
    if (annotations != null) {
      resolveAnnotations(
        staticInitializerScope, 
        annotations, 
        binding);
    }
    return true;
  }
  
  private void resolveAnnotations(BlockScope scope, Annotation[] annotations, Binding currentBinding)
  {
    ASTNode.resolveAnnotations(scope, annotations, currentBinding);
    Annotation[] arrayOfAnnotation;
    int j = (arrayOfAnnotation = annotations).length;
    for (int i = 0; i < j; i++)
    {
      Annotation annotation = arrayOfAnnotation[i];
      AnnotationBinding binding = annotation.getCompilerAnnotation();
      if (binding != null)
      {
        TypeElement anno = (TypeElement)_factory.newElement(binding.getAnnotationType());
        Element element = _factory.newElement(currentBinding);
        _annoToElement.put(anno, element);
      }
    }
  }
}

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

import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;

public class AptProblem
  extends DefaultProblem
{
  private static final String MARKER_ID = "org.eclipse.jdt.apt.pluggable.core.compileProblem";
  public final ReferenceContext _referenceContext;
  
  public AptProblem(ReferenceContext referenceContext, char[] originatingFileName, String message, int id, String[] stringArguments, int severity, int startPosition, int endPosition, int line, int column)
  {
    super(originatingFileName, message, id, stringArguments, severity, startPosition, endPosition, line, column);
    _referenceContext = referenceContext;
  }
  
  public int getCategoryID()
  {
    return 0;
  }
  
  public String getMarkerType()
  {
    return "org.eclipse.jdt.apt.pluggable.core.compileProblem";
  }
}

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

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;

public abstract class BaseAnnotationProcessorManager
  extends AbstractAnnotationProcessorManager
  implements IProcessorProvider
{
  protected PrintWriter _out;
  protected PrintWriter _err;
  protected BaseProcessingEnvImpl _processingEnv;
  protected boolean _isFirstRound = true;
  protected List<ProcessorInfo> _processors = new ArrayList();
  protected boolean _printProcessorInfo = false;
  protected boolean _printRounds = false;
  protected int _round;
  
  public void configure(Object batchCompiler, String[] options)
  {
    throw new UnsupportedOperationException();
  }
  
  public void configureFromPlatform(Compiler compiler, Object compilationUnitLocator, Object javaProject)
  {
    throw new UnsupportedOperationException();
  }
  
  public List<ProcessorInfo> getDiscoveredProcessors()
  {
    return _processors;
  }
  
  public ICompilationUnit[] getDeletedUnits()
  {
    return _processingEnv.getDeletedUnits();
  }
  
  public ICompilationUnit[] getNewUnits()
  {
    return _processingEnv.getNewUnits();
  }
  
  public ReferenceBinding[] getNewClassFiles()
  {
    return _processingEnv.getNewClassFiles();
  }
  
  public void reset()
  {
    _processingEnv.reset();
  }
  
  public void setErr(PrintWriter err)
  {
    _err = err;
  }
  
  public void setOut(PrintWriter out)
  {
    _out = out;
  }
  
  public void setProcessors(Object[] processors)
  {
    throw new UnsupportedOperationException();
  }
  
  public void processAnnotations(CompilationUnitDeclaration[] units, ReferenceBinding[] referenceBindings, boolean isLastRound)
  {
    RoundEnvImpl roundEnv = new RoundEnvImpl(units, referenceBindings, isLastRound, _processingEnv);
    if (_isFirstRound) {
      _isFirstRound = false;
    }
    PrintWriter traceProcessorInfo = _printProcessorInfo ? _out : null;
    PrintWriter traceRounds = _printRounds ? _out : null;
    if (traceRounds != null) {
      traceRounds.println("Round " + ++_round + ':');
    }
    RoundDispatcher dispatcher = new RoundDispatcher(
      this, roundEnv, roundEnv.getRootAnnotations(), traceProcessorInfo, traceRounds);
    dispatcher.round();
  }
}

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

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.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.apt.model.AnnotationMemberValue;
import org.eclipse.jdt.internal.compiler.apt.model.AnnotationMirrorImpl;
import org.eclipse.jdt.internal.compiler.apt.model.ExecutableElementImpl;
import org.eclipse.jdt.internal.compiler.apt.model.TypeElementImpl;
import org.eclipse.jdt.internal.compiler.apt.model.VariableElementImpl;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.AptSourceLocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.eclipse.jdt.internal.compiler.util.Util;

public class BaseMessagerImpl
{
  static final String[] NO_ARGUMENTS = new String[0];
  
  public static AptProblem createProblem(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a, AnnotationValue v)
  {
    ReferenceContext referenceContext = null;
    Annotation[] elementAnnotations = (Annotation[])null;
    int startPosition = 0;
    int endPosition = 0;
    if (e != null) {
      switch (e.getKind())
      {
      case CLASS: 
      case CONSTRUCTOR: 
      case ENUM: 
      case ENUM_CONSTANT: 
        TypeElementImpl typeElementImpl = (TypeElementImpl)e;
        Binding typeBinding = _binding;
        if ((typeBinding instanceof SourceTypeBinding))
        {
          SourceTypeBinding sourceTypeBinding = (SourceTypeBinding)typeBinding;
          TypeDeclaration typeDeclaration = (TypeDeclaration)scope.referenceContext();
          referenceContext = typeDeclaration;
          elementAnnotations = annotations;
          startPosition = sourceStart;
          endPosition = sourceEnd;
        }
        break;
      case ANNOTATION_TYPE: 
        break;
      case METHOD: 
      case OTHER: 
        ExecutableElementImpl executableElementImpl = (ExecutableElementImpl)e;
        Binding binding = _binding;
        if ((binding instanceof MethodBinding))
        {
          MethodBinding methodBinding = (MethodBinding)binding;
          AbstractMethodDeclaration sourceMethod = methodBinding.sourceMethod();
          if (sourceMethod != null)
          {
            referenceContext = sourceMethod;
            elementAnnotations = annotations;
            startPosition = sourceStart;
            endPosition = sourceEnd;
          }
        }
        break;
      case EXCEPTION_PARAMETER: 
        break;
      case LOCAL_VARIABLE: 
        break;
      case FIELD: 
      case INSTANCE_INIT: 
        VariableElementImpl variableElementImpl = (VariableElementImpl)e;
        Binding binding = _binding;
        if ((binding instanceof FieldBinding))
        {
          FieldBinding fieldBinding = (FieldBinding)binding;
          FieldDeclaration fieldDeclaration = fieldBinding.sourceField();
          if (fieldDeclaration != null)
          {
            ReferenceBinding declaringClass = declaringClass;
            if ((declaringClass instanceof SourceTypeBinding))
            {
              SourceTypeBinding sourceTypeBinding = (SourceTypeBinding)declaringClass;
              TypeDeclaration typeDeclaration = (TypeDeclaration)scope.referenceContext();
              referenceContext = typeDeclaration;
            }
            elementAnnotations = annotations;
            startPosition = sourceStart;
            endPosition = sourceEnd;
          }
        }
        else if ((binding instanceof AptSourceLocalVariableBinding))
        {
          AptSourceLocalVariableBinding parameterBinding = (AptSourceLocalVariableBinding)binding;
          LocalDeclaration parameterDeclaration = declaration;
          if (parameterDeclaration != null)
          {
            MethodBinding methodBinding = methodBinding;
            if (methodBinding != null) {
              referenceContext = methodBinding.sourceMethod();
            }
            elementAnnotations = annotations;
            startPosition = sourceStart;
            endPosition = sourceEnd;
          }
        }
        break;
      case PACKAGE: 
      case PARAMETER: 
        break;
      }
    }
    StringBuilder builder = new StringBuilder();
    if (msg != null) {
      builder.append(msg);
    }
    if ((a != null) && (elementAnnotations != null))
    {
      AnnotationBinding annotationBinding = _binding;
      Annotation annotation = null;
      for (int i = 0; (annotation == null) && (i < elementAnnotations.length); i++) {
        if (annotationBinding == elementAnnotations[i].getCompilerAnnotation()) {
          annotation = elementAnnotations[i];
        }
      }
      if (annotation != null)
      {
        startPosition = sourceStart;
        endPosition = sourceEnd;
        if ((v != null) && ((v instanceof AnnotationMemberValue)))
        {
          MethodBinding methodBinding = ((AnnotationMemberValue)v).getMethodBinding();
          MemberValuePair[] memberValuePairs = annotation.memberValuePairs();
          MemberValuePair memberValuePair = null;
          for (int i = 0; (memberValuePair == null) && (i < memberValuePairs.length); i++) {
            if (methodBinding == binding) {
              memberValuePair = memberValuePairs[i];
            }
          }
          if (memberValuePair != null)
          {
            startPosition = sourceStart;
            endPosition = sourceEnd;
          }
        }
      }
    }
    int lineNumber = 0;
    int columnNumber = 1;
    char[] fileName = (char[])null;
    if (referenceContext != null)
    {
      CompilationResult result = referenceContext.compilationResult();
      fileName = fileName;
      int[] lineEnds = (int[])null;
      lineNumber = startPosition >= 0 ? 
        Util.getLineNumber(startPosition, lineEnds = result.getLineSeparatorPositions(), 0, lineEnds.length - 1) : 
        0;
      columnNumber = startPosition >= 0 ? 
        Util.searchColumnNumber(result.getLineSeparatorPositions(), lineNumber, startPosition) : 
        0;
    }
    int severity;
    int severity;
    switch (kind)
    {
    case ERROR: 
      severity = 1;
      break;
    default: 
      severity = 0;
    }
    return new AptProblem(
      referenceContext, 
      fileName, 
      String.valueOf(builder), 
      0, 
      NO_ARGUMENTS, 
      severity, 
      startPosition, 
      endPosition, 
      lineNumber, 
      columnNumber);
  }
}

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

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.apt.model.ElementsImpl;
import org.eclipse.jdt.internal.compiler.apt.model.Factory;
import org.eclipse.jdt.internal.compiler.apt.model.TypesImpl;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;

public abstract class BaseProcessingEnvImpl
  implements ProcessingEnvironment
{
  protected Filer _filer;
  protected Messager _messager;
  protected Map<String, String> _processorOptions;
  protected Compiler _compiler;
  protected Elements _elementUtils;
  protected Types _typeUtils;
  private List<ICompilationUnit> _addedUnits;
  private List<ReferenceBinding> _addedClassFiles;
  private List<ICompilationUnit> _deletedUnits;
  private boolean _errorRaised;
  private Factory _factory;
  
  public BaseProcessingEnvImpl()
  {
    _addedUnits = new ArrayList();
    _addedClassFiles = new ArrayList();
    _deletedUnits = new ArrayList();
    _elementUtils = new ElementsImpl(this);
    _typeUtils = new TypesImpl(this);
    _factory = new Factory(this);
    _errorRaised = false;
  }
  
  public void addNewUnit(ICompilationUnit unit)
  {
    _addedUnits.add(unit);
  }
  
  public void addNewClassFile(ReferenceBinding binding)
  {
    _addedClassFiles.add(binding);
  }
  
  public Compiler getCompiler()
  {
    return _compiler;
  }
  
  public ICompilationUnit[] getDeletedUnits()
  {
    ICompilationUnit[] result = new ICompilationUnit[_deletedUnits.size()];
    _deletedUnits.toArray(result);
    return result;
  }
  
  public ICompilationUnit[] getNewUnits()
  {
    ICompilationUnit[] result = new ICompilationUnit[_addedUnits.size()];
    _addedUnits.toArray(result);
    return result;
  }
  
  public Elements getElementUtils()
  {
    return _elementUtils;
  }
  
  public Filer getFiler()
  {
    return _filer;
  }
  
  public Messager getMessager()
  {
    return _messager;
  }
  
  public Map<String, String> getOptions()
  {
    return _processorOptions;
  }
  
  public Types getTypeUtils()
  {
    return _typeUtils;
  }
  
  public LookupEnvironment getLookupEnvironment()
  {
    return _compiler.lookupEnvironment;
  }
  
  public SourceVersion getSourceVersion()
  {
    if (_compiler.options.sourceLevel <= 3211264L) {
      return SourceVersion.RELEASE_5;
    }
    if (_compiler.options.sourceLevel == 3276800L) {
      return SourceVersion.RELEASE_6;
    }
    try
    {
      return SourceVersion.valueOf("RELEASE_7");
    }
    catch (IllegalArgumentException localIllegalArgumentException) {}
    return SourceVersion.RELEASE_6;
  }
  
  public void reset()
  {
    _addedUnits.clear();
    _addedClassFiles.clear();
    _deletedUnits.clear();
  }
  
  public boolean errorRaised()
  {
    return _errorRaised;
  }
  
  public void setErrorRaised(boolean b)
  {
    _errorRaised = true;
  }
  
  public Factory getFactory()
  {
    return _factory;
  }
  
  public ReferenceBinding[] getNewClassFiles()
  {
    ReferenceBinding[] result = new ReferenceBinding[_addedClassFiles.size()];
    _addedClassFiles.toArray(result);
    return result;
  }
}

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

import java.io.PrintWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import javax.annotation.processing.Processor;
import javax.tools.JavaFileManager;
import javax.tools.StandardLocation;
import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;

public class BatchAnnotationProcessorManager
  extends BaseAnnotationProcessorManager
{
  private List<Processor> _setProcessors = null;
  private Iterator<Processor> _setProcessorIter = null;
  private List<String> _commandLineProcessors;
  private Iterator<String> _commandLineProcessorIter = null;
  private ServiceLoader<Processor> _serviceLoader = null;
  private Iterator<Processor> _serviceLoaderIter;
  private ClassLoader _procLoader;
  private static final boolean VERBOSE_PROCESSOR_DISCOVERY = true;
  private boolean _printProcessorDiscovery = false;
  
  public void configure(Object batchCompiler, String[] commandLineArguments)
  {
    if (_processingEnv != null) {
      throw new IllegalStateException(
        "Calling configure() more than once on an AnnotationProcessorManager is not supported");
    }
    BatchProcessingEnvImpl processingEnv = new BatchProcessingEnvImpl(this, (Main)batchCompiler, commandLineArguments);
    _processingEnv = processingEnv;
    _procLoader = processingEnv.getFileManager().getClassLoader(StandardLocation.ANNOTATION_PROCESSOR_PATH);
    parseCommandLine(commandLineArguments);
    _round = 0;
  }
  
  private void parseCommandLine(String[] commandLineArguments)
  {
    List<String> commandLineProcessors = null;
    for (int i = 0; i < commandLineArguments.length; i++)
    {
      String option = commandLineArguments[i];
      if ("-XprintProcessorInfo".equals(option))
      {
        _printProcessorInfo = true;
        _printProcessorDiscovery = true;
      }
      else if ("-XprintRounds".equals(option))
      {
        _printRounds = true;
      }
      else if ("-processor".equals(option))
      {
        commandLineProcessors = new ArrayList();
        String procs = commandLineArguments[(++i)];
        String[] arrayOfString;
        int j = (arrayOfString = procs.split(",")).length;
        for (int i = 0; i < j; i++)
        {
          String proc = arrayOfString[i];
          commandLineProcessors.add(proc);
        }
        break;
      }
    }
    _commandLineProcessors = commandLineProcessors;
    if (_commandLineProcessors != null) {
      _commandLineProcessorIter = _commandLineProcessors.iterator();
    }
  }
  
  public ProcessorInfo discoverNextProcessor()
  {
    if (_setProcessors != null)
    {
      if (_setProcessorIter.hasNext())
      {
        Processor p = (Processor)_setProcessorIter.next();
        p.init(_processingEnv);
        ProcessorInfo pi = new ProcessorInfo(p);
        _processors.add(pi);
        if ((_printProcessorDiscovery) && (_out != null)) {
          _out.println("API specified processor: " + pi);
        }
        return pi;
      }
      return null;
    }
    if (_commandLineProcessors != null)
    {
      if (_commandLineProcessorIter.hasNext())
      {
        String proc = (String)_commandLineProcessorIter.next();
        try
        {
          Class<?> clazz = _procLoader.loadClass(proc);
          Object o = clazz.newInstance();
          Processor p = (Processor)o;
          p.init(_processingEnv);
          ProcessorInfo pi = new ProcessorInfo(p);
          _processors.add(pi);
          if ((_printProcessorDiscovery) && (_out != null)) {
            _out.println("Command line specified processor: " + pi);
          }
          return pi;
        }
        catch (Exception e)
        {
          throw new AbortCompilation(null, e);
        }
      }
      return null;
    }
    if (_serviceLoader == null)
    {
      _serviceLoader = ServiceLoader.load(Processor.class, _procLoader);
      _serviceLoaderIter = _serviceLoader.iterator();
    }
    try
    {
      if (_serviceLoaderIter.hasNext())
      {
        Processor p = (Processor)_serviceLoaderIter.next();
        p.init(_processingEnv);
        ProcessorInfo pi = new ProcessorInfo(p);
        _processors.add(pi);
        if ((_printProcessorDiscovery) && (_out != null))
        {
          StringBuilder sb = new StringBuilder();
          sb.append("Discovered processor service ");
          sb.append(pi);
          sb.append("\n  supporting ");
          sb.append(pi.getSupportedAnnotationTypesAsString());
          sb.append("\n  in ");
          sb.append(getProcessorLocation(p));
          _out.println(sb.toString());
        }
        return pi;
      }
    }
    catch (ServiceConfigurationError e)
    {
      throw new AbortCompilation(null, e);
    }
    return null;
  }
  
  private String getProcessorLocation(Processor p)
  {
    boolean isMember = false;
    Class<?> outerClass = p.getClass();
    StringBuilder innerName = new StringBuilder();
    while (outerClass.isMemberClass())
    {
      innerName.insert(0, outerClass.getSimpleName());
      innerName.insert(0, '$');
      isMember = true;
      outerClass = outerClass.getEnclosingClass();
    }
    String path = outerClass.getName();
    path = path.replace('.', '/');
    if (isMember) {
      path = path + innerName;
    }
    path = path + ".class";
    
    String location = _procLoader.getResource(path).toString();
    if (location.endsWith(path)) {
      location = location.substring(0, location.length() - path.length());
    }
    return location;
  }
  
  public void reportProcessorException(Processor p, Exception e)
  {
    throw new AbortCompilation(null, e);
  }
  
  public void setProcessors(Object[] processors)
  {
    if (!_isFirstRound) {
      throw new IllegalStateException("setProcessors() cannot be called after processing has begun");
    }
    _setProcessors = new ArrayList(processors.length);
    Object[] arrayOfObject;
    int j = (arrayOfObject = processors).length;
    for (int i = 0; i < j; i++)
    {
      Object o = arrayOfObject[i];
      Processor p = (Processor)o;
      _setProcessors.add(p);
    }
    _setProcessorIter = _setProcessors.iterator();
    
    _commandLineProcessors = null;
    _commandLineProcessorIter = null;
  }
}

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

import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.util.HashSet;
import javax.annotation.processing.Filer;
import javax.annotation.processing.FilerException;
import javax.lang.model.element.Element;
import javax.tools.FileObject;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileManager.Location;
import javax.tools.JavaFileObject;
import javax.tools.JavaFileObject.Kind;
import javax.tools.StandardLocation;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;

public class BatchFilerImpl
  implements Filer
{
  protected final BaseAnnotationProcessorManager _dispatchManager;
  protected final BaseProcessingEnvImpl _env;
  protected final JavaFileManager _fileManager;
  protected final HashSet<URI> _createdFiles;
  
  public BatchFilerImpl(BaseAnnotationProcessorManager dispatchManager, BatchProcessingEnvImpl env)
  {
    _dispatchManager = dispatchManager;
    _fileManager = _fileManager;
    _env = env;
    _createdFiles = new HashSet();
  }
  
  public void addNewUnit(ICompilationUnit unit)
  {
    _env.addNewUnit(unit);
  }
  
  public void addNewClassFile(ReferenceBinding binding)
  {
    _env.addNewClassFile(binding);
  }
  
  public JavaFileObject createClassFile(CharSequence name, Element... originatingElements)
    throws IOException
  {
    JavaFileObject jfo = _fileManager.getJavaFileForOutput(
      StandardLocation.CLASS_OUTPUT, name.toString(), JavaFileObject.Kind.CLASS, null);
    URI uri = jfo.toUri();
    if (_createdFiles.contains(uri)) {
      throw new FilerException("Class file already created : " + name);
    }
    _createdFiles.add(uri);
    return new HookedJavaFileObject(jfo, jfo.getName(), this);
  }
  
  public FileObject createResource(JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName, Element... originatingElements)
    throws IOException
  {
    validateName(relativeName);
    FileObject fo = _fileManager.getFileForOutput(
      location, pkg.toString(), relativeName.toString(), null);
    URI uri = fo.toUri();
    if (_createdFiles.contains(uri)) {
      throw new FilerException("Resource already created : " + location + '/' + pkg + '/' + relativeName);
    }
    _createdFiles.add(uri);
    return fo;
  }
  
  private static void validateName(CharSequence relativeName)
  {
    int length = relativeName.length();
    if (length == 0) {
      throw new IllegalArgumentException("relative path cannot be empty");
    }
    String path = relativeName.toString();
    if (path.indexOf('\\') != -1) {
      path = path.replace('\\', '/');
    }
    if (path.charAt(0) == '/') {
      throw new IllegalArgumentException("relative path is absolute");
    }
    boolean hasDot = false;
    for (int i = 0; i < length; i++) {
      switch (path.charAt(i))
      {
      case '/': 
        if (hasDot) {
          throw new IllegalArgumentException("relative name " + relativeName + " is not relative");
        }
        break;
      case '.': 
        hasDot = true;
        break;
      default: 
        hasDot = false;
      }
    }
    if (hasDot) {
      throw new IllegalArgumentException("relative name " + relativeName + " is not relative");
    }
  }
  
  public JavaFileObject createSourceFile(CharSequence name, Element... originatingElements)
    throws IOException
  {
    JavaFileObject jfo = _fileManager.getJavaFileForOutput(
      StandardLocation.SOURCE_OUTPUT, name.toString(), JavaFileObject.Kind.SOURCE, null);
    URI uri = jfo.toUri();
    if (_createdFiles.contains(uri)) {
      throw new FilerException("Source file already created : " + name);
    }
    _createdFiles.add(uri);
    
    return new HookedJavaFileObject(jfo, jfo.getName(), this);
  }
  
  public FileObject getResource(JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName)
    throws IOException
  {
    validateName(relativeName);
    FileObject fo = _fileManager.getFileForInput(
      location, pkg.toString(), relativeName.toString());
    if (fo == null) {
      throw new FileNotFoundException("Resource does not exist : " + location + '/' + pkg + '/' + relativeName);
    }
    URI uri = fo.toUri();
    if (_createdFiles.contains(uri)) {
      throw new FilerException("Resource already created : " + location + '/' + pkg + '/' + relativeName);
    }
    _createdFiles.add(uri);
    return fo;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.compiler.apt.dispatch.BatchFilerImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.compiler.apt.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.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.internal.compiler.batch.Main;

public class BatchMessagerImpl
  extends BaseMessagerImpl
  implements Messager
{
  private final Main _compiler;
  private final BaseProcessingEnvImpl _processingEnv;
  
  public BatchMessagerImpl(BaseProcessingEnvImpl processingEnv, Main compiler)
  {
    _compiler = compiler;
    _processingEnv = processingEnv;
  }
  
  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)
  {
    if (kind == Diagnostic.Kind.ERROR) {
      _processingEnv.setErrorRaised(true);
    }
    CategorizedProblem problem = createProblem(kind, msg, e, a, v);
    if (problem != null) {
      _compiler.addExtraProblems(problem);
    }
  }
}

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

import java.lang.reflect.Field;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import javax.tools.JavaFileManager;
import org.eclipse.jdt.internal.compiler.apt.util.EclipseFileManager;
import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;

public class BatchProcessingEnvImpl
  extends BaseProcessingEnvImpl
{
  protected final BaseAnnotationProcessorManager _dispatchManager;
  protected final JavaFileManager _fileManager;
  protected final Main _compilerOwner;
  
  public BatchProcessingEnvImpl(BaseAnnotationProcessorManager dispatchManager, Main batchCompiler, String[] commandLineArguments)
  {
    _compilerOwner = batchCompiler;
    _compiler = batchCompiler;
    _dispatchManager = dispatchManager;
    Class<?> c = null;
    try
    {
      c = Class.forName("org.eclipse.jdt.internal.compiler.tool.EclipseCompilerImpl");
    }
    catch (ClassNotFoundException localClassNotFoundException) {}
    Field field = null;
    JavaFileManager javaFileManager = null;
    if (c != null) {
      try
      {
        field = c.getField("fileManager");
      }
      catch (SecurityException localSecurityException) {}catch (IllegalArgumentException localIllegalArgumentException1) {}catch (NoSuchFieldException localNoSuchFieldException) {}
    }
    if (field != null) {
      try
      {
        javaFileManager = (JavaFileManager)field.get(batchCompiler);
      }
      catch (IllegalArgumentException localIllegalArgumentException2) {}catch (IllegalAccessException localIllegalAccessException) {}
    }
    if (javaFileManager != null)
    {
      _fileManager = javaFileManager;
    }
    else
    {
      String encoding = (String)options.get("org.eclipse.jdt.core.encoding");
      Charset charset = encoding != null ? Charset.forName(encoding) : null;
      JavaFileManager manager = new EclipseFileManager(compilerLocale, charset);
      ArrayList<String> options = new ArrayList();
      String[] arrayOfString;
      int j = (arrayOfString = commandLineArguments).length;
      for (int i = 0; i < j; i++)
      {
        String argument = arrayOfString[i];
        options.add(argument);
      }
      for (Iterator<String> iterator = options.iterator(); iterator.hasNext();) {
        manager.handleOption((String)iterator.next(), iterator);
      }
      _fileManager = manager;
    }
    _processorOptions = Collections.unmodifiableMap(parseProcessorOptions(commandLineArguments));
    _filer = new BatchFilerImpl(_dispatchManager, this);
    _messager = new BatchMessagerImpl(this, _compilerOwner);
  }
  
  private Map<String, String> parseProcessorOptions(String[] args)
  {
    Map<String, String> options = new LinkedHashMap();
    String[] arrayOfString;
    int j = (arrayOfString = args).length;
    for (int i = 0; i < j; i++)
    {
      String arg = arrayOfString[i];
      if (arg.startsWith("-A"))
      {
        int equals = arg.indexOf('=');
        if (equals == 2)
        {
          Exception e = new IllegalArgumentException("-A option must have a key before the equals sign");
          throw new AbortCompilation(null, e);
        }
        if (equals == arg.length() - 1) {
          options.put(arg.substring(2, equals), null);
        } else if (equals == -1) {
          options.put(arg.substring(2), null);
        } else {
          options.put(arg.substring(2, equals), arg.substring(equals + 1));
        }
      }
    }
    return options;
  }
  
  public JavaFileManager getFileManager()
  {
    return _fileManager;
  }
  
  public Locale getLocale()
  {
    return _compilerOwner.compilerLocale;
  }
}

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

import java.io.IOException;
import java.io.OutputStream;

class HookedJavaFileObject$ForwardingOutputStream
  extends OutputStream
{
  private final OutputStream _os;
  
  HookedJavaFileObject$ForwardingOutputStream(HookedJavaFileObject paramHookedJavaFileObject, OutputStream os)
  {
    _os = os;
  }
  
  public void close()
    throws IOException
  {
    _os.close();
    this$0.closed();
  }
  
  public void flush()
    throws IOException
  {
    _os.flush();
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    _os.write(b, off, len);
  }
  
  public void write(byte[] b)
    throws IOException
  {
    _os.write(b);
  }
  
  public void write(int b)
    throws IOException
  {
    _os.write(b);
  }
  
  protected Object clone()
    throws CloneNotSupportedException
  {
    return new ForwardingOutputStream(this$0, _os);
  }
  
  public int hashCode()
  {
    return _os.hashCode();
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    ForwardingOutputStream other = (ForwardingOutputStream)obj;
    if (_os == null)
    {
      if (_os != null) {
        return false;
      }
    }
    else if (!_os.equals(_os)) {
      return false;
    }
    return true;
  }
  
  public String toString()
  {
    return "ForwardingOutputStream wrapping " + _os.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.internal.compiler.apt.dispatch.HookedJavaFileObject.ForwardingOutputStream
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.internal.compiler.apt
1 2 3 4 5 6 7

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