Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP code #1

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
21 changes: 9 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ buildscript {

plugins {
id 'org.jetbrains.intellij' version '0.4.17'
id 'net.ltgt.errorprone' version '0.0.16'
id 'net.ltgt.errorprone' version '2.0.2'
id 'idea'
id 'java'
id 'checkstyle'
@@ -45,11 +45,10 @@ checkstyle {
ignoreFailures = false // Whether this task will ignore failures and continue running the build.
configFile rootProject.file('config/checkstyle/checkstyle.xml')
// The Checkstyle configuration file to use.
toolVersion = '8.29' // The version of Checkstyle you want to be used
toolVersion = '9.1' // The version of Checkstyle you want to be used
}

def hasPyCharm = project.hasProperty('pycharmPath')
def hasPythonPlugin = project.hasProperty('pythonPlugin')
def hasPycharmPath = project.hasProperty('pycharmPath')
def props = new Properties()
rootProject.file('src/main/resources/com/leinardi/pycharm/mypy/MypyBundle.properties')
.withInputStream {
@@ -69,16 +68,14 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

intellij {
version ideaVersion
version ideVersion
pluginName props.getProperty('plugin.name').toLowerCase().replace(' ', '-')
downloadSources Boolean.valueOf(downloadIdeaSources)
updateSinceUntilBuild = true
if (hasPyCharm) {
if (hasPycharmPath) {
alternativeIdePath pycharmPath
}
if (hasPythonPlugin) {
plugins += [pythonPlugin]
}
plugins += [pythonPlugin]
}

patchPluginXml {
@@ -99,18 +96,18 @@ repositories {
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'https://dl.bintray.com/jetbrains/intellij-plugin-service' }
if (hasPyCharm) {
if (hasPycharmPath) {
flatDir {
dirs "$pycharmPath/lib"
}
}
}

dependencies {
if (hasPyCharm) {
if (hasPycharmPath) {
compileOnly name: 'pycharm'
}
errorprone 'com.google.errorprone:error_prone_core:2.3.1'
errorprone 'com.google.errorprone:error_prone_core:2.10.0'
}

def getChangelogHtml() {
6 changes: 3 additions & 3 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -15,13 +15,13 @@
-->

<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">

<module name="SuppressionFilter">
<property name="file" value="config/checkstyle/checkstyle-suppressions.xml"/>
<property name="file" value="${config_loc}/checkstyle-suppressions.xml"/>
</module>

<!-- Checks that a package-info.java file exists for each package. -->
11 changes: 4 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -14,16 +14,13 @@
# limitations under the License.
#
version=0.11.2
ideaVersion=2018.1.8
ideVersion=PC-2021.2.3
pythonPlugin=PythonCore:212.5457.59
sinceBuild=181.5684
untilBuild=
downloadIdeaSources=true
publishUsername=leinardi
publishChannels=Stable
#######################################################################################################################
# Uncomment one of the following settings: either pycharmPath or pythonPlugin
#######################################################################################################################
# Run Mypy plugin inside PyCharm installed into the following path
pycharmPath=/home/leinardi/pycharm-community
# Run Mypy plugin inside IntelliJ IDEA with the Python plugin. The IDE and the plugin will be downloaded automatically
pythonPlugin=PythonCore:2018.1.181.5087.50
# To run PyCharm from a custom path, uncomment and change the following line
# pycharmPath=/home/leinardi/pycharm-community
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -16,6 +16,6 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
* Tree node with togglable visibility.
@@ -44,9 +44,10 @@ public void setVisible(final boolean visible) {
this.visible = visible;
}

@SuppressWarnings("unchecked")
List<TogglableTreeNode> getAllChildren() {
return Collections.unmodifiableList(children);
return children.stream()
.map(child -> (TogglableTreeNode) child)
.collect(Collectors.toList());
}

@Override
Original file line number Diff line number Diff line change
@@ -5,16 +5,22 @@

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;

public class MypyRunnerTest {
private static InputStream stringToStream(String s) {
return new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
}

@Test
public void testParseWithColon() throws IOException {
String message = "Dict entry 0 has incompatible type \"int\": \"str\"; expected \"int\": \"int\" [dict-item]";
String input = "path/testfile.py:1:22: error: " + message + "\n";
Issue parsed = new Issue("path/testfile.py", 1, 22, SeverityLevel.ERROR, message);

List<Issue> results = MypyRunner.parseMypyOutput(new ByteArrayInputStream(input.getBytes()));
List<Issue> results = MypyRunner.parseMypyOutput(stringToStream(input));
Assert.assertArrayEquals(results.toArray(), new Issue[]{parsed});
}
}