// PY-12409
  public void testResultExceedsRightMargin() {
    final CodeStyleSettings settings = getCodeStyleSettings();
    final CommonCodeStyleSettings commonSettings =
        settings.getCommonSettings(PythonLanguage.getInstance());

    final int oldRightMargin = settings.getRightMargin(PythonLanguage.getInstance());
    final boolean oldWrapLongLines = commonSettings.WRAP_LONG_LINES;

    settings.setRightMargin(PythonLanguage.getInstance(), 80);
    commonSettings.WRAP_LONG_LINES = true;
    try {
      doTest();
    } finally {
      commonSettings.WRAP_LONG_LINES = oldWrapLongLines;
      settings.setRightMargin(PythonLanguage.getInstance(), oldRightMargin);
    }
  }
 private static TokenSet allButLambda() {
   final PythonLanguage pythonLanguage = PythonLanguage.getInstance();
   return TokenSet.create(
       IElementType.enumerate(
           new IElementType.Predicate() {
             @Override
             public boolean matches(@NotNull IElementType type) {
               return type != LAMBDA_KEYWORD && type.getLanguage().isKindOf(pythonLanguage);
             }
           }));
 }
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, final int rowIndex, final int vColIndex) {
   myEditor =
       new MyTableEditor(
           myProject,
           new PyDebuggerEditorsProvider(),
           "numpy.array.table.view",
           null,
           new XExpressionImpl(
               value.toString(), PythonLanguage.getInstance(), "", EvaluationMode.CODE_FRAGMENT),
           getActionsAdapter(rowIndex, vColIndex));
   myLastValue = value;
   return myEditor.getComponent();
 }
  @Override
  public void collectRefElements(
      PsiElement psiElement,
      @Nullable RenameProcessor renameProcessor,
      @NotNull String newName,
      Collection<PsiElement> elementsToInvert) {
    final Collection<PsiReference> refs = ReferencesSearch.search(psiElement).findAll();

    for (PsiReference ref : refs) {
      final PsiElement refElement = ref.getElement();
      final PsiElement elementToInvert = getElementToInvert(psiElement, refElement);
      if (elementToInvert != null) {
        elementsToInvert.add(elementToInvert);
      } else {
        ContainerUtil.addIfNotNull(
            elementsToInvert,
            getForeignElementToInvert(psiElement, refElement, PythonLanguage.getInstance()));
      }
    }
  }
  @NotNull
  private static Course getCourse(
      @NotNull Project project,
      @NotNull String name,
      @NotNull String[] authors,
      @NotNull String description) {
    final Course course = new Course();
    course.setName(name);
    course.setAuthors(authors);
    course.setDescription(description);
    course.setLanguage(PythonLanguage.getInstance().getID());
    course.setCourseMode(CCUtils.COURSE_MODE);

    File coursesDir = new File(PathManager.getConfigPath(), "courses");
    File courseDir = new File(coursesDir, name + "-" + project.getName());
    course.setCourseDirectory(courseDir.getPath());

    StudyTaskManager.getInstance(project).setCourse(course);
    StudyProjectComponent.getInstance(project).registerStudyToolWindow(course);
    return course;
  }
  /** @noinspection UnusedParameters */
  public PyCharmEduInitialConfigurator(
      MessageBus bus,
      CodeInsightSettings codeInsightSettings,
      final PropertiesComponent propertiesComponent,
      FileTypeManager fileTypeManager,
      final ProjectManagerEx projectManager) {
    if (!propertiesComponent.getBoolean(CONFIGURED, false)) {
      propertiesComponent.setValue(CONFIGURED, "true");
      propertiesComponent.setValue("toolwindow.stripes.buttons.info.shown", "true");
      UISettings uiSettings = UISettings.getInstance();
      uiSettings.HIDE_TOOL_STRIPES = false;
      uiSettings.SHOW_MEMORY_INDICATOR = false;
      uiSettings.SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true;
      uiSettings.SHOW_MAIN_TOOLBAR = false;
      uiSettings.SHOW_NAVIGATION_BAR = false;
      codeInsightSettings.REFORMAT_ON_PASTE = CodeInsightSettings.NO_REFORMAT;

      Registry.get("ide.new.settings.dialog").setValue(true);

      GeneralSettings.getInstance().setShowTipsOnStartup(false);

      EditorSettingsExternalizable.getInstance().setVirtualSpace(false);
      EditorSettingsExternalizable.getInstance().getOptions().ARE_LINE_NUMBERS_SHOWN = true;
      final CodeStyleSettings settings =
          CodeStyleSettingsManager.getInstance().getCurrentSettings();
      settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
      settings.getCommonSettings(PythonLanguage.getInstance()).ALIGN_MULTILINE_PARAMETERS_IN_CALLS =
          true;
      uiSettings.SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true;
      uiSettings.SHOW_MEMORY_INDICATOR = false;
      final String ignoredFilesList = fileTypeManager.getIgnoredFilesList();
      ApplicationManager.getApplication()
          .invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  ApplicationManager.getApplication()
                      .runWriteAction(
                          new Runnable() {
                            @Override
                            public void run() {
                              FileTypeManager.getInstance()
                                  .setIgnoredFilesList(ignoredFilesList + ";*$py.class");
                            }
                          });
                }
              });
      PyCodeInsightSettings.getInstance().SHOW_IMPORT_POPUP = false;
    }

    if (!propertiesComponent.isValueSet(DISPLAYED_PROPERTY)) {

      bus.connect()
          .subscribe(
              AppLifecycleListener.TOPIC,
              new AppLifecycleListener.Adapter() {
                @Override
                public void welcomeScreenDisplayed() {

                  ApplicationManager.getApplication()
                      .invokeLater(
                          new Runnable() {
                            @Override
                            public void run() {
                              if (!propertiesComponent.isValueSet(DISPLAYED_PROPERTY)) {
                                GeneralSettings.getInstance().setShowTipsOnStartup(false);
                                propertiesComponent.setValue(DISPLAYED_PROPERTY, "true");

                                patchKeymap();
                              }
                            }
                          });
                }
              });
    }

    bus.connect()
        .subscribe(
            ProjectManager.TOPIC,
            new ProjectManagerAdapter() {
              @Override
              public void projectOpened(final Project project) {
                if (project.isDefault()) return;
                if (FileChooserUtil.getLastOpenedFile(project) == null) {
                  FileChooserUtil.setLastOpenedFile(project, VfsUtil.getUserHomeDir());
                }

                patchProjectAreaExtensions(project);

                StartupManager.getInstance(project)
                    .runWhenProjectIsInitialized(
                        new DumbAwareRunnable() {
                          @Override
                          public void run() {
                            if (project.isDisposed()) return;

                            ToolWindowManager.getInstance(project)
                                .invokeLater(
                                    new Runnable() {
                                      int count = 0;

                                      public void run() {
                                        if (project.isDisposed()) return;
                                        if (count++
                                            < 3) { // we need to call this after
                                                   // ToolWindowManagerImpl.registerToolWindowsFromBeans
                                          ToolWindowManager.getInstance(project).invokeLater(this);
                                          return;
                                        }
                                        ToolWindow toolWindow =
                                            ToolWindowManager.getInstance(project)
                                                .getToolWindow("Project");
                                        if (toolWindow.getType() != ToolWindowType.SLIDING) {
                                          toolWindow.activate(null);
                                        }
                                      }
                                    });
                          }
                        });
              }
            });
  }
  /** @noinspection UnusedParameters */
  public PyCharmEduInitialConfigurator(
      MessageBus bus,
      CodeInsightSettings codeInsightSettings,
      final PropertiesComponent propertiesComponent,
      FileTypeManager fileTypeManager,
      final ProjectManagerEx projectManager) {
    final UISettings uiSettings = UISettings.getInstance();
    if (!propertiesComponent.getBoolean(CONFIGURED_V2)) {
      EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
      editorSettings.setEnsureNewLineAtEOF(true);

      propertiesComponent.setValue(CONFIGURED_V2, true);
    }
    if (!propertiesComponent.getBoolean(CONFIGURED_V1)) {
      patchMainMenu();
      uiSettings.SHOW_NAVIGATION_BAR = false;
      propertiesComponent.setValue(CONFIGURED_V1, true);
      propertiesComponent.setValue("ShowDocumentationInToolWindow", true);
    }

    if (!propertiesComponent.getBoolean(CONFIGURED)) {
      propertiesComponent.setValue(CONFIGURED, "true");
      propertiesComponent.setValue("toolwindow.stripes.buttons.info.shown", "true");

      uiSettings.HIDE_TOOL_STRIPES = false;
      uiSettings.SHOW_MEMORY_INDICATOR = false;
      uiSettings.SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true;
      uiSettings.SHOW_MAIN_TOOLBAR = false;

      codeInsightSettings.REFORMAT_ON_PASTE = CodeInsightSettings.NO_REFORMAT;

      GeneralSettings.getInstance().setShowTipsOnStartup(false);

      EditorSettingsExternalizable.getInstance().setVirtualSpace(false);
      EditorSettingsExternalizable.getInstance().getOptions().ARE_LINE_NUMBERS_SHOWN = true;
      final CodeStyleSettings settings =
          CodeStyleSettingsManager.getInstance().getCurrentSettings();
      settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
      settings.getCommonSettings(PythonLanguage.getInstance()).ALIGN_MULTILINE_PARAMETERS_IN_CALLS =
          true;
      uiSettings.SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true;
      uiSettings.SHOW_MEMORY_INDICATOR = false;
      final String ignoredFilesList = fileTypeManager.getIgnoredFilesList();
      ApplicationManager.getApplication()
          .invokeLater(
              () ->
                  ApplicationManager.getApplication()
                      .runWriteAction(
                          () ->
                              FileTypeManager.getInstance()
                                  .setIgnoredFilesList(ignoredFilesList + ";*$py.class")));
      PyCodeInsightSettings.getInstance().SHOW_IMPORT_POPUP = false;
    }
    final EditorColorsScheme editorColorsScheme =
        EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
    editorColorsScheme.setEditorFontSize(14);

    if (!propertiesComponent.isValueSet(DISPLAYED_PROPERTY)) {

      bus.connect()
          .subscribe(
              AppLifecycleListener.TOPIC,
              new AppLifecycleListener() {
                @Override
                public void welcomeScreenDisplayed() {

                  ApplicationManager.getApplication()
                      .invokeLater(
                          () -> {
                            if (!propertiesComponent.isValueSet(DISPLAYED_PROPERTY)) {
                              GeneralSettings.getInstance().setShowTipsOnStartup(false);
                              propertiesComponent.setValue(DISPLAYED_PROPERTY, "true");

                              patchKeymap();
                            }
                          });
                }
              });
    }

    bus.connect()
        .subscribe(
            ProjectManager.TOPIC,
            new ProjectManagerAdapter() {
              @Override
              public void projectOpened(final Project project) {
                if (project.isDefault()) return;
                if (FileChooserUtil.getLastOpenedFile(project) == null) {
                  FileChooserUtil.setLastOpenedFile(project, VfsUtil.getUserHomeDir());
                }

                patchProjectAreaExtensions(project);

                StartupManager.getInstance(project)
                    .runWhenProjectIsInitialized(
                        new DumbAwareRunnable() {
                          @Override
                          public void run() {
                            if (project.isDisposed()) return;
                            updateInspectionsProfile();
                            openProjectStructure();
                          }

                          private void openProjectStructure() {
                            ToolWindowManager.getInstance(project)
                                .invokeLater(
                                    new Runnable() {
                                      int count = 0;

                                      public void run() {
                                        if (project.isDisposed()) return;
                                        if (count++
                                            < 3) { // we need to call this after
                                                   // ToolWindowManagerImpl.registerToolWindowsFromBeans
                                          ToolWindowManager.getInstance(project).invokeLater(this);
                                          return;
                                        }
                                        ToolWindow toolWindow =
                                            ToolWindowManager.getInstance(project)
                                                .getToolWindow("Project");
                                        if (toolWindow != null
                                            && toolWindow.getType() != ToolWindowType.SLIDING) {
                                          toolWindow.activate(null);
                                        }
                                      }
                                    });
                          }

                          private void updateInspectionsProfile() {
                            final String[] codes = new String[] {"W29", "E501"};
                            final VirtualFile baseDir = project.getBaseDir();
                            final PsiDirectory directory =
                                PsiManager.getInstance(project).findDirectory(baseDir);
                            if (directory != null) {
                              InspectionProjectProfileManager.getInstance(project)
                                  .getInspectionProfile()
                                  .modifyToolSettings(
                                      Key.<PyPep8Inspection>create(
                                          PyPep8Inspection.INSPECTION_SHORT_NAME),
                                      directory,
                                      inspection ->
                                          Collections.addAll(inspection.ignoredErrors, codes));
                            }
                          }
                        });
              }
            });
  }
