Java Code Examples for lombok.javac.JavacNode#getKind()

The following examples show how to use lombok.javac.JavacNode#getKind() . 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: JavacHandlerUtil.java    From EasyMPermission with MIT License 6 votes vote down vote up
/**
 * Searches the given field node for annotations and returns each one that matches the provided regular expression pattern.
 * 
 * Only the simple name is checked - the package and any containing class are ignored.
 */
public static List<JCAnnotation> findAnnotations(JavacNode fieldNode, Pattern namePattern) {
	ListBuffer<JCAnnotation> result = new ListBuffer<JCAnnotation>();
	for (JavacNode child : fieldNode.down()) {
		if (child.getKind() == Kind.ANNOTATION) {
			JCAnnotation annotation = (JCAnnotation) child.get();
			String name = annotation.annotationType.toString();
			int idx = name.lastIndexOf(".");
			String suspect = idx == -1 ? name : name.substring(idx + 1);
			if (namePattern.matcher(suspect).matches()) {
				result.append(annotation);
			}
		}
	}	
	return result.toList();
}
 
Example 2
Source File: JavacHandlerUtil.java    From EasyMPermission with MIT License 6 votes vote down vote up
private static Comment createJavadocComment(final String text, final JavacNode field) {
	return new Comment() {
		@Override public String getText() {
			return text;
		}
		
		@Override public int getSourcePos(int index) {
			return -1;
		}
		
		@Override public CommentStyle getStyle() {
			return CommentStyle.JAVADOC;
		}
		
		@Override public boolean isDeprecated() {
			return text.contains("@deprecated") && field.getKind() == Kind.FIELD && isFieldDeprecated(field);
		}
	};
}
 
Example 3
Source File: JavacHandlerUtil.java    From EasyMPermission with MIT License 6 votes vote down vote up
/**
 * Given a list of field names and a node referring to a type, finds each name in the list that does not match a field within the type.
 */
public static List<Integer> createListOfNonExistentFields(List<String> list, JavacNode type, boolean excludeStandard, boolean excludeTransient) {
	boolean[] matched = new boolean[list.size()];
	
	for (JavacNode child : type.down()) {
		if (list.isEmpty()) break;
		if (child.getKind() != Kind.FIELD) continue;
		JCVariableDecl field = (JCVariableDecl)child.get();
		if (excludeStandard) {
			if ((field.mods.flags & Flags.STATIC) != 0) continue;
			if (field.name.toString().startsWith("$")) continue;
		}
		if (excludeTransient && (field.mods.flags & Flags.TRANSIENT) != 0) continue;
		
		int idx = list.indexOf(child.getName());
		if (idx > -1) matched[idx] = true;
	}
	
	ListBuffer<Integer> problematic = new ListBuffer<Integer>();
	for (int i = 0 ; i < list.size() ; i++) {
		if (!matched[i]) problematic.append(i);
	}
	
	return problematic.toList();
}
 
Example 4
Source File: JavacHandlerUtil.java    From EasyMPermission with MIT License 6 votes vote down vote up
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;
	}
}
 
Example 5
Source File: HandleUtilityClass.java    From EasyMPermission with MIT License 5 votes vote down vote up
private static boolean checkLegality(JavacNode typeNode, JavacNode errorNode) {
	JCClassDecl typeDecl = null;
	if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get();
	long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags;
	boolean notAClass = (modifiers & (Flags.INTERFACE | Flags.ANNOTATION | Flags.ENUM)) != 0;
	
	if (typeDecl == null || notAClass) {
		errorNode.addError("@UtilityClass is only supported on a class (can't be an interface, enum, or annotation).");
		return false;
	}
	
	// It might be an inner class. This is okay, but only if it is / can be a static inner class. Thus, all of its parents have to be static inner classes until the top-level.
	JavacNode typeWalk = typeNode;
	while (true) {
		typeWalk = typeWalk.up();
		switch (typeWalk.getKind()) {
		case TYPE:
			JCClassDecl typeDef = (JCClassDecl) typeWalk.get();
			if ((typeDef.mods.flags & (Flags.STATIC | Flags.ANNOTATION | Flags.ENUM | Flags.INTERFACE)) != 0) continue;
			if (typeWalk.up().getKind() == Kind.COMPILATION_UNIT) return true;
			errorNode.addError("@UtilityClass automatically makes the class static, however, this class cannot be made static.");
			return false;
		case COMPILATION_UNIT:
			return true;
		default:
			errorNode.addError("@UtilityClass cannot be placed on a method local or anonymous inner class, or any class nested in such a class.");
			return false;
		}
	}
}
 
