0f74c0277511026d97765710fce2c199d10432f9
[idea/community.git] / python / educational-python / src / com / jetbrains / python / edu / debugger / PyEduConsoleInputFilterProvider.java
1 package com.jetbrains.python.edu.debugger;
2
3 import com.intellij.execution.filters.ConsoleInputFilterProvider;
4 import com.intellij.execution.filters.InputFilter;
5 import com.intellij.execution.ui.ConsoleViewContentType;
6 import com.intellij.openapi.project.Project;
7 import com.intellij.openapi.util.Pair;
8 import org.jetbrains.annotations.NotNull;
9 import org.jetbrains.annotations.Nullable;
10
11 import java.util.Collections;
12 import java.util.List;
13
14 public class PyEduConsoleInputFilterProvider implements ConsoleInputFilterProvider {
15   @NotNull
16   @Override
17   public InputFilter[] getDefaultFilters(@NotNull Project project) {
18     return new InputFilter[]{new InputFilter() {
19       @Nullable
20       @Override
21       public List<Pair<String, ConsoleViewContentType>> applyFilter(String text, ConsoleViewContentType outputType) {
22         if (outputType.equals(ConsoleViewContentType.SYSTEM_OUTPUT) && !text.contains("exit code")) {
23           return Collections.emptyList();
24         }
25         if (text.startsWith("pydev debugger")) {
26           return Collections.emptyList();
27         }
28         return Collections.singletonList(Pair.create(text, outputType));
29       }
30     }};
31   }
32 }