From 2c74eadae344e4314321e439847841d286f733ef Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Dec 2012 13:30:48 +0400 Subject: [PATCH] cleanup --- .../openapi/editor/impl/EditorImpl.java | 18 ++++++------------ .../com/intellij/util/containers/HashMap.java | 1 + .../intellij/util/text/CharSequenceReader.java | 12 +++++++++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 6476e9cf7349..5602538652aa 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -88,6 +88,7 @@ import gnu.trove.TIntArrayList; import gnu.trove.TIntHashSet; import gnu.trove.TIntIntHashMap; import org.intellij.lang.annotations.JdkConstants; +import org.intellij.lang.annotations.MagicConstant; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -200,6 +201,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi private EditorHighlighter myHighlighter; private final TextDrawingCallback myTextDrawingCallback = new MyTextDrawingCallback(); + @MagicConstant(intValues = {VERTICAL_SCROLLBAR_LEFT, VERTICAL_SCROLLBAR_RIGHT}) private int myScrollBarOrientation; private boolean myMousePressedInsideSelection; private FontMetrics myPlainFontMetrics; @@ -2695,6 +2697,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi myPaintSelection = paintSelection; } + @Override @NotNull @NonNls public String dumpState() { @@ -4699,24 +4702,15 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi @Override public void setVerticalScrollbarVisible(boolean b) { - if (b) { - myScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - } - else { - myScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); - } + myScrollPane.setVerticalScrollBarPolicy(b ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS : ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); } @Override public void setHorizontalScrollbarVisible(boolean b) { - if (b) { - myScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - } - else { - myScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - } + myScrollPane.setHorizontalScrollBarPolicy(b ? ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED : ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); } + @Override public int getVerticalScrollbarOrientation() { return myScrollBarOrientation; } diff --git a/platform/util-rt/src/com/intellij/util/containers/HashMap.java b/platform/util-rt/src/com/intellij/util/containers/HashMap.java index 235d46edbbc8..af41488814d0 100644 --- a/platform/util-rt/src/com/intellij/util/containers/HashMap.java +++ b/platform/util-rt/src/com/intellij/util/containers/HashMap.java @@ -33,6 +33,7 @@ public class HashMap extends java.util.HashMap { super(map); } + @Override public void clear() { if (size() == 0) return; // optimization super.clear(); diff --git a/platform/util/src/com/intellij/util/text/CharSequenceReader.java b/platform/util/src/com/intellij/util/text/CharSequenceReader.java index c238d523e64b..e92bb6a7a140 100644 --- a/platform/util/src/com/intellij/util/text/CharSequenceReader.java +++ b/platform/util/src/com/intellij/util/text/CharSequenceReader.java @@ -15,6 +15,8 @@ */ package com.intellij.util.text; +import org.jetbrains.annotations.NotNull; + import java.io.Reader; /** @@ -24,17 +26,20 @@ public class CharSequenceReader extends Reader { private final CharSequence myText; private int myCurPos; - public CharSequenceReader(final CharSequence text) { + public CharSequenceReader(@NotNull CharSequence text) { myText = text; myCurPos = 0; } + @Override public void close() {} + @Override public int read(char[] cbuf, int off, int len) { if (off < 0 || off > cbuf.length || len < 0 || off + len > cbuf.length || off + len < 0) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { + throw new IndexOutOfBoundsException("cbuf.length="+cbuf.length+"; off="+off+"; len="+len); + } + if (len == 0) { return 0; } @@ -56,6 +61,7 @@ public class CharSequenceReader extends Reader { return charsToCopy; } + @Override public int read() { if (myCurPos >= myText.length()) return -1; return myText.charAt(myCurPos++);