createJ2EEModule throws error if cannot create module, add notnull annotations

This commit is contained in:
Vladimir Krivosheev
2017-01-27 11:50:36 +01:00
parent 576787ccae
commit c93a1a4a4b
4 changed files with 26 additions and 6 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -335,6 +335,7 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
return iprFile;
}
@NotNull
@Override
protected Module doCreateRealModule(String moduleName) {
//todo[nik] reuse code from PlatformTestCase
@@ -1,5 +1,17 @@
/*
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
* Copyright 2000-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
@@ -21,6 +33,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.introduceField.BaseExpressionToFieldHandler;
import com.intellij.refactoring.introduceField.LocalToFieldHandler;
import com.intellij.util.PathUtil;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import java.io.File;
@@ -31,6 +44,7 @@ public class IntroduceFieldWitSetUpInitializationTest extends CodeInsightTestCas
return JavaTestUtil.getJavaTestDataPath();
}
@NotNull
@Override
protected Module createModule(final String name) {
final Module module = super.createModule(name);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -325,25 +325,29 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
}.execute().throwException();
}
@NotNull
protected Module createMainModule() throws IOException {
return createModule(myProject.getName());
}
@NotNull
protected Module createModule(@NonNls final String moduleName) {
return doCreateRealModule(moduleName);
}
@NotNull
protected Module doCreateRealModule(final String moduleName) {
return doCreateRealModuleIn(moduleName, myProject, getModuleType());
}
@NotNull
protected static Module doCreateRealModuleIn(String moduleName, final Project project, final ModuleType moduleType) {
final VirtualFile baseDir = project.getBaseDir();
assertNotNull(baseDir);
String path = baseDir.getPath();
return createModuleAt(moduleName, project, moduleType, path);
return createModuleAt(moduleName, project, moduleType, baseDir.getPath());
}
@NotNull
protected static Module createModuleAt(String moduleName, Project project, ModuleType moduleType, String path) {
File moduleFile = new File(FileUtil.toSystemDependentName(path), moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
FileUtil.createIfDoesntExist(moduleFile);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -55,6 +55,7 @@ public abstract class Eclipse2ModulesTest extends IdeaTestCase {
copyDirContentsTo(vTestRoot, getProject().getBaseDir());
}
@NotNull
@Override
protected Module createMainModule() {
return createModule(DEPEND_MODULE_NAME);