Example 6
Source File: JavacHandlerUtil.java    From EasyMPermission with MIT License 5 votes vote down vote up
private static void deleteAnnotationIfNeccessary0(JavacNode annotation, Class<? extends Annotation>... annotationTypes) {
	if (inNetbeansEditor(annotation)) return;
	if (!annotation.shouldDeleteLombokAnnotations()) return;
	JavacNode parentNode = annotation.directUp();
	switch (parentNode.getKind()) {
	case FIELD:
	case ARGUMENT:
	case LOCAL:
		JCVariableDecl variable = (JCVariableDecl) parentNode.get();
		variable.mods.annotations = filterList(variable.mods.annotations, annotation.get());
		break;
	case METHOD:
		JCMethodDecl method = (JCMethodDecl) parentNode.get();
		method.mods.annotations = filterList(method.mods.annotations, annotation.get());
		break;
	case TYPE:
		try {
			JCClassDecl type = (JCClassDecl) parentNode.get();
			type.mods.annotations = filterList(type.mods.annotations, annotation.get());
		} catch (ClassCastException e) {
			//something rather odd has been annotated. Better to just break only delombok instead of everything.
		}
		break;
	default:
		//This really shouldn't happen, but if it does, better just break delombok instead of breaking everything.
		return;
	}
	
	parentNode.getAst().setChanged();
	for (Class<?> annotationType : annotationTypes) {
		deleteImportFromCompilationUnit(annotation, annotationType.getName());
	}
}
 
Example 7
Source File: HandleFieldDefaults.java    From EasyMPermission with MIT License 5 votes vote down vote up
public boolean generateFieldDefaultsForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean makeFinal, boolean checkForTypeLevelFieldDefaults) {
	if (checkForTypeLevelFieldDefaults) {
		if (hasAnnotation(FieldDefaults.class, typeNode)) {
			//The annotation will make it happen, so we can skip it.
			return true;
		}
	}
	
	JCClassDecl typeDecl = null;
	if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get();
	long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags;
	boolean notAClass = (modifiers & (Flags.INTERFACE | Flags.ANNOTATION)) != 0;
	
	if (typeDecl == null || notAClass) {
		errorNode.addError("@FieldDefaults is only supported on a class or an enum.");
		return false;
	}
	
	for (JavacNode field : typeNode.down()) {
		if (field.getKind() != Kind.FIELD) continue;
		JCVariableDecl fieldDecl = (JCVariableDecl) field.get();
		//Skip fields that start with $
		if (fieldDecl.name.toString().startsWith("$")) continue;
		
		setFieldDefaultsForField(field, errorNode.get(), level, makeFinal);
	}
	
	return true;
}
 
Example 8
Source File: HandleBuilder.java    From EasyMPermission with MIT License 5 votes vote down vote up
public JavacNode findInnerClass(JavacNode parent, String name) {
	for (JavacNode child : parent.down()) {
		if (child.getKind() != Kind.TYPE) continue;
		JCClassDecl td = (JCClassDecl) child.get();
		if (td.name.contentEquals(name)) return child;
	}
	return null;
}
 
