@Override
@NotNull
public PsiElement insertItemIntoListRemoveRedundantCommas(
@NotNull final PyElement list,
@Nullable final PyExpression afterThis,
@NotNull final PyExpression toInsert) {
// TODO: #insertItemIntoList is probably buggy. In such case, fix it and get rid of this method
final PsiElement result = insertItemIntoList(list, afterThis, toInsert);
final LeafPsiElement[] leafs = PsiTreeUtil.getChildrenOfType(list, LeafPsiElement.class);
if (leafs != null) {
final Deque<LeafPsiElement> commas = Queues.newArrayDeque(Collections2.filter(Arrays.asList(leafs), COMMAS_ONLY));
if (!commas.isEmpty()) {
final LeafPsiElement lastComma = commas.getLast();
if (PsiTreeUtil.getNextSiblingOfType(lastComma, PyExpression.class) == null) { //Comma has no expression after it
lastComma.delete();
}
}
}
return result;
}
PyElementGeneratorImpl.java 文件源码
java
阅读 37
收藏 0
点赞 0
评论 0
项目:intellij-ce-playground
作者:
评论列表
文章目录