[Java Resolve] fix compilation of projects which use JavaElement compiler internals
The original problem was the KT-58194 where JavaElement's were reworked. The rework changed the signatures of some declarations which were used in the KSP ^KT-59031 fixed
This commit is contained in:
committed by
Space Team
parent
f2031ae642
commit
c78997d0f2
+5
@@ -26,11 +26,16 @@ import org.jetbrains.kotlin.asJava.isSyntheticValuesOrValueOfMethod
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementPsiSource
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementSourceFactory
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
|
||||
class JavaClassImpl(psiClassSource: JavaElementPsiSource<PsiClass>) : JavaClassifierImpl<PsiClass>(psiClassSource), VirtualFileBoundJavaClass, JavaAnnotationOwnerImpl, JavaModifierListOwnerImpl {
|
||||
|
||||
@SuppressWarnings("unused") // used in KSP
|
||||
constructor(psiClass: PsiClass) : this(JavaElementSourceFactory.getInstance(psiClass.project).createPsiSource(psiClass))
|
||||
|
||||
init {
|
||||
assert(psiClassSource.psi !is PsiTypeParameter) { "PsiTypeParameter should be wrapped in JavaTypeParameter, not JavaClass: use JavaClassifier.create()" }
|
||||
}
|
||||
|
||||
+8
@@ -16,12 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.structure.impl;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaConstructor;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaValueParameter;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementPsiSource;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementSourceFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,6 +39,12 @@ public class JavaConstructorImpl extends JavaMemberImpl<PsiMethod> implements Ja
|
||||
psiMethod.getName() + " " + psiMethod.getClass().getName();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // used in KSP
|
||||
public JavaConstructorImpl(PsiMethod psiMethod) {
|
||||
this(JavaElementSourceFactory.getInstance(psiMethod.getProject()).createPsiSource(psiMethod));
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JavaValueParameter> getValueParameters() {
|
||||
|
||||
+8
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java.structure.impl;
|
||||
|
||||
import com.intellij.psi.PsiEnumConstant;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiVariable;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -25,12 +26,19 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaField;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaType;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementPsiSource;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementSourceFactory;
|
||||
|
||||
public class JavaFieldImpl extends JavaMemberImpl<PsiField> implements JavaField {
|
||||
public JavaFieldImpl(@NotNull JavaElementPsiSource<PsiField> psiFieldSource) {
|
||||
super(psiFieldSource);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused") // used in KSP
|
||||
public JavaFieldImpl(PsiField psiField) {
|
||||
this(JavaElementSourceFactory.getInstance(psiField.getProject()).createPsiSource(psiField));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnumEntry() {
|
||||
return getPsi() instanceof PsiEnumConstant;
|
||||
|
||||
+7
@@ -18,11 +18,13 @@ package org.jetbrains.kotlin.load.java.structure.impl;
|
||||
|
||||
import com.intellij.psi.PsiAnnotationMemberValue;
|
||||
import com.intellij.psi.PsiAnnotationMethod;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.load.java.structure.*;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementPsiSource;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementSourceFactory;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,6 +41,11 @@ public class JavaMethodImpl extends JavaMemberImpl<PsiMethod> implements JavaMet
|
||||
"PsiMethod which is a constructor should be wrapped in JavaConstructorImpl: " + method.getName();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // used in KSP
|
||||
public JavaMethodImpl(PsiMethod psiMethod) {
|
||||
this(JavaElementSourceFactory.getInstance(psiMethod.getProject()).createPsiSource(psiMethod));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getName() {
|
||||
|
||||
+13
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaAnnotation;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaType;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementSourceFactory;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementTypeSource;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaFixedElementSourceFactory;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaSourceFactoryOwner;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
|
||||
@@ -59,6 +60,18 @@ public abstract class JavaTypeImpl<Psi extends PsiType> implements JavaType, Jav
|
||||
return create(psiTypeSource.getType(), psiTypeSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated used only for a source/binary compatibility with existing 3rd party tools. Should not be used from Analysis API, Kotlin compiler, or from any other place in the Kotlin repository.
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public static JavaTypeImpl<?> create(PsiType psiType) {
|
||||
// The JavaFixedElementSourceFactory is directly created here.
|
||||
// Instead, the `JavaElementSourceFactory.getInstance(project)` should be called, but in order to do this we need a `com.intellij.openapi.project.Project` instance
|
||||
return create(new JavaFixedElementSourceFactory().createTypeSource(psiType));
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static JavaTypeImpl<?> create(@NotNull PsiType psiType, JavaElementTypeSource<? extends PsiType> psiTypeSource) {
|
||||
return psiType.accept(new PsiTypeVisitor<JavaTypeImpl<?>>() {
|
||||
|
||||
+7
@@ -17,12 +17,14 @@
|
||||
package org.jetbrains.kotlin.load.java.structure.impl;
|
||||
|
||||
import com.intellij.psi.PsiAnnotationOwner;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiTypeParameter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClassifierType;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementPsiSource;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementSourceFactory;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.name.SpecialNames;
|
||||
|
||||
@@ -35,6 +37,11 @@ public class JavaTypeParameterImpl extends JavaClassifierImpl<PsiTypeParameter>
|
||||
super(psiTypeParameterSource);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // used in KSP
|
||||
public JavaTypeParameterImpl(PsiTypeParameter psiTypeParameter) {
|
||||
this(JavaElementSourceFactory.getInstance(psiTypeParameter.getProject()).createPsiSource(psiTypeParameter));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getName() {
|
||||
|
||||
Reference in New Issue
Block a user