Skip to content

Commit

Permalink
Use UAST instead of Kotlin plugin APIs
Browse files Browse the repository at this point in the history
Fixes #69
  • Loading branch information
ifrankwang authored and filiphr committed Mar 28, 2021
1 parent 4b1cf20 commit 6942570
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 46 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id "org.jetbrains.intellij" version "0.4.21"
id "com.github.hierynomus.license" version "0.14.0"
id "de.undercouch.download" version "4.0.4"
id 'org.jetbrains.kotlin.jvm' version '1.3.71'
id 'org.jetbrains.kotlin.jvm' version '1.4.31'
}


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 = 2019.1
ideaVersion = 2020.3.3
ideaType = IC
sources = true
isEAP = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLiteral;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiReferenceBase;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.mapstruct.intellij.util.MapstructUtilKt;
import org.jetbrains.uast.ULiteralExpression;
import org.jetbrains.uast.UMethod;
import org.jetbrains.uast.UastContextKt;
import org.jetbrains.uast.UastUtils;

/**
* Base Reference for MapStruct.
Expand Down Expand Up @@ -43,14 +44,13 @@ abstract class BaseReference extends PsiReferenceBase<PsiElement> {
@Nullable
PsiMethod getMappingMethod() {
PsiElement element = getElement();
if ( element instanceof PsiLiteral ) {
return PsiTreeUtil.getParentOfType( element, PsiMethod.class );
ULiteralExpression expression = UastContextKt.toUElement( element, ULiteralExpression.class );
if ( expression != null ) {
UMethod parent = UastUtils.getParentOfType( expression, UMethod.class );
if ( parent != null ) {
return parent.getJavaPsi();
}
}
else if ( "KtStringTemplateExpression".equals( element.getClass().getSimpleName() ) ) {
// We cannot do an instanceOf check here because the kotlin class is optional
return MapstructUtilKt.getPsiMethod( element );
}

return null;
}
}
34 changes: 0 additions & 34 deletions src/main/java/org/mapstruct/intellij/util/MapstructUtil.kt

This file was deleted.

0 comments on commit 6942570

Please sign in to comment.