Skip to content

Commit

Permalink
Merge pull request #95 from leinardi/master
Browse files Browse the repository at this point in the history
Release 0.15.0
  • Loading branch information
leinardi authored Apr 24, 2023
2 parents d1f7fc2 + 8161a8b commit 05d3546
Show file tree
Hide file tree
Showing 48 changed files with 601 additions and 852 deletions.
26 changes: 13 additions & 13 deletions .idea/checkstyle-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
**[0.15.0] 2023-04-24**
- Fixed Icons not visible in new Jetbrains UI
- New: Min IDEA version raised from PC-2021.2 to PC-2022.1.4
- Several dependency updates

**[0.14.0] 2022-02-26**
- New: Improved executable auto-detection on Windows
- New: Make plugin hot-reloadable
Expand Down
24 changes: 12 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath 'com.atlassian.commonmark:commonmark:0.11.0'
classpath 'com.atlassian.commonmark:commonmark:0.17.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

plugins {
id 'org.jetbrains.intellij' version '1.4.0'
id 'net.ltgt.errorprone' version '2.0.2'
id 'org.jetbrains.intellij' version '1.13.3'
id 'net.ltgt.errorprone' version '3.1.0'
id 'idea'
id 'java'
id 'checkstyle'
id 'com.github.ben-manes.versions' version '0.27.0'
id 'se.bjurr.violations.violation-comments-to-github-gradle-plugin' version '1.60'
id 'com.github.ben-manes.versions' version '0.46.0'
id 'se.bjurr.violations.violation-comments-to-github-gradle-plugin' version '1.70.0'
}

checkstyle {
Expand All @@ -55,24 +55,24 @@ rootProject.file('src/main/resources/com/leinardi/pycharm/pylint/PylintBundle.pr
}

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
}
}

group 'com.leinardi.pycharm'
version version

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

intellij {
version = ideVersion
pluginName = props.getProperty('plugin.name').toLowerCase().replace(' ', '-')
downloadSources = Boolean.valueOf(downloadIdeaSources)
updateSinceUntilBuild = true
if (hasPycharmPath) {
alternativeIdePath.set(pycharmPath)
alternativeIdePath = pycharmPath
}
plugins = [pythonPlugin]
}
Expand All @@ -99,7 +99,7 @@ patchPluginXml {

publishPlugin {
def publishToken = project.hasProperty('jetbrainsPublishToken') ? jetbrainsPublishToken : ""
token = publishToken
token.set(publishToken)
channels = [publishChannels]
}

Expand All @@ -118,7 +118,7 @@ dependencies {
compileOnly name: 'pycharm'
}
implementation 'com.squareup.moshi:moshi:1.9.1'
errorprone 'com.google.errorprone:error_prone_core:2.10.0'
errorprone 'com.google.errorprone:error_prone_core:2.18.0'
}

