Skip to content

Commit 012cbf2

Browse files
committed
#157 Use 2023.3 and remove MockJDK downloads
1 parent 3978833 commit 012cbf2

13 files changed

+27
-141
lines changed

Diff for: build.gradle

-40
Original file line numberDiff line numberDiff line change
@@ -126,46 +126,6 @@ task libs(type: Sync) {
126126
rename 'mapstruct-1.5.3.Final.jar', 'mapstruct.jar'
127127
}
128128

129-
def mockJdkLocation = "https://github.com/JetBrains/intellij-community/raw/212.5712/java/mock"
130-
def mockJdkDest = layout.buildDirectory.dir("mock").get().asFile.toString()
131-
def downloadMockJdk(mockJdkLocation, mockJdkDest, mockJdkVersion) {
132-
def location = mockJdkLocation + mockJdkVersion
133-
def destination = mockJdkDest + mockJdkVersion
134-
download.run {
135-
src([
136-
"$location/jre/lib/annotations.jar",
137-
"$location/jre/lib/rt.jar"
138-
])
139-
dest "$destination/jre/lib/"
140-
overwrite false
141-
quiet false
142-
}
143-
}
144-
145-
task downloadMockJdk7() {
146-
def jdkVersion = "JDK-1.7"
147-
def mockJdk7Location = mockJdkLocation + jdkVersion
148-
def mockJdk7Dest = mockJdkDest + jdkVersion
149-
downloadMockJdk(mockJdkLocation, mockJdkDest, jdkVersion)
150-
download.run {
151-
src([
152-
"$mockJdk7Location/src.zip"
153-
])
154-
dest "$mockJdk7Dest"
155-
overwrite false
156-
quiet false
157-
}
158-
}
159-
160-
task downloadMockJdk8() {
161-
downloadMockJdk(mockJdkLocation, mockJdkDest, "JDK-1.8")
162-
}
163-
164-
task downloadMockJdk11() {
165-
downloadMockJdk(mockJdkLocation, mockJdkDest, "JDK-11")
166-
}
167-
168-
test.dependsOn( libs, downloadMockJdk7, downloadMockJdk8, downloadMockJdk11 )
169129
prepareSandbox.dependsOn( libs )
170130
composedJar.dependsOn( libs )
171131

Diff for: gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://www.jetbrains.com/intellij-repository/releases
33
# https://www.jetbrains.com/intellij-repository/snapshots
44

5-
ideaVersion = 2022.3
5+
ideaVersion = 2023.3
66
ideaType = IC
77
sources = true
88
runGenerators = true

Diff for: src/main/java/org/mapstruct/intellij/codeinsight/references/MapstructMappingQualifiedByNameReference.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.intellij.psi.PsiParameter;
2222
import com.intellij.psi.PsiReference;
2323
import com.intellij.psi.PsiType;
24+
import com.intellij.psi.PsiTypes;
2425
import org.jetbrains.annotations.NotNull;
2526
import org.jetbrains.annotations.Nullable;
2627
import org.mapstruct.intellij.util.MapstructUtil;
@@ -97,7 +98,7 @@ Object[] getVariantsInternal(@NotNull PsiMethod mappingMethod) {
9798
}
9899

99100
private boolean methodHasReturnType(@NotNull PsiMethod psiMethod) {
100-
return !PsiType.VOID.equals( psiMethod.getReturnType() );
101+
return !PsiTypes.voidType().equals( psiMethod.getReturnType() );
101102
}
102103

103104
@NotNull