Example 9
Source File: HandleSetter.java    From EasyMPermission with MIT License 5 votes vote down vote up
public void generateSetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelSetter) {
	if (checkForTypeLevelSetter) {
		if (hasAnnotation(Setter.class, typeNode)) {
			//The annotation will make it happen, so we can skip it.
			return;
		}
	}
	
	JCClassDecl typeDecl = null;
	if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get();
	long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags;
	boolean notAClass = (modifiers & (Flags.INTERFACE | Flags.ANNOTATION | Flags.ENUM)) != 0;
	
	if (typeDecl == null || notAClass) {
		errorNode.addError("@Setter is only supported on a class or a field.");
		return;
	}
	
	for (JavacNode field : typeNode.down()) {
		if (field.getKind() != Kind.FIELD) continue;
		JCVariableDecl fieldDecl = (JCVariableDecl) field.get();
		//Skip fields that start with $
		if (fieldDecl.name.toString().startsWith("$")) continue;
		//Skip static fields.
		if ((fieldDecl.mods.flags & Flags.STATIC) != 0) continue;
		//Skip final fields.
		if ((fieldDecl.mods.flags & Flags.FINAL) != 0) continue;
		
		generateSetterForField(field, errorNode, level);
	}
}
 
Example 10
Source File: HandleUtilityClass.java    From EasyMPermission with MIT License 5 votes vote down vote up
private void changeModifiersAndGenerateConstructor(JavacNode typeNode, JavacNode errorNode) {
	JCClassDecl classDecl = (JCClassDecl) typeNode.get();
	
	boolean makeConstructor = true;
	
	classDecl.mods.flags |= Flags.FINAL;
	
	boolean markStatic = true;
	
	if (typeNode.up().getKind() == Kind.COMPILATION_UNIT) markStatic = false;
	if (markStatic && typeNode.up().getKind() == Kind.TYPE) {
		JCClassDecl typeDecl = (JCClassDecl) typeNode.up().get();
		if ((typeDecl.mods.flags & Flags.INTERFACE) != 0) markStatic = false;
	}
	
	if (markStatic) classDecl.mods.flags |= Flags.STATIC;
	
	for (JavacNode element : typeNode.down()) {
		if (element.getKind() == Kind.FIELD) {
			JCVariableDecl fieldDecl = (JCVariableDecl) element.get();
			fieldDecl.mods.flags |= Flags.STATIC;
		} else if (element.getKind() == Kind.METHOD) {
			JCMethodDecl methodDecl = (JCMethodDecl) element.get();
			if (methodDecl.name.contentEquals("<init>")) {
				if (getGeneratedBy(methodDecl) == null && (methodDecl.mods.flags & Flags.GENERATEDCONSTR) == 0) {
					element.addError("@UtilityClasses cannot have declared constructors.");
					makeConstructor = false;
					continue;
				}
			}
			
			methodDecl.mods.flags |= Flags.STATIC;
		} else if (element.getKind() == Kind.TYPE) {
			JCClassDecl innerClassDecl = (JCClassDecl) element.get();
			innerClassDecl.mods.flags |= Flags.STATIC;
		}
	}
	
	if (makeConstructor) createPrivateDefaultConstructor(typeNode);
}
 
Example 11
Source File: HandleColumn.java    From sqlitemagic with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(AnnotationValues<Column> annotation, JCTree.JCAnnotation ast, JavacNode annotationNode) {
  // FIXME: 9.04.16 remove
  JavacNode node = annotationNode.up();
  if (node.getKind() == AST.Kind.FIELD) {
    JCTree.JCVariableDecl fieldDec = (JCTree.JCVariableDecl) node.get();
    if ((fieldDec.mods.flags & Flags.PRIVATE) != 0 && (fieldDec.mods.flags & (Flags.STATIC | Flags.FINAL)) == 0) {
      fieldDec.mods.flags &= ~Flags.PRIVATE;
    }
    node.rebuild();
  }
}
 
