Skip to content

Commit

Permalink
Implement JavacAnnotationBinding.getKey
Browse files Browse the repository at this point in the history
Closes eclipse-jdt#218

Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 authored and mickaelistria committed May 14, 2024
1 parent cb54711 commit 072941f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@

public class JavacAnnotationBinding implements IAnnotationBinding {

private JavacBindingResolver resolver;
private Compound annotation;
private final JavacBindingResolver resolver;
private final Compound annotation;

public JavacAnnotationBinding(Compound ann, JavacBindingResolver resolver) {
private transient String key;
private final IBinding recipient;

public JavacAnnotationBinding(Compound ann, JavacBindingResolver resolver, IBinding recipient) {
this.resolver = resolver;
this.annotation = ann;
this.recipient = recipient;
}

@Override
Expand Down Expand Up @@ -68,8 +72,11 @@ public IJavaElement getJavaElement() {

@Override
public String getKey() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getKey'");
StringBuilder builder = new StringBuilder();
builder.append(this.recipient.getKey());
builder.append('@');
builder.append(this.getAnnotationType().getKey());
return builder.toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public JavacMethodBinding(MethodSymbol sym, JavacBindingResolver resolver, List<

@Override
public IAnnotationBinding[] getAnnotations() {
return methodSymbol.getAnnotationMirrors().stream().map(ann -> new JavacAnnotationBinding(ann, this.resolver)).toArray(IAnnotationBinding[]::new);
return methodSymbol.getAnnotationMirrors().stream().map(ann -> new JavacAnnotationBinding(ann, this.resolver, this)).toArray(IAnnotationBinding[]::new);
}

@Override
Expand Down Expand Up @@ -217,7 +217,7 @@ public Object getDefaultValue() {
public IAnnotationBinding[] getParameterAnnotations(int paramIndex) {
VarSymbol parameter = this.methodSymbol.params.get(paramIndex);
return parameter.getAnnotationMirrors().stream() //
.map(annotation -> new JavacAnnotationBinding(annotation, this.resolver)) //
.map(annotation -> new JavacAnnotationBinding(annotation, this.resolver, this)) //
.toArray(IAnnotationBinding[]::new);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public JavacTypeBinding(final Type type, final JavacBindingResolver resolver, fi
@Override
public IAnnotationBinding[] getAnnotations() {
return typeSymbol.getAnnotationMirrors().stream()
.map(am -> new JavacAnnotationBinding(am, resolver))
.map(am -> new JavacAnnotationBinding(am, resolver, this))
.toArray(IAnnotationBinding[]::new);
}

Expand Down Expand Up @@ -340,7 +340,7 @@ public ITypeBinding getSuperclass() {
@Override
public IAnnotationBinding[] getTypeAnnotations() {
return this.typeSymbol.getAnnotationMirrors().stream() //
.map(annotation -> new JavacAnnotationBinding(annotation, this.resolver)) //
.map(annotation -> new JavacAnnotationBinding(annotation, this.resolver, this)) //
.toArray(IAnnotationBinding[]::new);
}

Expand Down

0 comments on commit 072941f

Please sign in to comment.