From 02a9c6e577cf32d2d0af04f7c3a6e2c11493d4c1 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 24 Apr 2014 18:24:25 +0400 Subject: [PATCH] notnull --- .../src/com/intellij/openapi/vfs/VirtualFile.java | 4 +++- .../openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java | 6 +++--- platform/testFramework/src/com/intellij/mock/Mock.java | 8 +++++--- .../src/com/intellij/mock/MockVirtualFile.java | 1 + .../fixtures/impl/TempDirTestFixtureImpl.java | 8 +++++--- .../properties/editor/ResourceBundleAsVirtualFile.java | 4 +++- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java index 5ac232d80274..0725d7a1ea0e 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java @@ -393,7 +393,8 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica * @return VirtualFile representing the created directory * @throws java.io.IOException if directory failed to be created */ - public VirtualFile createChildDirectory(Object requestor, @NonNls String name) throws IOException { + @NotNull + public VirtualFile createChildDirectory(Object requestor, @NotNull @NonNls String name) throws IOException { if (!isDirectory()) { throw new IOException(VfsBundle.message("directory.create.wrong.parent.error")); } @@ -423,6 +424,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica * @return VirtualFile representing the created file * @throws IOException if file failed to be created */ + @NotNull public VirtualFile createChildData(Object requestor, @NotNull @NonNls String name) throws IOException { if (!isDirectory()) { throw new IOException(VfsBundle.message("file.create.wrong.parent.error")); diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java index 48bfc01c0fa2..faf3819dfe69 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java @@ -322,13 +322,13 @@ public abstract class VirtualFileSystemEntry extends NewVirtualFile { @Override @NotNull - public VirtualFile createChildDirectory(final Object requestor, final String name) throws IOException { + public VirtualFile createChildDirectory(final Object requestor, @NotNull final String name) throws IOException { validateName(name); return ourPersistence.createChildDirectory(requestor, this, name); } - private static void validateName(String name) throws IOException { - if (name == null || name.isEmpty()) throw new IOException("File name cannot be empty"); + private static void validateName(@NotNull String name) throws IOException { + if (name.isEmpty()) throw new IOException("File name cannot be empty"); if (name.indexOf('/') >= 0 || name.indexOf(File.separatorChar) >= 0) { throw new IOException("File name cannot contain file path separators: '" + name + "'"); } diff --git a/platform/testFramework/src/com/intellij/mock/Mock.java b/platform/testFramework/src/com/intellij/mock/Mock.java index f0ca6a19e745..575bc0991c3e 100644 --- a/platform/testFramework/src/com/intellij/mock/Mock.java +++ b/platform/testFramework/src/com/intellij/mock/Mock.java @@ -494,14 +494,16 @@ public class Mock { return new VirtualFile[0]; } + @NotNull @Override - public VirtualFile createChildDirectory(Object requestor, String name) throws IOException { - return null; + public VirtualFile createChildDirectory(Object requestor, @NotNull String name) throws IOException { + throw new IOException(name); } + @NotNull @Override public VirtualFile createChildData(Object requestor, @NotNull String name) throws IOException { - return null; + throw new IOException(name); } @Override diff --git a/platform/testFramework/src/com/intellij/mock/MockVirtualFile.java b/platform/testFramework/src/com/intellij/mock/MockVirtualFile.java index 9f31bbb9b10f..cd06c19af81d 100644 --- a/platform/testFramework/src/com/intellij/mock/MockVirtualFile.java +++ b/platform/testFramework/src/com/intellij/mock/MockVirtualFile.java @@ -72,6 +72,7 @@ public class MockVirtualFile extends VirtualFile { myParent = parent; } + @NotNull @Override public VirtualFile createChildData(final Object requestor, @NotNull @NonNls final String name) { final MockVirtualFile file = new MockVirtualFile(name); diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/TempDirTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/TempDirTestFixtureImpl.java index 7493cb17bde0..dfdaf2e0acf1 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/TempDirTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/TempDirTestFixtureImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -166,11 +166,13 @@ public class TempDirTestFixtureImpl extends BaseFixture implements TempDirTestFi return null; } + @NotNull protected File createTempDirectory() { try { if (myTempDir == null) { - File th = getTempHome(); - myTempDir = th != null ? FileUtil.createTempDirectory(th, "unitTest", null,false) : FileUtil.createTempDirectory("unitTest", null,false); + File tempHome = getTempHome(); + myTempDir = tempHome == null ? FileUtil.createTempDirectory("unitTest", null, false) : + FileUtil.createTempDirectory(tempHome, "unitTest", null, false); myFilesToDelete.add(myTempDir); } return myTempDir; diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java index f61c3b87e80b..2f799368084c 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleAsVirtualFile.java @@ -104,11 +104,13 @@ public class ResourceBundleAsVirtualFile extends VirtualFile { return EMPTY_ARRAY; } + @NotNull @Override - public VirtualFile createChildDirectory(Object requestor, String name) throws IOException { + public VirtualFile createChildDirectory(Object requestor, @NotNull String name) throws IOException { throw new UnsupportedOperationException(); } + @NotNull @Override public VirtualFile createChildData(Object requestor, @NotNull String name) throws IOException { throw new UnsupportedOperationException();