Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ jobs:
- name: Fetch Sources
uses: actions/checkout@v4

# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/actions/wrapper-validation@v3

# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

## [Unreleased]

## [1.6.0]
### Changed
- Removed the until-build version, so that the plugin potentially will need less new releases when
there is no compatibility issue with a newer IDE major version. The earliest IDE version supported now is 2025.1.
- Updated project dependency versions and fine-tuned their configuration.
- Added some minor simplifications to features.

## [1.5.0]
### Changed
- New supported IDE version range: 2024.3 - 2025.1.*.
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Some messages, like inspection titles are not yet included, and simply are in th

The following markers are placed on extension point implementations and more important types, to help identify certain aspects of the code:
- `@since <version number>` in javadocs
- `@HasSonarLintAlternative` annotation if an inspection has an alternative in SonarLint

## CI/CD

Expand Down
17 changes: 9 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
group = providers.gradleProperty("pluginGroup").get()
version = providers.gradleProperty("pluginVersion").get()

// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
// Set the JVM language level used to build the project.
kotlin {
jvmToolchain(21)
}
Expand All @@ -34,10 +34,10 @@ dependencies {

//Required for 'junit.framework.TestCase' referenced in 'com.intellij.testFramework.UsefulTestCase'
testImplementation(libs.junit)
testImplementation("org.assertj:assertj-core:3.27.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.4")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.4")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.4")
testImplementation(libs.assertj)
testImplementation(libs.junitJupiterApi)
testRuntimeOnly(libs.junitJupiterEngine)
testImplementation(libs.junitJupiterParams)

// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html

Expand All @@ -50,7 +50,6 @@ dependencies {
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })

