From 0853b2fc76312eb2f041e376f3a60728fa59218d Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 31 Oct 2012 18:32:38 +0400 Subject: [PATCH] cleanup --- .../com/intellij/openapi/editor/impl/DocumentImpl.java | 2 +- .../intellij/psi/impl/source/tree/CompositeElement.java | 2 +- .../editorActions/moveUpDown/StatementUpDownMover.java | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index 0833ff7b9313..4ef6644c13fa 100644 --- a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -377,8 +377,8 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { @Override public void moveText(int srcStart, int srcEnd, int dstOffset) { assertBounds(srcStart, srcEnd); - ProperTextRange srcRange = new ProperTextRange(srcStart, srcEnd); if (dstOffset == srcEnd) return; + ProperTextRange srcRange = new ProperTextRange(srcStart, srcEnd); assert !srcRange.containsOffset(dstOffset) : String.format("Can't perform text move from range [%d; %d) to offset %d", srcStart, srcEnd, dstOffset); diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java index 09b3e324b1ef..3e358f948f73 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java @@ -283,7 +283,7 @@ public class CompositeElement extends TreeElement { final int len = getTextLength(); if (startStamp != myModificationsCount) { - throw new AssertionError("Tree changed while calculating text. startStamp:"+startStamp+"; current:"+myModificationsCount+"; myHC:"+myHC+"; assertThreading:"+ASSERT_THREADING+"; Thread.holdsLock(START_OFFSET_LOCK):"+Thread.holdsLock(START_OFFSET_LOCK)+"; Thread.holdsLock(PSI_LOCK):"+Thread.holdsLock(PsiLock.LOCK)); + throw new AssertionError("Tree changed while calculating text. startStamp:"+startStamp+"; current:"+myModificationsCount+"; myHC:"+myHC+"; assertThreading:"+ASSERT_THREADING+"; Thread.holdsLock(START_OFFSET_LOCK):"+Thread.holdsLock(START_OFFSET_LOCK)+"; Thread.holdsLock(PSI_LOCK):"+Thread.holdsLock(PsiLock.LOCK)+"; this: " + this); } char[] buffer = new char[len]; diff --git a/platform/lang-api/src/com/intellij/codeInsight/editorActions/moveUpDown/StatementUpDownMover.java b/platform/lang-api/src/com/intellij/codeInsight/editorActions/moveUpDown/StatementUpDownMover.java index f68a5da94994..ebb5f51a960d 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/editorActions/moveUpDown/StatementUpDownMover.java +++ b/platform/lang-api/src/com/intellij/codeInsight/editorActions/moveUpDown/StatementUpDownMover.java @@ -68,12 +68,13 @@ public abstract class StatementUpDownMover { public void afterMove(@NotNull final Editor editor, @NotNull final PsiFile file, @NotNull final MoveInfo info, final boolean down) { } - public static int getLineStartSafeOffset(final Document document, int line) { + public static int getLineStartSafeOffset(@NotNull Document document, int line) { if (line == document.getLineCount()) return document.getTextLength(); return document.getLineStartOffset(line); } - protected static LineRange getLineRangeFromSelection(final Editor editor) { + @NotNull + protected static LineRange getLineRangeFromSelection(@NotNull Editor editor) { final int startLine; final int endLine; final SelectionModel selectionModel = editor.getSelectionModel(); @@ -93,7 +94,7 @@ public abstract class StatementUpDownMover { } @Nullable - protected static Pair getElementRange(Editor editor, PsiFile file, final LineRange range) { + protected static Pair getElementRange(@NotNull Editor editor, @NotNull PsiFile file, @NotNull LineRange range) { final int startOffset = editor.logicalPositionToOffset(new LogicalPosition(range.startLine, 0)); PsiElement startingElement = firstNonWhiteElement(startOffset, file, true); if (startingElement == null) return null; @@ -112,7 +113,7 @@ public abstract class StatementUpDownMover { } @Nullable - protected static PsiElement firstNonWhiteElement(int offset, PsiFile file, final boolean lookRight) { + protected static PsiElement firstNonWhiteElement(int offset, @NotNull PsiFile file, final boolean lookRight) { final ASTNode leafElement = file.getNode().findLeafElementAt(offset); return leafElement == null ? null : firstNonWhiteElement(leafElement.getPsi(), lookRight); }