HintsAnnotationProcessingImpl cleanup
authorJan Lahoda <jlahoda@netbeans.org>
Sun, 16 Jan 2011 19:22:56 +0100
changeset 52128cbfe7484a0
parent 520 cb67f7df8dd1
child 522 e0beda79deac
child 523 9263091c58de
HintsAnnotationProcessingImpl cleanup
cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java
     1.1 --- a/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java	Sun Jan 16 19:22:56 2011 +0100
     1.2 +++ b/cmdline/compiler/src/org/netbeans/modules/jackpot30/compiler/HintsAnnotationProcessingImpl.java	Sun Jan 16 19:22:56 2011 +0100
     1.3 @@ -38,85 +38,45 @@
     1.4   */
     1.5  package org.netbeans.modules.jackpot30.compiler;
     1.6  
     1.7 -import com.sun.source.tree.ClassTree;
     1.8 -import com.sun.source.tree.CompilationUnitTree;
     1.9 -import com.sun.source.tree.IdentifierTree;
    1.10 -import com.sun.source.tree.MemberSelectTree;
    1.11 -import com.sun.source.tree.MethodTree;
    1.12 -import com.sun.source.tree.ParameterizedTypeTree;
    1.13 -import com.sun.source.tree.Tree;
    1.14 -import com.sun.source.util.SourcePositions;
    1.15  import com.sun.source.util.TaskEvent;
    1.16  import com.sun.source.util.TaskListener;
    1.17  import com.sun.source.util.TreePath;
    1.18 -import com.sun.source.util.TreeScanner;
    1.19  import com.sun.source.util.Trees;
    1.20  import com.sun.tools.javac.api.JavacTrees;
    1.21 -import com.sun.tools.javac.comp.Attr;
    1.22 -import com.sun.tools.javac.comp.AttrContext;
    1.23 -import com.sun.tools.javac.comp.Enter;
    1.24 -import com.sun.tools.javac.comp.Env;
    1.25  import com.sun.tools.javac.jvm.Gen;
    1.26 -import com.sun.tools.javac.main.JavaCompiler;
    1.27  import com.sun.tools.javac.processing.JavacProcessingEnvironment;
    1.28 -import com.sun.tools.javac.tree.JCTree;
    1.29 -import com.sun.tools.javac.tree.JCTree.JCClassDecl;
    1.30  import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
    1.31 -import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
    1.32 -import com.sun.tools.javac.tree.JCTree.JCIdent;
    1.33 -import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
    1.34  import com.sun.tools.javac.util.Context;
    1.35  import com.sun.tools.javac.util.Log;
    1.36  import com.sun.tools.javac.util.Options;
    1.37  import java.io.File;
    1.38 -import java.io.IOException;
    1.39  import java.lang.reflect.Field;
    1.40  import java.net.URL;
    1.41 -import java.util.ArrayList;
    1.42  import java.util.Collection;
    1.43  import java.util.HashSet;
    1.44  import java.util.LinkedList;
    1.45  import java.util.List;
    1.46 -import java.util.Properties;
    1.47 -import java.util.Queue;
    1.48  import java.util.Set;
    1.49 -import java.util.prefs.AbstractPreferences;
    1.50 -import java.util.prefs.BackingStoreException;
    1.51 -import java.util.prefs.Preferences;
    1.52 -import java.util.prefs.PreferencesFactory;
    1.53  import javax.annotation.processing.AbstractProcessor;
    1.54  import javax.annotation.processing.ProcessingEnvironment;
    1.55  import javax.annotation.processing.Processor;
    1.56  import javax.annotation.processing.RoundEnvironment;
    1.57  import javax.annotation.processing.SupportedAnnotationTypes;
    1.58  import javax.lang.model.SourceVersion;
    1.59 -import javax.lang.model.element.Element;
    1.60 -import javax.lang.model.element.ElementKind;
    1.61  import javax.lang.model.element.TypeElement;
    1.62  import javax.lang.model.util.ElementFilter;
    1.63 -import javax.swing.event.ChangeListener;
    1.64  import javax.tools.Diagnostic.Kind;
    1.65  import javax.tools.JavaFileManager;
    1.66  import javax.tools.JavaFileObject;
    1.67  import javax.tools.StandardJavaFileManager;
    1.68  import javax.tools.StandardLocation;
    1.69 -import org.netbeans.api.editor.mimelookup.MimePath;
    1.70  import org.netbeans.api.java.classpath.ClassPath;
    1.71 -import org.netbeans.api.java.queries.SourceForBinaryQuery;
    1.72  import org.netbeans.api.java.source.ClasspathInfo;
    1.73  import org.netbeans.api.java.source.CompilationInfoHack;
    1.74  import org.netbeans.modules.jackpot30.compiler.AbstractHintsAnnotationProcessing.Reporter;
    1.75 -import org.netbeans.modules.java.source.parsing.JavacParserFactory;
    1.76 -import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
    1.77 -import org.netbeans.spi.editor.mimelookup.MimeDataProvider;
    1.78  import org.netbeans.spi.java.classpath.support.ClassPathSupport;
    1.79 -import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
    1.80 -import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2;
    1.81  import org.openide.filesystems.FileUtil;
    1.82  import org.openide.util.Lookup;
    1.83 -import org.openide.util.NbPreferences;
    1.84 -import org.openide.util.NbPreferences.Provider;
    1.85 -import org.openide.util.lookup.Lookups;
    1.86  import org.openide.util.lookup.ServiceProvider;
    1.87  
    1.88  /**
    1.89 @@ -297,165 +257,4 @@
    1.90          }
    1.91      }
    1.92  
    1.93 -    @ServiceProvider(service=MimeDataProvider.class)
    1.94 -    public static final class MimeDataProviderImpl implements MimeDataProvider {
    1.95 -
    1.96 -        private static final Lookup L = Lookups.fixed(new JavacParserFactory());
    1.97 -
    1.98 -        public Lookup getLookup(MimePath mimePath) {
    1.99 -            if ("text/x-java".equals(mimePath.getPath()))
   1.100 -                return L;
   1.101 -            return null;
   1.102 -        }
   1.103 -        
   1.104 -    }
   1.105 -
   1.106 -    public static final class StandaloneMimeDataProviderImpl implements MimeDataProvider {
   1.107 -
   1.108 -        private static final Lookup L = Lookups.fixed(NbPreferences.forModule(HintsAnnotationProcessing.class), new JavacParserFactory());
   1.109 -
   1.110 -        public Lookup getLookup(MimePath mimePath) {
   1.111 -            if ("text/x-java".equals(mimePath.getPath()))
   1.112 -                return L;
   1.113 -            return null;
   1.114 -        }
   1.115 -
   1.116 -    }
   1.117 -
   1.118 -    @ServiceProvider(service=SourceForBinaryQueryImplementation.class, position=0)
   1.119 -    public static final class EmptySourceForBinaryQueryImpl implements SourceForBinaryQueryImplementation2 {
   1.120 -        public Result findSourceRoots2(URL binaryRoot) {
   1.121 -            return INSTANCE;
   1.122 -        }
   1.123 -        public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) {
   1.124 -            return findSourceRoots2(binaryRoot);
   1.125 -        }
   1.126 -        private static final Result INSTANCE = new Result() {
   1.127 -            public boolean preferSources() {
   1.128 -                return false;
   1.129 -            }
   1.130 -            public org.openide.filesystems.FileObject[] getRoots() {
   1.131 -                return new org.openide.filesystems.FileObject[0];
   1.132 -            }
   1.133 -            public void addChangeListener(ChangeListener l) {}
   1.134 -            public void removeChangeListener(ChangeListener l) {}
   1.135 -        };
   1.136 -    }
   1.137 -
   1.138 -    public static class PreferencesProvider implements Provider {
   1.139 -
   1.140 -        private final MemoryPreferencesFactory f;
   1.141 -
   1.142 -        public PreferencesProvider() {
   1.143 -            this.f = new MemoryPreferencesFactory();
   1.144 -        }
   1.145 -
   1.146 -        @Override
   1.147 -        public Preferences preferencesForModule(Class cls) {
   1.148 -            return f.userRoot().node(cls.getPackage().getName());
   1.149 -        }
   1.150 -
   1.151 -        @Override
   1.152 -        public Preferences preferencesRoot() {
   1.153 -            return f.userRoot();
   1.154 -        }
   1.155 -
   1.156 -    }
   1.157 -    //copied from NB junit:
   1.158 -    public static class MemoryPreferencesFactory implements PreferencesFactory {
   1.159 -        /** Creates a new instance  */
   1.160 -        public MemoryPreferencesFactory() {}
   1.161 -
   1.162 -        public Preferences userRoot() {
   1.163 -            return NbPreferences.userRootImpl();
   1.164 -        }
   1.165 -
   1.166 -        public Preferences systemRoot() {
   1.167 -            return NbPreferences.systemRootImpl();
   1.168 -        }
   1.169 -
   1.170 -        private static class NbPreferences extends AbstractPreferences {
   1.171 -            private static Preferences USER_ROOT;
   1.172 -            private static Preferences SYSTEM_ROOT;
   1.173 -
   1.174 -            /*private*/Properties properties;
   1.175 -
   1.176 -            static Preferences userRootImpl() {
   1.177 -                if (USER_ROOT == null) {
   1.178 -                    USER_ROOT = new NbPreferences();
   1.179 -                }
   1.180 -                return USER_ROOT;
   1.181 -            }
   1.182 -
   1.183 -            static Preferences systemRootImpl() {
   1.184 -                if (SYSTEM_ROOT == null) {
   1.185 -                    SYSTEM_ROOT = new NbPreferences();
   1.186 -                }
   1.187 -                return SYSTEM_ROOT;
   1.188 -            }
   1.189 -
   1.190 -
   1.191 -            private NbPreferences() {
   1.192 -                super(null, "");
   1.193 -            }
   1.194 -
   1.195 -            /** Creates a new instance of PreferencesImpl */
   1.196 -            private  NbPreferences(NbPreferences parent, String name)  {
   1.197 -                super(parent, name);
   1.198 -                newNode = true;
   1.199 -            }
   1.200 -
   1.201 -            protected final String getSpi(String key) {
   1.202 -                return properties().getProperty(key);
   1.203 -            }
   1.204 -
   1.205 -            protected final String[] childrenNamesSpi() throws BackingStoreException {
   1.206 -                return new String[0];
   1.207 -            }
   1.208 -
   1.209 -            protected final String[] keysSpi() throws BackingStoreException {
   1.210 -                return properties().keySet().toArray(new String[0]);
   1.211 -            }
   1.212 -
   1.213 -            protected final void putSpi(String key, String value) {
   1.214 -                properties().put(key,value);
   1.215 -            }
   1.216 -
   1.217 -            protected final void removeSpi(String key) {
   1.218 -                properties().remove(key);
   1.219 -            }
   1.220 -
   1.221 -            protected final void removeNodeSpi() throws BackingStoreException {}
   1.222 -            protected  void flushSpi() throws BackingStoreException {}
   1.223 -            protected void syncSpi() throws BackingStoreException {
   1.224 -                properties().clear();
   1.225 -            }
   1.226 -
   1.227 -            @Override
   1.228 -            public void put(String key, String value) {
   1.229 -                try {
   1.230 -                    super.put(key, value);
   1.231 -                } catch (IllegalArgumentException iae) {
   1.232 -                    if (iae.getMessage().contains("too long")) {
   1.233 -                        // Not for us!
   1.234 -                        putSpi(key, value);
   1.235 -                    } else {
   1.236 -                        throw iae;
   1.237 -                    }
   1.238 -                }
   1.239 -            }
   1.240 -
   1.241 -            Properties properties()  {
   1.242 -                if (properties == null) {
   1.243 -                    properties = new Properties();
   1.244 -                }
   1.245 -                return properties;
   1.246 -            }
   1.247 -
   1.248 -            protected AbstractPreferences childSpi(String name) {
   1.249 -                return new NbPreferences(this, name);
   1.250 -            }
   1.251 -        }
   1.252 -
   1.253 -    }
   1.254  }