Source:
public boolean checkAvailable(@NotNull Editor editor, @NotNull PsiFile file, @NotNull MoveInfo info, boolean down) { if (!(file instanceof GoFile || super.checkAvailable(editor, file, info, down))) return false; Pair<PsiElement, PsiElement> primeElementRange = getElementRange(editor, file, getLineRangeFromSelection(editor)); if (primeElementRange == null) return false; PsiElement commonParent = primeElementRange.first.isEquivalentTo(primeElementRange.second) ? primeElementRange.first.getParent() : PsiTreeUtil.findCommonParent(primeElementRange.first, primeElementRange.second); if (commonParent == null) return false; Pair<PsiElement, PsiElement> elementRange = getLogicElementRange(primeElementRange, commonParent); if (elementRange == null) return false; if (commonParent == elementRange.first) commonParent = commonParent.getParent(); info.toMove = new LineRange(elementRange.first, elementRange.second); if (elementRange.first instanceof GoTopLevelDeclaration) { if (!file.isValid()) { return true; } GoTopLevelDeclaration toMove2 = (GoTopLevelDeclaration)getElementOfTypeAfter(commonParent, elementRange, GoTopLevelDeclaration.class, down); info.toMove2 = toMove2 == null ? null : new LineRange(toMove2); return true; } if (commonParent instanceof GoImportList) { GoImportDeclaration toMove2 = (GoImportDeclaration)getElementOfTypeAfter(commonParent, elementRange, GoImportDeclaration.class, down); info.toMove2 = toMove2 == null ? null : new LineRange(toMove2); return true; } setUpInfo(info, elementRange, commonParent, down); return true; }

Target:
public boolean checkAvailable(@NotNull Editor editor, @NotNull PsiFile file, @NotNull MoveInfo info, boolean down) { if (!(file instanceof GoFile && super.checkAvailable(editor, file, info, down))) return false; Pair<PsiElement, PsiElement> primeElementRangePair = getElementRange(editor, file, getLineRangeFromSelection(editor)); if (primeElementRangePair == null) return false; ASTNode firstNode = TreeUtil.findFirstLeaf(primeElementRangePair.first.getNode()); ASTNode lastNode = TreeUtil.findLastLeaf(primeElementRangePair.second.getNode()); if (firstNode == null || lastNode == null) return false; Couple<PsiElement> primeElementRange = Couple.of(firstNode.getPsi(), lastNode.getPsi()); PsiElement commonParent = primeElementRange.first.isEquivalentTo(primeElementRange.second) ? primeElementRange.first.getParent() : PsiTreeUtil.findCommonParent(primeElementRange.first, primeElementRange.second); if (commonParent == null) return false; Couple<PsiElement> elementRange = getLogicElementRange(primeElementRange, commonParent); if (elementRange == null) return false; if (commonParent == elementRange.first) commonParent = commonParent.getParent(); info.toMove = new LineRange(elementRange.first, elementRange.second); if (elementRange.first instanceof GoTopLevelDeclaration && commonParent instanceof GoFile) { GoTopLevelDeclaration toMove2 = (GoTopLevelDeclaration)getNeighborOfType(commonParent, elementRange, GoTopLevelDeclaration.class, down); info.toMove2 = toMove2 == null ? null : new LineRange(toMove2); return true; } if (commonParent instanceof GoImportList) { GoImportDeclaration toMove2 = (GoImportDeclaration)getNeighborOfType(commonParent, elementRange, GoImportDeclaration.class, down); info.toMove2 = toMove2 == null ? null : new LineRange(toMove2); return true; } return setUpInfo(info, elementRange, commonParent, down); }