1 12 13 package org.eclipse.jdt.internal.compiler.apt.dispatch; 14 15 import java.util.ArrayList ; 16 import java.util.List ; 17 import java.util.Map ; 18 19 import javax.annotation.processing.Filer; 20 import javax.annotation.processing.Messager; 21 import javax.annotation.processing.ProcessingEnvironment; 22 import javax.lang.model.SourceVersion; 23 import javax.lang.model.util.Elements; 24 import javax.lang.model.util.Types; 25 26 import org.eclipse.jdt.internal.compiler.Compiler; 27 import org.eclipse.jdt.internal.compiler.apt.model.ElementsImpl; 28 import org.eclipse.jdt.internal.compiler.apt.model.Factory; 29 import org.eclipse.jdt.internal.compiler.apt.model.TypesImpl; 30 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; 31 import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment; 32 import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; 33 34 37 public abstract class BaseProcessingEnvImpl implements ProcessingEnvironment { 38 39 protected Filer _filer; 41 protected Messager _messager; 42 protected Map <String , String > _processorOptions; 43 protected Compiler _compiler; 44 45 protected Elements _elementUtils; 47 protected Types _typeUtils; 48 private List <ICompilationUnit> _addedUnits; 49 private List <ReferenceBinding> _addedClassFiles; 50 private List <ICompilationUnit> _deletedUnits; 51 private boolean _errorRaised; 52 private Factory _factory; 53 54 public BaseProcessingEnvImpl() { 55 _addedUnits = new ArrayList <ICompilationUnit>(); 56 _addedClassFiles = new ArrayList <ReferenceBinding>(); 57 _deletedUnits = new ArrayList <ICompilationUnit>(); 58 _elementUtils = new ElementsImpl(this); 59 _typeUtils = new TypesImpl(this); 60 _factory = new Factory(this); 61 _errorRaised = false; 62 } 63 64 public void addNewUnit(ICompilationUnit unit) { 65 _addedUnits.add(unit); 66 } 67 68 public void addNewClassFile(ReferenceBinding binding) { 69 _addedClassFiles.add(binding); 70 } 71 72 public Compiler getCompiler() { 73 return _compiler; 74 } 75 76 public ICompilationUnit[] getDeletedUnits() { 77 ICompilationUnit[] result = new ICompilationUnit[_deletedUnits.size()]; 78 _deletedUnits.toArray(result); 79 return result; 80 } 81 82 public ICompilationUnit[] getNewUnits() { 83 ICompilationUnit[] result = new ICompilationUnit[_addedUnits.size()]; 84 _addedUnits.toArray(result); 85 return result; 86 } 87 88 @Override 89 public Elements getElementUtils() { 90 return _elementUtils; 91 } 92 93 @Override 94 public Filer getFiler() { 95 return _filer; 96 } 97 98 @Override 99 public Messager getMessager() { 100 return _messager; 101 } 102 103 @Override 104 public Map <String , String > getOptions() { 105 return _processorOptions; 106 } 107 108 @Override 109 public Types getTypeUtils() { 110 return _typeUtils; 111 } 112 113 public LookupEnvironment getLookupEnvironment() { 114 return _compiler.lookupEnvironment; 115 } 116 117 @Override 118 public SourceVersion getSourceVersion() { 119 return SourceVersion.RELEASE_6; 124 } 125 126 130 public void reset() { 131 _addedUnits.clear(); 132 _addedClassFiles.clear(); 133 _deletedUnits.clear(); 134 } 135 136 140 public boolean errorRaised() 141 { 142 return _errorRaised; 143 } 144 145 149 public void setErrorRaised(boolean b) 150 { 151 _errorRaised = true; 152 } 153 154 public Factory getFactory() 155 { 156 return _factory; 157 } 158 159 public ReferenceBinding[] getNewClassFiles() { 160 ReferenceBinding[] result = new ReferenceBinding[_addedClassFiles.size()]; 161 _addedClassFiles.toArray(result); 162 return result; 163 } 164 165 } 166 | Popular Tags |