Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…harm into features/#359-rules-unresolved
  • Loading branch information
Dmitry committed Dec 18, 2021
2 parents 7cf76da + 9bcac56 commit 2b1d0b4
Show file tree
Hide file tree
Showing 103 changed files with 2,375 additions and 900 deletions.
25 changes: 22 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,32 @@

## [Unreleased]
Released on ...

### Changed
- TODO (see [#NNN](https://github.com/JetBrains-Research/snakecharm/issues/NNN))

### Fixed
- TODO (see [#NNN](https://github.com/JetBrains-Research/snakecharm/issues/NNN))

### Added
- TODO (see [#NNN](https://github.com/JetBrains-Research/snakecharm/issues/NNN))

## [2021.3.661]
Released on December 7th 2021

### Changed
- PyCharm 2021.3 compatibility (see [#444](https://github.com/JetBrains-Research/snakecharm/issues/444))
Released on December 7th 2021

## [2021.2.657]
Released on December 6th 2021

### Changed
- Show argument preview for int indexes completion in `output[i]` (see [#378](https://github.com/JetBrains-Research/snakecharm/issues/378))
- Allocation of all top-level sections into one token and support for unknown top-level sections (see [#373](https://github.com/JetBrains-Research/snakecharm/issues/373))
- TODO (see [#NNN](https://github.com/JetBrains-Research/snakecharm/issues/NNN))

### Fixed
- Resolve and completion for 'script' section (see [#426](https://github.com/JetBrains-Research/snakecharm/issues/426))
- Only snakemake file can't end with a comment (see [#365](https://github.com/JetBrains-Research/snakecharm/issues/365))
- SmkSectionDuplicatedArgsInspection now checks workflow top-level sections (see [#407](https://github.com/JetBrains-Research/snakecharm/issues/407))
- All inspections warnings now can be overridden (see [#423](https://github.com/JetBrains-Research/snakecharm/issues/423))
Expand All @@ -21,10 +40,11 @@ Released on ...
- Inspection: Do not show warning that rule section is unused variable if rule is defined in method (see [#385](https://github.com/JetBrains-Research/snakecharm/issues/385))
- SOE: From UnusedLocal inspection for SnakemakeSL expression (see [#380](https://github.com/JetBrains-Research/snakecharm/issues/380))
- Do not show syntax error for rule w/o body (see [#420](https://github.com/JetBrains-Research/snakecharm/issues/420))
- TODO (see [#NNN](https://github.com/JetBrains-Research/snakecharm/issues/NNN))

### Added
- Color Settings Page (see [#431](https://github.com/JetBrains-Research/snakecharm/issues/431))
- Inspection: highlights 'use rule' section which overrides several rules as one (see [#411](https://github.com/JetBrains-Research/snakecharm/issues/411))
- Collecting wildcards from overridden rules in 'use' sections (see [#418](https://github.com/JetBrains-Research/snakecharm/issues/418))
- Weak warnings for unused 'log' sections in 'use rule' (see [#414](https://github.com/JetBrains-Research/snakecharm/issues/414))
- Weak warnings for unused 'log' sections (see [#300](https://github.com/JetBrains-Research/snakecharm/issues/300))
- Support for 'module' and 'use' keywords (see [#355](https://github.com/JetBrains-Research/snakecharm/issues/355))
Expand All @@ -36,7 +56,6 @@ Released on ...
- Completion features related to 'use' section (see [#413](https://github.com/JetBrains-Research/snakecharm/issues/413))
- Add reference for 'snakefile:' in module declaration (see [#409](https://github.com/JetBrains-Research/snakecharm/issues/409))
- Initial PEPs support (see [#360](https://github.com/JetBrains-Research/snakecharm/issues/360))
- TODO (see [#NNN](https://github.com/JetBrains-Research/snakecharm/issues/NNN))

## [2021.2.424]
Released on July 5th 2021
Expand Down
58 changes: 28 additions & 30 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.changelog.date
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand All @@ -11,13 +10,13 @@ plugins {
id("java")

// Kotlin support
kotlin("jvm") version "1.5.31"
kotlin("plugin.serialization") version "1.5.31"
kotlin("jvm") version "1.6.0"
kotlin("plugin.serialization") version "1.6.0"

// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
// This plugin allows you to build plugins for IntelliJ platform using specific
// IntelliJ SDK and bundled plugins.
id("org.jetbrains.intellij") version "1.2.1"
id("org.jetbrains.intellij") version "1.3.0"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "1.3.1"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
Expand All @@ -42,7 +41,7 @@ dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:1.3.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:1.3.1")
}

// Configure gradle-intellij-plugin plugin.
Expand Down Expand Up @@ -97,18 +96,18 @@ detekt {
}

tasks {
// TODO [1.8] ?
// Set the compatibility versions to 11
withType<JavaCompile> {
sourceCompatibility = "11"
targetCompatibility = "11"
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
properties("javaVersion").let {
withType<JavaCompile> {
sourceCompatibility = it
targetCompatibility = it
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = it
}
}

withType<Detekt> {
jvmTarget = "11"
wrapper {
gradleVersion = properties("gradleVersion")
}

patchPluginXml {
Expand All @@ -117,17 +116,17 @@ tasks {
untilBuild.set(properties("pluginUntilBuild"))

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
File(projectDir, "README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").run { markdownToHTML(this) }
)
pluginDescription.set(
projectDir.resolve("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").run { markdownToHTML(this) }
)

// Get the latest available change notes from the changelog file
changeNotes.set(provider { changelog.getLatest().toHTML() })
Expand All @@ -139,7 +138,6 @@ tasks {
}

publishPlugin {

dependsOn("patchChangelog")
token.set(properties("intellijPublishToken"))
// plugin version is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
Expand Down Expand Up @@ -173,8 +171,8 @@ tasks {
dependsOn("compileKotlin", "compileJava")
doLast {
javaexec {
main = "com.jetbrains.snakecharm.codeInsight.completion.wrapper.SmkWrapperCrawler"
classpath = project.sourceSets.main.get().runtimeClasspath + files(intellij.ideaDependency.get().jarFiles)
mainClass.set("com.jetbrains.snakecharm.codeInsight.completion.wrapper.SmkWrapperCrawler")
classpath = project.sourceSets.main.get().runtimeClasspath + files(setupDependencies.get().idea.get().jarFiles)
enableAssertions = true
args = listOf(
properties("snakemakeWrappersRepoPath"),
Expand Down Expand Up @@ -202,7 +200,7 @@ tasks {
doLast {
javaexec {
mainClass.set("com.jetbrains.snakecharm.codeInsight.completion.wrapper.SmkWrapperCrawler")
classpath = project.sourceSets.main.get().runtimeClasspath + files(intellij.ideaDependency.get().jarFiles)
classpath = project.sourceSets.main.get().runtimeClasspath + files(setupDependencies.get().idea.get().jarFiles)
enableAssertions = true
args = listOf(
"${project.projectDir}/testData/wrappers_storage",
Expand Down
17 changes: 12 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pluginName = snakecharm
# Version naming based on https://semver.org:
# * {pluginVersion}.{pluginBuildCounter}{pluginPreReleaseSuffix}
# * {pluginPreReleaseSuffix}: Use empty string [..=] for release, for eap: [..=-eap] or [..=-eap.2]
pluginVersion = 2021.2
pluginVersion = 2021.3
pluginPreReleaseSuffix=-eap
# Project build counter from CI. Can be overridden during build using `./gradlew -PbuildCounter=nnnn my_task_name`
pluginBuildCounter=SNAPSHOT
Expand All @@ -17,12 +17,12 @@ pluginBuildCounter=SNAPSHOT
#######################################################################################################################
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 211.6693.1
pluginSinceBuild = 213
pluginUntilBuild = 213.*

# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions.
pluginVerifierIdeVersions = 2021.2.2, 2021.2.3
pluginVerifierIdeVersions = 2021.3

# Versions: 2021.1.1, LATEST-EAP-SNAPSHOT, LATEST-TRUNK-SNAPSHOT, 201-EAP-SNAPSHOT, 201.7223.69
# Platforms: PC, PY, IC
Expand All @@ -42,7 +42,8 @@ platformPlugins = org.jetbrains.plugins.yaml
platformType = PC
# 2021.1.1, 213-EAP-SNAPSHOT, LATEST-TRUNK-SNAPSHOT, LATEST-EAP-SNAPSHOT, 213.5281.17, 212.5457-EAP-CANDIDATE-SNAPSHOT
# see: https://www.jetbrains.com/intellij-repository/snapshots/
platformVersion = 2021.2
platformVersion = 2021.3
#platformVersion = LATEST-EAP-SNAPSHOT
platformDownloadSources = true
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
Expand Down Expand Up @@ -70,12 +71,18 @@ pythonPlugin =
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
kotlin.stdlib.default.dependency = false

# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
javaVersion = 11

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 7.3

# Repo version for :buildWrappersBundle task. E.g. 'master', '0.68.0', 'xxx.yyy.zzz'.
# Doesn't checkout directory, please ensure that wrappers repo content version matches the value used here
# * Teamcity CI: SnakeCharm Plugin | VCS Roots | snakemake-wrappers root |
# - VCS root name: snakemake-wrappers (xxx.yyy.zzz release)
# - Branch default: refs/tags/xxx.yyy.zzz
# - Branch specification: +:refs/tags/xxx.yyy.zzz
# * To checkout tag run: `git checkout tags/xxx.yyy.zzz -b tags/xxx.yyy.zzz`
snakemakeWrappersRepoVersion=0.75.0
snakemakeWrappersRepoVersion=0.80.2
snakemakeWrappersRepoPath=/Users/romeo/work/git_repos/snakecharm_related/snakemake-wrappers
3 changes: 2 additions & 1 deletion src/main/kotlin/com/jetbrains/snakecharm/SmkNotifier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ object SmkNotifier {
fun notifySnakefileDetected(module: Module) {
NotificationGroupManager.getInstance().getNotificationGroup(NOTIFICATION_GROUP_ID).createNotification(
title = SnakemakeBundle.message("notifier.msg.framework.by.snakefile.title"),
content = SnakemakeBundle.message("notifier.msg.framework.by.snakefile", module.name)
content = SnakemakeBundle.message("notifier.msg.framework.by.snakefile", module.name),
type = NotificationType.INFORMATION
).addAction(object : NotificationAction(
SnakemakeBundle.message("notifier.msg.framework.by.snakefile.action.configure")
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.jetbrains.snakecharm.actions

import com.intellij.navigation.ChooseByNameContributorEx
import com.intellij.navigation.NavigationItem
import com.intellij.openapi.project.Project
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.stubs.StubIndex
import com.intellij.util.Processor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ object SmkWrapperCrawler {
wrapperFileExt: String,
metaYamlContent: String
): SmkWrapperStorage.WrapperInfo {
val wrapperArgs: List<Pair<String, String>> = when (wrapperFileExt.toLowerCase()) {
val wrapperArgs: List<Pair<String, String>> = when (wrapperFileExt.lowercase()) {
"py" -> parseArgsPython(wrapperFileContent)
"r" -> parseArgsR(wrapperFileContent)
else -> emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class SmkWrapperStorage(val project: Project) : Disposable {

fun cleanVersion() = version.removePrefix("refs/tags/").removePrefix("refs/heads/")

@ExperimentalSerializationApi
fun initOnStartup() {
subscribeOnEvents()

Expand All @@ -62,6 +63,7 @@ class SmkWrapperStorage(val project: Project) : Disposable {
}
}

@ExperimentalSerializationApi
private fun subscribeOnEvents() {
val connection = project.messageBus.connect()
connection.subscribe(SmkSupportProjectSettings.TOPIC, object : SmkSupportProjectSettingsListener {
Expand Down Expand Up @@ -121,6 +123,7 @@ class SmkWrapperStorage(val project: Project) : Disposable {
Disposer.register(this, connection)
}

@Suppress("PROVIDED_RUNTIME_TOO_LOW")
@Serializable
data class WrapperInfo(
val path: String = "", // system independent separators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.jetbrains.snakecharm.codeInsight.ImplicitPySymbolsProvider
import com.jetbrains.snakecharm.framework.SmkSupportProjectSettings
import kotlinx.serialization.ExperimentalSerializationApi

@ExperimentalSerializationApi
class SnakemakeStartupActivity : StartupActivity.Background {
@ExperimentalSerializationApi
override fun runActivity(project: Project) {
val smkSettings = project.service<SmkSupportProjectSettings>()
smkSettings.initOnStartup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import com.jetbrains.python.findUsages.PythonFindUsagesProvider
import com.jetbrains.snakecharm.codeInsight.resolve.SmkFakePsiElement
import com.jetbrains.snakecharm.lang.parser.SmkTokenTypes.WORKFLOW_TOPLEVEL_DECORATORS
import com.jetbrains.snakecharm.lang.parser.SnakemakeLexer
import com.jetbrains.snakecharm.lang.psi.SmkCheckPoint
import com.jetbrains.snakecharm.lang.psi.SmkRule
import com.jetbrains.snakecharm.lang.psi.SmkRuleOrCheckpointArgsSection
import com.jetbrains.snakecharm.lang.psi.SmkSection
import com.jetbrains.snakecharm.lang.psi.*
import com.jetbrains.snakecharm.stringLanguage.lang.psi.SmkSLReferenceExpressionImpl

/**
Expand All @@ -26,6 +23,7 @@ class SmkAndSmkSLFindUsagesProvider : PythonFindUsagesProvider() {
is SmkRuleOrCheckpointArgsSection -> "rule section"
is SmkRule -> "rule"
is SmkCheckPoint -> "checkpoint"
is SmkUse -> "use rule"
is SmkSection -> "section"
is SmkFakePsiElement -> "element"
is SmkSLReferenceExpressionImpl -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ class SmkAvoidTabWhitespace : SnakemakeInspection() {
override fun buildVisitor(
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
) = object : SnakemakeInspectionVisitor(holder, session) {
session: LocalInspectionToolSession,
) = object : SnakemakeInspectionVisitor(holder, getContext(session)) {

override fun visitWhiteSpace(space: PsiWhiteSpace) {
if (space.containingFile is SmkFile) {
val text = space.text
val text = space.text
if (text.startsWith("\n") && '\t' in text) {
registerProblem(space, SnakemakeBundle.message("INSP.NAME.codestyle.avoid.whitespace.tab"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class SmkCondaSectionNotAllowedWithRun : SnakemakeInspection() {
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
) = object : SnakemakeInspectionVisitor(holder, session) {
) = object : SnakemakeInspectionVisitor(holder, getContext(session)) {

override fun visitSmkRuleOrCheckpointArgsSection(st: SmkRuleOrCheckpointArgsSection) {
if (st.sectionKeyword == SnakemakeNames.SECTION_CONDA) {
val ruleOrCheckPoint = st.getParentRuleOrCheckPoint()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class SmkEnvmodulesNotAllowedSectionInspection : SnakemakeInspection() {
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
) = object : SnakemakeInspectionVisitor(holder, session) {
) = object : SnakemakeInspectionVisitor(holder, getContext(session)) {

override fun visitSmkRuleOrCheckpointArgsSection(st: SmkRuleOrCheckpointArgsSection) {
if (st.sectionKeyword == SnakemakeNames.SECTION_ENVMODULES) {
val ruleOrCheckPoint = st.getParentRuleOrCheckPoint()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import com.intellij.codeInspection.ProblemsHolder
import com.jetbrains.snakecharm.SnakemakeBundle
import com.jetbrains.snakecharm.codeInsight.SnakemakeAPI
import com.jetbrains.snakecharm.lang.SnakemakeNames
import com.jetbrains.snakecharm.lang.psi.*
import com.jetbrains.snakecharm.lang.psi.SmkRuleOrCheckpointArgsSection
import com.jetbrains.snakecharm.lang.psi.SmkUse

class SmkExecutionSubsectionInUseSectionInspection : SnakemakeInspection() {
override fun buildVisitor(
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
) = object : SnakemakeInspectionVisitor(holder, session) {
) = object : SnakemakeInspectionVisitor(holder, getContext(session)) {

override fun visitSmkRuleOrCheckpointArgsSection(st: SmkRuleOrCheckpointArgsSection) {
val sectionNamePsi = st.nameIdentifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import com.jetbrains.snakecharm.SnakemakeBundle
import com.jetbrains.snakecharm.lang.psi.SmkFile
import com.jetbrains.snakecharm.stringLanguage.lang.psi.SmkSLExpression

class SmkFileEndsWithCommentInspection : SnakemakeInspection() {
class SmkFileEndsWithCommentInspection : SnakemakeInspection() {
override fun buildVisitor(
holder: ProblemsHolder,
isOnTheFly: Boolean,
session: LocalInspectionToolSession
) = object : SnakemakeInspectionVisitor(holder, session) {
session: LocalInspectionToolSession,
) = object : SnakemakeInspectionVisitor(holder, getContext(session)) {

override fun visitComment(comment: PsiComment) {
if(comment.containingFile !is SmkFile) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SmkIgnorePyInspectionExtension : PyInspectionExtension() {
// Ignore references imported by 'module' from remote file
//
// First check that reference is in `use` imported rules list
if (use.getImportedRuleNames()?.any { it == refElement } == true) {
if (use.getDefinedReferencesOfImportedRuleNames()?.any { it == refElement } == true) {
val module = use.getModuleName()?.reference?.resolve()
val file = (module as? SmkModule)?.getPsiFile()?.virtualFile
return module != null && (file == null || file is HttpVirtualFile)
Expand Down
Loading

0 comments on commit 2b1d0b4

Please sign in to comment.