Example 12
Source File: HandleGetter.java    From EasyMPermission with MIT License 5 votes vote down vote up
@Override public void handle(AnnotationValues<Getter> annotation, JCAnnotation ast, JavacNode annotationNode) {
	handleFlagUsage(annotationNode, ConfigurationKeys.GETTER_FLAG_USAGE, "@Getter");
	
	Collection<JavacNode> fields = annotationNode.upFromAnnotationToFields();
	deleteAnnotationIfNeccessary(annotationNode, Getter.class);
	deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
	JavacNode node = annotationNode.up();
	Getter annotationInstance = annotation.getInstance();
	AccessLevel level = annotationInstance.value();
	boolean lazy = annotationInstance.lazy();
	if (lazy) handleFlagUsage(annotationNode, ConfigurationKeys.GETTER_LAZY_FLAG_USAGE, "@Getter(lazy=true)");
	
	if (level == AccessLevel.NONE) {
		if (lazy) annotationNode.addWarning("'lazy' does not work with AccessLevel.NONE.");
		return;
	}
	
	if (node == null) return;
	
	List<JCAnnotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Getter(onMethod=", annotationNode);
	
	switch (node.getKind()) {
	case FIELD:
		createGetterForFields(level, fields, annotationNode, true, lazy, onMethod);
		break;
	case TYPE:
		if (!onMethod.isEmpty()) {
			annotationNode.addError("'onMethod' is not supported for @Getter on a type.");
		}
		if (lazy) annotationNode.addError("'lazy' is not supported for @Getter on a type.");
		generateGetterForType(node, annotationNode, level, false);
		break;
	}
}
 
Example 13
Source File: HandleBuilder.java    From EasyMPermission with MIT License 5 votes vote down vote up
public void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JCTree source) {
	int len = builderFields.size();
	java.util.List<JavacNode> existing = new ArrayList<JavacNode>();
	for (JavacNode child : builderType.down()) {
		if (child.getKind() == Kind.FIELD) existing.add(child);
	}
	
	top:
	for (int i = len - 1; i >= 0; i--) {
		BuilderFieldData bfd = builderFields.get(i);
		if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
			bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType, source));
		} else {
			for (JavacNode exists : existing) {
				Name n = ((JCVariableDecl) exists.get()).name;
				if (n.equals(bfd.name)) {
					bfd.createdFields.add(exists);
					continue top;
				}
			}
			JavacTreeMaker maker = builderType.getTreeMaker();
			JCModifiers mods = maker.Modifiers(Flags.PRIVATE);
			JCVariableDecl newField = maker.VarDef(mods, bfd.name, cloneType(maker, bfd.type, source, builderType.getContext()), null);
			bfd.createdFields.add(injectFieldAndMarkGenerated(builderType, newField));
		}
	}
}
 
Example 14
Source File: HandleConstructor.java    From EasyMPermission with MIT License 5 votes vote down vote up
public void generateConstructor(JavacNode typeNode, AccessLevel level, List<JCAnnotation> onConstructor, List<JavacNode> fields, String staticName, SkipIfConstructorExists skipIfConstructorExists, Boolean suppressConstructorProperties, JavacNode source) {
	boolean staticConstrRequired = staticName != null && !staticName.equals("");
	
	if (skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return;
	if (skipIfConstructorExists != SkipIfConstructorExists.NO) {
		for (JavacNode child : typeNode.down()) {
			if (child.getKind() == Kind.ANNOTATION) {
				boolean skipGeneration = annotationTypeMatches(NoArgsConstructor.class, child) ||
						annotationTypeMatches(AllArgsConstructor.class, child) ||
						annotationTypeMatches(RequiredArgsConstructor.class, child);
				
				if (!skipGeneration && skipIfConstructorExists == SkipIfConstructorExists.YES) {
					skipGeneration = annotationTypeMatches(Builder.class, child);
				}
				
				if (skipGeneration) {
					if (staticConstrRequired) {
						// @Data has asked us to generate a constructor, but we're going to skip this instruction, as an explicit 'make a constructor' annotation
						// will take care of it. However, @Data also wants a specific static name; this will be ignored; the appropriate way to do this is to use
						// the 'staticName' parameter of the @XArgsConstructor you've stuck on your type.
						// We should warn that we're ignoring @Data's 'staticConstructor' param.
						source.addWarning("Ignoring static constructor name: explicit @XxxArgsConstructor annotation present; its `staticName` parameter will be used.");
					}
					return;
				}
			}
		}
	}
	
	JCMethodDecl constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, onConstructor, typeNode, fields, suppressConstructorProperties, source);
	injectMethod(typeNode, constr);
	if (staticConstrRequired) {
		JCMethodDecl staticConstr = createStaticConstructor(staticName, level, typeNode, fields, source.get());
		injectMethod(typeNode, staticConstr);
	}
}
 
