mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-10182 Pass --hang-closing to pycodestyle.py if it's enabled in settings
This commit is contained in:
@@ -125,14 +125,16 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
|
||||
private final HighlightDisplayLevel level;
|
||||
private final List<String> ignoredErrors;
|
||||
private final int margin;
|
||||
private final boolean hangClosingBrackets;
|
||||
|
||||
public State(String interpreterPath, String fileText, HighlightDisplayLevel level,
|
||||
List<String> ignoredErrors, int margin) {
|
||||
List<String> ignoredErrors, int margin, boolean hangClosingBrackets) {
|
||||
this.interpreterPath = interpreterPath;
|
||||
this.fileText = fileText;
|
||||
this.level = level;
|
||||
this.ignoredErrors = ignoredErrors;
|
||||
this.margin = margin;
|
||||
this.hangClosingBrackets = hangClosingBrackets;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,20 +181,22 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
|
||||
return null;
|
||||
}
|
||||
final PyPep8Inspection inspection = (PyPep8Inspection)profile.getUnwrappedTool(PyPep8Inspection.KEY.toString(), file);
|
||||
final CodeStyleSettings currentSettings = CodeStyleSettingsManager.getInstance(file.getProject()).getCurrentSettings();
|
||||
final CodeStyleSettings commonSettings = CodeStyleSettingsManager.getInstance(file.getProject()).getCurrentSettings();
|
||||
final PyCodeStyleSettings customSettings = commonSettings.getCustomSettings(PyCodeStyleSettings.class);
|
||||
|
||||
final List<String> ignoredErrors = Lists.newArrayList(inspection.ignoredErrors);
|
||||
if (!currentSettings.getCustomSettings(PyCodeStyleSettings.class).SPACE_AFTER_NUMBER_SIGN) {
|
||||
if (!customSettings.SPACE_AFTER_NUMBER_SIGN) {
|
||||
ignoredErrors.add("E262"); // Block comment should start with a space
|
||||
ignoredErrors.add("E265"); // Inline comment should start with a space
|
||||
}
|
||||
|
||||
if (!currentSettings.getCustomSettings(PyCodeStyleSettings.class).SPACE_BEFORE_NUMBER_SIGN) {
|
||||
if (!customSettings.SPACE_BEFORE_NUMBER_SIGN) {
|
||||
ignoredErrors.add("E261"); // At least two spaces before inline comment
|
||||
}
|
||||
|
||||
final int margin = currentSettings.getRightMargin(file.getLanguage());
|
||||
return new State(homePath, file.getText(), profile.getErrorLevel(key, file), ignoredErrors, margin);
|
||||
final int margin = commonSettings.getRightMargin(file.getLanguage());
|
||||
return new State(homePath, file.getText(), profile.getErrorLevel(key, file),
|
||||
ignoredErrors, margin, customSettings.HANG_CLOSING_BRACKETS);
|
||||
}
|
||||
|
||||
private static void reportMissingInterpreter() {
|
||||
@@ -214,6 +218,9 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
|
||||
if (!collectedInfo.ignoredErrors.isEmpty()) {
|
||||
options.add("--ignore=" + DEFAULT_IGNORED_ERRORS + "," + StringUtil.join(collectedInfo.ignoredErrors, ","));
|
||||
}
|
||||
if (collectedInfo.hangClosingBrackets) {
|
||||
options.add("--hang-closing");
|
||||
}
|
||||
options.add("--max-line-length=" + collectedInfo.margin);
|
||||
options.add("-");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user