Lines 26-31
Link Here
|
26 |
package com.sun.tools.javac.processing; |
26 |
package com.sun.tools.javac.processing; |
27 |
|
27 |
|
28 |
import java.lang.reflect.*; |
28 |
import java.lang.reflect.*; |
|
|
29 |
import java.net.URI; |
29 |
import java.util.*; |
30 |
import java.util.*; |
30 |
import java.util.Map.Entry; |
31 |
import java.util.Map.Entry; |
31 |
import java.util.logging.Level; |
32 |
import java.util.logging.Level; |
Lines 83-88
Link Here
|
83 |
import com.sun.tools.javac.util.Name; |
84 |
import com.sun.tools.javac.util.Name; |
84 |
import com.sun.tools.javac.util.Names; |
85 |
import com.sun.tools.javac.util.Names; |
85 |
import com.sun.tools.javac.util.Options; |
86 |
import com.sun.tools.javac.util.Options; |
|
|
87 |
import javax.tools.StandardLocation; |
86 |
|
88 |
|
87 |
import static javax.tools.StandardLocation.*; |
89 |
import static javax.tools.StandardLocation.*; |
88 |
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; |
90 |
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; |
Lines 102-107
Link Here
|
102 |
|
104 |
|
103 |
private static final Logger LOGGER = Logger.getLogger(JavacProcessingEnvironment.class.getName()); |
105 |
private static final Logger LOGGER = Logger.getLogger(JavacProcessingEnvironment.class.getName()); |
104 |
|
106 |
|
|
|
107 |
private static final Set<String> blackList = new HashSet<String>(){{add("org.netbeans.modules.openide.util.NbBundleProcessor");}}; //NOI18N |
108 |
|
105 |
Options options; |
109 |
Options options; |
106 |
|
110 |
|
107 |
private final boolean printProcessorInfo; |
111 |
private final boolean printProcessorInfo; |
Lines 732-738
Link Here
|
732 |
} |
736 |
} |
733 |
|
737 |
|
734 |
if (matchedNames.size() > 0 || ps.contributed) { |
738 |
if (matchedNames.size() > 0 || ps.contributed) { |
735 |
boolean processingResult = callProcessor(ps.processor, typeElements, renv); |
739 |
RoundEnvironment currentRenv; |
|
|
740 |
if (blackList.contains(ps.processor.getClass().getName())) { |
741 |
final Set<Element> extElements = new HashSet<Element>(rootElements); |
742 |
final Map<String,Set<URI>> processorGeneratedCache = new HashMap<String, Set<URI>>(); |
743 |
for (Element rootElement : rootElements) { |
744 |
if ((rootElement.getKind().isClass() || rootElement.getKind().isInterface()) && !isProcessorGenerated((TypeElement)rootElement, processorGeneratedCache)) { |
745 |
final Element encElement = rootElement.getEnclosingElement(); |
746 |
assert encElement.getKind() == ElementKind.PACKAGE; |
747 |
extElements.addAll(encElement.getEnclosedElements()); |
748 |
} |
749 |
} |
750 |
currentRenv = new JavacRoundEnvironment(false, false, extElements, JavacProcessingEnvironment.this); |
751 |
} else { |
752 |
currentRenv = renv; |
753 |
} |
754 |
|
755 |
boolean processingResult = callProcessor(ps.processor, typeElements, currentRenv); |
736 |
ps.contributed = true; |
756 |
ps.contributed = true; |
737 |
ps.removeSupportedOptions(unmatchedProcessorOptions); |
757 |
ps.removeSupportedOptions(unmatchedProcessorOptions); |
738 |
|
758 |
|
Lines 769-774
Link Here
|
769 |
filer.displayState(); |
789 |
filer.displayState(); |
770 |
} |
790 |
} |
771 |
|
791 |
|
|
|
792 |
private boolean isProcessorGenerated(final TypeElement topLevel, final Map<String,Set<URI>> cache) { |
793 |
final JavaFileObject sourceFile = ((ClassSymbol)topLevel).sourcefile; |
794 |
if (sourceFile == null) { |
795 |
return false; |
796 |
} |
797 |
final String pkg = ((PackageElement)topLevel.getEnclosingElement()).getQualifiedName().toString(); |
798 |
Set<URI> cacheLine = cache.get(pkg); |
799 |
if (cacheLine == null) { |
800 |
final JavaFileManager fileManager = context.get(JavaFileManager.class); |
801 |
cacheLine = new HashSet<URI>(); |
802 |
cache.put(pkg,cacheLine); |
803 |
try { |
804 |
final Iterable<? extends JavaFileObject> content = fileManager.list( |
805 |
StandardLocation.SOURCE_OUTPUT, |
806 |
pkg, |
807 |
EnumSet.of(JavaFileObject.Kind.SOURCE), |
808 |
false); |
809 |
for (JavaFileObject jfo : content) { |
810 |
cacheLine.add(jfo.toUri()); |
811 |
} |
812 |
} catch (IOException ioe) {/*pass*/} |
813 |
} |
814 |
return cacheLine.contains(sourceFile.toUri()); |
815 |
} |
816 |
|
772 |
/** |
817 |
/** |
773 |
* Computes the set of annotations on the symbol in question. |
818 |
* Computes the set of annotations on the symbol in question. |
774 |
* Leave class public for external testing purposes. |
819 |
* Leave class public for external testing purposes. |