From b35148099022fb9e8c8e8b329aa55ef190ca547d Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Thu, 30 Aug 2018 21:33:50 +0200 Subject: [PATCH] Properly handling plurals --- build.gradle | 1 + gradle.properties | 2 +- .../pycharm/pylint/PylintConfigurable.java | 4 + .../pylint/toolwindow/ResultTreeModel.java | 56 +++++---- src/main/resources/META-INF/plugin.xml | 2 +- .../pycharm/pylint/PylintBundle.properties | 114 ++---------------- 6 files changed, 49 insertions(+), 130 deletions(-) diff --git a/build.gradle b/build.gradle index 6f8b809..4f02746 100644 --- a/build.gradle +++ b/build.gradle @@ -63,6 +63,7 @@ intellij { version ideaVersion pluginName 'Pylint' downloadSources Boolean.valueOf(downloadIdeaSources) + updateSinceUntilBuild = false if (hasPyCharm) { alternativeIdePath pycharmPath } else if (hasPythonPlugin) { diff --git a/gradle.properties b/gradle.properties index 5c9c776..2db6e6a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ # limitations under the License. # version=0.1.0 -ideaVersion=2018.2.1 +ideaVersion=2016.1 downloadIdeaSources=true ####################################################################################################################### # Uncomment one of the following settings: either pycharmPath or pythonPlugin diff --git a/src/main/java/com/leinardi/pycharm/pylint/PylintConfigurable.java b/src/main/java/com/leinardi/pycharm/pylint/PylintConfigurable.java index 6a25aaf..bd62a33 100644 --- a/src/main/java/com/leinardi/pycharm/pylint/PylintConfigurable.java +++ b/src/main/java/com/leinardi/pycharm/pylint/PylintConfigurable.java @@ -60,6 +60,10 @@ public JComponent createComponent() { return configPanel.getPanel(); } + @Override + public void reset() { + } + @Override public boolean isModified() { boolean result = !configPanel.getPathToPylint().equals(pylintConfigService.getPathToPylint()); diff --git a/src/main/java/com/leinardi/pycharm/pylint/toolwindow/ResultTreeModel.java b/src/main/java/com/leinardi/pycharm/pylint/toolwindow/ResultTreeModel.java index 02a20af..ae1f772 100644 --- a/src/main/java/com/leinardi/pycharm/pylint/toolwindow/ResultTreeModel.java +++ b/src/main/java/com/leinardi/pycharm/pylint/toolwindow/ResultTreeModel.java @@ -16,6 +16,7 @@ package com.leinardi.pycharm.pylint.toolwindow; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFileSystemItem; import com.leinardi.pycharm.pylint.PylintBundle; @@ -195,9 +196,10 @@ public void setModel(final Map> results, } if (hasProblems) { - setRootText(PylintBundle.message("plugin.results.scan-results", - concatProblems(totalCounts), - results.size())); + setRootText(StringUtil.pluralize( + PylintBundle.message("plugin.results.scan-results", + concatProblems(totalCounts), + results.size()), results.size())); } else { setRootMessage("plugin.results.scan-no-results"); } @@ -217,30 +219,40 @@ private Iterable sortedFileNames(final Map> resu static String concatProblems(int[] problemCounts) { StringBuilder violations = new StringBuilder(); - if (problemCounts[SeverityLevel.FATAL.ordinal()] > 0) { - violations.append(PylintBundle.message("plugin.results.scan-results.fatal", - problemCounts[SeverityLevel.FATAL.ordinal()])); + int fatalCount = problemCounts[SeverityLevel.FATAL.ordinal()]; + if (fatalCount > 0) { + violations.append(StringUtil.pluralize( + PylintBundle.message("plugin.results.scan-results.fatal", fatalCount), + fatalCount)); violations.append(' '); } - if (problemCounts[SeverityLevel.ERROR.ordinal()] > 0) { - violations.append(PylintBundle.message("plugin.results.scan-results.error", - problemCounts[SeverityLevel.ERROR.ordinal()])); - violations.append(' '); + int errorsCount = problemCounts[SeverityLevel.ERROR.ordinal()]; + if (errorsCount > 0) { + violations.append(StringUtil.pluralize( + PylintBundle.message("plugin.results.scan-results.error", errorsCount), + errorsCount)); + violations.append(", "); } - if (problemCounts[SeverityLevel.WARNING.ordinal()] > 0) { - violations.append(PylintBundle.message("plugin.results.scan-results.warning", - problemCounts[SeverityLevel.WARNING.ordinal()])); - violations.append(' '); + int warningCount = problemCounts[SeverityLevel.WARNING.ordinal()]; + if (warningCount > 0) { + violations.append(StringUtil.pluralize( + PylintBundle.message("plugin.results.scan-results.warning", warningCount), + warningCount)); + violations.append(", "); } - if (problemCounts[SeverityLevel.CONVENTION.ordinal()] > 0) { - violations.append(PylintBundle.message("plugin.results.scan-results.convention", - problemCounts[SeverityLevel.CONVENTION.ordinal()])); - violations.append(' '); + int conventionCount = problemCounts[SeverityLevel.CONVENTION.ordinal()]; + if (conventionCount > 0) { + violations.append(StringUtil.pluralize( + PylintBundle.message("plugin.results.scan-results.convention", conventionCount), + conventionCount)); + violations.append(", "); } - if (problemCounts[SeverityLevel.REFACTOR.ordinal()] > 0) { - violations.append(PylintBundle.message("plugin.results.scan-results.refactor", - problemCounts[SeverityLevel.REFACTOR.ordinal()])); - violations.append(' '); + int refactorCount = problemCounts[SeverityLevel.REFACTOR.ordinal()]; + if (refactorCount > 0) { + violations.append(StringUtil.pluralize( + PylintBundle.message("plugin.results.scan-results.refactor", refactorCount), + refactorCount)); + violations.append(", "); } return new String(violations.deleteCharAt(violations.length() - 2)); } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index af44be1..9415ad6 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -27,7 +27,7 @@ ]]> - + diff --git a/src/main/resources/com/leinardi/pycharm/pylint/PylintBundle.properties b/src/main/resources/com/leinardi/pycharm/pylint/PylintBundle.properties index c423996..e8346be 100644 --- a/src/main/resources/com/leinardi/pycharm/pylint/PylintBundle.properties +++ b/src/main/resources/com/leinardi/pycharm/pylint/PylintBundle.properties @@ -21,8 +21,6 @@ plugin.toolwindow.action=Scan plugin.toolwindow.override=Rules: plugin.toolwindow.default-file= plugin.results.no-scan=No scan has been run as yet -plugin.results.no-rules-file=No rules file has been configured -plugin.results.rules-blacklist=The rules file is blacklisted for {0}s due to an error - you can use the ''Reload Rules file'' button to bypass this plugin.results.in-progress=A scan is in progress plugin.results.error=The scan failed due to an error - please see the event log \ for more information @@ -30,13 +28,13 @@ plugin.results.error.missing-property=Please define the property ''{0}'' in \ the Pylint settings panel plugin.results.error.instantiation-failed=The module {0} could not be loaded - \ please check you have added any prerequisites to the classpath -plugin.results.scan-no-results=Pylint found no problems in the file(s) -plugin.results.scan-results=Pylint found {0} in {1} file(s) -plugin.results.scan-results.fatal={0} fatal(s), -plugin.results.scan-results.error={0} error(s), -plugin.results.scan-results.warning={0} warning(s), -plugin.results.scan-results.convention={0} convention(s), -plugin.results.scan-results.refactor={0} refactor(s), +plugin.results.scan-no-results=Pylint found no problems +plugin.results.scan-results=Pylint found {0} in {1} file +plugin.results.scan-results.fatal={0} fatal +plugin.results.scan-results.error={0} error +plugin.results.scan-results.warning={0} warning +plugin.results.scan-results.convention={0} convention +plugin.results.scan-results.refactor={0} refactor plugin.results.scan-file-result={0} : {1} plugin.results.file-result={0} ({1}:{2}) [{3}] plugin.results.unknown-source=unknown @@ -49,25 +47,13 @@ plugin.status.aborted=Check was aborted plugin.Pylint-PyCharm.description=

This plugin provides both real-time \ and on-demand scanning of Java files with Pylint from within the PyCharm \ IDE.

-plugin.debugging=The PyCharm classpath is inconsistent, which probably means we're debugging. The classpath will be parent-first, which will break some breaks in some circumstances. -plugin.update=Pylint-PyCharm has been updated.
Release Notes plugin.notification.alerts=Pylint Alerts plugin.notification.logging=Pylint Logging plugin.exception=Unexpected Exception Caught inspection.group=Pylint inspection.display-name=Pylint real-time scan inspection.message=Pylint: {0} -pylint.not-found.SuppressionFilter=The Pylint suppression filter file was not found and will be ignored -pylint.not-found.RegexpHeader=The Pylint regexp header file was not found and will be ignored -pylint.not-found.ImportControl=The Pylint import control file was not found and will be ignored -pylint.not-found.Header=The Pylint header file was not found and will be ignored -pylint.file-not-found=The Pylint rules file could not be read pylint.file-io-failed=The Pylint rules file could not be read -pylint.configuration-disabled.file-not-found=The current Pylint configuration has been disabled as the rules file is missing. -pylint.checker-failed=The Pylint rules file could not be loaded.
{0}
The file has been blacklisted for 60s. -pylint.parse-failed=The Pylint rules file could not be parsed.
{0}
The file has been blacklisted for 60s. -pylint.could-not-read-properties=Properties could not be read from the Pylint configuration file -pylint.double-checked-locking=The Pylint configuration file is not compatible with Pylint 5.6 or above.
Please remove the DoubleCheckingLocking check. pylint.exception=The scan failed due to an exception: {0} pylint.exception-with-root-cause=The scan failed due to an exception: {0}
Root cause:
{1} config.pylint.path=Path to Pylint executable: @@ -75,98 +61,14 @@ config.pylint.path.default=pylint config.pylint.path.test=Test config.pylint.path.success.message=Success: executable found! config.pylint.path.failure.message=Failure: executable "{0}" not found -config.file.tab=Configuration File -config.file.description=The active rules file may be overridden, or deactivated, by module settings. -config.file.label.text=Configuration File: -config.url.label.text=Configuration URL: -config.file.xml.description=XML files (*.xml) -config.file.jar.description=Java Archive files (*.jar) -config.file.properties.table.0=Property Name -config.file.properties.table.1=Value -config.file.locations.table.0=Active -config.file.locations.table.1=Description -config.file.locations.table.2=File -config.file.add.text=Add -config.file.add.tooltip=Add a new configuration location -config.file.properties.text=Edit Properties -config.file.properties.tooltip=Edit the properties of the selected configuration -config.file.remove.text=Remove -config.file.remove.tooltip=Remove the selected configuration location +config.pylint.show-message-id=Show Pylint message ID in scan results config.file.browse.text=Browse config.file.browse.tooltip=Browse the file-system for Pylint executable -config.path.tab=Third-Party Checks -config.path.add.text=Add -config.path.add.tooltip=Add a new path element -config.path.edit.text=Edit -config.path.edit.tooltip=Edit an existing path element -config.path.remove.text=Remove -config.path.remove.tooltip=Remove a path element -config.path.move-up.text=Move Up -config.path.move-up.tooltip=Move a path element up in the list -config.path.move-down.text=Move Down -config.path.move-down.tooltip=Move a path element down in the list -config.csversion.labelText=Pylint version -config.scanscope.JavaOnly=Only Java sources (but not tests) -config.scanscope.JavaOnlyWithTests=Only Java sources (including tests) -config.scanscope.AllSources=All sources (but not tests) -config.scanscope.AllSourcesWithTests=All sources (including tests) -config.scanscope.Everything=All files in project -config.scanscope.labelText=Scan Scope -config.scanscope.tooltip=Choose which files should be scanned by Pylint -config.suppress-errors.checkbox.text=Treat Pylint errors as warnings -config.suppress-errors.checkbox.tooltip=If active then Pylint errors will not be marked as errors by PyCharm. -config.stabilize-classpath.text=Copy libraries from project directory (requires restart) -config.stabilize-classpath.tooltip=Prevents them from getting locked (slower) config.inspection.description=Please use the Pylint item in the Settings \ dialogue to configure the inspection -config.file.okay.text=Finish -config.file.okay.tooltip=Commit your changes and close this window -config.file.next.text=Next -config.file.previous.text=Previous -config.file.previous.tooltip=Move to the previous step of the wizard -config.file.cancel.text=Cancel -config.file.cancel.tooltip=Abandon your changes and close this window -config.file.relative-file.text=Store relative to project location -config.file.relative-file.tooltip=The file path should be stored as relative to the project location. -config.file.insecure-http.text=Ignore invalid certificates -config.file.insecure-http.tooltip=Ignore invalid certificates. Caveat emptor. -config.file.file.text=Use a local Pylint file -config.file.file.label=File: -config.file.url.text=Use a Pylint file accessible via HTTP -config.file.url.label=URL: -config.file.classpath.text=Use a Pylint file accessible via the plugin classpath -config.file.classpath.label=File: -config.file.description.text=Description: -config.file.description.tooltip=A description of this configuration file -config.file.no-file=No location has been entered. -config.file.no-description=No description has been entered. -config.file.resolve-failed=The location could not be loaded:\n\n{0} -config.file.error.caption=Loading the rule file caused an error: -config.file.error.title=Error -config.file.error.duplicate.text=This location has already been added. -config.file.error.duplicate.title=Duplicate Location -config.file.complete.text=The rules file has been validated and is ready to add. -config.module.information=You can configure available files in the project configuration. -config.module.project-configuration.text=Use project configuration -config.module.project-configuration.tooltip=If selected then the project-level settings will be used for this module -config.module.module-configuration.text=Use a custom configuration -config.module.module-configuration.tooltip=If selected then the selected rules will be used for this module -config.module.exclude.text=Exclude this module from all checks -config.module.exclude.tooltip=If selected then no checks will be run against this module -config.module.module-file.text=Pylint Rules: -config.module.module-file.tooltip=The selected Pylint rules will be used for this module -action.PylintPluginActions=Close Pylint Window -action.PylintCurrentFileAction=Check Current File -action.PylintProjectFilesAction=Check Project -action.PylintScrollToSourceAction=Autoscroll to Source -action.PylintExpandAllAction=Expand All -action.PylintCollapseAllAction=Collapse All handler.before.checkin.checkbox=Scan with Pylint handler.before.checkin.error.text={0} files contain problems handler.before.checkin.error.title=Pylint Scan handler.before.checkin.error.review=Review handler.before.checkin.scan.in-progress=Scanning... handler.before.checkin.scan.text=Pylint is Scanning -error.no-config-file=No Pylint configuration file has been specified. -error.no-config-url=No Pylint configuration URL has been specified. -error.invalid-config-url=The configuration URL is invalid.