instrumentationTools()
pluginVerifier()
zipSigner()
testFramework(TestFrameworkType.Platform)
Expand All @@ -62,6 +61,7 @@ dependencies {
// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
intellijPlatform {
pluginConfiguration {
name = providers.gradleProperty("pluginName")
version = providers.gradleProperty("pluginVersion")

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
Expand Down Expand Up @@ -92,7 +92,7 @@ intellijPlatform {

ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = providers.gradleProperty("pluginUntilBuild")
// untilBuild = providers.gradleProperty("pluginUntilBuild")
}
}

Expand All @@ -106,13 +106,14 @@ intellijPlatform {
intellijPlatformTesting {
val runTestsInIJCommunity by intellijPlatformTesting.testIde.registering {
type = IntelliJPlatformType.IntellijIdeaCommunity
version = "2024.3"
version = "2025.1"
task {
useJUnitPlatform {
isScanForTestClasses = false
include("**/*Test.class")
//Excluded due to https://github.com/picimako/mockitools/issues/69
exclude("**/MockFieldInitializationInspectionTest.class, **/StubOnlyMockInVerificationInspectionTest.class")
environment("NO_FS_ROOTS_ACCESS_CHECK", true)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
pluginGroup = com.picimako.mockitools
pluginName = Mockitools
# SemVer format -> https://semver.org
pluginVersion = 1.5.0
pluginVersion = 1.6.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 243
pluginUntilBuild = 251.*
pluginSinceBuild = 251
#pluginUntilBuild = 251.*

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IC
platformVersion = 2024.3
platformVersion = 2025.1

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
Expand All @@ -21,7 +21,7 @@ platformPlugins =
platformBundledPlugins = com.intellij.java

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

# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency = false
Expand Down
12 changes: 9 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
[versions]
# libraries
junit = "4.13.2"
assertj = "3.27.3"
junitJupiter = "5.11.3"

# plugins
changelog = "2.2.1"
intelliJPlatform = "2.0.1"
kotlin = "2.1.0"
lombok = "8.12.1"
intelliJPlatform = "2.5.0"
kotlin = "2.1.20"
lombok = "8.13.1"

[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
assertj = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" }
junitJupiterApi = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junitJupiter" }
junitJupiterEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junitJupiter" }
junitJupiterParams = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junitJupiter" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
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,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 2 additions & 3 deletions gradlew

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

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
8 changes: 2 additions & 6 deletions src/main/java/com/picimako/mockitools/CallChainEndsWith.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand All @@ -7,20 +7,16 @@
import java.util.List;

import com.intellij.psi.PsiMethodCallExpression;
import lombok.RequiredArgsConstructor;

/**
* Analyzes a call chain whether the penultimate call is a call to a predefined method name, either {@code when()} or {@code given()}, in which the mock
* object, or the call to a mock object is specified.
*/
@RequiredArgsConstructor
public final class CallChainEndsWith implements CallChainAnalyzer {
public record CallChainEndsWith(String stubbingCallName) implements CallChainAnalyzer {

public static final CallChainEndsWith ENDS_WITH_WHEN = new CallChainEndsWith("when");
public static final CallChainEndsWith ENDS_WITH_GIVEN = new CallChainEndsWith("given");

private final String stubbingCallName;

@Override
public boolean analyze(List<PsiMethodCallExpression> calls) {
return calls.size() >= 2 && stubbingCallName.equals(getMethodName(calls.get(calls.size() - 2)));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/picimako/mockitools/Convention.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/picimako/mockitools/StubType.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.picimako.mockitools.completion;

import static com.intellij.patterns.PlatformPatterns.psiElement;
Expand Down Expand Up @@ -46,6 +46,10 @@ final class MockCompletionContributor extends CompletionContributor {
private static final Pattern MOCKITO_VERIFY_PATTERN = Pattern.compile("Mockito\\.(verifyNoInteractions|verifyNoMoreInteractions|verifyZeroInteractions)");
private static final Pattern VERIFY_PATTERN = Pattern.compile("verifyNoInteractions|verifyNoMoreInteractions|verifyZeroInteractions");

/**
* This capture uses regex based identification of the target method calls because the CallMatcher based
* solution can't resolve calls to their methods when the completion is triggered in an empty argument list.
*/
private static final PsiElementPattern.Capture<PsiElement> MOCK_OBJECT_PARAMETER_HOLDER_PATTERN =
psiElement(JavaTokenType.IDENTIFIER)
.withSuperParent(3, psiElement(PsiMethodCallExpression.class)
Expand All @@ -54,14 +58,12 @@ final class MockCompletionContributor extends CompletionContributor {
public boolean accepts(@NotNull PsiMethodCallExpression element, ProcessingContext context) {
if (MockitoolsPsiUtil.MOCK_OBJECT_PARAMETER_HOLDER.matches(element))
return true;
else {

String canonicalText = element.getMethodExpression().getCanonicalText();
//E.g. 'Mockito.verifyNoInteractions'
return MOCKITO_VERIFY_PATTERN.matcher(canonicalText).matches()
//E.g. 'verifyNoInteractions' when static-imported
|| (VERIFY_PATTERN.matcher(canonicalText).matches() && isMethodDeclaredInMockitoClass(element));
}
String canonicalText = element.getMethodExpression().getCanonicalText();
//E.g. 'Mockito.verifyNoInteractions'
return MOCKITO_VERIFY_PATTERN.matcher(canonicalText).matches()
//E.g. 'verifyNoInteractions' when static-imported
|| (VERIFY_PATTERN.matcher(canonicalText).matches() && isMethodDeclaredInMockitoClass(element));
}
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools.dsl;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/picimako/mockitools/dsl/MockObject.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools.dsl;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools.dsl;

Expand Down
30 changes: 30 additions & 0 deletions src/main/java/com/picimako/mockitools/inspection/BaseQuickFix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools.inspection;

import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;

/**
* Base implementation for quick fixes. Based on the original {@code com.siyeh.ig.InspectionGadgetsFix}.
*/
public abstract class BaseQuickFix implements LocalQuickFix {

public final void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
var problemElement = descriptor.getPsiElement();
if (problemElement != null && problemElement.isValid()) {
try {
doFix(project, descriptor, problemElement);
} catch (IncorrectOperationException e) {
Logger.getInstance(this.getClass().getName()).error(e);
}
}
}

protected abstract void doFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor, PsiElement problemElement);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools.inspection;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2024 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//Copyright 2025 Tamás Balog. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.picimako.mockitools.inspection;

Expand Down
Loading