Example 15
Source File: HandleBuilder.java    From EasyMPermission with MIT License 5 votes vote down vote up
private void makeSimpleSetterMethodForBuilder(JavacNode builderType, JavacNode fieldNode, JavacNode source, boolean fluent, boolean chain) {
	Name fieldName = ((JCVariableDecl) fieldNode.get()).name;
	
	for (JavacNode child : builderType.down()) {
		if (child.getKind() != Kind.METHOD) continue;
		Name existingName = ((JCMethodDecl) child.get()).name;
		if (existingName.equals(fieldName)) return;
	}
	
	String setterName = fluent ? fieldNode.getName() : HandlerUtil.buildAccessorName("set", fieldNode.getName());
	
	JavacTreeMaker maker = fieldNode.getTreeMaker();
	JCMethodDecl newMethod = HandleSetter.createSetter(Flags.PUBLIC, fieldNode, maker, setterName, chain, source, List.<JCAnnotation>nil(), List.<JCAnnotation>nil());
	injectMethod(builderType, newMethod);
}
 
Example 16
Source File: HandleLog.java    From EasyMPermission with MIT License 5 votes vote down vote up
public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode, String loggerTopic) {
	deleteAnnotationIfNeccessary(annotationNode, framework.getAnnotationClass());

	JavacNode typeNode = annotationNode.up();
	switch (typeNode.getKind()) {
	case TYPE:
		String logFieldName = annotationNode.getAst().readConfiguration(ConfigurationKeys.LOG_ANY_FIELD_NAME);
		if (logFieldName == null) logFieldName = "log";
		
		boolean useStatic = !Boolean.FALSE.equals(annotationNode.getAst().readConfiguration(ConfigurationKeys.LOG_ANY_FIELD_IS_STATIC));
		
		if ((((JCClassDecl)typeNode.get()).mods.flags & Flags.INTERFACE) != 0) {
			annotationNode.addError("@Log is legal only on classes and enums.");
			return;
		}
		if (fieldExists(logFieldName, typeNode) != MemberExistsResult.NOT_EXISTS) {
			annotationNode.addWarning("Field '" + logFieldName + "' already exists.");
			return;
		}

		JCFieldAccess loggingType = selfType(typeNode);
		createField(framework, typeNode, loggingType, annotationNode.get(), logFieldName, useStatic, loggerTopic);
		break;
	default:
		annotationNode.addError("@Log is legal only on types.");
		break;
	}
}
 
Example 17
Source File: HandleTable.java    From sqlitemagic with Apache License 2.0 5 votes vote down vote up
private Set<String> findAllMethodNames(JavacNode typeNode) {
  Set<String> methodNames = new LinkedHashSet<>();
  for (JavacNode child : typeNode.down()) {
    if (child.getKind() != AST.Kind.METHOD) continue;
    JCTree.JCMethodDecl methodDecl = (JCTree.JCMethodDecl) child.get();
    long methodFlags = methodDecl.mods.flags;
    //Skip static methods
    if ((methodFlags & Flags.STATIC) != 0) continue;
    methodNames.add(child.getName());
  }
  return methodNames;
}
 
Example 18
Source File: HandleTable.java    From sqlitemagic with Apache License 2.0 5 votes vote down vote up
private static Set<String> findAllStaticMethodNames(JavacNode typeNode) {
  Set<String> methodNames = new LinkedHashSet<>();
  for (JavacNode child : typeNode.down()) {
    if (child.getKind() != AST.Kind.METHOD) continue;
    JCTree.JCMethodDecl methodDecl = (JCTree.JCMethodDecl) child.get();
    long methodFlags = methodDecl.mods.flags;
    //Take static methods
    if ((methodFlags & Flags.STATIC) != 0) {
      methodNames.add(child.getName());
    }
  }
  return methodNames;
}
 
