Minor refactoring in InTextDirectivesUtils
This commit is contained in:
@@ -71,7 +71,7 @@ public class JetConfidenceTest extends LightCompletionTestCase {
|
|||||||
protected static String getTypeTextFromFile() {
|
protected static String getTypeTextFromFile() {
|
||||||
String text = getEditor().getDocument().getText();
|
String text = getEditor().getDocument().getText();
|
||||||
|
|
||||||
String[] directives = InTextDirectivesUtils.findListWithPrefix(TYPE_DIRECTIVE_PREFIX, text);
|
String[] directives = InTextDirectivesUtils.findArrayWithPrefix(TYPE_DIRECTIVE_PREFIX, text);
|
||||||
assertEquals("One directive with \"" + TYPE_DIRECTIVE_PREFIX +"\" expected", 1, directives.length);
|
assertEquals("One directive with \"" + TYPE_DIRECTIVE_PREFIX +"\" expected", 1, directives.length);
|
||||||
|
|
||||||
return StringUtil.unquoteString(directives[0]);
|
return StringUtil.unquoteString(directives[0]);
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ public class FormattingSettingsConfigurator {
|
|||||||
private final String[] settingsToFalse;
|
private final String[] settingsToFalse;
|
||||||
|
|
||||||
public FormattingSettingsConfigurator(String fileText) {
|
public FormattingSettingsConfigurator(String fileText) {
|
||||||
settingsToTrue = InTextDirectivesUtils.findListWithPrefix("// SET_TRUE:", fileText);
|
settingsToTrue = InTextDirectivesUtils.findArrayWithPrefix("// SET_TRUE:", fileText);
|
||||||
settingsToFalse = InTextDirectivesUtils.findListWithPrefix("// SET_FALSE:", fileText);
|
settingsToFalse = InTextDirectivesUtils.findArrayWithPrefix("// SET_FALSE:", fileText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configureSettings(CodeStyleSettings settings) {
|
public void configureSettings(CodeStyleSettings settings) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public final class ImplementationTestUtils {
|
|||||||
|
|
||||||
public static void assertGotoImplementations(Editor editor, GotoTargetHandler.GotoData gotoData) {
|
public static void assertGotoImplementations(Editor editor, GotoTargetHandler.GotoData gotoData) {
|
||||||
// Get expected references from the tested document
|
// Get expected references from the tested document
|
||||||
List<String> expectedReferences = Arrays.asList(InTextDirectivesUtils.findListWithPrefix("// REF:", editor.getDocument().getText()));
|
List<String> expectedReferences = InTextDirectivesUtils.findListWithPrefix("// REF:", editor.getDocument().getText());
|
||||||
Collections.sort(expectedReferences);
|
Collections.sort(expectedReferences);
|
||||||
|
|
||||||
if (gotoData != null) {
|
if (gotoData != null) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public final class InTextDirectivesUtils {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Integer getPrefixedInt(String fileText, String prefix) {
|
public static Integer getPrefixedInt(String fileText, String prefix) {
|
||||||
final String[] numberStrings = findListWithPrefix(prefix, fileText);
|
final String[] numberStrings = findArrayWithPrefix(prefix, fileText);
|
||||||
if (numberStrings.length > 0) {
|
if (numberStrings.length > 0) {
|
||||||
return Integer.parseInt(numberStrings[0]);
|
return Integer.parseInt(numberStrings[0]);
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,12 @@ public final class InTextDirectivesUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String[] findListWithPrefix(String prefix, String fileText) {
|
public static String[] findArrayWithPrefix(String prefix, String fileText) {
|
||||||
|
return ArrayUtil.toStringArray(findListWithPrefix(prefix, fileText));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static List<String> findListWithPrefix(String prefix, String fileText) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
for (String line : findLinesWithPrefixRemoved(prefix, fileText)) {
|
for (String line : findLinesWithPrefixRemoved(prefix, fileText)) {
|
||||||
@@ -57,7 +62,7 @@ public final class InTextDirectivesUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ArrayUtil.toStringArray(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user