Skip to content

Commit 6942570

Browse files
ifrankwangfiliphr
authored andcommitted
Use UAST instead of Kotlin plugin APIs
Fixes #69
1 parent 4b1cf20 commit 6942570

File tree

4 files changed

+12
-46
lines changed

4 files changed

+12
-46
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id "org.jetbrains.intellij" version "0.4.21"
66
id "com.github.hierynomus.license" version "0.14.0"
77
id "de.undercouch.download" version "4.0.4"
8-
id 'org.jetbrains.kotlin.jvm' version '1.3.71'
8+
id 'org.jetbrains.kotlin.jvm' version '1.4.31'
99
}
1010

1111

gradle.properties

Lines changed: 1 addition & 1 deletion
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 = 2019.1
5+
ideaVersion = 2020.3.3
66
ideaType = IC
77
sources = true
88
isEAP = false

src/main/java/org/mapstruct/intellij/codeinsight/references/BaseReference.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
import com.intellij.openapi.util.TextRange;
99
import com.intellij.psi.PsiElement;
10-
import com.intellij.psi.PsiLiteral;
1110
import com.intellij.psi.PsiMethod;
1211
import com.intellij.psi.PsiReferenceBase;
13-
import com.intellij.psi.util.PsiTreeUtil;
1412
import org.jetbrains.annotations.NotNull;
1513
import org.jetbrains.annotations.Nullable;
16-
import org.mapstruct.intellij.util.MapstructUtilKt;
14+
import org.jetbrains.uast.ULiteralExpression;
15+
import org.jetbrains.uast.UMethod;
16+
import org.jetbrains.uast.UastContextKt;
17+
import org.jetbrains.uast.UastUtils;
1718

1819
/**
1920
* Base Reference for MapStruct.
@@ -43,14 +44,13 @@ abstract class BaseReference extends PsiReferenceBase<PsiElement> {
4344
@Nullable
4445
PsiMethod getMappingMethod() {
4546
PsiElement element = getElement();
46-
if ( element instanceof PsiLiteral ) {
47-
return PsiTreeUtil.getParentOfType( element, PsiMethod.class );
47+
ULiteralExpression expression = UastContextKt.toUElement( element, ULiteralExpression.class );
48+
if ( expression != null ) {
49+
UMethod parent = UastUtils.getParentOfType( expression, UMethod.class );
50+
if ( parent != null ) {
51+
return parent.getJavaPsi();
52+
}
4853
}
49-
else if ( "KtStringTemplateExpression".equals( element.getClass().getSimpleName() ) ) {
50-
// We cannot do an instanceOf check here because the kotlin class is optional
51-
return MapstructUtilKt.getPsiMethod( element );
52-
}
53-
5454
return null;
5555
}
5656
}

src/main/java/org/mapstruct/intellij/util/MapstructUtil.kt

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)