diff options
author | Tor Norbye <tnorbye@google.com> | 2014-08-19 22:27:03 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-08-19 21:25:05 +0000 |
commit | 4ca751c002784c4bfd349cc5240b045b62277c80 (patch) | |
tree | dfc17b31990e2429535609b85f6d080c4fa0d9fe /platform/testFramework/src | |
parent | 890d9a2952301682ffecaed4495f5f65c84c3642 (diff) | |
parent | 060e58b3afea3ea39f5ba1cb5a443ca3ebda28c8 (diff) | |
download | idea-4ca751c002784c4bfd349cc5240b045b62277c80.tar.gz |
Merge "Merge remote-tracking branch 'aosp/upstream-master' into merge"
Diffstat (limited to 'platform/testFramework/src')
12 files changed, 111 insertions, 55 deletions
diff --git a/platform/testFramework/src/com/intellij/FileSetTestCase.java b/platform/testFramework/src/com/intellij/FileSetTestCase.java index ba2afa2f8d86..d89e175a52c2 100644 --- a/platform/testFramework/src/com/intellij/FileSetTestCase.java +++ b/platform/testFramework/src/com/intellij/FileSetTestCase.java @@ -16,6 +16,7 @@ import com.intellij.util.ArrayUtil; import junit.framework.TestSuite; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; @@ -80,6 +81,10 @@ public abstract class FileSetTestCase extends TestSuite { } } + protected String loadFile(File testFile) throws IOException { + return FileUtil.loadFile(testFile); + } + protected String getDelimiter() { return "---"; } @@ -116,7 +121,7 @@ public abstract class FileSetTestCase extends TestSuite { @Override protected void runTest() throws Throwable { - String content = FileUtil.loadFile(myTestFile); + String content = loadFile(myTestFile); assertNotNull(content); List<String> input = new ArrayList<String>(); diff --git a/platform/testFramework/src/com/intellij/GroupBasedTestClassFilter.java b/platform/testFramework/src/com/intellij/GroupBasedTestClassFilter.java index 3fa50dec3032..f7a84c0470d9 100644 --- a/platform/testFramework/src/com/intellij/GroupBasedTestClassFilter.java +++ b/platform/testFramework/src/com/intellij/GroupBasedTestClassFilter.java @@ -56,7 +56,7 @@ public class GroupBasedTestClassFilter extends TestClassesFilter { private final List<Pattern> myTestGroupPatterns; private boolean myContainsAllExcludeDefinedGroup; - private GroupBasedTestClassFilter(Map<String, List<String>> filters, List<String> testGroupNames) { + public GroupBasedTestClassFilter(Map<String, List<String>> filters, List<String> testGroupNames) { //empty group means all patterns from each defined group should be excluded myContainsAllExcludeDefinedGroup = containsAllExcludeDefinedGroup(testGroupNames); @@ -120,6 +120,10 @@ public class GroupBasedTestClassFilter extends TestClassesFilter { */ @NotNull public static TestClassesFilter createOn(@NotNull Reader reader, @NotNull List<String> testGroupNames) throws IOException { + return new GroupBasedTestClassFilter(readGroups(reader), testGroupNames); + } + + public static Map<String, List<String>> readGroups(Reader reader) throws IOException { Map<String, List<String>> groupNameToPatternsMap = new HashMap<String, List<String>>(); String currentGroupName = ""; @@ -137,8 +141,7 @@ public class GroupBasedTestClassFilter extends TestClassesFilter { groupNameToPatternsMap.get(currentGroupName).add(line); } } - - return new GroupBasedTestClassFilter(groupNameToPatternsMap, testGroupNames); + return groupNameToPatternsMap; } /** diff --git a/platform/testFramework/src/com/intellij/TestCaseLoader.java b/platform/testFramework/src/com/intellij/TestCaseLoader.java index 5d11e48548b8..a01070363482 100644 --- a/platform/testFramework/src/com/intellij/TestCaseLoader.java +++ b/platform/testFramework/src/com/intellij/TestCaseLoader.java @@ -62,15 +62,24 @@ public class TestCaseLoader { System.out.println("Using patterns: [" + patterns +"]"); } else { - URL excludedStream = StringUtil.isEmpty(classFilterName) ? null : getClass().getClassLoader().getResource(classFilterName); - if (excludedStream != null) { - TestClassesFilter filter; + List<URL> groupingFileUrls = Collections.emptyList(); + if (!StringUtil.isEmpty(classFilterName)) { try { - List<String> testGroupNames = StringUtil.split(System.getProperty(TARGET_TEST_GROUP, "").trim(), ";"); - InputStreamReader reader = new InputStreamReader(excludedStream.openStream()); + groupingFileUrls = Collections.list(getClass().getClassLoader().getResources(classFilterName)); + } + catch (IOException e) { + e.printStackTrace(); + } + } + + List<String> testGroupNames = StringUtil.split(System.getProperty(TARGET_TEST_GROUP, "").trim(), ";"); + Map<String, List<String>> groups = new LinkedHashMap<String, List<String>>(); + + for (URL fileUrl : groupingFileUrls) { + try { + InputStreamReader reader = new InputStreamReader(fileUrl.openStream()); try { - filter = GroupBasedTestClassFilter.createOn(reader, testGroupNames); - System.out.println("Using test groups: " + testGroupNames); + groups.putAll(GroupBasedTestClassFilter.readGroups(reader)); } finally { reader.close(); @@ -78,14 +87,17 @@ public class TestCaseLoader { } catch (IOException e) { e.printStackTrace(); - filter = TestClassesFilter.ALL_CLASSES; - System.out.println("Using all classes"); + System.err.println("Failed to load test groups from " + fileUrl); } - myTestClassesFilter = filter; } - else { - myTestClassesFilter = TestClassesFilter.ALL_CLASSES; + + if (groups.isEmpty()) { System.out.println("Using all classes"); + myTestClassesFilter = TestClassesFilter.ALL_CLASSES; + } + else { + System.out.println("Using test groups: " + testGroupNames); + myTestClassesFilter = new GroupBasedTestClassFilter(groups, testGroupNames); } } } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java index 24e4074ed4ee..3c1f96113532 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java @@ -35,10 +35,10 @@ import com.intellij.openapi.editor.actionSystem.EditorActionManager; import com.intellij.openapi.editor.ex.util.EditorUtil; import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.openapi.editor.impl.EditorImpl; +import com.intellij.openapi.editor.impl.TrailingSpacesStripper; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; -import com.intellij.openapi.fileEditor.impl.TrailingSpacesStripper; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.ThrowableComputable; diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java index 0c46f14b98e0..307fb65e5ef1 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java @@ -44,6 +44,7 @@ import com.intellij.openapi.vfs.VirtualFileFilter; import com.intellij.openapi.vfs.ex.temp.TempFileSystem; import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; +import com.intellij.util.ReflectionUtil; import com.intellij.util.ThrowableRunnable; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashMap; @@ -62,11 +63,8 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.InvocationEvent; -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; +import java.io.*; import java.lang.ref.SoftReference; -import java.lang.reflect.Field; import java.nio.charset.Charset; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; @@ -823,9 +821,24 @@ public class PlatformTestUtil { } private static void patchSystemFileEncoding(String encoding) throws NoSuchFieldException, IllegalAccessException { - Field charset = Charset.class.getDeclaredField("defaultCharset"); - charset.setAccessible(true); - charset.set(Charset.class, null); + ReflectionUtil.resetField(Charset.class, Charset.class, "defaultCharset"); System.setProperty("file.encoding", encoding); } + + public static void withStdErrSuppressed(@NotNull Runnable r) { + PrintStream std = System.err; + System.setErr(new PrintStream(NULL)); + try { + r.run(); + } + finally { + System.setErr(std); + } + } + + @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") + private static final OutputStream NULL = new OutputStream() { + @Override + public void write(int b) throws IOException { } + }; } diff --git a/platform/testFramework/src/com/intellij/testFramework/PsiTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PsiTestUtil.java index 0f746d43c6ca..3960159e5bb4 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PsiTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PsiTestUtil.java @@ -220,11 +220,11 @@ public class PsiTestUtil { return entry; } - public static void removeContentEntry(Module module, final ContentEntry e) { + public static void removeContentEntry(Module module, final VirtualFile contentRoot) { ModuleRootModificationUtil.updateModel(module, new Consumer<ModifiableRootModel>() { @Override public void consume(ModifiableRootModel model) { - model.removeContentEntry(e); + model.removeContentEntry(findContentEntryWithAssertion(model, contentRoot)); } }); } diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index fa752b4643b0..6deda3d4b70a 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -570,8 +570,12 @@ public abstract class UsefulTestCase extends TestCase { public static <T> T assertOneElement(Collection<T> collection) { Assert.assertNotNull(collection); - Assert.assertEquals(toString(collection), 1, collection.size()); - return collection.iterator().next(); + Iterator<T> iterator = collection.iterator(); + String toString = toString(collection); + Assert.assertTrue(toString, iterator.hasNext()); + T t = iterator.next(); + Assert.assertFalse(toString, iterator.hasNext()); + return t; } public static <T> T assertOneElement(T[] ts) { diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java index e721401a82ba..a309f9acda8f 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java @@ -463,7 +463,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture { void type(final char c); - void type(final String s); + void type(@NotNull String s); void performEditorAction(@NotNull String actionId); diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/HeavyIdeaTestFixture.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/HeavyIdeaTestFixture.java index 490d2c3ff05b..57e78061cc3c 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/HeavyIdeaTestFixture.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/HeavyIdeaTestFixture.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. @@ -17,6 +17,7 @@ package com.intellij.testFramework.fixtures; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -25,5 +26,5 @@ import java.io.IOException; * @author peter */ public interface HeavyIdeaTestFixture extends IdeaProjectTestFixture { - PsiFile addFileToProject(@NonNls String rootPath, @NonNls String relativePath, @NonNls String fileText) throws IOException; + PsiFile addFileToProject(@NonNls @NotNull String rootPath, @NonNls @NotNull String relativePath, @NonNls @NotNull String fileText) throws IOException; } 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 4857acd2d328..449b1bacf8e9 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -146,7 +146,6 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig private final TempDirTestFixture myTempDirFixture; protected final IdeaProjectTestFixture myProjectFixture; - @NonNls private static final String XXX = "XXX"; private final FileTreeAccessFilter myJavaFilesFilter = new FileTreeAccessFilter(); private boolean myAllowDirt; private boolean myCaresAboutInjection = true; @@ -369,7 +368,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig private long collectAndCheckHighlightings(final boolean checkWarnings, final boolean checkInfos, final boolean checkWeakWarnings, - final VirtualFile[] files) { + @NotNull VirtualFile[] files) { final List<Trinity<PsiFile, Editor, ExpectedHighlightingData>> datas = ContainerUtil.map2List(files, new Function<VirtualFile, Trinity<PsiFile, Editor, ExpectedHighlightingData>>() { @Override @@ -787,12 +786,13 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig }); } + @NotNull private DataContext getEditorDataContext() { return ((EditorEx)myEditor).getDataContext(); } @Override - public void type(String s) { + public void type(@NotNull String s) { for (int i = 0; i < s.length(); i++) { type(s.charAt(i)); } @@ -804,7 +804,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig _performEditorAction(actionId); } - private boolean _performEditorAction(String actionId) { + private boolean _performEditorAction(@NotNull String actionId) { final DataContext dataContext = getEditorDataContext(); final ActionManagerEx managerEx = ActionManagerEx.getInstanceEx(); @@ -948,7 +948,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig private static void addGutterIconRenderer(final GutterMark renderer, final int offset, - SortedMap<Integer, List<GutterMark>> result) { + @NotNull SortedMap<Integer, List<GutterMark>> result) { if (renderer == null) return; List<GutterMark> renderers = result.get(offset); @@ -965,7 +965,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return addFileToProject(getTempDirPath(), relativePath, fileText); } - protected PsiFile addFileToProject(final String rootPath, final String relativePath, final String fileText) { + protected PsiFile addFileToProject(@NotNull final String rootPath, @NotNull final String relativePath, @NotNull final String fileText) { return new WriteCommandAction<PsiFile>(getProject()) { @Override protected void run(@NotNull Result<PsiFile> result) throws Throwable { @@ -1377,7 +1377,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return PsiDocumentManager.getInstance(getProject()).getDocument(file); } - private PsiFile configureByFileInner(@NonNls String filePath) { + private PsiFile configureByFileInner(@NonNls @NotNull String filePath) { assertInitialized(); final VirtualFile file = copyFileToProject(filePath); return configureByFileInner(file); @@ -1401,7 +1401,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return configureInner(copy, SelectionAndCaretMarkupLoader.fromFile(copy)); } - private PsiFile configureInner(@NotNull final VirtualFile copy, final SelectionAndCaretMarkupLoader loader) { + private PsiFile configureInner(@NotNull final VirtualFile copy, @NotNull final SelectionAndCaretMarkupLoader loader) { assertInitialized(); new WriteCommandAction.Simple(getProject()) { @Override @@ -1459,13 +1459,17 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig } @Nullable - private Editor createEditor(VirtualFile file) { + private Editor createEditor(@NotNull VirtualFile file) { final Project project = getProject(); final FileEditorManager instance = FileEditorManager.getInstance(project); if (file.getFileType().isBinary()) { return null; } - return instance.openTextEditor(new OpenFileDescriptor(project, file, 0), false); + Editor editor = instance.openTextEditor(new OpenFileDescriptor(project, file), false); + if (editor != null) { + editor.getCaretModel().moveToOffset(0); + } + return editor; } private long collectAndCheckHighlighting(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings) throws Exception { @@ -1487,14 +1491,14 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig //to initialize caches if (!DumbService.isDumb(project)) { - CacheManager.SERVICE.getInstance(project).getFilesWithWord(XXX, UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(project), true); + CacheManager.SERVICE.getInstance(project).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(project), true); } - List<HighlightInfo> infos; final long start = System.currentTimeMillis(); ((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(myJavaFilesFilter, myTestRootDisposable); // ProfilingUtil.startCPUProfiling(); + List<HighlightInfo> infos; try { infos = doHighlighting(); removeDuplicatedRangesForInjected(infos); @@ -1510,7 +1514,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return elapsed; } - private static void removeDuplicatedRangesForInjected(List<HighlightInfo> infos) { + private static void removeDuplicatedRangesForInjected(@NotNull List<HighlightInfo> infos) { Collections.sort(infos, new Comparator<HighlightInfo>() { @Override public int compare(HighlightInfo o1, HighlightInfo o2) { @@ -1582,7 +1586,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig throw exception; } - public static void ensureIndexesUpToDate(Project project) { + public static void ensureIndexesUpToDate(@NotNull Project project) { if (!DumbService.isDumb(project)) { FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, null); FileBasedIndex.getInstance().ensureUpToDate(TodoIndex.NAME, project, null); @@ -1625,6 +1629,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig }); } + @NotNull public static List<IntentionAction> getAvailableIntentions(@NotNull final Editor editor, @NotNull final PsiFile file) { return ApplicationManager.getApplication().runReadAction(new Computable<List<IntentionAction>>() { @Override @@ -1634,6 +1639,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig }); } + @NotNull private static List<IntentionAction> doGetAvailableIntentions(@NotNull Editor editor, @NotNull PsiFile file) { ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo(); ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1); @@ -1681,15 +1687,17 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig myJavaFilesFilter.allowTreeAccessForAllFiles(); } - static class SelectionAndCaretMarkupLoader { + private static class SelectionAndCaretMarkupLoader { final String filePath; final String newFileText; final EditorTestUtil.CaretAndSelectionState caretState; - static SelectionAndCaretMarkupLoader fromFile(String path, String charset) throws IOException { + @NotNull + static SelectionAndCaretMarkupLoader fromFile(@NotNull String path, String charset) throws IOException { return new SelectionAndCaretMarkupLoader(StringUtil.convertLineSeparators(FileUtil.loadFile(new File(path), charset)), path); } + @NotNull static SelectionAndCaretMarkupLoader fromFile(@NotNull VirtualFile file) { final String text; try { @@ -1701,11 +1709,12 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return new SelectionAndCaretMarkupLoader(StringUtil.convertLineSeparators(text), file.getPath()); } - static SelectionAndCaretMarkupLoader fromText(String text) { + @NotNull + static SelectionAndCaretMarkupLoader fromText(@NotNull String text) { return new SelectionAndCaretMarkupLoader(text, null); } - private SelectionAndCaretMarkupLoader(String fileText, String filePath) { + private SelectionAndCaretMarkupLoader(@NotNull String fileText, String filePath) { this.filePath = filePath; final Document document = EditorFactory.getInstance().createDocument(fileText); caretState = EditorTestUtil.extractCaretAndSelectionMarkers(document); @@ -1735,11 +1744,10 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig } - @SuppressWarnings("ConstantConditions") private void checkResult(@NotNull String expectedFile, final boolean stripTrailingSpaces, - final SelectionAndCaretMarkupLoader loader, - String actualText) { + @NotNull SelectionAndCaretMarkupLoader loader, + @NotNull String actualText) { assertInitialized(); Project project = getProject(); Editor editor = getEditor(); @@ -1773,7 +1781,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig EditorTestUtil.verifyCaretAndSelectionState(editor, loader.caretState, expectedFile); } - private String stripTrailingSpaces(String actualText) { + @NotNull + private String stripTrailingSpaces(@NotNull String actualText) { final Document document = EditorFactory.getInstance().createDocument(actualText); ((DocumentImpl)document).stripTrailingSpaces(getProject()); actualText = document.getText(); @@ -1824,6 +1833,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig } } + @NotNull public String getFoldingDescription(boolean withCollapseStatus) { CodeFoldingManager.getInstance(getProject()).buildInitialFoldings(myEditor); @@ -1849,7 +1859,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return result.toString(); } - private void testFoldingRegions(final String verificationFileName, boolean doCheckCollapseStatus) { + private void testFoldingRegions(@NotNull String verificationFileName, boolean doCheckCollapseStatus) { String expectedContent; try { expectedContent = FileUtil.loadFile(new File(verificationFileName)); diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java index 4adc2aa57cef..27a45cbfe99e 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java @@ -235,7 +235,7 @@ class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTestFixtu } @Override - public PsiFile addFileToProject(@NonNls String rootPath, @NonNls final String relativePath, @NonNls final String fileText) throws IOException { + public PsiFile addFileToProject(@NotNull @NonNls String rootPath, @NotNull @NonNls final String relativePath, @NotNull @NonNls final String fileText) throws IOException { final VirtualFile dir = VfsUtil.createDirectories(rootPath + "/" + PathUtil.getParentPath(relativePath)); final VirtualFile[] virtualFile = new VirtualFile[1]; diff --git a/platform/testFramework/src/com/intellij/util/io/TestFileSystemBuilder.java b/platform/testFramework/src/com/intellij/util/io/TestFileSystemBuilder.java index da7dc5cfa162..9ee314d52b8d 100644 --- a/platform/testFramework/src/com/intellij/util/io/TestFileSystemBuilder.java +++ b/platform/testFramework/src/com/intellij/util/io/TestFileSystemBuilder.java @@ -1,5 +1,7 @@ package com.intellij.util.io; +import org.jetbrains.annotations.NotNull; + /** * @author nik */ @@ -12,6 +14,7 @@ public class TestFileSystemBuilder { myParent = parent; } + @NotNull public TestFileSystemItem build() { TestFileSystemBuilder builder = this; while (builder.myParent != null) { @@ -20,23 +23,27 @@ public class TestFileSystemBuilder { return builder.myItem; } + @NotNull public TestFileSystemBuilder dir(String name) { final TestFileSystemItem item = new TestFileSystemItem(name, false, true); myItem.addChild(item); return new TestFileSystemBuilder(item, this); } + @NotNull public TestFileSystemBuilder archive(String name) { final TestFileSystemItem item = new TestFileSystemItem(name, true, false); myItem.addChild(item); return new TestFileSystemBuilder(item, this); } + @NotNull public TestFileSystemBuilder file(String name) { myItem.addChild(new TestFileSystemItem(name, false, false)); return this; } + @NotNull public TestFileSystemBuilder file(String name, String content) { myItem.addChild(new TestFileSystemItem(name, false, false, content)); return this; @@ -46,6 +53,7 @@ public class TestFileSystemBuilder { return myParent; } + @NotNull public static TestFileSystemBuilder fs() { return new TestFileSystemBuilder(new TestFileSystemItem("root", false, true), null); } |