Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 111292 | Differences between
and this patch

Collapse All | Expand All

(-)a/openide.util/src/org/netbeans/modules/openide/util/ServiceProviderProcessor.java (+75 lines)
 Lines 49-59    Link Here 
49
import java.io.PrintWriter;
49
import java.io.PrintWriter;
50
import java.lang.annotation.Annotation;
50
import java.lang.annotation.Annotation;
51
import java.util.ArrayList;
51
import java.util.ArrayList;
52
import java.util.Collection;
53
import java.util.Collections;
52
import java.util.HashMap;
54
import java.util.HashMap;
55
import java.util.LinkedList;
53
import java.util.List;
56
import java.util.List;
54
import java.util.Map;
57
import java.util.Map;
55
import java.util.Set;
58
import java.util.Set;
56
import javax.annotation.processing.AbstractProcessor;
59
import javax.annotation.processing.AbstractProcessor;
60
import javax.annotation.processing.Completion;
57
import javax.annotation.processing.RoundEnvironment;
61
import javax.annotation.processing.RoundEnvironment;
58
import javax.annotation.processing.SupportedAnnotationTypes;
62
import javax.annotation.processing.SupportedAnnotationTypes;
59
import javax.annotation.processing.SupportedSourceVersion;
63
import javax.annotation.processing.SupportedSourceVersion;
 Lines 65-70    Link Here 
65
import javax.lang.model.element.Modifier;
69
import javax.lang.model.element.Modifier;
66
import javax.lang.model.element.TypeElement;
70
import javax.lang.model.element.TypeElement;
67
import javax.lang.model.type.MirroredTypeException;
71
import javax.lang.model.type.MirroredTypeException;
72
import javax.lang.model.type.TypeKind;
68
import javax.lang.model.type.TypeMirror;
73
import javax.lang.model.type.TypeMirror;
69
import javax.lang.model.util.ElementFilter;
74
import javax.lang.model.util.ElementFilter;
70
import javax.tools.Diagnostic.Kind;
75
import javax.tools.Diagnostic.Kind;
 Lines 270-273    Link Here 
270
        return null;
275
        return null;
271
    }
276
    }
272
277
278
    @Override
279
    public Iterable<? extends Completion> getCompletions(Element annotated, AnnotationMirror annotation, ExecutableElement attr, String userText) {
280
        if (processingEnv == null || annotated == null || !annotated.getKind().isClass()) {
281
            return Collections.emptyList();
282
        }
283
284
        if (   annotation == null
285
            || !"org.openide.util.lookup.ServiceProvider".contentEquals(((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName())) {
286
            return Collections.emptyList();
287
        }
288
289
        if (!"service".contentEquals(attr.getSimpleName())) {
290
            return Collections.emptyList();
291
        }
292
293
        TypeElement jlObject = processingEnv.getElementUtils().getTypeElement("java.lang.Object");
294
295
        if (jlObject == null) {
296
            return Collections.emptyList();
297
        }
298
        
299
        Collection<Completion> result = new LinkedList<Completion>();
300
        List<TypeElement> toProcess = new LinkedList<TypeElement>();
301
302
        toProcess.add((TypeElement) annotated);
303
304
        while (!toProcess.isEmpty()) {
305
            TypeElement c = toProcess.remove(0);
306
307
            result.add(new TypeCompletion(c.getQualifiedName().toString()));
308
309
            List<TypeMirror> parents = new LinkedList<TypeMirror>();
310
311
            parents.add(c.getSuperclass());
312
            parents.addAll(c.getInterfaces());
313
314
            for (TypeMirror tm : parents) {
315
                if (tm == null || tm.getKind() != TypeKind.DECLARED) {
316
                    continue;
317
                }
318
319
                TypeElement type = (TypeElement) processingEnv.getTypeUtils().asElement(tm);
320
321
                if (!jlObject.equals(type)) {
322
                    toProcess.add(type);
323
                }
324
            }
325
        }
326
327
        return result;
328
    }
329
330
    private static final class TypeCompletion implements Completion {
331
332
        private final String fqn;
333
334
        public TypeCompletion(String fqn) {
335
            this.fqn = fqn;
336
        }
337
338
        public String getValue() {
339
            return fqn;
340
        }
341
342
        public String getMessage() {
343
            return null;
344
        }
345
        
346
    }
347
273
}
348
}

Return to bug 111292
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo