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

Adjust minimum IntelliJ version and remove downloads of mockJDK #209

Merged
merged 3 commits into from
Oct 20, 2024
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
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ jobs:
fail-fast: false
matrix:
version:
- { jdk: 17, idea: 2022.3 }
- { jdk: 17, idea: 2023.1 }
- { jdk: 17, idea: 2023.2 }
- { jdk: 17, idea: 2023.3 }
- { jdk: 17, idea: 2024.1 }
- { jdk: 17, idea: 2024.2 }
Expand Down
40 changes: 0 additions & 40 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,46 +126,6 @@ task libs(type: Sync) {
rename 'mapstruct-1.5.3.Final.jar', 'mapstruct.jar'
}

def mockJdkLocation = "https://github.com/JetBrains/intellij-community/raw/212.5712/java/mock"
def mockJdkDest = layout.buildDirectory.dir("mock").get().asFile.toString()
def downloadMockJdk(mockJdkLocation, mockJdkDest, mockJdkVersion) {
def location = mockJdkLocation + mockJdkVersion
def destination = mockJdkDest + mockJdkVersion
download.run {
src([
"$location/jre/lib/annotations.jar",
"$location/jre/lib/rt.jar"
])
dest "$destination/jre/lib/"
overwrite false
quiet false
}
}

task downloadMockJdk7() {
def jdkVersion = "JDK-1.7"
def mockJdk7Location = mockJdkLocation + jdkVersion
def mockJdk7Dest = mockJdkDest + jdkVersion
downloadMockJdk(mockJdkLocation, mockJdkDest, jdkVersion)
download.run {
src([
"$mockJdk7Location/src.zip"
])
dest "$mockJdk7Dest"
overwrite false
quiet false
}
}

task downloadMockJdk8() {
downloadMockJdk(mockJdkLocation, mockJdkDest, "JDK-1.8")
}

task downloadMockJdk11() {
downloadMockJdk(mockJdkLocation, mockJdkDest, "JDK-11")
}

test.dependsOn( libs, downloadMockJdk7, downloadMockJdk8, downloadMockJdk11 )
prepareSandbox.dependsOn( libs )
composedJar.dependsOn( libs )

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://www.jetbrains.com/intellij-repository/releases
# https://www.jetbrains.com/intellij-repository/snapshots

ideaVersion = 2022.3
ideaVersion = 2023.3
ideaType = IC
sources = true
runGenerators = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiTypes;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.mapstruct.intellij.util.MapstructUtil;
Expand Down Expand Up @@ -97,7 +98,7 @@ Object[] getVariantsInternal(@NotNull PsiMethod mappingMethod) {
}

private boolean methodHasReturnType(@NotNull PsiMethod psiMethod) {
return !PsiType.VOID.equals( psiMethod.getReturnType() );
return !PsiTypes.voidType().equals( psiMethod.getReturnType() );
}

@NotNull
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/mapstruct/intellij/util/SourceUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.intellij.psi.PsiRecordComponent;
import com.intellij.psi.PsiSubstitutor;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiTypes;
import com.intellij.psi.impl.source.PsiClassReferenceType;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -187,7 +188,7 @@ private static String extractPublicGetterPropertyName(PsiMethod method) {
// This logic is aligned with the DefaultAccessorNamingStrategy

PsiType returnType = method.getReturnType();
if ( returnType == null || PsiType.VOID.equals( returnType ) ) {
if ( returnType == null || PsiTypes.voidType().equals( returnType ) ) {
return null;
}

Expand All @@ -201,7 +202,7 @@ private static String extractPublicGetterPropertyName(PsiMethod method) {
}
}
else if ( methodName.startsWith( "is" ) && (
PsiType.BOOLEAN.equals( returnType ) ||
PsiTypes.booleanType().equals( returnType ) ||
returnType.equalsToText( CommonClassNames.JAVA_LANG_BOOLEAN ) )
) {
// boolean getter
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/mapstruct/intellij/util/TargetUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiSubstitutor;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiTypes;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -77,7 +78,7 @@ public static PsiType getRelevantType(@NotNull PsiMethod mappingMethod) {
return null;
}
PsiType psiType = mappingMethod.getReturnType();
if ( psiType == null || PsiType.VOID.equalsToText( psiType.getCanonicalText() ) ) {
if ( psiType == null || PsiTypes.voidType().equalsToText( psiType.getCanonicalText() ) ) {
psiType = Stream.of( mappingMethod.getParameterList().getParameters() )
.filter( MapstructUtil::isMappingTarget )
.findAny()
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<vendor url="https://www.mapstruct.org">MapStruct</vendor>

<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="223"/>
<idea-version since-build="233"/>

<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,11 @@
import java.io.File;

import com.intellij.codeInsight.completion.LightFixtureCompletionTestCase;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.LanguageLevelModuleExtension;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
import com.intellij.util.PathUtil;
import com.intellij.util.lang.JavaVersion;
import org.jetbrains.annotations.NotNull;

/**
Expand All @@ -32,7 +23,6 @@
public abstract class MapstructBaseCompletionTestCase extends LightFixtureCompletionTestCase {

private static final String BUILD_LIBS_DIRECTORY = "build/libs";
private static final String BUILD_MOCK_JDK_DIRECTORY = "build/mockJDK-";

@Override
protected void setUp() throws Exception {
Expand All @@ -56,33 +46,6 @@ protected void addDirectoryToProject(@NotNull String directory) {
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
LanguageLevel languageLevel = getLanguageLevel();
return new DefaultLightProjectDescriptor() {
@Override
public Sdk getSdk() {
JavaVersion version = languageLevel.toJavaVersion();
int mockJdk;
if ( version.feature >= 11 ) {
mockJdk = 11;
}
else {
mockJdk = version.feature;
}
String compilerOption = ( mockJdk < 11 ? "1." : "" ) + mockJdk;
return JavaSdk.getInstance()
.createJdk( "java " + compilerOption, BUILD_MOCK_JDK_DIRECTORY + compilerOption, false );
}

@Override
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model,
@NotNull ContentEntry contentEntry) {
model.getModuleExtension( LanguageLevelModuleExtension.class )
.setLanguageLevel( languageLevel );
}
};
}

protected LanguageLevel getLanguageLevel() {
return LanguageLevel.JDK_1_8;
return JAVA_17;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementPresentation;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiRecordComponent;

Expand All @@ -32,11 +31,6 @@ protected void setUp() throws Exception {
addDirectoryToProject( "dto" );
}

@Override
protected LanguageLevel getLanguageLevel() {
return LanguageLevel.JDK_17;
}

private void assertCarDtoRecordAutoComplete() {
assertThat( myItems )
.extracting( LookupElement::getLookupString )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;

import java.util.List;
Expand Down Expand Up @@ -63,9 +62,4 @@ public void testJavaExpressionUnnecessaryWhitespacesTextBlock() {
List<IntentionAction> allQuickFixes = myFixture.getAllQuickFixes();
assertThat( allQuickFixes ).isEmpty();
}

@Override
protected LanguageLevel getLanguageLevel() {
return LanguageLevel.JDK_15;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.List;

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -29,11 +28,6 @@ protected void setUp() throws Exception {
super.setUp();
}

@Override
protected LanguageLevel getLanguageLevel() {
return LanguageLevel.JDK_17;
}

public void testUnmappedRecordTargetProperties() {
doTest();
String testName = getTestName( false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.List;

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.ide.util.PropertiesComponent;
import org.jetbrains.annotations.NotNull;
import org.mapstruct.intellij.settings.ProjectSettings;

Expand All @@ -33,6 +34,14 @@ protected void setUp() throws Exception {
);
}

@Override
public void tearDown() throws Exception {
PropertiesComponent.getInstance( myFixture.getProject() )
.unsetValue( ProjectSettings.PREFER_SOURCE_BEFORE_TARGET_IN_MAPPING );

super.tearDown();
}

public void testUnmappedTargetPropertiesSourceBeforeTarget() {
ProjectSettings.setPreferSourceBeforeTargetInMapping( myFixture.getProject(), true );
doTest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NotNull;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -18,11 +19,6 @@
*/
public class UnmappedTargetPropertiesInspectionTest extends BaseInspectionTest {

@Override
protected LanguageLevel getLanguageLevel() {
return LanguageLevel.JDK_1_7;
}

@NotNull
@Override
protected Class<UnmappedTargetPropertiesInspection> getInspection() {
Expand All @@ -32,12 +28,19 @@ protected Class<UnmappedTargetPropertiesInspection> getInspection() {
@Override
protected void setUp() throws Exception {
super.setUp();
IdeaTestUtil.setModuleLanguageLevel( getModule(), LanguageLevel.JDK_1_7 );
myFixture.copyFileToProject(
"UnmappedTargetPropertiesData.java",
"org/example/data/UnmappedTargetPropertiesData.java"
);
}

@Override
public void tearDown() throws Exception {
IdeaTestUtil.setModuleLanguageLevel( getModule(), LanguageLevel.JDK_17 );
super.tearDown();
}

public void testUnmappedTargetProperties() {
doTest();
List<IntentionAction> allQuickFixes = myFixture.getAllQuickFixes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package org.mapstruct.intellij.rename;

import com.intellij.pom.java.LanguageLevel;
import org.mapstruct.intellij.MapstructBaseCompletionTestCase;

/**
Expand All @@ -18,11 +17,6 @@ protected String getTestDataPath() {
return "testData/rename";
}

@Override
protected LanguageLevel getLanguageLevel() {
return LanguageLevel.JDK_17;
}

public void testRenameRecordSourceParameter() {
myFixture.configureByFile( "RenameRecordSourceParameter.java" );
myFixture.renameElementAtCaret( "anotherName" );
Expand Down
Loading