[configuration] Implement LombokConfiguration (using the CONSOLE error reporter)

This commit is contained in:
Roel Spilker committed 2014-01-15 21:36:52 +01:00
1 parent 923a366003
commit 610f250c1d
1 file changed
+6 -48
+6 -48
View File
@@ -21,62 +21,20 @@
*/
package lombok.core;
import java.util.List;
import javax.lang.model.SourceVersion;
import lombok.core.configuration.BubblingConfigurationResolver;
import lombok.core.configuration.ConfigurationErrorReporterFactory;
import lombok.core.configuration.ConfigurationKey;
import lombok.core.configuration.FileSystemSourceCache;
public class LombokConfiguration {
private static FileSystemSourceCache cache = new FileSystemSourceCache();
private LombokConfiguration() {
// prevent instantiation
}
static <T> T read(ConfigurationKey<T> key, AST<?, ?, ?> ast) {
// if (key.keyName.equals("lombok.log.varName")) return (T)"loggertje";
// if (key.keyName.equals("lombok.log.static")) return (T)Boolean.FALSE;
return null;
}
@SuppressWarnings("rawtypes")
public static void main(String[] args) {
try { new ConfigurationKey<List<String>>("List<String>") {}; } catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<Integer>("Integer") {}; } catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<Class<?>>("Class<?>") {}; } catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<SourceVersion>("SourceVersion") {}; } catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<Class>("Class") {}; } catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<Class<Number>>("Class<Number>") {}; } catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<Class<? extends Number>>("Class<? extends Number>") {}; } catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<Class<? super String>>("Class<? super String>") {}; } catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<Number>("Number") {}; } catch (Exception e) { e.printStackTrace();}
try { class Between extends ConfigurationKey<String> {
public Between() {
super("between");
}
};
new Between(){};
} catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<String>("more than once") {}; } catch (Exception e) { e.printStackTrace();}
try { new ConfigurationKey<Integer>("more than once") {}; } catch (Exception e) { e.printStackTrace();}
System.out.println(System.identityHashCode(ConfigurationKey.registeredKeys()));
System.out.println(System.identityHashCode(ConfigurationKey.registeredKeys()));
ConfigurationKey<?> first = null;
try { first = new ConfigurationKey<Integer>("anint") {}; } catch (Exception e) { e.printStackTrace();}
System.out.println(System.identityHashCode(ConfigurationKey.registeredKeys()));
System.out.println(System.identityHashCode(ConfigurationKey.registeredKeys()));
ConfigurationKey<?> second = null;
try { second = new ConfigurationKey<Integer>("anint") {}; } catch (Exception e) { e.printStackTrace();}
System.out.println(System.identityHashCode(ConfigurationKey.registeredKeys()));
System.out.println(System.identityHashCode(ConfigurationKey.registeredKeys()));
System.out.println(first == second);
System.out.println(first.getClass() == second.getClass());
System.out.println(first.equals(second));
return new BubblingConfigurationResolver(cache.sourcesForJavaFile(ast.getAbsoluteFileLocation(), ConfigurationErrorReporterFactory.CONSOLE)).resolve(key);
}
}