/** @author Ilya.Kazakevich */
class PyExtractSuperclassPresenterImpl
    extends MembersBasedPresenterNoPreviewImpl<
        PyExtractSuperclassView, MemberInfoModel<PyElement, PyMemberInfo<PyElement>>>
    implements PyExtractSuperclassPresenter {
  private final NamesValidator myNamesValidator =
      LanguageNamesValidation.INSTANCE.forLanguage(PythonLanguage.getInstance());

  PyExtractSuperclassPresenterImpl(
      @NotNull final PyExtractSuperclassView view,
      @NotNull final PyClass classUnderRefactoring,
      @NotNull final PyMemberInfoStorage infoStorage) {
    super(
        view,
        classUnderRefactoring,
        infoStorage,
        new PyExtractSuperclassInfoModel(classUnderRefactoring));
  }

  @Override
  protected void validateView() throws BadDataException {
    super.validateView();
    final Project project = myClassUnderRefactoring.getProject();
    if (!myNamesValidator.isIdentifier(myView.getSuperClassName(), project)) {
      throw new BadDataException(
          PyBundle.message(
              "refactoring.extract.super.name.0.must.be.ident", myView.getSuperClassName()));
    }
    boolean rootFound = false;
    final File moduleFile = new File(myView.getModuleFile());
    try {
      final String targetDir = FileUtil.toSystemIndependentName(moduleFile.getCanonicalPath());
      for (final VirtualFile file : ProjectRootManager.getInstance(project).getContentRoots()) {
        if (StringUtil.startsWithIgnoreCase(targetDir, file.getPath())) {
          rootFound = true;
          break;
        }
      }
    } catch (final IOException ignore) {
    }
    if (!rootFound) {
      throw new BadDataException(
          PyBundle.message("refactoring.extract.super.target.path.outside.roots"));
    }

    // TODO: Cover with test. It can't be done for now, because testFixture reports root path
    // incorrectly
    // PY-12173
    myView.getModuleFile();
    final VirtualFile moduleVirtualFile =
        LocalFileSystem.getInstance().findFileByIoFile(moduleFile);
    if (moduleVirtualFile != null) {
      final PsiFile psiFile = PsiManager.getInstance(project).findFile(moduleVirtualFile);
      if (psiFile instanceof PyFile) {
        if (((PyFile) psiFile).findTopLevelClass(myView.getSuperClassName()) != null) {
          throw new BadDataException(
              PyBundle.message(
                  "refactoring.extract.super.target.class.already.exists",
                  myView.getSuperClassName()));
        }
      }
    }
  }

  @Override
  public void launch() {
    final String defaultFilePath =
        FileUtil.toSystemDependentName(
            myClassUnderRefactoring.getContainingFile().getVirtualFile().getPath());
    final VirtualFile[] roots =
        ProjectRootManager.getInstance(myClassUnderRefactoring.getProject()).getContentRoots();
    final Collection<PyMemberInfo<PyElement>> pyMemberInfos =
        PyUtil.filterOutObject(myStorage.getClassMemberInfos(myClassUnderRefactoring));
    myView.configure(
        new PyExtractSuperclassInitializationInfo(myModel, pyMemberInfos, defaultFilePath, roots));
    myView.initAndShow();
  }

  @NotNull
  @Override
  protected String getCommandName() {
    return RefactoringBundle.message(
        "extract.superclass.command.name",
        myView.getSuperClassName(),
        myClassUnderRefactoring.getName());
  }

  @Override
  protected void refactorNoPreview() {
    PyExtractSuperclassHelper.extractSuperclass(
        myClassUnderRefactoring,
        myView.getSelectedMemberInfos(),
        myView.getSuperClassName(),
        myView.getModuleFile());
  }

  @NotNull
  @Override
  protected Iterable<? extends PyClass> getDestClassesToCheckConflicts() {
    return Collections.emptyList(); // No conflict can take place in newly created classes
  }
}
  public void doProcessLine(final String line) {
    final LanguageConsoleImpl console = myConsoleView.getConsole();
    final Editor currentEditor = console.getConsoleEditor();

    if (myInputBuffer == null) {
      myInputBuffer = new StringBuilder();
    }

    if (!StringUtil.isEmptyOrSpaces(line)) {
      myInputBuffer.append(line);
      if (!line.endsWith("\n")) {
        myInputBuffer.append("\n");
      }
    }

    if (StringUtil.isEmptyOrSpaces(line) && StringUtil.isEmptyOrSpaces(myInputBuffer.toString())) {
      myInputBuffer.append("");
    }

    // multiline strings handling
    if (myInMultilineStringState != null) {
      if (PyConsoleUtil.isDoubleQuoteMultilineStarts(line)
          || PyConsoleUtil.isSingleQuoteMultilineStarts(line)) {
        myInMultilineStringState = null;
        // restore language
        console.setLanguage(PythonLanguage.getInstance());
        console.setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
      } else {
        if (line.equals("\n")) {
          myInputBuffer.append("\n");
        }
        return;
      }
    } else {
      if (PyConsoleUtil.isDoubleQuoteMultilineStarts(line)) {
        myInMultilineStringState = PyConsoleUtil.DOUBLE_QUOTE_MULTILINE;
      } else if (PyConsoleUtil.isSingleQuoteMultilineStarts(line)) {
        myInMultilineStringState = PyConsoleUtil.SINGLE_QUOTE_MULTILINE;
      }
      if (myInMultilineStringState != null) {
        // change language
        console.setLanguage(PlainTextLanguage.INSTANCE);
        console.setPrompt(PyConsoleUtil.INDENT_PROMPT);
        return;
      }
    }

    // Process line continuation
    if (line.endsWith("\\")) {
      console.setPrompt(PyConsoleUtil.INDENT_PROMPT);
      return;
    }

    if (!StringUtil.isEmptyOrSpaces(line)) {
      int indent = IndentHelperImpl.getIndent(getProject(), PythonFileType.INSTANCE, line, false);
      boolean flag = false;
      if (PyConsoleIndentUtil.shouldIndent(line)) {
        indent += getPythonIndent();
        flag = true;
      }
      if ((myCurrentIndentSize > 0 && indent > 0) || flag) {
        setCurrentIndentSize(indent);
        indentEditor(currentEditor, indent);
        more(console, currentEditor);

        myConsoleCommunication.notifyCommandExecuted(true);
        return;
      }
    }

    sendLineToConsole(
        new ConsoleCommunication.ConsoleCodeFragment(myInputBuffer.toString(), true),
        console,
        currentEditor);
  }
  protected SpacingBuilder createSpacingBuilder(CodeStyleSettings settings) {
    final IFileElementType file =
        LanguageParserDefinitions.INSTANCE
            .forLanguage(PythonLanguage.getInstance())
            .getFileNodeType();
    final PyCodeStyleSettings pySettings = settings.getCustomSettings(PyCodeStyleSettings.class);

    final CommonCodeStyleSettings commonSettings =
        settings.getCommonSettings(PythonLanguage.getInstance());
    return new SpacingBuilder(commonSettings)
        .between(CLASS_DECLARATION, STATEMENT_OR_DECLARATION)
        .blankLines(commonSettings.BLANK_LINES_AROUND_CLASS)
        .between(STATEMENT_OR_DECLARATION, CLASS_DECLARATION)
        .blankLines(commonSettings.BLANK_LINES_AROUND_CLASS)
        .between(FUNCTION_DECLARATION, STATEMENT_OR_DECLARATION)
        .blankLines(commonSettings.BLANK_LINES_AROUND_METHOD)
        .between(STATEMENT_OR_DECLARATION, FUNCTION_DECLARATION)
        .blankLines(commonSettings.BLANK_LINES_AROUND_METHOD)
        .after(FUNCTION_DECLARATION)
        .blankLines(commonSettings.BLANK_LINES_AROUND_METHOD)
        .after(CLASS_DECLARATION)
        .blankLines(commonSettings.BLANK_LINES_AROUND_CLASS)
        // Remove excess blank lines between imports, because ImportOptimizer gets rid of them
        // anyway.
        // Empty lines between import groups are handles in PyBlock#getSpacing
        .between(IMPORT_STATEMENTS, IMPORT_STATEMENTS)
        .spacing(0, Integer.MAX_VALUE, 1, false, 0)
        .between(STATEMENT_OR_DECLARATION, STATEMENT_OR_DECLARATION)
        .spacing(0, Integer.MAX_VALUE, 1, false, 1)
        .between(COLON, STATEMENT_LIST)
        .spacing(1, Integer.MAX_VALUE, 0, true, 0)
        .afterInside(COLON, TokenSet.create(KEY_VALUE_EXPRESSION, LAMBDA_EXPRESSION))
        .spaceIf(pySettings.SPACE_AFTER_PY_COLON)
        .afterInside(GT, ANNOTATION)
        .spaces(1)
        .betweenInside(MINUS, GT, ANNOTATION)
        .none()
        .beforeInside(ANNOTATION, FUNCTION_DECLARATION)
        .spaces(1)
        .beforeInside(ANNOTATION, NAMED_PARAMETER)
        .none()
        .afterInside(COLON, ANNOTATION)
        .spaces(1)
        .afterInside(RARROW, ANNOTATION)
        .spaces(1)
        .between(allButLambda(), PARAMETER_LIST)
        .spaceIf(commonSettings.SPACE_BEFORE_METHOD_PARENTHESES)
        .before(COLON)
        .spaceIf(pySettings.SPACE_BEFORE_PY_COLON)
        .after(COMMA)
        .spaceIf(commonSettings.SPACE_AFTER_COMMA)
        .before(COMMA)
        .spaceIf(commonSettings.SPACE_BEFORE_COMMA)
        .between(FROM_KEYWORD, DOT)
        .spaces(1)
        .between(DOT, IMPORT_KEYWORD)
        .spaces(1)
        .around(DOT)
        .spaces(0)
        .aroundInside(AT, DECORATOR_CALL)
        .none()
        .before(SEMICOLON)
        .spaceIf(commonSettings.SPACE_BEFORE_SEMICOLON)
        .withinPairInside(LPAR, RPAR, ARGUMENT_LIST)
        .spaceIf(commonSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES)
        .withinPairInside(LPAR, RPAR, PARAMETER_LIST)
        .spaceIf(commonSettings.SPACE_WITHIN_METHOD_PARENTHESES)
        .withinPairInside(LPAR, RPAR, FROM_IMPORT_STATEMENT)
        .spaces(0)
        .withinPairInside(LPAR, RPAR, GENERATOR_EXPRESSION)
        .spaces(0)
        .withinPairInside(LPAR, RPAR, PARENTHESIZED_EXPRESSION)
        .spaces(0)
        .before(LBRACKET)
        .spaceIf(pySettings.SPACE_BEFORE_LBRACKET)
        .afterInside(LBRACE, DICT_LITERAL_EXPRESSION)
        .spaceIf(pySettings.SPACE_WITHIN_BRACES, pySettings.DICT_NEW_LINE_AFTER_LEFT_BRACE)
        .beforeInside(RBRACE, DICT_LITERAL_EXPRESSION)
        .spaceIf(pySettings.SPACE_WITHIN_BRACES, pySettings.DICT_NEW_LINE_BEFORE_RIGHT_BRACE)
        .withinPair(LBRACE, RBRACE)
        .spaceIf(pySettings.SPACE_WITHIN_BRACES)
        .withinPair(LBRACKET, RBRACKET)
        .spaceIf(commonSettings.SPACE_WITHIN_BRACKETS)
        .before(ARGUMENT_LIST)
        .spaceIf(commonSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES)
        .around(DECORATOR_CALL)
        .spacing(1, Integer.MAX_VALUE, 0, true, 0)
        .after(DECORATOR_LIST)
        .spacing(1, Integer.MAX_VALUE, 0, true, 0)
        .aroundInside(EQ, ASSIGNMENT_STATEMENT)
        .spaceIf(commonSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS)
        .aroundInside(EQ, NAMED_PARAMETER)
        .spaceIf(pySettings.SPACE_AROUND_EQ_IN_NAMED_PARAMETER)
        .aroundInside(EQ, KEYWORD_ARGUMENT_EXPRESSION)
        .spaceIf(pySettings.SPACE_AROUND_EQ_IN_KEYWORD_ARGUMENT)
        .around(AUG_ASSIGN_OPERATIONS)
        .spaceIf(commonSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS)
        .aroundInside(ADDITIVE_OPERATIONS, BINARY_EXPRESSION)
        .spaceIf(commonSettings.SPACE_AROUND_ADDITIVE_OPERATORS)
        .aroundInside(MULTIPLICATIVE_OR_EXP, STAR_PARAMETERS)
        .none()
        .around(MULTIPLICATIVE_OR_EXP)
        .spaceIf(commonSettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS)
        .around(SHIFT_OPERATIONS)
        .spaceIf(commonSettings.SPACE_AROUND_SHIFT_OPERATORS)
        .around(BITWISE_OPERATIONS)
        .spaceIf(commonSettings.SPACE_AROUND_BITWISE_OPERATORS)
        .around(EQUALITY_OPERATIONS)
        .spaceIf(commonSettings.SPACE_AROUND_EQUALITY_OPERATORS)
        .around(RELATIONAL_OPERATIONS)
        .spaceIf(commonSettings.SPACE_AROUND_RELATIONAL_OPERATORS)
        .around(SINGLE_SPACE_KEYWORDS)
        .spaces(1);
  }
 public boolean isEngagedToFormat(PsiElement context) {
   PsiFile file = context.getContainingFile();
   return file != null && file.getLanguage() == PythonLanguage.getInstance();
 }