void (String name, boolean doSet) { if (doSet) { if (isEmptyModifierList()) { final PsiElement nextSibling = getNextSibling(); if (nextSibling != null && !PsiImplUtil.isWhiteSpaceOrNls(nextSibling)) { getNode().getTreeParent().addLeaf(TokenType.WHITE_SPACE, " ", nextSibling.getNode()); } } PsiElement modifier = GroovyPsiElementFactory.getInstance(getProject()).createModifierFromText(name); PsiElement anchor = findAnchor(name); addAfter(modifier, anchor); } else { final PsiElement[] modifiers = findChildrenByType(TokenSets.MODIFIERS, PsiElement.class); for (PsiElement modifier : modifiers) { if (name.equals(modifier.getText())) { deleteChildRange(modifier, modifier); break; } } if (isEmptyModifierList()) { final PsiElement nextSibling = getNextSibling(); if (nextSibling != null && PsiImplUtil.isWhiteSpaceOrNls(nextSibling)) { nextSibling.delete(); } } } }