本文整理汇总了Java中lombok.javac.JavacNode类的典型用法代码示例。如果您正苦于以下问题:Java JavacNode类的具体用法?Java JavacNode怎么用?Java JavacNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavacNode类属于lombok.javac包,在下文中一共展示了JavacNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createField
import lombok.javac.JavacNode; //导入依赖的package包/类
private static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String logFieldName, boolean useStatic, String loggerTopic) {
JavacTreeMaker maker = typeNode.getTreeMaker();
// private static final <loggerType> log = <factoryMethod>(<parameter>);
JCExpression loggerType = chainDotsString(typeNode, framework.getLoggerTypeName());
JCExpression factoryMethod = chainDotsString(typeNode, framework.getLoggerFactoryMethodName());
JCExpression loggerName;
if (loggerTopic == null || loggerTopic.trim().length() == 0) {
loggerName = framework.createFactoryParameter(typeNode, loggingType);
} else {
loggerName = maker.Literal(loggerTopic);
}
JCMethodInvocation factoryMethodCall = maker.Apply(List.<JCExpression>nil(), factoryMethod, List.<JCExpression>of(loggerName));
JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef(
maker.Modifiers(Flags.PRIVATE | Flags.FINAL | (useStatic ? Flags.STATIC : 0)),
typeNode.toName(logFieldName), loggerType, factoryMethodCall), source, typeNode.getContext());
injectFieldAndMarkGenerated(typeNode, fieldDecl);
return true;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:24,代码来源:HandleLog.java
示例2: createTypeReference
import lombok.javac.JavacNode; //导入依赖的package包/类
public JCExpression createTypeReference(JavacNode type) {
java.util.List<String> list = new ArrayList<String>();
list.add(type.getName());
JavacNode tNode = type.up();
while (tNode != null && tNode.getKind() == Kind.TYPE) {
list.add(tNode.getName());
tNode = tNode.up();
}
Collections.reverse(list);
JavacTreeMaker maker = type.getTreeMaker();
JCExpression chain = maker.Ident(type.toName(list.get(0)));
for (int i = 1; i < list.size(); i++) {
chain = maker.Select(chain, type.toName(list.get(i)));
}
return chain;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:20,代码来源:HandleEqualsAndHashCode.java
示例3: handle
import lombok.javac.JavacNode; //导入依赖的package包/类
@Override public void handle(AnnotationValues<NoArgsConstructor> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.NO_ARGS_CONSTRUCTOR_FLAG_USAGE, "@NoArgsConstructor", ConfigurationKeys.ANY_CONSTRUCTOR_FLAG_USAGE, "any @xArgsConstructor");
deleteAnnotationIfNeccessary(annotationNode, NoArgsConstructor.class);
deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
JavacNode typeNode = annotationNode.up();
if (!checkLegality(typeNode, annotationNode, NoArgsConstructor.class.getSimpleName())) return;
List<JCAnnotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@NoArgsConstructor(onConstructor=", annotationNode);
NoArgsConstructor ann = annotation.getInstance();
AccessLevel level = ann.access();
if (level == AccessLevel.NONE) return;
String staticName = ann.staticName();
boolean force = ann.force();
List<JavacNode> fields = force ? findFinalFields(typeNode) : List.<JavacNode>nil();
new HandleConstructor().generateConstructor(typeNode, level, onConstructor, fields, force, staticName, SkipIfConstructorExists.NO, null, annotationNode);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:HandleConstructor.java
示例4: createCanEqual
import lombok.javac.JavacNode; //导入依赖的package包/类
public JCMethodDecl createCanEqual(JavacNode typeNode, JCTree source, List<JCAnnotation> onParam) {
/* protected boolean canEqual(final java.lang.Object other) {
* return other instanceof Outer.Inner.MyType;
* }
*/
JavacTreeMaker maker = typeNode.getTreeMaker();
JCModifiers mods = maker.Modifiers(Flags.PROTECTED, List.<JCAnnotation>nil());
JCExpression returnType = maker.TypeIdent(CTC_BOOLEAN);
Name canEqualName = typeNode.toName("canEqual");
JCExpression objectType = genJavaLangTypeRef(typeNode, "Object");
Name otherName = typeNode.toName("other");
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, typeNode.getContext());
List<JCVariableDecl> params = List.of(maker.VarDef(maker.Modifiers(flags, onParam), otherName, objectType, null));
JCBlock body = maker.Block(0, List.<JCStatement>of(
maker.Return(maker.TypeTest(maker.Ident(otherName), createTypeReference(typeNode)))));
return recursiveSetGeneratedBy(maker.MethodDef(mods, canEqualName, returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source, typeNode.getContext());
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:21,代码来源:HandleEqualsAndHashCode.java
示例5: findFields
import lombok.javac.JavacNode; //导入依赖的package包/类
public static List<JavacNode> findFields(JavacNode typeNode, boolean nullMarked) {
ListBuffer<JavacNode> fields = new ListBuffer<JavacNode>();
for (JavacNode child : typeNode.down()) {
if (child.getKind() != Kind.FIELD) continue;
JCVariableDecl fieldDecl = (JCVariableDecl) child.get();
//Skip fields that start with $
if (fieldDecl.name.toString().startsWith("$")) continue;
long fieldFlags = fieldDecl.mods.flags;
//Skip static fields.
if ((fieldFlags & Flags.STATIC) != 0) continue;
boolean isFinal = (fieldFlags & Flags.FINAL) != 0;
boolean isNonNull = nullMarked && !findAnnotations(child, NON_NULL_PATTERN).isEmpty();
if ((isFinal || isNonNull) && fieldDecl.init == null) fields.append(child);
}
return fields.toList();
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:HandleConstructor.java
示例6: findAllFields
import lombok.javac.JavacNode; //导入依赖的package包/类
public static List<JavacNode> findAllFields(JavacNode typeNode) {
ListBuffer<JavacNode> fields = new ListBuffer<JavacNode>();
for (JavacNode child : typeNode.down()) {
if (child.getKind() != Kind.FIELD) continue;
JCVariableDecl fieldDecl = (JCVariableDecl) child.get();
//Skip fields that start with $
if (fieldDecl.name.toString().startsWith("$")) continue;
long fieldFlags = fieldDecl.mods.flags;
//Skip static fields.
if ((fieldFlags & Flags.STATIC) != 0) continue;
//Skip initialized final fields
boolean isFinal = (fieldFlags & Flags.FINAL) != 0;
if (!isFinal || fieldDecl.init == null) fields.append(child);
}
return fields.toList();
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:HandleConstructor.java
示例7: generateMethods
import lombok.javac.JavacNode; //导入依赖的package包/类
@Override public void generateMethods(SingularData data, JavacNode builderType, JCTree source, boolean fluent, boolean chain) {
if (useGuavaInstead(builderType)) {
guavaMapSingularizer.generateMethods(data, builderType, source, fluent, chain);
return;
}
JavacTreeMaker maker = builderType.getTreeMaker();
JCExpression returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
JCStatement returnStatement = chain ? maker.Return(maker.Ident(builderType.toName("this"))) : null;
generateSingularMethod(maker, returnType, returnStatement, data, builderType, source, fluent);
returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
returnStatement = chain ? maker.Return(maker.Ident(builderType.toName("this"))) : null;
generatePluralMethod(maker, returnType, returnStatement, data, builderType, source, fluent);
returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
returnStatement = chain ? maker.Return(maker.Ident(builderType.toName("this"))) : null;
generateClearMethod(maker, returnType, returnStatement, data, builderType, source);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:21,代码来源:JavacJavaUtilMapSingularizer.java
示例8: cloneParamType
import lombok.javac.JavacNode; //导入依赖的package包/类
protected JCExpression cloneParamType(int index, JavacTreeMaker maker, List<JCExpression> typeArgs, JavacNode builderType, JCTree source) {
if (typeArgs == null || typeArgs.size() <= index) {
return genJavaLangTypeRef(builderType, "Object");
} else {
JCExpression originalType = typeArgs.get(index);
if (originalType.getKind() == Kind.UNBOUNDED_WILDCARD || originalType.getKind() == Kind.SUPER_WILDCARD) {
return genJavaLangTypeRef(builderType, "Object");
} else if (originalType.getKind() == Kind.EXTENDS_WILDCARD) {
try {
return cloneType(maker, (JCExpression) ((JCWildcard) originalType).inner, source, builderType.getContext());
} catch (Exception e) {
return genJavaLangTypeRef(builderType, "Object");
}
} else {
return cloneType(maker, originalType, source, builderType.getContext());
}
}
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:19,代码来源:JavacSingularsRecipes.java
示例9: handle
import lombok.javac.JavacNode; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Setter> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.SETTER_FLAG_USAGE, "@Setter");
Collection<JavacNode> fields = annotationNode.upFromAnnotationToFields();
deleteAnnotationIfNeccessary(annotationNode, Setter.class);
deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
JavacNode node = annotationNode.up();
AccessLevel level = annotation.getInstance().value();
if (level == AccessLevel.NONE || node == null) return;
List<JCAnnotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Setter(onMethod=", annotationNode);
List<JCAnnotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Setter(onParam=", annotationNode);
switch (node.getKind()) {
case FIELD:
createSetterForFields(level, fields, annotationNode, true, onMethod, onParam);
break;
case TYPE:
if (!onMethod.isEmpty()) annotationNode.addError("'onMethod' is not supported for @Setter on a type.");
if (!onParam.isEmpty()) annotationNode.addError("'onParam' is not supported for @Setter on a type.");
generateSetterForType(node, annotationNode, level, false);
break;
}
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:26,代码来源:HandleSetter.java
示例10: generateBulkMethod
import lombok.javac.JavacNode; //导入依赖的package包/类
private void generateBulkMethod(JavacTreeMaker maker, JavacNode tableElement,
Set<String> allStaticMethodNames, String methodName,
String callClassName, String tableClassName,
CollectionType collectionType) {
final String invokeKey = getCreateInvokeKey(callClassName, tableClassName);
if (!allStaticMethodNames.contains(methodName)) {
final JCTree.JCAnnotation invokesAnnotation = maker.Annotation(chainDotsString(tableElement, Invokes.class.getCanonicalName()),
List.<JCTree.JCExpression>of(maker.Literal(invokeKey)));
final JCTree.JCModifiers mods = maker.Modifiers(PUBLIC_STATIC, List.of(invokesAnnotation));
final Name name = tableElement.toName(methodName);
final JCTree.JCExpression returnType = getMagicMethodReturnType(tableElement, callClassName, tableClassName);
final JCTree.JCExpression tableClassType = chainDotsString(tableElement, tableElement.getPackageDeclaration() + "." + tableClassName);
final JCTree.JCExpression paramType = maker.TypeApply(collectionType.genericType(tableElement), List.of(tableClassType));
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, tableElement.getContext());
final JCTree.JCVariableDecl param = maker.VarDef(maker.Modifiers(flags), tableElement.toName("o"), paramType, null);
final JCTree.JCBlock body = defaultMagicMethodBody(maker, tableElement);
final JCTree.JCMethodDecl method = maker.MethodDef(mods, name, returnType,
List.<JCTree.JCTypeParameter>nil(),
List.of(param),
List.<JCTree.JCExpression>nil(),
body,
null);
injectMethod(tableElement, recursiveSetGeneratedBy(method, tableElement.get(), tableElement.getContext()));
}
}
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:26,代码来源:HandleTable.java
示例11: handle
import lombok.javac.JavacNode; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Wither> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITHER_FLAG_USAGE, "@Wither");
Collection<JavacNode> fields = annotationNode.upFromAnnotationToFields();
deleteAnnotationIfNeccessary(annotationNode, Wither.class);
deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
JavacNode node = annotationNode.up();
AccessLevel level = annotation.getInstance().value();
if (level == AccessLevel.NONE || node == null) return;
List<JCAnnotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Wither(onMethod=", annotationNode);
List<JCAnnotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Wither(onParam=", annotationNode);
switch (node.getKind()) {
case FIELD:
createWitherForFields(level, fields, annotationNode, true, onMethod, onParam);
break;
case TYPE:
if (!onMethod.isEmpty()) annotationNode.addError("'onMethod' is not supported for @Wither on a type.");
if (!onParam.isEmpty()) annotationNode.addError("'onParam' is not supported for @Wither on a type.");
generateWitherForType(node, annotationNode, level, false);
break;
}
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:26,代码来源:HandleWither.java
示例12: generateMethods
import lombok.javac.JavacNode; //导入依赖的package包/类
@Override public void generateMethods(SingularData data, JavacNode builderType, JCTree source, boolean fluent, boolean chain) {
if (useGuavaInstead(builderType)) {
guavaListSetSingularizer.generateMethods(data, builderType, source, fluent, chain);
return;
}
JavacTreeMaker maker = builderType.getTreeMaker();
Name thisName = builderType.toName("this");
JCExpression returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
JCStatement returnStatement = chain ? maker.Return(maker.Ident(thisName)) : null;
generateSingularMethod(maker, returnType, returnStatement, data, builderType, source, fluent);
returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
returnStatement = chain ? maker.Return(maker.Ident(thisName)) : null;
generatePluralMethod(maker, returnType, returnStatement, data, builderType, source, fluent);
returnType = chain ? cloneSelfType(builderType) : maker.Type(createVoidType(maker, CTC_VOID));
returnStatement = chain ? maker.Return(maker.Ident(thisName)) : null;
generateClearMethod(maker, returnType, returnStatement, data, builderType, source);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:22,代码来源:JavacJavaUtilListSetSingularizer.java
示例13: generateCleanMethod
import lombok.javac.JavacNode; //导入依赖的package包/类
private JCMethodDecl generateCleanMethod(java.util.List<BuilderFieldData> builderFields, JavacNode type, JCTree source) {
JavacTreeMaker maker = type.getTreeMaker();
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
for (BuilderFieldData bfd : builderFields) {
if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, type, source, statements);
}
}
statements.append(maker.Exec(maker.Assign(maker.Select(maker.Ident(type.toName("this")), type.toName("$lombokUnclean")), maker.Literal(CTC_BOOLEAN, false))));
JCBlock body = maker.Block(0, statements.toList());
return maker.MethodDef(maker.Modifiers(Flags.PUBLIC), type.toName("$lombokClean"), maker.Type(Javac.createVoidType(maker, CTC_VOID)), List.<JCTypeParameter>nil(), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
/*
* if (shouldReturnThis) {
methodType = cloneSelfType(field);
}
if (methodType == null) {
//WARNING: Do not use field.getSymbolTable().voidType - that field has gone through non-backwards compatible API changes within javac1.6.
methodType = treeMaker.Type(Javac.createVoidType(treeMaker, CTC_VOID));
shouldReturnThis = false;
}
*/
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:27,代码来源:HandleBuilder.java
示例14: generateClearMethod
import lombok.javac.JavacNode; //导入依赖的package包/类
private void generateClearMethod(JavacTreeMaker maker, JCExpression returnType, JCStatement returnStatement, SingularData data, JavacNode builderType, JCTree source) {
JCModifiers mods = maker.Modifiers(Flags.PUBLIC);
List<JCTypeParameter> typeParams = List.nil();
List<JCExpression> thrown = List.nil();
List<JCVariableDecl> params = List.nil();
List<JCExpression> jceBlank = List.nil();
JCExpression thisDotField = maker.Select(maker.Ident(builderType.toName("this")), data.getPluralName());
JCExpression thisDotFieldDotClear = maker.Select(maker.Select(maker.Ident(builderType.toName("this")), data.getPluralName()), builderType.toName("clear"));
JCStatement clearCall = maker.Exec(maker.Apply(jceBlank, thisDotFieldDotClear, jceBlank));
JCExpression cond = maker.Binary(CTC_NOT_EQUAL, thisDotField, maker.Literal(CTC_BOT, null));
JCStatement ifSetCallClear = maker.If(cond, clearCall, null);
List<JCStatement> statements = returnStatement != null ? List.of(ifSetCallClear, returnStatement) : List.of(ifSetCallClear);
JCBlock body = maker.Block(0, statements);
Name methodName = builderType.toName(HandlerUtil.buildAccessorName("clear", data.getPluralName().toString()));
JCMethodDecl method = maker.MethodDef(mods, methodName, returnType, typeParams, params, thrown, body, null);
injectMethod(builderType, method);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:20,代码来源:JavacJavaUtilListSetSingularizer.java
示例15: cloneSelfType
import lombok.javac.JavacNode; //导入依赖的package包/类
public static JCExpression cloneSelfType(JavacNode childOfType) {
JavacNode typeNode = childOfType;
JavacTreeMaker maker = childOfType.getTreeMaker();
while (typeNode != null && typeNode.getKind() != Kind.TYPE) typeNode = typeNode.up();
if (typeNode != null && typeNode.get() instanceof JCClassDecl) {
JCClassDecl type = (JCClassDecl) typeNode.get();
ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>();
if (!type.typarams.isEmpty()) {
for (JCTypeParameter tp : type.typarams) {
typeArgs.append(maker.Ident(tp.name));
}
return maker.TypeApply(maker.Ident(type.name), typeArgs.toList());
} else {
return maker.Ident(type.name);
}
} else {
return null;
}
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:20,代码来源:JavacHandlerUtil.java
示例16: handle
import lombok.javac.JavacNode; //导入依赖的package包/类
@Override public void handle(AnnotationValues<SneakyThrows> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.SNEAKY_THROWS_FLAG_USAGE, "@SneakyThrows");
deleteAnnotationIfNeccessary(annotationNode, SneakyThrows.class);
Collection<String> exceptionNames = annotation.getRawExpressions("value");
if (exceptionNames.isEmpty()) {
exceptionNames = Collections.singleton("java.lang.Throwable");
}
java.util.List<String> exceptions = new ArrayList<String>();
for (String exception : exceptionNames) {
if (exception.endsWith(".class")) exception = exception.substring(0, exception.length() - 6);
exceptions.add(exception);
}
JavacNode owner = annotationNode.up();
switch (owner.getKind()) {
case METHOD:
handleMethod(annotationNode, (JCMethodDecl)owner.get(), exceptions);
break;
default:
annotationNode.addError("@SneakyThrows is legal only on methods and constructors.");
break;
}
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:26,代码来源:HandleSneakyThrows.java
示例17: handle
import lombok.javac.JavacNode; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Data> annotation, JCAnnotation ast, JavacNode annotationNode) {
handleFlagUsage(annotationNode, ConfigurationKeys.DATA_FLAG_USAGE, "@Data");
deleteAnnotationIfNeccessary(annotationNode, Data.class);
JavacNode typeNode = annotationNode.up();
boolean notAClass = !isClass(typeNode);
if (notAClass) {
annotationNode.addError("@Data is only supported on a class.");
return;
}
String staticConstructorName = annotation.getInstance().staticConstructor();
// TODO move this to the end OR move it to the top in eclipse.
new HandleConstructor().generateRequiredArgsConstructor(typeNode, AccessLevel.PUBLIC, staticConstructorName, SkipIfConstructorExists.YES, annotationNode);
new HandleGetter().generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true);
new HandleSetter().generateSetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true);
new HandleEqualsAndHashCode().generateEqualsAndHashCodeForType(typeNode, annotationNode);
new HandleToString().generateToStringForType(typeNode, annotationNode);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:22,代码来源:HandleData.java
示例18: chainDots
import lombok.javac.JavacNode; //导入依赖的package包/类
/**
* In javac, dotted access of any kind, from {@code java.lang.String} to {@code var.methodName}
* is represented by a fold-left of {@code Select} nodes with the leftmost string represented by
* a {@code Ident} node. This method generates such an expression.
* <p>
* The position of the generated node(s) will be equal to the {@code pos} parameter.
*
* For example, maker.Select(maker.Select(maker.Ident(NAME[java]), NAME[lang]), NAME[String]).
*
* @see com.sun.tools.javac.tree.JCTree.JCIdent
* @see com.sun.tools.javac.tree.JCTree.JCFieldAccess
*/
public static JCExpression chainDots(JavacNode node, int pos, String elem1, String elem2, String... elems) {
assert elems != null;
JavacTreeMaker maker = node.getTreeMaker();
if (pos != -1) maker = maker.at(pos);
JCExpression e = null;
if (elem1 != null) e = maker.Ident(node.toName(elem1));
if (elem2 != null) e = e == null ? maker.Ident(node.toName(elem2)) : maker.Select(e, node.toName(elem2));
for (int i = 0 ; i < elems.length ; i++) {
e = e == null ? maker.Ident(node.toName(elems[i])) : maker.Select(e, node.toName(elems[i]));
}
assert e != null;
return e;
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:29,代码来源:JavacHandlerUtil.java
示例19: generateBuilderMethod
import lombok.javac.JavacNode; //导入依赖的package包/类
public JCMethodDecl generateBuilderMethod(boolean isStatic, String builderMethodName, String builderClassName, JavacNode type, List<JCTypeParameter> typeParams) {
JavacTreeMaker maker = type.getTreeMaker();
ListBuffer<JCExpression> typeArgs = new ListBuffer<JCExpression>();
for (JCTypeParameter typeParam : typeParams) {
typeArgs.append(maker.Ident(typeParam.name));
}
JCExpression call = maker.NewClass(null, List.<JCExpression>nil(), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), List.<JCExpression>nil(), null);
JCStatement statement = maker.Return(call);
JCBlock body = maker.Block(0, List.<JCStatement>of(statement));
int modifiers = Flags.PUBLIC;
if (isStatic) modifiers |= Flags.STATIC;
return maker.MethodDef(maker.Modifiers(modifiers), type.toName(builderMethodName), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), copyTypeParams(maker, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null);
}
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:HandleBuilder.java
示例20: generateDeleteTable
import lombok.javac.JavacNode; //导入依赖的package包/类
private void generateDeleteTable(JavacTreeMaker maker, JavacNode tableElement, Set<String> allStaticMethodNames, String tableClassName) {
final String callClassName = CLASS_DELETE_TABLE;
final String methodName = METHOD_DELETE_TABLE;
final String invokeKey = getCreateInvokeKey(callClassName, tableClassName);
if (!allStaticMethodNames.contains(methodName)) {
final JCTree.JCAnnotation invokesAnnotation = maker.Annotation(chainDotsString(tableElement, Invokes.class.getCanonicalName()),
List.<JCTree.JCExpression>of(maker.Literal(invokeKey)));
final JCTree.JCModifiers mods = maker.Modifiers(PUBLIC_STATIC, List.of(invokesAnnotation));
final Name name = tableElement.toName(methodName);
final JCTree.JCExpression returnType = getMagicMethodReturnType(tableElement, callClassName, tableClassName);
final JCTree.JCBlock body = defaultMagicMethodBody(maker, tableElement);
final JCTree.JCMethodDecl method = maker.MethodDef(mods, name, returnType,
List.<JCTree.JCTypeParameter>nil(),
List.<JCTree.JCVariableDecl>nil(),
List.<JCTree.JCExpression>nil(),
body,
null);
injectMethod(tableElement, recursiveSetGeneratedBy(method, tableElement.get(), tableElement.getContext()));
}
}
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:21,代码来源:HandleTable.java
注:本文中的lombok.javac.JavacNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论