Rename methods (prefix -> prefixes)
This commit is contained in:
@@ -36,7 +36,7 @@ public final class InTextDirectivesUtils {
|
||||
|
||||
@Nullable
|
||||
public static Integer getPrefixedInt(String fileText, String prefix) {
|
||||
String[] numberStrings = findArrayWithPrefix(fileText, prefix);
|
||||
String[] numberStrings = findArrayWithPrefixes(fileText, prefix);
|
||||
if (numberStrings.length > 0) {
|
||||
return Integer.parseInt(numberStrings[0]);
|
||||
}
|
||||
@@ -45,15 +45,15 @@ public final class InTextDirectivesUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String[] findArrayWithPrefix(String fileText, String... prefixes) {
|
||||
return ArrayUtil.toStringArray(findListWithPrefix(fileText, prefixes));
|
||||
public static String[] findArrayWithPrefixes(String fileText, String... prefixes) {
|
||||
return ArrayUtil.toStringArray(findListWithPrefixes(fileText, prefixes));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<String> findListWithPrefix(String fileText, String... prefixes) {
|
||||
public static List<String> findListWithPrefixes(String fileText, String... prefixes) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
|
||||
for (String line : findLinesWithPrefixRemoved(fileText, prefixes)) {
|
||||
for (String line : findLinesWithPrefixesRemoved(fileText, prefixes)) {
|
||||
String[] variants = line.split(",");
|
||||
|
||||
for (String variant : variants) {
|
||||
@@ -65,18 +65,18 @@ public final class InTextDirectivesUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String findStringWithPrefix(String fileText, String... prefixes) {
|
||||
List<String> strings = findListWithPrefix(fileText, prefixes);
|
||||
public static String findStringWithPrefixes(String fileText, String... prefixes) {
|
||||
List<String> strings = findListWithPrefixes(fileText, prefixes);
|
||||
if (strings.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
assert strings.size() == 1 : "There is more than one string with given prefixes " +
|
||||
Arrays.toString(prefixes) + ". Use findListWithPrefix() instead.";
|
||||
Arrays.toString(prefixes) + ". Use findListWithPrefixes() instead.";
|
||||
return strings.get(0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<String> findLinesWithPrefixRemoved(String fileText, String... prefixes) {
|
||||
public static List<String> findLinesWithPrefixesRemoved(String fileText, String... prefixes) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> cleanedPrefixes = cleanDirectivesFromComments(Arrays.asList(prefixes));
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.InTextDirectivesUtils.findListWithPrefix;
|
||||
import static org.jetbrains.jet.InTextDirectivesUtils.findListWithPrefixes;
|
||||
|
||||
public abstract class AbstractDefaultConstructorCodegenTest extends CodegenTestCase {
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class AbstractDefaultConstructorCodegenTest extends CodegenTestC
|
||||
}
|
||||
|
||||
private String loadInstructionValue(String fileContent, String instructionName) {
|
||||
List<String> testedClass = findListWithPrefix(fileContent, "// " + instructionName + ": ");
|
||||
List<String> testedClass = findListWithPrefixes(fileContent, "// " + instructionName + ": ");
|
||||
assertTrue("Cannot find " + instructionName + " instruction", !testedClass.isEmpty());
|
||||
assertTrue(instructionName + " instruction must have only one element", testedClass.size() == 1);
|
||||
return testedClass.get(0);
|
||||
|
||||
@@ -31,8 +31,8 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.InTextDirectivesUtils.findListWithPrefix;
|
||||
import static org.jetbrains.jet.InTextDirectivesUtils.findStringWithPrefix;
|
||||
import static org.jetbrains.jet.InTextDirectivesUtils.findListWithPrefixes;
|
||||
import static org.jetbrains.jet.InTextDirectivesUtils.findStringWithPrefixes;
|
||||
|
||||
/*
|
||||
* Test correctness of written flags in class file
|
||||
@@ -94,7 +94,7 @@ public abstract class AbstractWriteFlagsTest extends UsefulTestCase {
|
||||
|
||||
private static TestedObject parseExpectedTestedObject(String fileText) {
|
||||
TestedObject result = new TestedObject();
|
||||
List<String> testedObjects = findListWithPrefix(fileText, "// TESTED_OBJECTS: ");
|
||||
List<String> testedObjects = findListWithPrefixes(fileText, "// TESTED_OBJECTS: ");
|
||||
assertTrue("Cannot find TESTED_OBJECTS instruction", !testedObjects.isEmpty());
|
||||
result.containingClass = testedObjects.get(0);
|
||||
if (testedObjects.size() == 1) {
|
||||
@@ -108,8 +108,8 @@ public abstract class AbstractWriteFlagsTest extends UsefulTestCase {
|
||||
"TESTED_OBJECTS instruction must contains one (for class) or two (for function and property) values");
|
||||
}
|
||||
|
||||
result.kind = findStringWithPrefix(fileText, "// TESTED_OBJECT_KIND: ");
|
||||
List<String> isFullName = findListWithPrefix(fileText, "// IS_FULL_CONTAINING_CLASS_NAME: ");
|
||||
result.kind = findStringWithPrefixes(fileText, "// TESTED_OBJECT_KIND: ");
|
||||
List<String> isFullName = findListWithPrefixes(fileText, "// IS_FULL_CONTAINING_CLASS_NAME: ");
|
||||
if (isFullName.size() == 1) {
|
||||
result.isFullContainingClassName = Boolean.parseBoolean(isFullName.get(0));
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public abstract class AbstractWriteFlagsTest extends UsefulTestCase {
|
||||
private static int getExpectedFlags(String text) {
|
||||
int expectedAccess = 0;
|
||||
Class klass = Opcodes.class;
|
||||
List<String> flags = findListWithPrefix(text, "// FLAGS: ");
|
||||
List<String> flags = findListWithPrefixes(text, "// FLAGS: ");
|
||||
for (String flag : flags) {
|
||||
try {
|
||||
Field field = klass.getDeclaredField(flag);
|
||||
|
||||
@@ -167,7 +167,7 @@ public class ExpectedCompletionUtils {
|
||||
|
||||
public static CompletionProposal[] processProposalAssertions(String fileText, String... prefixes) {
|
||||
Collection<CompletionProposal> proposals = new ArrayList<CompletionProposal>();
|
||||
for (String proposalStr : InTextDirectivesUtils.findListWithPrefix(fileText, prefixes)) {
|
||||
for (String proposalStr : InTextDirectivesUtils.findListWithPrefixes(fileText, prefixes)) {
|
||||
Matcher matcher = CompletionProposal.PATTERN.matcher(proposalStr);
|
||||
matcher.find();
|
||||
proposals.add(new CompletionProposal(matcher.group(CompletionProposal.LOOKUP_STRING_GROUP_INDEX),
|
||||
|
||||
@@ -79,7 +79,7 @@ public class JetConfidenceTest extends LightCompletionTestCase {
|
||||
protected static String getTypeTextFromFile() {
|
||||
String text = getEditor().getDocument().getText();
|
||||
|
||||
String[] directives = InTextDirectivesUtils.findArrayWithPrefix(text, TYPE_DIRECTIVE_PREFIX);
|
||||
String[] directives = InTextDirectivesUtils.findArrayWithPrefixes(text, TYPE_DIRECTIVE_PREFIX);
|
||||
assertEquals("One directive with \"" + TYPE_DIRECTIVE_PREFIX +"\" expected", 1, directives.length);
|
||||
|
||||
return StringUtil.unquoteString(directives[0]);
|
||||
|
||||
@@ -30,8 +30,8 @@ public class FormattingSettingsConfigurator {
|
||||
private final String[] settingsToFalse;
|
||||
|
||||
public FormattingSettingsConfigurator(String fileText) {
|
||||
settingsToTrue = InTextDirectivesUtils.findArrayWithPrefix(fileText, "// SET_TRUE:");
|
||||
settingsToFalse = InTextDirectivesUtils.findArrayWithPrefix(fileText, "// SET_FALSE:");
|
||||
settingsToTrue = InTextDirectivesUtils.findArrayWithPrefixes(fileText, "// SET_TRUE:");
|
||||
settingsToFalse = InTextDirectivesUtils.findArrayWithPrefixes(fileText, "// SET_FALSE:");
|
||||
}
|
||||
|
||||
public void configureSettings(CodeStyleSettings settings) {
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
|
||||
configureByFile(path);
|
||||
|
||||
String fileText = FileUtil.loadFile(new File(path));
|
||||
String isApplicableString = InTextDirectivesUtils.findStringWithPrefix(fileText, "// IS_APPLICABLE: ");
|
||||
String isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// IS_APPLICABLE: ");
|
||||
boolean isApplicableExpected = isApplicableString == null || isApplicableString.equals("true");
|
||||
|
||||
assert isApplicableExpected == intentionAction.isAvailable(getProject(), getEditor(), getFile())
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public abstract class AbstractSurroundWithTest extends LightCodeInsightTestCase
|
||||
configureByFile(path);
|
||||
|
||||
String fileText = FileUtil.loadFile(new File(path));
|
||||
String isApplicableString = InTextDirectivesUtils.findStringWithPrefix(fileText, "// IS_APPLICABLE: ");
|
||||
String isApplicableString = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// IS_APPLICABLE: ");
|
||||
|
||||
if (isApplicableString != null) {
|
||||
boolean isApplicableExpected = toString().equals("true");
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class NavigationTestUtils {
|
||||
|
||||
public static void assertGotoImplementations(Editor editor, GotoTargetHandler.GotoData gotoData) {
|
||||
// Get expected references from the tested document
|
||||
List<String> expectedReferences = InTextDirectivesUtils.findListWithPrefix(editor.getDocument().getText(), "// REF:");
|
||||
List<String> expectedReferences = InTextDirectivesUtils.findListWithPrefixes(editor.getDocument().getText(), "// REF:");
|
||||
Collections.sort(expectedReferences);
|
||||
|
||||
if (gotoData != null) {
|
||||
@@ -72,11 +72,11 @@ public final class NavigationTestUtils {
|
||||
|
||||
public static void assertGotoSymbol(@NotNull Project project, @NotNull Editor editor) {
|
||||
|
||||
List<String> searchTextList = InTextDirectivesUtils.findListWithPrefix(editor.getDocument().getText(), "// SEARCH_TEXT:");
|
||||
List<String> searchTextList = InTextDirectivesUtils.findListWithPrefixes(editor.getDocument().getText(), "// SEARCH_TEXT:");
|
||||
Assert.assertFalse("There's no search text in test data file given. Use '// SEARCH_TEXT:' directive",
|
||||
searchTextList.isEmpty());
|
||||
|
||||
List<String> expectedReferences = InTextDirectivesUtils.findListWithPrefix(editor.getDocument().getText(), "// REF:");
|
||||
List<String> expectedReferences = InTextDirectivesUtils.findListWithPrefixes(editor.getDocument().getText(), "// REF:");
|
||||
|
||||
String searchText = searchTextList.get(0);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class QuickFixActionsUtils {
|
||||
}
|
||||
});
|
||||
|
||||
List<String> expectedErrorStrings = InTextDirectivesUtils.findLinesWithPrefixRemoved(file.getText(), "// ERROR:");
|
||||
List<String> expectedErrorStrings = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ERROR:");
|
||||
Collections.sort(expectedErrorStrings);
|
||||
|
||||
UsefulTestCase.assertOrderedEquals(
|
||||
@@ -69,7 +69,7 @@ public class QuickFixActionsUtils {
|
||||
|
||||
public static void checkAvailableActionsAreExpected(JetFile file, Collection<IntentionAction> availableActions) {
|
||||
List<String> validActions = Ordering.natural().sortedCopy(
|
||||
Sets.newHashSet(InTextDirectivesUtils.findLinesWithPrefixRemoved(file.getText(), "// ACTION:")));
|
||||
Sets.newHashSet(InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ACTION:")));
|
||||
|
||||
Collection<String> actualActions = Ordering.natural().sortedCopy(
|
||||
Collections2.transform(availableActions, new Function<IntentionAction, String>() {
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class AbstractSearcherTest extends LightCodeInsightFixtureTestCa
|
||||
}
|
||||
|
||||
protected void checkResult(Query<?> actual) throws IOException {
|
||||
List<String> expected = InTextDirectivesUtils.findListWithPrefix(FileUtil.loadFile(new File(getPathToFile())), "// SEARCH: ");
|
||||
List<String> expected = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())), "// SEARCH: ");
|
||||
List<String> actualModified = new ArrayList<String>();
|
||||
for (Object member : actual) {
|
||||
actualModified.add(member.toString());
|
||||
|
||||
@@ -42,7 +42,8 @@ public class AnnotatedMembersSearchTest extends AbstractSearcherTest {
|
||||
|
||||
private void doTest() throws IOException {
|
||||
myFixture.configureByFile(getFileName());
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefix(FileUtil.loadFile(new File(getPathToFile())), "// ANNOTATION: ");
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())),
|
||||
"// ANNOTATION: ");
|
||||
assertFalse("Specify ANNOTATION directive in test file", directives.isEmpty());
|
||||
String annotationClassName = directives.get(0);
|
||||
PsiClass psiClass = getPsiClass(annotationClassName);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ClassInheritorsSearchTest extends AbstractSearcherTest {
|
||||
|
||||
private void doTest() throws IOException {
|
||||
myFixture.configureByFile(getFileName());
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefix(FileUtil.loadFile(new File(getPathToFile())), "// CLASS: ");
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())), "// CLASS: ");
|
||||
assertFalse("Specify CLASS directive in test file", directives.isEmpty());
|
||||
String superClassName = directives.get(0);
|
||||
PsiClass psiClass = getPsiClass(superClassName);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class JUnitMembersSearcherTest extends AbstractSearcherTest {
|
||||
|
||||
private void doJUnit3test() throws IOException {
|
||||
myFixture.configureByFile(getFileName());
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefix(FileUtil.loadFile(new File(getPathToFile())), "// CLASS: ");
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())), "// CLASS: ");
|
||||
assertFalse("Specify CLASS directive in test file", directives.isEmpty());
|
||||
String superClassName = directives.get(0);
|
||||
PsiClass psiClass = getPsiClass(superClassName);
|
||||
@@ -58,7 +58,8 @@ public class JUnitMembersSearcherTest extends AbstractSearcherTest {
|
||||
|
||||
private void doJUnit4test() throws IOException {
|
||||
myFixture.configureByFile(getFileName());
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefix(FileUtil.loadFile(new File(getPathToFile())), "// ANNOTATION: ");
|
||||
List<String> directives = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile())),
|
||||
"// ANNOTATION: ");
|
||||
assertFalse("Specify ANNOTATION directive in test file", directives.isEmpty());
|
||||
String annotationClassName = directives.get(0);
|
||||
PsiClass psiClass = getPsiClass(annotationClassName);
|
||||
|
||||
Reference in New Issue
Block a user