Search in sources :

Example 1 with CLASS_OUTPUT

use of javax.tools.StandardLocation.CLASS_OUTPUT in project neo4j by neo4j.

the class ServiceAnnotationProcessor method loadIfExists.

private SortedSet<String> loadIfExists(String path) {
    final SortedSet<String> result = new TreeSet<>();
    try {
        final FileObject file = processingEnv.getFiler().getResource(CLASS_OUTPUT, "", path);
        final List<String> lines = new ArrayList<>();
        try (BufferedReader in = new BufferedReader(new InputStreamReader(file.openInputStream(), StandardCharsets.UTF_8))) {
            String line;
            while ((line = in.readLine()) != null) {
                lines.add(line);
            }
        }
        lines.stream().map(s -> substringBefore(s, "#")).map(String::trim).filter(StringUtils::isNotEmpty).forEach(result::add);
        info("Loaded existing providers: " + result);
    } catch (IOException ignore) {
        info("No existing providers loaded");
    }
    return result;
}
Also used : SortedSet(java.util.SortedSet) AbstractProcessor(javax.annotation.processing.AbstractProcessor) TypeElement(javax.lang.model.element.TypeElement) StringUtils(org.apache.commons.lang3.StringUtils) Elements(javax.lang.model.util.Elements) ERROR(javax.tools.Diagnostic.Kind.ERROR) Multimaps(org.eclipse.collections.impl.factory.Multimaps) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FileObject(javax.tools.FileObject) DEFAULT_NEW_LINE(org.neo4j.annotations.AnnotationConstants.DEFAULT_NEW_LINE) MutableMultimap(org.eclipse.collections.api.multimap.MutableMultimap) CLASS_OUTPUT(javax.tools.StandardLocation.CLASS_OUTPUT) Collectors.toSet(java.util.stream.Collectors.toSet) BufferedWriter(java.io.BufferedWriter) Set(java.util.Set) ExceptionUtils.getStackTrace(org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace) UnifiedSet.newSetWith(org.eclipse.collections.impl.set.mutable.UnifiedSet.newSetWith) IOException(java.io.IOException) Element(javax.lang.model.element.Element) Types(javax.lang.model.util.Types) InputStreamReader(java.io.InputStreamReader) StandardCharsets(java.nio.charset.StandardCharsets) String.format(java.lang.String.format) SourceVersion(javax.lang.model.SourceVersion) NOTE(javax.tools.Diagnostic.Kind.NOTE) List(java.util.List) TypeMirror(javax.lang.model.type.TypeMirror) Collectors.toList(java.util.stream.Collectors.toList) RoundEnvironment(javax.annotation.processing.RoundEnvironment) ProcessingEnvironment(javax.annotation.processing.ProcessingEnvironment) Optional(java.util.Optional) BufferedReader(java.io.BufferedReader) StringUtils.substringBefore(org.apache.commons.lang3.StringUtils.substringBefore) InputStreamReader(java.io.InputStreamReader) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileObject(javax.tools.FileObject) IOException(java.io.IOException)

Aggregations

BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 String.format (java.lang.String.format)1 StandardCharsets (java.nio.charset.StandardCharsets)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 AbstractProcessor (javax.annotation.processing.AbstractProcessor)1 ProcessingEnvironment (javax.annotation.processing.ProcessingEnvironment)1 RoundEnvironment (javax.annotation.processing.RoundEnvironment)1 SourceVersion (javax.lang.model.SourceVersion)1 Element (javax.lang.model.element.Element)1