diff --git a/java/java-runtime/src/com/intellij/rt/execution/junit/FileComparisonFailure.java b/java/java-runtime/src/com/intellij/rt/execution/junit/FileComparisonFailure.java index b6b728192713..a540eceacad8 100644 --- a/java/java-runtime/src/com/intellij/rt/execution/junit/FileComparisonFailure.java +++ b/java/java-runtime/src/com/intellij/rt/execution/junit/FileComparisonFailure.java @@ -25,12 +25,14 @@ public class FileComparisonFailure extends ComparisonFailure implements KnownExc private final String myFilePath; private final String myActualFilePath; - public FileComparisonFailure(String message, String expected, String actual, String filePath) { - this(message, expected, actual, filePath, null); + public FileComparisonFailure(String message, /*@NotNull */String expected, /*@NotNull */String actual, String expectedFilePath) { + this(message, expected, actual, expectedFilePath, null); } - public FileComparisonFailure(String message, String expected, String actual, String expectedFilePath, String actualFilePath) { + public FileComparisonFailure(String message, /*@NotNull */String expected, /*@NotNull */String actual, String expectedFilePath, String actualFilePath) { super(message, expected, actual); + if (expected == null) throw new NullPointerException("'expected' must not be null"); + if (actual == null) throw new NullPointerException("'actual' must not be null"); myExpected = expected; myActual = actual; myFilePath = expectedFilePath; @@ -60,7 +62,7 @@ public class FileComparisonFailure extends ComparisonFailure implements KnownExc private static class MyPacketFactory extends ComparisonDetailsExtractor { private final String myFilePath; - public MyPacketFactory(ComparisonFailure assertion, String expected, String actual, String filePath) { + MyPacketFactory(ComparisonFailure assertion, String expected, String actual, String filePath) { super(assertion, expected, actual); myFilePath = filePath; } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java index 72bcca058e93..5e4173fbb4a2 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorPaintingTest.java @@ -198,7 +198,7 @@ public class EditorPaintingTest extends AbstractEditorTest { } } - private void fail(String message, File expectedResultsFile, BufferedImage actualImage) throws IOException { + private void fail(@NotNull String message, @NotNull File expectedResultsFile, BufferedImage actualImage) throws IOException { File savedImage = FileUtil.createTempFile(getName(), ".png", false); addTmpFileToKeep(savedImage); ImageIO.write(actualImage, "png", savedImage); diff --git a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java index 33dd5fbb1aa5..5d72a50f04be 100644 --- a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java @@ -251,7 +251,8 @@ public class EditorTestUtil { * * @see #extractCaretAndSelectionMarkers(Document, boolean) */ - public static CaretAndSelectionState extractCaretAndSelectionMarkers(Document document) { + @NotNull + public static CaretAndSelectionState extractCaretAndSelectionMarkers(@NotNull Document document) { return extractCaretAndSelectionMarkers(document, true); } @@ -261,7 +262,8 @@ public class EditorTestUtil { * * @param processBlockSelection if true, <block> and </block> tags describing a block selection state will also be extracted. */ - public static CaretAndSelectionState extractCaretAndSelectionMarkers(final Document document, final boolean processBlockSelection) { + @NotNull + public static CaretAndSelectionState extractCaretAndSelectionMarkers(@NotNull Document document, final boolean processBlockSelection) { return new WriteCommandAction(null) { @Override public void run(@NotNull Result actionResult) { @@ -271,9 +273,8 @@ public class EditorTestUtil { } @NotNull - public static CaretAndSelectionState extractCaretAndSelectionMarkersImpl(Document document, boolean processBlockSelection) { + public static CaretAndSelectionState extractCaretAndSelectionMarkersImpl(@NotNull Document document, boolean processBlockSelection) { List carets = ContainerUtil.newArrayList(); - TextRange blockSelection = null; String fileText = document.getText(); RangeMarker blockSelectionStartMarker = null; @@ -354,6 +355,7 @@ public class EditorTestUtil { if (carets.isEmpty()) { carets.add(new CaretInfo(null, null)); } + TextRange blockSelection = null; if (blockSelectionStartMarker != null) { blockSelection = new TextRange(blockSelectionStartMarker.getStartOffset(), blockSelectionEndMarker.getStartOffset()); } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index e96aee74fb41..4423c4b3bdc8 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -1891,6 +1891,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig private static class SelectionAndCaretMarkupLoader { private final String filePath; + @NotNull private final String newFileText; private final EditorTestUtil.CaretAndSelectionState caretState; diff --git a/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java b/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java index 319191e523dd..83b31097be7f 100644 --- a/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java @@ -25,6 +25,8 @@ import java.io.*; import java.nio.charset.Charset; public class StreamUtil { + private static final Logger LOG = Logger.getInstance(StreamUtil.class); + private StreamUtil() { } @@ -34,9 +36,8 @@ public class StreamUtil { * @param inputStream source stream * @param outputStream destination stream * @return bytes copied - * @throws IOException */ - public static int copyStreamContent(InputStream inputStream, OutputStream outputStream) throws IOException { + public static int copyStreamContent(@NotNull InputStream inputStream, @NotNull OutputStream outputStream) throws IOException { final byte[] buffer = new byte[10 * 1024]; int count; int total = 0; @@ -47,7 +48,8 @@ public class StreamUtil { return total; } - public static byte[] loadFromStream(InputStream inputStream) throws IOException { + @NotNull + public static byte[] loadFromStream(@NotNull InputStream inputStream) throws IOException { final UnsyncByteArrayOutputStream outputStream = new UnsyncByteArrayOutputStream(); try { copyStreamContent(inputStream, outputStream); @@ -61,31 +63,37 @@ public class StreamUtil { /** * @deprecated depends on the default encoding, use StreamUtil#readText(java.io.InputStream, String) instead */ - public static String readText(InputStream inputStream) throws IOException { + @NotNull + public static String readText(@NotNull InputStream inputStream) throws IOException { final byte[] data = loadFromStream(inputStream); return new String(data); } - public static String readText(InputStream inputStream, @NotNull String encoding) throws IOException { + @NotNull + public static String readText(@NotNull InputStream inputStream, @NotNull String encoding) throws IOException { final byte[] data = loadFromStream(inputStream); return new String(data, encoding); } - public static String readText(InputStream inputStream, @NotNull Charset encoding) throws IOException { + @NotNull + public static String readText(@NotNull InputStream inputStream, @NotNull Charset encoding) throws IOException { final byte[] data = loadFromStream(inputStream); return new String(data, encoding); } - public static String convertSeparators(String s) { + @NotNull + public static String convertSeparators(@NotNull String s) { return StringFactory.createShared(convertSeparators(s.toCharArray())); } - public static char[] readTextAndConvertSeparators(Reader reader) throws IOException { + @NotNull + public static char[] readTextAndConvertSeparators(@NotNull Reader reader) throws IOException { char[] buffer = readText(reader); return convertSeparators(buffer); } - private static char[] convertSeparators(char[] buffer) { + @NotNull + private static char[] convertSeparators(@NotNull char[] buffer) { int dst = 0; char prev = ' '; for (char c : buffer) { @@ -113,11 +121,13 @@ public class StreamUtil { return result; } - public static String readTextFrom(Reader reader) throws IOException { + @NotNull + public static String readTextFrom(@NotNull Reader reader) throws IOException { return StringFactory.createShared(readText(reader)); } - private static char[] readText(Reader reader) throws IOException { + @NotNull + private static char[] readText(@NotNull Reader reader) throws IOException { CharArrayWriter writer = new CharArrayWriter(); char[] buffer = new char[2048]; @@ -140,7 +150,4 @@ public class StreamUtil { } } } - - private static final Logger LOG = Logger.getInstance(StreamUtil.class); - }