Rename: Implement automatic renamer for test classes

#KT-8512 Fixed
This commit is contained in:
Alexey Sedunov
2016-05-27 20:30:43 +03:00
parent 42b71ae90c
commit 188531017a
13 changed files with 157 additions and 10 deletions
@@ -189,8 +189,8 @@ public class ConfigLibraryUtil {
addLibrary(editor, module);
}
public static void configureLibrariesByDirective(@NotNull Module module, String rootPath, String fileText) {
for (String libraryInfo : InTextDirectivesUtils.findListWithPrefixes(fileText, "// CONFIGURE_LIBRARY: ")) {
public static void configureLibraries(@NotNull Module module, String rootPath, List<String> libraryInfos) {
for (String libraryInfo : libraryInfos) {
int i = libraryInfo.indexOf('@');
String libraryName = libraryInfo.substring(0, i);
String[] jarPaths = libraryInfo.substring(i + 1).split(";");
@@ -198,6 +198,29 @@ public class ConfigLibraryUtil {
}
}
public static void unconfigureLibrariesByName(@NotNull Module module, List<String> libraryNames) {
for (Iterator<String> iterator = libraryNames.iterator(); iterator.hasNext(); ) {
String libraryName = iterator.next();
if (removeLibrary(module, libraryName)) {
iterator.remove();
}
}
if (!libraryNames.isEmpty()) throw new AssertionError("Couldn't find the following libraries: " + libraryNames);
}
public static void unconfigureLibrariesByInfo(@NotNull Module module, List<String> libraryInfos) {
List<String> libraryNames = new ArrayList<String>();
for (String libraryInfo : libraryInfos) {
libraryNames.add(libraryInfo.substring(0, libraryInfo.indexOf('@')));
}
unconfigureLibrariesByName(module, libraryNames);
}
public static void configureLibrariesByDirective(@NotNull Module module, String rootPath, String fileText) {
configureLibraries(module, rootPath, InTextDirectivesUtils.findListWithPrefixes(fileText, "// CONFIGURE_LIBRARY: "));
}
public static void unconfigureLibrariesByDirective(@NotNull Module module, String fileText) {
List<String> libraryNames = new ArrayList<String>();
for (String libInfo : InTextDirectivesUtils.findListWithPrefixes(fileText, "// CONFIGURE_LIBRARY: ")) {
@@ -207,13 +230,6 @@ public class ConfigLibraryUtil {
libraryNames.add(libraryName);
}
for (Iterator<String> iterator = libraryNames.iterator(); iterator.hasNext(); ) {
String libraryName = iterator.next();
if (removeLibrary(module, libraryName)) {
iterator.remove();
}
}
if (!libraryNames.isEmpty()) throw new AssertionError("Couldn't find the following libraries: " + libraryNames);
unconfigureLibrariesByName(module, libraryNames);
}
}