Diff for: src/main/java/org/mapstruct/intellij/util/SourceUtils.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.intellij.psi.PsiRecordComponent;
2626
import com.intellij.psi.PsiSubstitutor;
2727
import com.intellij.psi.PsiType;
28+
import com.intellij.psi.PsiTypes;
2829
import com.intellij.psi.impl.source.PsiClassReferenceType;
2930
import com.intellij.psi.util.PsiUtil;
3031
import org.jetbrains.annotations.NotNull;
@@ -187,7 +188,7 @@ private static String extractPublicGetterPropertyName(PsiMethod method) {
187188
// This logic is aligned with the DefaultAccessorNamingStrategy
188189

189190
PsiType returnType = method.getReturnType();
190-
if ( returnType == null || PsiType.VOID.equals( returnType ) ) {
191+
if ( returnType == null || PsiTypes.voidType().equals( returnType ) ) {
191192
return null;
192193
}
193194

@@ -201,7 +202,7 @@ private static String extractPublicGetterPropertyName(PsiMethod method) {
201202
}
202203
}
203204
else if ( methodName.startsWith( "is" ) && (
204-
PsiType.BOOLEAN.equals( returnType ) ||
205+
PsiTypes.booleanType().equals( returnType ) ||
205206
returnType.equalsToText( CommonClassNames.JAVA_LANG_BOOLEAN ) )
206207
) {
207208
// boolean getter

Diff for: src/main/java/org/mapstruct/intellij/util/TargetUtils.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.intellij.psi.PsiParameter;
3535
import com.intellij.psi.PsiSubstitutor;
3636
import com.intellij.psi.PsiType;
37+
import com.intellij.psi.PsiTypes;
3738
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
3839
import com.intellij.psi.util.PsiUtil;
3940
import org.jetbrains.annotations.NotNull;
@@ -77,7 +78,7 @@ public static PsiType getRelevantType(@NotNull PsiMethod mappingMethod) {
7778
return null;
7879
}
7980
PsiType psiType = mappingMethod.getReturnType();
80-
if ( psiType == null || PsiType.VOID.equalsToText( psiType.getCanonicalText() ) ) {
81+
if ( psiType == null || PsiTypes.voidType().equalsToText( psiType.getCanonicalText() ) ) {
8182
psiType = Stream.of( mappingMethod.getParameterList().getParameters() )
8283
.filter( MapstructUtil::isMappingTarget )
8384
.findAny()

Diff for: src/main/resources/META-INF/plugin.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<vendor url="https://www.mapstruct.org">MapStruct</vendor>
2525

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

2929
<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
3030
on how to target different products -->

Diff for: src/test/java/org/mapstruct/intellij/MapstructBaseCompletionTestCase.java

+1-38
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,11 @@
88
import java.io.File;
99

1010
import com.intellij.codeInsight.completion.LightFixtureCompletionTestCase;
11-
import com.intellij.openapi.module.Module;
12-
import com.intellij.openapi.projectRoots.JavaSdk;
13-
import com.intellij.openapi.projectRoots.Sdk;
14-
import com.intellij.openapi.roots.ContentEntry;
15-
import com.intellij.openapi.roots.LanguageLevelModuleExtension;
16-
import com.intellij.openapi.roots.ModifiableRootModel;
1711
import com.intellij.openapi.util.text.StringUtil;
1812
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess;
19-
import com.intellij.pom.java.LanguageLevel;
2013
import com.intellij.testFramework.LightProjectDescriptor;
2114
import com.intellij.testFramework.PsiTestUtil;
22-
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
2315
import com.intellij.util.PathUtil;
24-
import com.intellij.util.lang.JavaVersion;
2516
import org.jetbrains.annotations.NotNull;
2617

2718
/**
@@ -32,7 +23,6 @@
3223
public abstract class MapstructBaseCompletionTestCase extends LightFixtureCompletionTestCase {
3324

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

3727
@Override
3828
protected void setUp() throws Exception {
@@ -56,33 +46,6 @@ protected void addDirectoryToProject(@NotNull String directory) {
5646
@NotNull
5747
@Override
5848
protected LightProjectDescriptor getProjectDescriptor() {
59-
LanguageLevel languageLevel = getLanguageLevel();
60-
return new DefaultLightProjectDescriptor() {
61-
@Override
62-
public Sdk getSdk() {
63-
JavaVersion version = languageLevel.toJavaVersion();
64-
int mockJdk;
65-
if ( version.feature >= 11 ) {
66-
mockJdk = 11;
67-
}
68-
else {
69-
mockJdk = version.feature;
70-
}
71-
String compilerOption = ( mockJdk < 11 ? "1." : "" ) + mockJdk;
72-
return JavaSdk.getInstance()
73-
.createJdk( "java " + compilerOption, BUILD_MOCK_JDK_DIRECTORY + compilerOption, false );
74-
}
75-
76-
@Override
77-
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model,
78-
@NotNull ContentEntry contentEntry) {
79-
model.getModuleExtension( LanguageLevelModuleExtension.class )
80-
.setLanguageLevel( languageLevel );
81-
}
82-
};
83-
}
84-
85-
protected LanguageLevel getLanguageLevel() {
86-
return LanguageLevel.JDK_1_8;
49+
return JAVA_17;
8750
}
8851
}

Diff for: src/test/java/org/mapstruct/intellij/MapstructCompletionJdk17TestCase.java

-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import com.intellij.codeInsight.lookup.LookupElement;
99
import com.intellij.codeInsight.lookup.LookupElementPresentation;
10-
import com.intellij.pom.java.LanguageLevel;
1110
import com.intellij.psi.PsiElement;
1211
import com.intellij.psi.PsiRecordComponent;
1312

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

35-
@Override
36-
protected LanguageLevel getLanguageLevel() {
37-
return LanguageLevel.JDK_17;
38-
}
39-
4034
private void assertCarDtoRecordAutoComplete() {
4135
assertThat( myItems )
4236
.extracting( LookupElement::getLookupString )

Diff for: src/test/java/org/mapstruct/intellij/inspection/JavaExpressionUnnecessaryWhitespacesInspectorTest.java

-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import com.intellij.codeInsight.intention.IntentionAction;
99
import com.intellij.codeInspection.LocalInspectionTool;
10-
import com.intellij.pom.java.LanguageLevel;
1110
import org.jetbrains.annotations.NotNull;
1211

1312
import java.util.List;
@@ -63,9 +62,4 @@ public void testJavaExpressionUnnecessaryWhitespacesTextBlock() {
6362
List<IntentionAction> allQuickFixes = myFixture.getAllQuickFixes();
6463
assertThat( allQuickFixes ).isEmpty();
6564
}
66-
67-
@Override
68-
protected LanguageLevel getLanguageLevel() {
69-
return LanguageLevel.JDK_15;
70-
}
7165
}

Diff for: src/test/java/org/mapstruct/intellij/inspection/UnmappedRecordTargetPropertiesInspectionTest.java

-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.List;
99

1010
import com.intellij.codeInsight.intention.IntentionAction;
11-
import com.intellij.pom.java.LanguageLevel;
1211
import org.jetbrains.annotations.NotNull;
1312

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

32-
@Override
33-
protected LanguageLevel getLanguageLevel() {
34-
return LanguageLevel.JDK_17;
35-
}
36-
3731
public void testUnmappedRecordTargetProperties() {
3832
doTest();
3933
String testName = getTestName( false );

Diff for: src/test/java/org/mapstruct/intellij/inspection/UnmappedTargetPropertiesInspectionTest.java

-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.List;
99

1010
import com.intellij.codeInsight.intention.IntentionAction;
11-
import com.intellij.pom.java.LanguageLevel;
1211
import org.jetbrains.annotations.NotNull;
1312

1413
import static org.assertj.core.api.Assertions.assertThat;
@@ -18,11 +17,6 @@
1817
*/
1918
public class UnmappedTargetPropertiesInspectionTest extends BaseInspectionTest {
2019

21-
@Override
22-
protected LanguageLevel getLanguageLevel() {
23-
return LanguageLevel.JDK_1_7;
24-
}
25-
2620
@NotNull
2721
@Override
2822
protected Class<UnmappedTargetPropertiesInspection> getInspection() {

Diff for: src/test/java/org/mapstruct/intellij/rename/RenameHandlerJdk17Test.java

-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
package org.mapstruct.intellij.rename;
77

8-
import com.intellij.pom.java.LanguageLevel;
98
import org.mapstruct.intellij.MapstructBaseCompletionTestCase;
109

1110
/**
@@ -18,11 +17,6 @@ protected String getTestDataPath() {
1817
return "testData/rename";
1918
}
2019

21-
@Override
22-
protected LanguageLevel getLanguageLevel() {
23-
return LanguageLevel.JDK_17;
24-
}
25-
2620
public void testRenameRecordSourceParameter() {
2721
myFixture.configureByFile( "RenameRecordSourceParameter.java" );
2822
myFixture.renameElementAtCaret( "anotherName" );

Diff for: testData/inspection/UnmappedTargetProperties_after.java

+17-27
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ interface NotMapStructMapper {
2020
@Mapper
2121
interface SingleMappingMapper {
2222

23-
@Mappings({
24-
@Mapping(target = "testName", source = "name"),
25-
@Mapping(target = "moreTarget", ignore = true),
26-
@Mapping(target = "moreTarget", source = "")
27-
})
23+
@Mapping(target = "moreTarget", source = "")
24+
@Mapping(target = "moreTarget", ignore = true)
25+
@Mapping(target = "testName", source = "name")
2826
Target map(Source source);
2927
}
3028

@@ -53,14 +51,12 @@ interface SingleMappingsNoBracesMapper {
5351
@Mapper
5452
interface NoMappingMapper {
5553

56-
@Mappings({
57-
@Mapping(target = "moreTarget", ignore = true),
58-
@Mapping(target = "moreTarget", source = ""),
59-
@Mapping(target = "testName", ignore = true),
60-
@Mapping(target = "testName", source = ""),
61-
@Mapping(target = "moreTarget", ignore = true),
62-
@Mapping(target = "testName", ignore = true)
63-
})
54+
@Mapping(target = "testName", ignore = true)
55+
@Mapping(target = "moreTarget", ignore = true)
56+
@Mapping(target = "testName", source = "")
57+
@Mapping(target = "testName", ignore = true)
58+
@Mapping(target = "moreTarget", source = "")
59+
@Mapping(target = "moreTarget", ignore = true)
6460
Target map(Source source);
6561

6662
@org.mapstruct.InheritInverseConfiguration
@@ -94,21 +90,17 @@ interface AllMappingsMapperConfig {
9490
@Mapper
9591
interface UpdateMapper {
9692

97-
@Mappings({
98-
@Mapping(target = "moreTarget", source = "moreSource"),
99-
@Mapping(target = "testName", ignore = true),
100-
@Mapping(target = "testName", source = "")
101-
})
93+
@Mapping(target = "testName", source = "")
94+
@Mapping(target = "testName", ignore = true)
95+
@Mapping(target = "moreTarget", source = "moreSource")
10296
void update(@MappingTarget Target target, Source source);
10397
}
10498

10599
@Mapper
106100
interface MultiSourceUpdateMapper {
107101

108-
@Mappings({
109-
@Mapping(target = "moreTarget", ignore = true),
110-
@Mapping(target = "moreTarget", source = "")
111-
})
102+
@Mapping(target = "moreTarget", source = "")
103+
@Mapping(target = "moreTarget", ignore = true)
112104
void update(@MappingTarget Target moreTarget, Source source, String testName, @org.mapstruct.Context String matching);
113105
}
114106

@@ -117,10 +109,8 @@ interface SingleMappingConstantReferenceMapper {
117109

118110
String TEST_NAME = "testName";
119111

120-
@Mappings({
121-
@Mapping(target = TEST_NAME, source = "name"),
122-
@Mapping(target = "moreTarget", ignore = true),
123-
@Mapping(target = "moreTarget", source = "")
124-
})
112+
@Mapping(target = "moreTarget", source = "")
113+
@Mapping(target = "moreTarget", ignore = true)
114+
@Mapping(target = TEST_NAME, source = "name")
125115
Target map(Source source);
126116
}

0 commit comments

Comments
 (0)