use of com.sun.tools.javac.tree.JCTree.JCAnnotation in project com.revolsys.open by revolsys.
the class DocumentationProcessor method process.
@Override
public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
if (this.elementUtils != null) {
final Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(Documentation.class);
for (final Element element : elements) {
String docComment = this.elementUtils.getDocComment(element);
if (docComment != null) {
docComment = docComment.trim();
if (docComment.length() > 0) {
final JCModifiers modifiers = getModifiers(element);
for (final JCAnnotation annotation : modifiers.annotations) {
if (annotation.type.toString().equals(Documentation.class.getName())) {
boolean hasValue = false;
final JCLiteral commentLiteral = this.maker.Literal(docComment);
for (final JCExpression arg : annotation.args) {
if (arg instanceof JCAssign) {
final JCAssign assign = (JCAssign) arg;
final JCExpression lhs = assign.lhs;
if (lhs instanceof JCIdent) {
final JCIdent ident = (JCIdent) lhs;
if (ident.name.contentEquals("value")) {
assign.rhs = commentLiteral;
hasValue = true;
}
}
}
}
if (!hasValue) {
final ClassSymbol classSymbol = (ClassSymbol) ((JCIdent) annotation.annotationType).sym;
MethodSymbol valueMethod = null;
for (final Symbol symbol : classSymbol.members_field.getElementsByName(this.names.value)) {
valueMethod = (MethodSymbol) symbol;
}
final JCAssign valueArg = this.maker.Assign(this.maker.Ident(valueMethod), commentLiteral);
annotation.args = annotation.args.append(valueArg);
}
}
}
}
}
}
}
return true;
}
use of com.sun.tools.javac.tree.JCTree.JCAnnotation in project ceylon-compiler by ceylon.
the class ExpressionTransformer method transformAnonymousAnnotation.
public void transformAnonymousAnnotation(Tree.AnonymousAnnotation annotation, Map<Class, ListBuffer<JCAnnotation>> annos) {
Type docType = ((TypeDeclaration) typeFact().getLanguageModuleDeclaration("DocAnnotation")).getType();
JCAnnotation docAnnotation = at(annotation).Annotation(makeJavaType(docType, JT_ANNOTATION), List.<JCExpression>of(make().Assign(naming.makeUnquotedIdent("description"), transform(annotation.getStringLiteral()))));
putAnnotation(annos, docAnnotation, (Class) docType.getDeclaration());
}
use of com.sun.tools.javac.tree.JCTree.JCAnnotation in project ceylon-compiler by ceylon.
the class ParameterDefinitionBuilder method build.
public JCVariableDecl build() {
if (built) {
throw new BugException("already built");
}
built = true;
ListBuffer<JCAnnotation> annots = ListBuffer.lb();
if (Annotations.includeModel(annotationFlags)) {
annots.appendList(gen.makeAtName(name));
if (functionalParameterName != null) {
annots.appendList(gen.makeAtFunctionalParameter(functionalParameterName));
}
if (sequenced) {
annots.appendList(gen.makeAtSequenced());
}
if (defaulted) {
annots.appendList(gen.makeAtDefaulted());
}
if (typeAnnos != null) {
annots.appendList(typeAnnos);
}
}
if (Annotations.includeUser(annotationFlags) && userAnnotations != null) {
annots.appendList(userAnnotations.toList());
}
if (Annotations.includeModel(annotationFlags)) {
if (modelAnnotations != null) {
annots.appendList(modelAnnotations.toList());
}
}
if (Annotations.includeIgnore(annotationFlags)) {
annots = annots.appendList(gen.makeAtIgnore());
}
Name name = gen.names().fromString(Naming.quoteParameterName(getJavaParameterName()));
return gen.make().VarDef(gen.make().Modifiers(modifiers | Flags.PARAMETER, annots.toList()), name, type, null);
}
use of com.sun.tools.javac.tree.JCTree.JCAnnotation in project ceylon-compiler by ceylon.
the class AbstractTransformer method makeAtAnnotations.
List<JCAnnotation> makeAtAnnotations(java.util.List<Annotation> annotations) {
if (!simpleAnnotationModels || annotations == null || annotations.isEmpty())
return List.nil();
long modifiers = 0;
ListBuffer<JCExpression> array = new ListBuffer<JCTree.JCExpression>();
for (Annotation annotation : annotations) {
if (isOmittedModelAnnotation(annotation)) {
continue;
}
Long mask = getModelModifierMask(annotation);
if (mask != null && mask != 0) {
modifiers |= mask;
} else {
array.append(makeAtAnnotation(annotation));
}
}
if (modifiers == 0 && array.isEmpty()) {
return List.<JCAnnotation>nil();
}
List<JCExpression> annotationsAndMods = List.<JCExpression>nil();
if (!array.isEmpty()) {
annotationsAndMods = annotationsAndMods.prepend(make().Assign(naming.makeUnquotedIdent("value"), make().NewArray(null, null, array.toList())));
}
if (modifiers != 0L) {
annotationsAndMods = annotationsAndMods.prepend(make().Assign(naming.makeUnquotedIdent("modifiers"), make().Literal(modifiers)));
}
return makeModelAnnotation(syms().ceylonAtAnnotationsType, annotationsAndMods);
}
use of com.sun.tools.javac.tree.JCTree.JCAnnotation in project ceylon-compiler by ceylon.
the class AbstractTransformer method makeReifiedTypeParameterVarDecl.
JCVariableDecl makeReifiedTypeParameterVarDecl(TypeParameter param, boolean isCompanion) {
String descriptorName = naming.getTypeArgumentDescriptorName(param);
long flags = PRIVATE;
if (!isCompanion)
flags |= FINAL;
List<JCAnnotation> annotations = makeAtIgnore();
JCVariableDecl localVar = make().VarDef(make().Modifiers(flags, annotations), names().fromString(descriptorName), makeTypeDescriptorType(), null);
return localVar;
}
Aggregations