This commit is contained in:
Alexey Kudravtsev
2014-04-28 13:10:49 +04:00
parent 81d2d986a3
commit 02a9c6e577
6 changed files with 20 additions and 11 deletions
@@ -393,7 +393,8 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @return <code>VirtualFile</code> 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 <code>VirtualFile</code> 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"));
@@ -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 + "'");
}
@@ -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
@@ -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);
@@ -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;
@@ -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();