public void execute() {
if (myProcessInputWriter == null || myConsoleHistoryModel == null) {
return;
}
LanguageConsoleImpl console = getConsole();
EditorEx consoleEditor = console.getConsoleEditor();
Document editorDocument = consoleEditor.getDocument();
String text = editorDocument.getText();
PsiFile file = console.getFile();
final Map<String, ErlangQVar> context = file.getOriginalFile().getUserData(ErlangVarProcessor.ERLANG_VARIABLE_CONTEXT);
if (context != null) { // todo: process only successful statements
file.accept(new ErlangRecursiveVisitor() {
@Override
public void visitQVar(@NotNull ErlangQVar o) {
String name = o.getName();
if (!context.containsKey(name)) context.put(name, o);
}
@Override
public void visitFunctionCallExpression(@NotNull ErlangFunctionCallExpression o) {
String name = o.getNameIdentifier().getText();
int size = o.getArgumentList().getExpressionList().size();
if (name.equals("f") && size == 0) context.clear();
}
});
}
console.addCurrentToHistory(new TextRange(0, text.length()), true, true);
myConsoleHistoryModel.addToHistory(text);
for (String line : text.split("\n")) {
try {
myProcessInputWriter.write(line + "\n");
myProcessInputWriter.flush();