def getChangelogHtml() {
Expand Down Expand Up @@ -148,6 +148,6 @@ task violationCommentsToGitHub(type: se.bjurr.violations.comments.github.plugin.
}

wrapper {
gradleVersion = "7.4"
gradleVersion = "7.6"
distributionType = Wrapper.DistributionType.ALL
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
version=0.14.0
ideVersion=PC-2021.3
version=0.15.0
ideVersion=PC-2022.1.4
pythonPlugin=python-ce
sinceBuild=201.8743
sinceBuild=221.6008
untilBuild=
downloadIdeaSources=true
publishUsername=leinardi
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void apply(@NotNull PsiFile file, Results results, @NotNull AnnotationHol
HighlightSeverity severity = profile.getErrorLevel(key, file).getSeverity();

for (Problem problem : results.issues) {
LOG.debug(" " + problem.getLine() + ": " + problem.getMessage());
LOG.debug(" " + problem.line() + ": " + problem.getMessage());
problem.createAnnotation(holder, severity);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

/**
* By itself, the `PylintAnnotator` class does not provide support for the explicit "Inspect code" feature.
*
* <p>
* This class uses `ExternalAnnotatorBatchInspection` middleware to provides that functionality.
*
* <p>
* Modeled after `com.jetbrains.python.inspections.PyPep8Inspection`
*/
public class PylintBatchInspection extends LocalInspectionTool implements ExternalAnnotatorBatchInspection {
Expand Down
32 changes: 6 additions & 26 deletions src/main/java/com/leinardi/pycharm/pylint/PylintBundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,22 @@

package com.leinardi.pycharm.pylint;

import com.intellij.CommonBundle;
import com.intellij.reference.SoftReference;
import com.intellij.AbstractBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.PropertyKey;

import java.lang.ref.Reference;
import java.util.ResourceBundle;

public final class PylintBundle {

private static Reference<ResourceBundle> bundleReference;

public final class PylintBundle extends AbstractBundle {
@NonNls
private static final String BUNDLE = "com.leinardi.pycharm.pylint.PylintBundle";

private static final PylintBundle INSTANCE = new PylintBundle();

private PylintBundle() {
// utility class
super(BUNDLE);
}

public static String message(@PropertyKey(resourceBundle = BUNDLE) final String key, final Object... params) {
return CommonBundle.message(getBundle(), key, params);
}

private static ResourceBundle getBundle() {
ResourceBundle bundle = null;

if (bundleReference != null) {
bundle = bundleReference.get();
}

if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
bundleReference = new SoftReference<>(bundle);
}

return bundle;
return INSTANCE.getMessage(key, params);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.leinardi.pycharm.pylint;

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.project.Project;
Expand Down Expand Up @@ -84,6 +83,6 @@ public void loadState(@NotNull PylintConfigService config) {

@Nullable
public static PylintConfigService getInstance(Project project) {
return ServiceManager.getService(project, PylintConfigService.class);
return project.getService(PylintConfigService.class);
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/leinardi/pycharm/pylint/PylintPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.intellij.openapi.components.Service;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.leinardi.pycharm.pylint.checker.Problem;
Expand Down Expand Up @@ -69,7 +70,7 @@ public Project getProject() {

@Nullable
private File getProjectPath() {
final VirtualFile baseDir = project.getBaseDir();
final VirtualFile baseDir = ProjectUtil.guessProjectDir(project);
if (baseDir == null) {
return null;
}
Expand Down
55 changes: 26 additions & 29 deletions src/main/java/com/leinardi/pycharm/pylint/actions/BaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,36 @@

package com.leinardi.pycharm.pylint.actions;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileVisitor;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.ui.content.Content;
import com.leinardi.pycharm.pylint.PylintBundle;
import com.leinardi.pycharm.pylint.PylintPlugin;
import com.leinardi.pycharm.pylint.toolwindow.PylintToolWindowPanel;
import org.jetbrains.annotations.NotNull;

import javax.swing.JComponent;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;

import static com.intellij.openapi.actionSystem.CommonDataKeys.PROJECT;
import static com.leinardi.pycharm.pylint.actions.ToolWindowAccess.actOnToolWindowPanel;
import static java.util.Optional.ofNullable;

/**
* Base class for plug-in actions.
*/
public abstract class BaseAction extends AnAction {
public abstract class BaseAction extends DumbAwareAction {

private static final Logger LOG = Logger.getInstance(BaseAction.class);

@Override
public void update(final AnActionEvent event) {
Project project;
public void update(final @NotNull AnActionEvent event) {
try {
project = PlatformDataKeys.PROJECT.getData(event.getDataContext());
final Project project = getEventProject(event);
final Presentation presentation = event.getPresentation();

// check a project is loaded
Expand All @@ -65,8 +62,7 @@ public void update(final AnActionEvent event) {
}

// check if tool window is registered
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(
PylintToolWindowPanel.ID_TOOLWINDOW);
final ToolWindow toolWindow = ToolWindowAccess.toolWindow(project);
if (toolWindow == null) {
presentation.setEnabled(false);
presentation.setVisible(false);
Expand All @@ -83,30 +79,31 @@ public void update(final AnActionEvent event) {
}

protected void setProgressText(final ToolWindow toolWindow, final String progressTextKey) {
final Content content = toolWindow.getContentManager().getContent(0);
if (content != null) {
final JComponent component = content.getComponent();
// the content instance will be a JLabel while the component initialises
if (component instanceof PylintToolWindowPanel) {
final PylintToolWindowPanel panel = (PylintToolWindowPanel) component;
panel.setProgressText(PylintBundle.message(progressTextKey));
}
}
actOnToolWindowPanel(toolWindow, panel -> panel.setProgressText(PylintBundle.message(progressTextKey)));
}

protected Optional<Project> project(@NotNull final AnActionEvent event) {
return ofNullable(PROJECT.getData(event.getDataContext()));
return ofNullable(getEventProject(event));
}

boolean containsAtLeastOneFile(@NotNull final VirtualFile... files) {
boolean result = false;
protected boolean containsAtLeastOneFile(@NotNull final VirtualFile... files) {
final var result = new AtomicBoolean(false);
for (VirtualFile file : files) {
if ((file.isDirectory() && containsAtLeastOneFile(file.getChildren())) || (!file.isDirectory() && file
.isValid())) {
result = true;
VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor<>() {
@Override
public @NotNull Result visitFileEx(@NotNull final VirtualFile file) {
if (!file.isDirectory() && file.isValid()) {
result.set(true);
return SKIP_CHILDREN;
}
return CONTINUE;
}
});

if (result.get()) {
break;
}
}
return result;
return result.get();
}
}
32 changes: 7 additions & 25 deletions src/main/java/com/leinardi/pycharm/pylint/actions/ClearAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,21 @@
package com.leinardi.pycharm.pylint.actions;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.ui.content.Content;
import com.leinardi.pycharm.pylint.PylintPlugin;
import com.leinardi.pycharm.pylint.toolwindow.PylintToolWindowPanel;
import org.jetbrains.annotations.NotNull;

import static com.leinardi.pycharm.pylint.actions.ToolWindowAccess.actOnToolWindowPanel;
import static com.leinardi.pycharm.pylint.actions.ToolWindowAccess.toolWindow;

/**
* Action to toggle error display in tool window.
*/
public class ClearAll extends BaseAction {

@Override
public void actionPerformed(final AnActionEvent event) {
final Project project = PlatformDataKeys.PROJECT.getData(event.getDataContext());
if (project == null) {
return;
}

final PylintPlugin pylintPlugin
= project.getService(PylintPlugin.class);
if (pylintPlugin == null) {
throw new IllegalStateException("Couldn't get pylint plugin");
}

final ToolWindow toolWindow = ToolWindowManager.getInstance(
project).getToolWindow(PylintToolWindowPanel.ID_TOOLWINDOW);

final Content content = toolWindow.getContentManager().getContent(0);
if (content != null && content.getComponent() instanceof PylintToolWindowPanel) {
((PylintToolWindowPanel) content.getComponent()).clearResult();
}
public void actionPerformed(final @NotNull AnActionEvent event) {
project(event).ifPresent(project -> actOnToolWindowPanel(toolWindow(project),
PylintToolWindowPanel::clearResult));
}

}
Loading

0 comments on commit 05d3546

Please sign in to comment.