Skip to content
Snippets Groups Projects
Commit ff7235a8 authored by dgelessus's avatar dgelessus
Browse files

Remove CommandUtils.(inspect|complete)In(BExpression|Preference)

All code now uses the (bExpression|preference)(Inspector|Completer)
methods instead.
parent d9cd8522
Branches
Tags
No related merge requests found
...@@ -393,7 +393,8 @@ public final class CommandUtils { ...@@ -393,7 +393,8 @@ public final class CommandUtils {
return result; return result;
} }
public static @Nullable DisplayData inspectInBExpression(final @NotNull Trace trace, final @NotNull String code, final int at) { public static @NotNull Inspector bExpressionInspector(final @NotNull Trace trace) {
return (code, at) -> {
final Matcher identifierMatcher = CommandUtils.matchBIdentifierAt(code, at); final Matcher identifierMatcher = CommandUtils.matchBIdentifierAt(code, at);
if (identifierMatcher == null) { if (identifierMatcher == null) {
return null; return null;
...@@ -404,13 +405,11 @@ public final class CommandUtils { ...@@ -404,13 +405,11 @@ public final class CommandUtils {
final AbstractEvalResult currentValue = trace.evalCurrent(formula); final AbstractEvalResult currentValue = trace.evalCurrent(formula);
return formatBExpressionInspectText(identifier, type, currentValue); return formatBExpressionInspectText(identifier, type, currentValue);
};
} }
public static @NotNull Inspector bExpressionInspector(final @NotNull Trace trace) { public static @NotNull Completer bExpressionCompleter(final @NotNull Trace trace) {
return (code, at) -> inspectInBExpression(trace, code, at); return (code, at) -> {
}
public static @NotNull ReplacementOptions completeInBExpression(final @NotNull Trace trace, final @NotNull String code, final int at) {
final Matcher identifierMatcher = matchBIdentifierAt(code, at); final Matcher identifierMatcher = matchBIdentifierAt(code, at);
// Try to find the identifier that the cursor is in. // Try to find the identifier that the cursor is in.
// If the cursor is not on an identifier, default to empty string, i. e. show all possible completions. // If the cursor is not on an identifier, default to empty string, i. e. show all possible completions.
...@@ -440,10 +439,7 @@ public final class CommandUtils { ...@@ -440,10 +439,7 @@ public final class CommandUtils {
completions.addAll(cmdIgnoreCase.getCompletions()); completions.addAll(cmdIgnoreCase.getCompletions());
return new ReplacementOptions(new ArrayList<>(completions), start, end); return new ReplacementOptions(new ArrayList<>(completions), start, end);
} };
public static @NotNull Completer bExpressionCompleter(final @NotNull Trace trace) {
return (code, at) -> completeInBExpression(trace, code, at);
} }
private static @NotNull DisplayData formatPreferenceInspectText(final String name, final String currentValue, final ProBPreference pref) { private static @NotNull DisplayData formatPreferenceInspectText(final String name, final String currentValue, final ProBPreference pref) {
...@@ -486,7 +482,8 @@ public final class CommandUtils { ...@@ -486,7 +482,8 @@ public final class CommandUtils {
return result; return result;
} }
public static @Nullable DisplayData inspectInPreference(final @NotNull Trace trace, final @NotNull String code, final int at) { public static @NotNull Inspector preferenceInspector(final @NotNull Trace trace) {
return (code, at) -> {
final Matcher prefNameMatcher = B_IDENTIFIER_PATTERN.matcher(code); final Matcher prefNameMatcher = B_IDENTIFIER_PATTERN.matcher(code);
if (prefNameMatcher.lookingAt() && at <= prefNameMatcher.end()) { if (prefNameMatcher.lookingAt() && at <= prefNameMatcher.end()) {
final String name = prefNameMatcher.group(); final String name = prefNameMatcher.group();
...@@ -504,13 +501,11 @@ public final class CommandUtils { ...@@ -504,13 +501,11 @@ public final class CommandUtils {
} else { } else {
return null; return null;
} }
};
} }
public static @NotNull Inspector preferenceInspector(final @NotNull Trace trace) { public static @NotNull Completer preferenceCompleter(final @NotNull Trace trace) {
return (code, at) -> inspectInPreference(trace, code, at); return (code, at) -> {
}
public static @Nullable ReplacementOptions completeInPreference(final @NotNull Trace trace, final @NotNull String code, final int at) {
final Matcher prefNameMatcher = B_IDENTIFIER_PATTERN.matcher(code); final Matcher prefNameMatcher = B_IDENTIFIER_PATTERN.matcher(code);
if (prefNameMatcher.lookingAt() && at <= prefNameMatcher.end()) { if (prefNameMatcher.lookingAt() && at <= prefNameMatcher.end()) {
final String prefix = code.substring(prefNameMatcher.start(), at); final String prefix = code.substring(prefNameMatcher.start(), at);
...@@ -521,9 +516,6 @@ public final class CommandUtils { ...@@ -521,9 +516,6 @@ public final class CommandUtils {
} else { } else {
return null; return null;
} }
} };
public static @NotNull Completer preferenceCompleter(final @NotNull Trace trace) {
return (code, at) -> completeInPreference(trace, code, at);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment