org.eclipse.jdt.internal.compiler.apt.model.ElementImpl Java Examples
The following examples show how to use
org.eclipse.jdt.internal.compiler.apt.model.ElementImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationDiscoveryVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void resolveAnnotations(BlockScope scope, Annotation[] annotations, Binding currentBinding) { int length = annotations == null ? 0 : annotations.length; if (length == 0) return; boolean old = scope.insideTypeAnnotation; scope.insideTypeAnnotation = true; ASTNode.resolveAnnotations(scope, annotations, currentBinding); scope.insideTypeAnnotation = old; ElementImpl element = (ElementImpl) _factory.newElement(currentBinding); AnnotationBinding [] annotationBindings = element.getPackedAnnotationBindings(); // discovery is never in terms of repeating annotation. for (AnnotationBinding binding : annotationBindings) { if (binding != null) { // binding should be resolved, but in case it's not, ignore it: it could have been wrapped into a container. TypeElement anno = (TypeElement)_factory.newElement(binding.getAnnotationType()); _annoToElement.put(anno, element); } } }
Example #2
Source File: AnnotationProcessorManager.java From takari-lifecycle with Eclipse Public License 1.0 | 6 votes |
private Set<? extends Element> recordProcessedSources(Supplier<Set<? extends Element>> elementsSupplier) { final boolean _recordingReferencedTypes = recordingReferencedTypes; try { recordingReferencedTypes = false; Set<? extends Element> elements = elementsSupplier.get(); if (_recordingReferencedTypes) { for (Element element : elements) { File sourceFile = getSourceFile((ElementImpl) element); if (sourceFile != null) { processedSources.add(sourceFile); } } } return elements; } finally { recordingReferencedTypes = _recordingReferencedTypes; } }
Example #3
Source File: SourceOrdering.java From immutables with Apache License 2.0 | 6 votes |
@Override public Ordering<Element> enclosedBy(Element element) { if (element instanceof ElementImpl && Iterables.all(element.getEnclosedElements(), Predicates.instanceOf(ElementImpl.class))) { ElementImpl implementation = (ElementImpl) element; if (implementation._binding instanceof SourceTypeBinding) { SourceTypeBinding sourceBinding = (SourceTypeBinding) implementation._binding; return Ordering.natural().onResultOf( Functions.compose(bindingsToSourceOrder(sourceBinding), this)); } } return DEFAULT_PROVIDER.enclosedBy(element); }
Example #4
Source File: AnnotationProcessorManager.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
/** * Given {@code Element}, returns source file that defines the element. Returns {@code null} if the element is not defined in a source file. */ private File getSourceFile(ElementImpl element) { TypeElementImpl topLevelType = getTopLevelType(element); if (topLevelType == null) { // TODO package-info.java annotation? return null; } Binding binding = topLevelType._binding; if (binding instanceof SourceTypeBinding) { return new File(new String(((SourceTypeBinding) binding).getFileName())); } return null; }
Example #5
Source File: AnnotationProcessorManager.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
/** * Returns enclosing top-level type of the element. Returns {@code null} if the element does not have enclosing top-level type. */ private TypeElementImpl getTopLevelType(ElementImpl element) { for (; element != null; element = (ElementImpl) element.getEnclosingElement()) { if (element instanceof TypeElementImpl && ((TypeElementImpl) element).getNestingKind() == NestingKind.TOP_LEVEL) { return (TypeElementImpl) element; } } return null; }
Example #6
Source File: SourceExtraction.java From immutables with Apache License 2.0 | 5 votes |
@Override public CharSequence extract(ProcessingEnvironment environment, TypeElement typeElement) throws IOException { if (typeElement instanceof ElementImpl) { Binding binding = ((ElementImpl) typeElement)._binding; if (binding instanceof SourceTypeBinding) { CompilationUnitDeclaration unit = ((SourceTypeBinding) binding).scope.referenceCompilationUnit(); char[] contents = unit.compilationResult.compilationUnit.getContents(); return CharBuffer.wrap(contents); } } return UNABLE_TO_EXTRACT; }
Example #7
Source File: SourceOrdering.java From immutables with Apache License 2.0 | 4 votes |
@Override public Object apply(Element input) { return ((ElementImpl) input)._binding; }
Example #8
Source File: SourceExtraction.java From immutables with Apache License 2.0 | 4 votes |
@Override public boolean claim(Element element) { return element instanceof ElementImpl; }