org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aspectjtools Show documentation
Show all versions of aspectjtools Show documentation
AspectJ tools most notably contains the AspectJ compiler (AJC). AJC applies aspects to Java classes during
compilation, fully replacing Javac for plain Java classes and also compiling native AspectJ or annotation-based
@AspectJ syntax. Furthermore, AJC can weave aspects into existing class files in a post-compile binary weaving step.
This library is a superset of AspectJ weaver and hence also of AspectJ runtime.
/*******************************************************************************
* Copyright (c) 2000, 2013 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
* Jesper Steen Moller - Contributions for:
* Bug 412149: [1.8][compiler] Emit repeated annotations into the designated container
*******************************************************************************/
package org.aspectj.org.eclipse.jdt.internal.compiler.ast;
import org.aspectj.org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.*;
/**
* SingleMemberAnnotation node
*/
public class SingleMemberAnnotation extends Annotation {
public Expression memberValue;
private MemberValuePair[] singlePairs; // fake pair set, only value has accurate positions
public SingleMemberAnnotation(TypeReference type, int sourceStart) {
this.type = type;
this.sourceStart = sourceStart;
this.sourceEnd = type.sourceEnd;
}
public SingleMemberAnnotation() {
// for subclasses.
}
@Override
public ElementValuePair[] computeElementValuePairs() {
return new ElementValuePair[] {memberValuePairs()[0].compilerElementPair};
}
/**
* @see org.eclipse.jdt.internal.compiler.ast.Annotation#memberValuePairs()
*/
@Override
public MemberValuePair[] memberValuePairs() {
if (this.singlePairs == null) {
this.singlePairs =
new MemberValuePair[]{
new MemberValuePair(VALUE, this.memberValue.sourceStart, this.memberValue.sourceEnd, this.memberValue)
};
}
return this.singlePairs;
}
@Override
public StringBuilder printExpression(int indent, StringBuilder output) {
super.printExpression(indent, output);
output.append('(');
this.memberValue.printExpression(indent, output);
return output.append(')');
}
@Override
public void traverse(ASTVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
if (this.type != null) {
this.type.traverse(visitor, scope);
}
if (this.memberValue != null) {
this.memberValue.traverse(visitor, scope);
}
}
visitor.endVisit(this, scope);
}
@Override
public void traverse(ASTVisitor visitor, ClassScope scope) {
if (visitor.visit(this, scope)) {
if (this.type != null) {
this.type.traverse(visitor, scope);
}
if (this.memberValue != null) {
this.memberValue.traverse(visitor, scope);
}
}
visitor.endVisit(this, scope);
}
}