Fixed EA-62981 - IOE: PsiJavaParserFacadeImpl.createExpressionFromText
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jetbrains.jet.j2k.usageProcessing
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.jet.j2k.CodeConverter
|
||||
import org.jetbrains.jet.j2k.ast.*
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
|
||||
class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, val isNullable: Boolean) : UsageProcessing {
|
||||
override val targetElement: PsiElement get() = field
|
||||
@@ -29,14 +30,19 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v
|
||||
val identifier = Identifier(propertyName, isNullable).assignNoPrototype()
|
||||
|
||||
val qualifier = expression.getQualifierExpression()
|
||||
return if (qualifier != null) {
|
||||
QualifiedExpression(codeConverter.convertExpression(qualifier), identifier)
|
||||
if (qualifier != null) {
|
||||
return QualifiedExpression(codeConverter.convertExpression(qualifier), identifier)
|
||||
}
|
||||
else {
|
||||
// check if field name is shadowed
|
||||
val elementFactory = PsiElementFactory.SERVICE.getInstance(expression.getProject())
|
||||
val refExpr = elementFactory.createExpressionFromText(propertyName, expression) as PsiReferenceExpression
|
||||
if (refExpr.resolve() == null)
|
||||
val refExpr = try {
|
||||
elementFactory.createExpressionFromText(propertyName, expression) as? PsiReferenceExpression ?: return identifier
|
||||
}
|
||||
catch(e: IncorrectOperationException) {
|
||||
return identifier
|
||||
}
|
||||
return if (refExpr.resolve() == null)
|
||||
identifier
|
||||
else
|
||||
QualifiedExpression(ThisExpression(Identifier.Empty).assignNoPrototype(), identifier) //TODO: this is not correct in case of nested/anonymous classes
|
||||
|
||||
+12
@@ -1419,6 +1419,18 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("JavaKeywordPropertyName.java")
|
||||
public void testJavaKeywordPropertyName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/tests/testData/fileOrElement/dropAccessors/JavaKeywordPropertyName.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KeywordPropertyName.java")
|
||||
public void testKeywordPropertyName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/tests/testData/fileOrElement/dropAccessors/KeywordPropertyName.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SetterTypeNotMatch.java")
|
||||
public void testSetterTypeNotMatch() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/tests/testData/fileOrElement/dropAccessors/SetterTypeNotMatch.java");
|
||||
|
||||
+12
@@ -1419,6 +1419,18 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("JavaKeywordPropertyName.java")
|
||||
public void testJavaKeywordPropertyName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/tests/testData/fileOrElement/dropAccessors/JavaKeywordPropertyName.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KeywordPropertyName.java")
|
||||
public void testKeywordPropertyName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/tests/testData/fileOrElement/dropAccessors/KeywordPropertyName.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("SetterTypeNotMatch.java")
|
||||
public void testSetterTypeNotMatch() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/tests/testData/fileOrElement/dropAccessors/SetterTypeNotMatch.java");
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class C {
|
||||
private int field = 0;
|
||||
|
||||
public int getDefault() {
|
||||
return field;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
System.out.println(field);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
public val default: Int = 0
|
||||
|
||||
fun foo() {
|
||||
System.out.println(default)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class C {
|
||||
private int field = 0;
|
||||
|
||||
public int getThis() {
|
||||
return field;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
System.out.println(field);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
public val `this`: Int = 0
|
||||
|
||||
fun foo() {
|
||||
System.out.println(`this`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user