Example 19
Source File: HandleGetter.java    From EasyMPermission with MIT License 4 votes vote down vote up
public void createGetterForField(AccessLevel level,
		JavacNode fieldNode, JavacNode source, boolean whineIfExists, boolean lazy, List<JCAnnotation> onMethod) {
	if (fieldNode.getKind() != Kind.FIELD) {
		source.addError("@Getter is only supported on a class or a field.");
		return;
	}
	
	JCVariableDecl fieldDecl = (JCVariableDecl)fieldNode.get();
	
	if (lazy) {
		if ((fieldDecl.mods.flags & Flags.PRIVATE) == 0 || (fieldDecl.mods.flags & Flags.FINAL) == 0) {
			source.addError("'lazy' requires the field to be private and final.");
			return;
		}
		if (fieldDecl.init == null) {
			source.addError("'lazy' requires field initialization.");
			return;
		}
	}
	
	String methodName = toGetterName(fieldNode);
	
	if (methodName == null) {
		source.addWarning("Not generating getter for this field: It does not fit your @Accessors prefix list.");
		return;
	}
	
	for (String altName : toAllGetterNames(fieldNode)) {
		switch (methodExists(altName, fieldNode, false, 0)) {
		case EXISTS_BY_LOMBOK:
			return;
		case EXISTS_BY_USER:
			if (whineIfExists) {
				String altNameExpl = "";
				if (!altName.equals(methodName)) altNameExpl = String.format(" (%s)", altName);
				source.addWarning(
					String.format("Not generating %s(): A method with that name already exists%s", methodName, altNameExpl));
			}
			return;
		default:
		case NOT_EXISTS:
			//continue scanning the other alt names.
		}
	}
	
	long access = toJavacModifier(level) | (fieldDecl.mods.flags & Flags.STATIC);
	
	injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), source.get(), lazy, onMethod));
}
 
Example 20
Source File: HandleSetter.java    From EasyMPermission with MIT License 4 votes vote down vote up
public void createSetterForField(AccessLevel level, JavacNode fieldNode, JavacNode sourceNode, boolean whineIfExists, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) {
	if (fieldNode.getKind() != Kind.FIELD) {
		fieldNode.addError("@Setter is only supported on a class or a field.");
		return;
	}
	
	JCVariableDecl fieldDecl = (JCVariableDecl)fieldNode.get();
	String methodName = toSetterName(fieldNode);
	
	if (methodName == null) {
		fieldNode.addWarning("Not generating setter for this field: It does not fit your @Accessors prefix list.");
		return;
	}
	
	if ((fieldDecl.mods.flags & Flags.FINAL) != 0) {
		fieldNode.addWarning("Not generating setter for this field: Setters cannot be generated for final fields.");
		return;
	}
	
	for (String altName : toAllSetterNames(fieldNode)) {
		switch (methodExists(altName, fieldNode, false, 1)) {
		case EXISTS_BY_LOMBOK:
			return;
		case EXISTS_BY_USER:
			if (whineIfExists) {
				String altNameExpl = "";
				if (!altName.equals(methodName)) altNameExpl = String.format(" (%s)", altName);
				fieldNode.addWarning(
					String.format("Not generating %s(): A method with that name already exists%s", methodName, altNameExpl));
			}
			return;
		default:
		case NOT_EXISTS:
			//continue scanning the other alt names.
		}
	}
	
	long access = toJavacModifier(level) | (fieldDecl.mods.flags & Flags.STATIC);
	
	JCMethodDecl createdSetter = createSetter(access, fieldNode, fieldNode.getTreeMaker(), sourceNode, onMethod, onParam);
	injectMethod(fieldNode.up(), createdSetter);
}