rename Jet* classes to Kt*

This commit is contained in:
Dmitry Jemerov
2015-10-19 18:43:17 +02:00
parent 660972b12d
commit 49033e0002
1965 changed files with 23732 additions and 23757 deletions
@@ -27,19 +27,19 @@ import com.intellij.psi.impl.java.stubs.*;
import com.intellij.psi.stubs.StubBase;
import com.intellij.psi.stubs.StubElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.psi.JetDeclaration;
import org.jetbrains.kotlin.psi.KtDeclaration;
class ClsWrapperStubPsiFactory extends StubPsiFactory {
public static final Key<PsiElement> ORIGIN_ELEMENT = Key.create("ORIGIN_ELEMENT");
private final StubPsiFactory delegate = new ClsStubPsiFactory();
public static JetDeclaration getOriginalDeclaration(PsiMember member) {
public static KtDeclaration getOriginalDeclaration(PsiMember member) {
if (member instanceof ClsRepositoryPsiElement<?>) {
StubElement stubElement = ((ClsRepositoryPsiElement<?>) member).getStub();
if (stubElement instanceof UserDataHolder) {
PsiElement original = ((UserDataHolder) stubElement).getUserData(ORIGIN_ELEMENT);
if (original instanceof JetDeclaration) {
return (JetDeclaration) original;
if (original instanceof KtDeclaration) {
return (KtDeclaration) original;
}
}
}
@@ -26,8 +26,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.KotlinLanguage;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetClassOrObject;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtClassOrObject;
import org.jetbrains.kotlin.psi.KtFile;
/**
* This class serves as a workaround for usages of {@link JavaElementFinder#findClasses} which eventually only need names of files
@@ -39,10 +39,10 @@ import org.jetbrains.kotlin.psi.JetFile;
*/
public class FakeLightClassForFileOfPackage extends AbstractLightClass implements KotlinLightClass, JetJavaMirrorMarker {
private final KotlinLightClassForFacade delegate;
private final JetFile file;
private final KtFile file;
public FakeLightClassForFileOfPackage(
@NotNull PsiManager manager, @NotNull KotlinLightClassForFacade delegate, @NotNull JetFile file
@NotNull PsiManager manager, @NotNull KotlinLightClassForFacade delegate, @NotNull KtFile file
) {
super(manager);
this.delegate = delegate;
@@ -51,7 +51,7 @@ public class FakeLightClassForFileOfPackage extends AbstractLightClass implement
@Nullable
@Override
public JetClassOrObject getOrigin() {
public KtClassOrObject getOrigin() {
return null;
}
@@ -32,12 +32,11 @@ import com.intellij.util.containers.SLRUCache;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.FqNamesUtilKt;
import org.jetbrains.kotlin.psi.JetClassOrObject;
import org.jetbrains.kotlin.psi.JetEnumEntry;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtClassOrObject;
import org.jetbrains.kotlin.psi.KtEnumEntry;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.jvm.KotlinFinderMarker;
import java.util.Collection;
@@ -128,11 +127,11 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
private void findClassesAndObjects(FqName qualifiedName, GlobalSearchScope scope, List<PsiClass> answer) {
findInterfaceDefaultImpls(qualifiedName, scope, answer);
Collection<JetClassOrObject> classOrObjectDeclarations =
Collection<KtClassOrObject> classOrObjectDeclarations =
lightClassGenerationSupport.findClassOrObjectDeclarations(qualifiedName, scope);
for (JetClassOrObject declaration : classOrObjectDeclarations) {
if (!(declaration instanceof JetEnumEntry)) {
for (KtClassOrObject declaration : classOrObjectDeclarations) {
if (!(declaration instanceof KtEnumEntry)) {
PsiClass lightClass = LightClassUtil.INSTANCE$.getPsiClass(declaration);
if (lightClass != null) {
answer.add(lightClass);
@@ -146,7 +145,7 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
if (!qualifiedName.shortName().asString().equals(JvmAbi.DEFAULT_IMPLS_CLASS_NAME)) return;
for (JetClassOrObject classOrObject : lightClassGenerationSupport.findClassOrObjectDeclarations(qualifiedName.parent(), scope)) {
for (KtClassOrObject classOrObject : lightClassGenerationSupport.findClassOrObjectDeclarations(qualifiedName.parent(), scope)) {
if (LightClassUtilsKt.getHasInterfaceDefaultImpls(classOrObject)) {
PsiClass interfaceClass = LightClassUtil.INSTANCE$.getPsiClass(classOrObject);
if (interfaceClass != null) {
@@ -164,12 +163,12 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
public Set<String> getClassNames(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
FqName packageFQN = new FqName(psiPackage.getQualifiedName());
Collection<JetClassOrObject> declarations = lightClassGenerationSupport.findClassOrObjectDeclarationsInPackage(packageFQN, scope);
Collection<KtClassOrObject> declarations = lightClassGenerationSupport.findClassOrObjectDeclarationsInPackage(packageFQN, scope);
Set<String> answer = Sets.newHashSet();
answer.addAll(lightClassGenerationSupport.getFacadeNames(packageFQN, scope));
for (JetClassOrObject declaration : declarations) {
for (KtClassOrObject declaration : declarations) {
String name = declaration.getName();
if (name != null) {
answer.add(name);
@@ -190,7 +189,7 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
// allScope() because the contract says that the whole project
GlobalSearchScope allScope = GlobalSearchScope.allScope(project);
if (lightClassGenerationSupport.packageExists(fqName, allScope)) {
return new JetLightPackage(psiManager, fqName, allScope);
return new KotlinLightPackage(psiManager, fqName, allScope);
}
return null;
@@ -206,7 +205,7 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
Collection<PsiPackage> answer = Collections2.transform(subpackages, new Function<FqName, PsiPackage>() {
@Override
public PsiPackage apply(@Nullable FqName input) {
return new JetLightPackage(psiManager, input, scope);
return new KotlinLightPackage(psiManager, input, scope);
}
});
@@ -221,8 +220,8 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
answer.addAll(lightClassGenerationSupport.getFacadeClassesInPackage(packageFQN, scope));
Collection<JetClassOrObject> declarations = lightClassGenerationSupport.findClassOrObjectDeclarationsInPackage(packageFQN, scope);
for (JetClassOrObject declaration : declarations) {
Collection<KtClassOrObject> declarations = lightClassGenerationSupport.findClassOrObjectDeclarationsInPackage(packageFQN, scope);
for (KtClassOrObject declaration : declarations) {
PsiClass aClass = LightClassUtil.INSTANCE$.getPsiClass(declaration);
if (aClass != null) {
answer.add(aClass);
@@ -236,7 +235,7 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
@NotNull
public PsiFile[] getPackageFiles(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
FqName packageFQN = new FqName(psiPackage.getQualifiedName());
Collection<JetFile> result = lightClassGenerationSupport.findFilesForPackage(packageFQN, scope);
Collection<KtFile> result = lightClassGenerationSupport.findFilesForPackage(packageFQN, scope);
return result.toArray(new PsiFile[result.size()]);
}
@@ -246,10 +245,10 @@ public class JavaElementFinder extends PsiElementFinder implements KotlinFinderM
return new Condition<PsiFile>() {
@Override
public boolean value(PsiFile input) {
if (!(input instanceof JetFile)) {
if (!(input instanceof KtFile)) {
return true;
}
return psiPackage.getQualifiedName().equals(((JetFile) input).getPackageFqName().asString());
return psiPackage.getQualifiedName().equals(((KtFile) input).getPackageFqName().asString());
}
};
}
@@ -36,7 +36,7 @@ public class KotlinCodeBlockModificationListener(modificationTracker: PsiModific
private val myModificationTracker = modificationTracker as PsiModificationTrackerImpl
override fun treeChanged(event: PsiTreeChangeEventImpl) {
if (event.file !is JetFile) return
if (event.file !is KtFile) return
when (event.code) {
BEFORE_CHILDREN_CHANGE,
@@ -72,7 +72,7 @@ public class KotlinCodeBlockModificationListener(modificationTracker: PsiModific
private fun processChange(parent: PsiElement?, child1: PsiElement?, child2: PsiElement?) {
try {
if (!isInsideCodeBlock(parent)) {
if (parent != null && parent.containingFile is JetFile) {
if (parent != null && parent.containingFile is KtFile) {
myModificationTracker.incCounter()
}
else {
@@ -111,10 +111,10 @@ public class KotlinCodeBlockModificationListener(modificationTracker: PsiModific
if (element == null || element.parent == null) return true
//TODO: other types
val blockDeclaration = JetPsiUtil.getTopmostParentOfTypes(element, *BLOCK_DECLARATION_TYPES) ?: return false
val blockDeclaration = KtPsiUtil.getTopmostParentOfTypes(element, *BLOCK_DECLARATION_TYPES) ?: return false
when (blockDeclaration) {
is JetNamedFunction -> {
is KtNamedFunction -> {
if (blockDeclaration.hasBlockBody()) {
return blockDeclaration.bodyExpression.isAncestor(element)
}
@@ -123,7 +123,7 @@ public class KotlinCodeBlockModificationListener(modificationTracker: PsiModific
}
}
is JetProperty -> {
is KtProperty -> {
for (accessor in blockDeclaration.accessors) {
if (accessor.initializer.isAncestor(element) || accessor.bodyExpression.isAncestor(element)) {
return true
@@ -137,13 +137,13 @@ public class KotlinCodeBlockModificationListener(modificationTracker: PsiModific
return false
}
public fun isBlockDeclaration(declaration: JetDeclaration): Boolean {
public fun isBlockDeclaration(declaration: KtDeclaration): Boolean {
return BLOCK_DECLARATION_TYPES.any { it.isInstance(declaration) }
}
private val BLOCK_DECLARATION_TYPES = arrayOf<Class<out JetDeclaration>>(
javaClass<JetProperty>(),
javaClass<JetNamedFunction>()
private val BLOCK_DECLARATION_TYPES = arrayOf<Class<out KtDeclaration>>(
javaClass<KtProperty>(),
javaClass<KtNamedFunction>()
)
}
}
@@ -52,10 +52,10 @@ import org.jetbrains.kotlin.fileClasses.FileClasses;
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo;
import org.jetbrains.kotlin.fileClasses.NoResolveFileClassesProvider;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetClassOrObject;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.JetPsiUtil;
import org.jetbrains.kotlin.psi.JetScript;
import org.jetbrains.kotlin.psi.KtClassOrObject;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.psi.KtPsiUtil;
import org.jetbrains.kotlin.psi.KtScript;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.BindingTraceContext;
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
@@ -82,13 +82,13 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
new StubGenerationStrategy<KotlinFacadeLightClassData>() {
@NotNull
@Override
public LightClassConstructionContext getContext(@NotNull Collection<JetFile> files) {
public LightClassConstructionContext getContext(@NotNull Collection<KtFile> files) {
return LightClassGenerationSupport.getInstance(project).getContextForPackage(files);
}
@NotNull
@Override
public Collection<JetFile> getFiles() {
public Collection<KtFile> getFiles() {
// Don't memoize this, it can be called again after an out-of-code-block modification occurs,
// and the set of files changes
return LightClassGenerationSupport.getInstance(project).findFilesForPackage(packageFqName, searchScope);
@@ -115,24 +115,24 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
return new GenerationState.GenerateClassFilter() {
@Override
public boolean shouldGeneratePackagePart(JetFile jetFile) {
public boolean shouldGeneratePackagePart(KtFile jetFile) {
return true;
}
@Override
public boolean shouldAnnotateClass(JetClassOrObject classOrObject) {
public boolean shouldAnnotateClass(KtClassOrObject classOrObject) {
return shouldGenerateClass(classOrObject);
}
@Override
public boolean shouldGenerateClass(JetClassOrObject classOrObject) {
public boolean shouldGenerateClass(KtClassOrObject classOrObject) {
// Top-level classes and such should not be generated for performance reasons.
// Local classes in top-level functions must still be generated
return JetPsiUtil.isLocal(classOrObject);
return KtPsiUtil.isLocal(classOrObject);
}
@Override
public boolean shouldGenerateScript(JetScript script) {
public boolean shouldGenerateScript(KtScript script) {
// Scripts yield top-level classes, and should not be generated
return false;
}
@@ -140,7 +140,7 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
}
@Override
public void generate(@NotNull GenerationState state, @NotNull Collection<JetFile> files) {
public void generate(@NotNull GenerationState state, @NotNull Collection<KtFile> files) {
KotlinCodegenFacade.doGenerateFiles(files, state, CompilationErrorHandler.THROW_EXCEPTION);
}
@@ -164,7 +164,7 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
new StubGenerationStrategy<KotlinFacadeLightClassData>() {
@NotNull
@Override
public Collection<JetFile> getFiles() {
public Collection<KtFile> getFiles() {
return LightClassGenerationSupport.getInstance(project).findFilesForFacade(facadeFqName, searchScope);
}
@@ -176,7 +176,7 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
@NotNull
@Override
public LightClassConstructionContext getContext(@NotNull Collection<JetFile> files) {
public LightClassConstructionContext getContext(@NotNull Collection<KtFile> files) {
return LightClassGenerationSupport.getInstance(project).getContextForFacade(files);
}
@@ -194,31 +194,31 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
public GenerationState.GenerateClassFilter getGenerateClassFilter() {
return new GenerationState.GenerateClassFilter() {
@Override
public boolean shouldAnnotateClass(JetClassOrObject classOrObject) {
public boolean shouldAnnotateClass(KtClassOrObject classOrObject) {
return shouldGenerateClass(classOrObject);
}
@Override
public boolean shouldGenerateClass(JetClassOrObject classOrObject) {
return JetPsiUtil.isLocal(classOrObject);
public boolean shouldGenerateClass(KtClassOrObject classOrObject) {
return KtPsiUtil.isLocal(classOrObject);
}
@Override
public boolean shouldGeneratePackagePart(JetFile jetFile) {
public boolean shouldGeneratePackagePart(KtFile jetFile) {
return true;
}
@Override
public boolean shouldGenerateScript(JetScript script) {
public boolean shouldGenerateScript(KtScript script) {
return false;
}
};
}
@Override
public void generate(@NotNull GenerationState state, @NotNull Collection<JetFile> files) {
public void generate(@NotNull GenerationState state, @NotNull Collection<KtFile> files) {
if (!files.isEmpty()) {
JetFile representativeFile = files.iterator().next();
KtFile representativeFile = files.iterator().next();
JvmFileClassInfo fileClassInfo = NoResolveFileClassesProvider.INSTANCE$.getFileClassInfo(representativeFile);
if (!fileClassInfo.getWithJvmMultifileClass()) {
PackageCodegen codegen = state.getFactory().forPackage(representativeFile.getPackageFqName(), files);
@@ -241,18 +241,18 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
}
@NotNull
public static KotlinJavaFileStubProvider<OutermostKotlinClassLightClassData> createForDeclaredClass(@NotNull final JetClassOrObject classOrObject) {
public static KotlinJavaFileStubProvider<OutermostKotlinClassLightClassData> createForDeclaredClass(@NotNull final KtClassOrObject classOrObject) {
return new KotlinJavaFileStubProvider<OutermostKotlinClassLightClassData>(
classOrObject.getProject(),
classOrObject.isLocal(),
new StubGenerationStrategy<OutermostKotlinClassLightClassData>() {
private JetFile getFile() {
private KtFile getFile() {
return classOrObject.getContainingJetFile();
}
@NotNull
@Override
public LightClassConstructionContext getContext(@NotNull Collection<JetFile> files) {
public LightClassConstructionContext getContext(@NotNull Collection<KtFile> files) {
return LightClassGenerationSupport.getInstance(classOrObject.getProject()).getContextForClassOrObject(classOrObject);
}
@@ -267,18 +267,18 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
if (classDescriptor == null) {
return new OutermostKotlinClassLightClassData(
javaFileStub, extraDiagnostics, FqName.ROOT, classOrObject,
Collections.<JetClassOrObject, InnerKotlinClassLightClassData>emptyMap()
Collections.<KtClassOrObject, InnerKotlinClassLightClassData>emptyMap()
);
}
FqName fqName = predictClassFqName(bindingContext, classDescriptor);
Collection<ClassDescriptor> allInnerClasses = CodegenBinding.getAllInnerClasses(bindingContext, classDescriptor);
Map<JetClassOrObject, InnerKotlinClassLightClassData> innerClassesMap = ContainerUtil.newHashMap();
Map<KtClassOrObject, InnerKotlinClassLightClassData> innerClassesMap = ContainerUtil.newHashMap();
for (ClassDescriptor innerClassDescriptor : allInnerClasses) {
PsiElement declaration = descriptorToDeclaration(innerClassDescriptor);
if (!(declaration instanceof JetClassOrObject)) continue;
JetClassOrObject innerClass = (JetClassOrObject) declaration;
if (!(declaration instanceof KtClassOrObject)) continue;
KtClassOrObject innerClass = (KtClassOrObject) declaration;
InnerKotlinClassLightClassData innerLightClassData = new InnerKotlinClassLightClassData(
predictClassFqName(bindingContext, innerClassDescriptor),
@@ -306,7 +306,7 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
@NotNull
@Override
public Collection<JetFile> getFiles() {
public Collection<KtFile> getFiles() {
return Collections.singletonList(getFile());
}
@@ -321,17 +321,17 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
return new GenerationState.GenerateClassFilter() {
@Override
public boolean shouldGeneratePackagePart(JetFile jetFile) {
public boolean shouldGeneratePackagePart(KtFile jetFile) {
return true;
}
@Override
public boolean shouldAnnotateClass(JetClassOrObject classOrObject) {
public boolean shouldAnnotateClass(KtClassOrObject classOrObject) {
return shouldGenerateClass(classOrObject);
}
@Override
public boolean shouldGenerateClass(JetClassOrObject generatedClassOrObject) {
public boolean shouldGenerateClass(KtClassOrObject generatedClassOrObject) {
// Trivial: generate and analyze class we are interested in.
if (generatedClassOrObject == classOrObject) return true;
@@ -364,7 +364,7 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
}
@Override
public boolean shouldGenerateScript(JetScript script) {
public boolean shouldGenerateScript(KtScript script) {
// We generate all enclosing classes
return PsiTreeUtil.isAncestor(script, classOrObject, false);
}
@@ -372,9 +372,9 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
}
@Override
public void generate(@NotNull GenerationState state, @NotNull Collection<JetFile> files) {
public void generate(@NotNull GenerationState state, @NotNull Collection<KtFile> files) {
PackageCodegen packageCodegen = state.getFactory().forPackage(getPackageFqName(), files);
JetFile file = classOrObject.getContainingJetFile();
KtFile file = classOrObject.getContainingJetFile();
Type packagePartType = FileClasses.getFileClassType(state.getFileClassesProvider(), file);
PackageContext context = state.getRootContext().intoPackagePart(packageCodegen.getPackageFragment(), packagePartType, file);
packageCodegen.generateClassOrObject(classOrObject, context);
@@ -409,7 +409,7 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
@Override
public Result<T> compute() {
FqName packageFqName = stubGenerationStrategy.getPackageFqName();
Collection<JetFile> files = stubGenerationStrategy.getFiles();
Collection<KtFile> files = stubGenerationStrategy.getFiles();
checkForBuiltIns(packageFqName, files);
@@ -465,7 +465,7 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
private static ClsFileImpl createFakeClsFile(
@NotNull Project project,
@NotNull final FqName packageFqName,
@NotNull Collection<JetFile> files,
@NotNull Collection<KtFile> files,
@NotNull final Function0<? extends PsiClassHolderFileStub> fileStubProvider
) {
PsiManager manager = PsiManager.getInstance(project);
@@ -490,7 +490,7 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
}
@NotNull
private PsiJavaFileStub createJavaFileStub(@NotNull FqName packageFqName, @NotNull Collection<JetFile> files) {
private PsiJavaFileStub createJavaFileStub(@NotNull FqName packageFqName, @NotNull Collection<KtFile> files) {
final PsiJavaFileStubImpl javaFileStub = new PsiJavaFileStubImpl(packageFqName.asString(), true);
javaFileStub.setPsiFactory(new ClsWrapperStubPsiFactory());
@@ -506,15 +506,15 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
}
@NotNull
private static VirtualFile getRepresentativeVirtualFile(@NotNull Collection<JetFile> files) {
JetFile firstFile = files.iterator().next();
private static VirtualFile getRepresentativeVirtualFile(@NotNull Collection<KtFile> files) {
KtFile firstFile = files.iterator().next();
VirtualFile virtualFile = firstFile.getVirtualFile();
assert virtualFile != null : "No virtual file for " + firstFile;
return virtualFile;
}
private static void checkForBuiltIns(@NotNull FqName fqName, @NotNull Collection<JetFile> files) {
for (JetFile file : files) {
private static void checkForBuiltIns(@NotNull FqName fqName, @NotNull Collection<KtFile> files) {
for (KtFile file : files) {
if (LightClassUtil.INSTANCE$.belongsToKotlinBuiltIns(file)) {
// We may not fail later due to some luck, but generating JetLightClasses for built-ins is a bad idea anyways
// If it fails later, there will be an exception logged
@@ -533,13 +533,13 @@ public class KotlinJavaFileStubProvider<T extends WithFileStubAndExtraDiagnostic
}
private interface StubGenerationStrategy<T extends WithFileStubAndExtraDiagnostics> {
@NotNull Collection<JetFile> getFiles();
@NotNull Collection<KtFile> getFiles();
@NotNull FqName getPackageFqName();
@NotNull LightClassConstructionContext getContext(@NotNull Collection<JetFile> files);
@NotNull LightClassConstructionContext getContext(@NotNull Collection<KtFile> files);
@NotNull T createLightClassData(PsiJavaFileStub javaFileStub, BindingContext bindingContext, Diagnostics extraDiagnostics);
GenerationState.GenerateClassFilter getGenerateClassFilter();
void generate(@NotNull GenerationState state, @NotNull Collection<JetFile> files);
void generate(@NotNull GenerationState state, @NotNull Collection<KtFile> files);
}
}
@@ -18,8 +18,8 @@ package org.jetbrains.kotlin.asJava;
import com.intellij.psi.PsiClass;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.KtClassOrObject
public interface KotlinLightClass : PsiClass, KotlinLightElement<JetClassOrObject, PsiClass> {
public interface KotlinLightClass : PsiClass, KotlinLightElement<KtClassOrObject, PsiClass> {
public fun getFqName(): FqName
}
@@ -26,9 +26,9 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetClassOrObject;
import org.jetbrains.kotlin.psi.KtClassOrObject;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import java.util.Collection;
@@ -37,7 +37,7 @@ class KotlinLightClassForAnonymousDeclaration extends KotlinLightClassForExplici
private SoftReference<PsiClassType> cachedBaseType = null;
KotlinLightClassForAnonymousDeclaration(@NotNull PsiManager manager, @NotNull FqName name, @NotNull JetClassOrObject classOrObject) {
KotlinLightClassForAnonymousDeclaration(@NotNull PsiManager manager, @NotNull FqName name, @NotNull KtClassOrObject classOrObject) {
super(manager, name, classOrObject);
}
@@ -52,11 +52,11 @@ class KotlinLightClassForAnonymousDeclaration extends KotlinLightClassForExplici
ClassDescriptor descriptor = getDescriptor();
if (descriptor == null) return CommonClassNames.JAVA_LANG_OBJECT;
Collection<JetType> superTypes = descriptor.getTypeConstructor().getSupertypes();
Collection<KtType> superTypes = descriptor.getTypeConstructor().getSupertypes();
if (superTypes.isEmpty()) return CommonClassNames.JAVA_LANG_OBJECT;
JetType superType = superTypes.iterator().next();
KtType superType = superTypes.iterator().next();
DeclarationDescriptor superClassDescriptor = superType.getConstructor().getDeclarationDescriptor();
if (superClassDescriptor == null) {
@@ -18,14 +18,14 @@ package org.jetbrains.kotlin.asJava
import com.intellij.psi.PsiManager
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetEnumEntry
import org.jetbrains.kotlin.psi.KtEnumEntry
import com.intellij.psi.PsiEnumConstantInitializer
import com.intellij.psi.PsiEnumConstant
public class KotlinLightClassForEnumEntry(
psiManager: PsiManager,
fqName: FqName,
enumEntry: JetEnumEntry,
enumEntry: KtEnumEntry,
private val enumConstant: PsiEnumConstant
): KotlinLightClassForAnonymousDeclaration(psiManager, fqName, enumEntry), PsiEnumConstantInitializer {
override fun getEnumConstant(): PsiEnumConstant = enumConstant
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.codegen.binding.PsiCodegenPredictor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.fileClasses.NoResolveFileClassesProvider
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.lexer.JetTokens.*
import org.jetbrains.kotlin.lexer.KtTokens.*
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
@@ -50,8 +50,8 @@ import javax.swing.Icon
public open class KotlinLightClassForExplicitDeclaration(
manager: PsiManager,
protected val classFqName: FqName, // FqName of (possibly inner) class
protected val classOrObject: JetClassOrObject)
: KotlinWrappingLightClass(manager), JetJavaMirrorMarker, StubBasedPsiElement<KotlinClassOrObjectStub<out JetClassOrObject>> {
protected val classOrObject: KtClassOrObject)
: KotlinWrappingLightClass(manager), JetJavaMirrorMarker, StubBasedPsiElement<KotlinClassOrObjectStub<out KtClassOrObject>> {
private var delegate: PsiClass? = null
private fun getLocalClassParent(): PsiElement? {
@@ -88,37 +88,37 @@ public open class KotlinLightClassForExplicitDeclaration(
return method
}
var declaration: PsiElement? = JetPsiUtil.getTopmostParentOfTypes(
var declaration: PsiElement? = KtPsiUtil.getTopmostParentOfTypes(
classOrObject,
JetNamedFunction::class.java,
JetConstructor::class.java,
JetProperty::class.java,
JetClassInitializer::class.java,
JetParameter::class.java)
KtNamedFunction::class.java,
KtConstructor::class.java,
KtProperty::class.java,
KtClassInitializer::class.java,
KtParameter::class.java)
if (declaration is JetParameter) {
declaration = declaration.getStrictParentOfType<JetNamedDeclaration>()
if (declaration is KtParameter) {
declaration = declaration.getStrictParentOfType<KtNamedDeclaration>()
}
if (declaration is JetFunction) {
if (declaration is KtFunction) {
return getParentByPsiMethod(LightClassUtil.getLightClassMethod(declaration), declaration.name, false)
}
// Represent the property as a fake method with the same name
if (declaration is JetProperty) {
if (declaration is KtProperty) {
return getParentByPsiMethod(LightClassUtil.getLightClassPropertyMethods(declaration).getter, declaration.name, true)
}
if (declaration is JetClassInitializer) {
if (declaration is KtClassInitializer) {
val parent = declaration.parent
val grandparent = parent.parent
if (parent is JetClassBody && grandparent is JetClassOrObject) {
if (parent is KtClassBody && grandparent is KtClassOrObject) {
return LightClassUtil.getPsiClass(grandparent)
}
}
if (declaration is JetClass) {
if (declaration is KtClass) {
return LightClassUtil.getPsiClass(declaration)
}
return null
@@ -133,12 +133,12 @@ public open class KotlinLightClassForExplicitDeclaration(
containingClass
}
override fun getOrigin(): JetClassOrObject = classOrObject
override fun getOrigin(): KtClassOrObject = classOrObject
override fun getFqName(): FqName = classFqName
override fun copy(): PsiElement {
return KotlinLightClassForExplicitDeclaration(manager, classFqName, classOrObject.copy() as JetClassOrObject)
return KotlinLightClassForExplicitDeclaration(manager, classFqName, classOrObject.copy() as KtClassOrObject)
}
override fun getDelegate(): PsiClass {
@@ -281,7 +281,7 @@ public open class KotlinLightClassForExplicitDeclaration(
if (isAbstract() || isSealed()) {
psiModifiers.add(PsiModifier.ABSTRACT)
}
else if (!(classOrObject.hasModifier(OPEN_KEYWORD) || (classOrObject is JetClass && classOrObject.isEnum()))) {
else if (!(classOrObject.hasModifier(OPEN_KEYWORD) || (classOrObject is KtClass && classOrObject.isEnum()))) {
psiModifiers.add(PsiModifier.FINAL)
}
@@ -308,9 +308,9 @@ public open class KotlinLightClassForExplicitDeclaration(
val typeReference = annotationEntry.typeReference ?: continue
val typeElement = typeReference.typeElement
if (typeElement !is JetUserType) continue // If it's not a user type, it's definitely not a ref to deprecated
if (typeElement !is KtUserType) continue // If it's not a user type, it's definitely not a ref to deprecated
val fqName = JetPsiUtil.toQualifiedName(typeElement) ?: continue
val fqName = KtPsiUtil.toQualifiedName(typeElement) ?: continue
if (deprecatedFqName == fqName) return true
if (deprecatedName == fqName.asString()) return true
@@ -319,15 +319,15 @@ public open class KotlinLightClassForExplicitDeclaration(
}
override fun isInterface(): Boolean {
if (classOrObject !is JetClass) return false
if (classOrObject !is KtClass) return false
return classOrObject.isInterface() || classOrObject.isAnnotation()
}
override fun isAnnotationType(): Boolean = classOrObject is JetClass && classOrObject.isAnnotation()
override fun isAnnotationType(): Boolean = classOrObject is KtClass && classOrObject.isAnnotation()
override fun isEnum(): Boolean = classOrObject is JetClass && classOrObject.isEnum()
override fun isEnum(): Boolean = classOrObject is KtClass && classOrObject.isEnum()
override fun hasTypeParameters(): Boolean = classOrObject is JetClass && !classOrObject.typeParameters.isEmpty()
override fun hasTypeParameters(): Boolean = classOrObject is KtClass && !classOrObject.typeParameters.isEmpty()
override fun isValid(): Boolean = classOrObject.isValid
@@ -364,7 +364,7 @@ public open class KotlinLightClassForExplicitDeclaration(
override fun getOwnInnerClasses(): List<PsiClass> {
return getDelegate().innerClasses
.map {
val declaration = ClsWrapperStubPsiFactory.getOriginalDeclaration(it) as JetClassOrObject?
val declaration = ClsWrapperStubPsiFactory.getOriginalDeclaration(it) as KtClassOrObject?
if (declaration != null) create(myManager, declaration, it) else null
}
.filterNotNull()
@@ -373,7 +373,7 @@ public open class KotlinLightClassForExplicitDeclaration(
override fun getUseScope(): SearchScope = getOrigin().useScope
override fun getElementType(): IStubElementType<out StubElement<*>, *>? = classOrObject.elementType
override fun getStub(): KotlinClassOrObjectStub<out JetClassOrObject>? = classOrObject.stub
override fun getStub(): KotlinClassOrObjectStub<out KtClassOrObject>? = classOrObject.stub
companion object {
private val JAVA_API_STUB = Key.create<CachedValue<OutermostKotlinClassLightClassData>>("JAVA_API_STUB")
@@ -388,7 +388,7 @@ public open class KotlinLightClassForExplicitDeclaration(
@JvmOverloads
public fun create(
manager: PsiManager,
classOrObject: JetClassOrObject,
classOrObject: KtClassOrObject,
psiClass: PsiClass? = null
): KotlinLightClassForExplicitDeclaration? {
if (LightClassUtil.belongsToKotlinBuiltIns(classOrObject.getContainingJetFile())) {
@@ -397,7 +397,7 @@ public open class KotlinLightClassForExplicitDeclaration(
val fqName = predictFqName(classOrObject) ?: return null
if (classOrObject is JetObjectDeclaration && classOrObject.isObjectLiteral()) {
if (classOrObject is KtObjectDeclaration && classOrObject.isObjectLiteral()) {
return KotlinLightClassForAnonymousDeclaration(manager, fqName, classOrObject)
}
@@ -411,7 +411,7 @@ public open class KotlinLightClassForExplicitDeclaration(
return KotlinLightClassForExplicitDeclaration(manager, fqName, classOrObject)
}
private fun predictFqName(classOrObject: JetClassOrObject): FqName? {
private fun predictFqName(classOrObject: KtClassOrObject): FqName? {
if (classOrObject.isLocal()) {
val data = getLightClassDataExactly(classOrObject)
return data?.jvmQualifiedName
@@ -420,11 +420,11 @@ public open class KotlinLightClassForExplicitDeclaration(
return if (internalName == null) null else JvmClassName.byInternalName(internalName).fqNameForClassNameWithoutDollars
}
public fun getLightClassData(classOrObject: JetClassOrObject): OutermostKotlinClassLightClassData {
public fun getLightClassData(classOrObject: KtClassOrObject): OutermostKotlinClassLightClassData {
return getLightClassCachedValue(classOrObject).value
}
public fun getLightClassCachedValue(classOrObject: JetClassOrObject): CachedValue<OutermostKotlinClassLightClassData> {
public fun getLightClassCachedValue(classOrObject: KtClassOrObject): CachedValue<OutermostKotlinClassLightClassData> {
val outermostClassOrObject = getOutermostClassOrObject(classOrObject)
var value = outermostClassOrObject.getUserData(JAVA_API_STUB)
if (value == null) {
@@ -435,13 +435,13 @@ public open class KotlinLightClassForExplicitDeclaration(
return value
}
private fun getLightClassDataExactly(classOrObject: JetClassOrObject): LightClassDataForKotlinClass? {
private fun getLightClassDataExactly(classOrObject: KtClassOrObject): LightClassDataForKotlinClass? {
val data = getLightClassData(classOrObject)
return data.dataForClass(classOrObject)
}
private fun getOutermostClassOrObject(classOrObject: JetClassOrObject): JetClassOrObject {
val outermostClass = JetPsiUtil.getOutermostClassOrObject(classOrObject) ?:
private fun getOutermostClassOrObject(classOrObject: KtClassOrObject): KtClassOrObject {
val outermostClass = KtPsiUtil.getOutermostClassOrObject(classOrObject) ?:
throw IllegalStateException("Attempt to build a light class for a local class: " + classOrObject.text)
return outermostClass
@@ -31,8 +31,8 @@ import com.intellij.util.containers.SLRUCache
import org.jetbrains.annotations.NonNls
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile
import javax.swing.Icon
public class KotlinLightClassForFacade private constructor(
@@ -40,7 +40,7 @@ public class KotlinLightClassForFacade private constructor(
private val facadeClassFqName: FqName,
private val searchScope: GlobalSearchScope,
private val lightClassDataCache: CachedValue<KotlinFacadeLightClassData>,
files: Collection<JetFile>,
files: Collection<KtFile>,
private val deprecated: Boolean
) : KotlinWrappingLightClass(manager), JetJavaMirrorMarker {
@@ -100,7 +100,7 @@ public class KotlinLightClassForFacade private constructor(
}
}
public val files: Collection<JetFile> = files.toSet() // needed for hashCode
public val files: Collection<KtFile> = files.toSet() // needed for hashCode
private val hashCode: Int =
computeHashCode()
@@ -118,7 +118,7 @@ public class KotlinLightClassForFacade private constructor(
lightClassDataCache.value.javaFileStub
}
override fun getOrigin(): JetClassOrObject? = null
override fun getOrigin(): KtClassOrObject? = null
override fun getFqName(): FqName = facadeClassFqName
@@ -240,7 +240,7 @@ public class KotlinLightClassForFacade private constructor(
manager: PsiManager,
facadeClassFqName: FqName,
searchScope: GlobalSearchScope,
files: Collection<JetFile>
files: Collection<KtFile>
): KotlinLightClassForFacade? {
if (files.any { LightClassUtil.belongsToKotlinBuiltIns(it) }) {
return null
@@ -19,16 +19,16 @@ package org.jetbrains.kotlin.asJava
import com.intellij.psi.*
import com.intellij.util.IncorrectOperationException
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.KtClassOrObject
public open class KotlinLightClassForInterfaceDefaultImpls(
manager: PsiManager,
classFqName: FqName,
classOrObject: JetClassOrObject)
classOrObject: KtClassOrObject)
: KotlinLightClassForExplicitDeclaration(manager, classFqName, classOrObject){
override fun copy(): PsiElement {
return KotlinLightClassForInterfaceDefaultImpls(manager, classFqName, classOrObject.copy() as JetClassOrObject)
return KotlinLightClassForInterfaceDefaultImpls(manager, classFqName, classOrObject.copy() as KtClassOrObject)
}
override fun getTypeParameterList(): PsiTypeParameterList? = null
@@ -16,11 +16,11 @@
package org.jetbrains.kotlin.asJava
import org.jetbrains.kotlin.psi.JetDeclaration
import org.jetbrains.kotlin.psi.KtDeclaration
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiNamedElement
public interface KotlinLightElement<T : JetDeclaration, D : PsiElement> : PsiNamedElement {
public interface KotlinLightElement<T : KtDeclaration, D : PsiElement> : PsiNamedElement {
public fun getOrigin(): T?
public fun getDelegate(): D
@@ -17,15 +17,15 @@
package org.jetbrains.kotlin.asJava
import com.intellij.psi.*
import org.jetbrains.kotlin.psi.JetEnumEntry
import org.jetbrains.kotlin.psi.KtEnumEntry
class KotlinLightEnumConstant(
manager: PsiManager,
origin: JetEnumEntry,
origin: KtEnumEntry,
enumConstant: PsiEnumConstant,
containingClass: PsiClass,
private val initializingClass: PsiEnumConstantInitializer?
) : KotlinLightField<JetEnumEntry, PsiEnumConstant>(manager, origin, enumConstant, containingClass), PsiEnumConstant {
) : KotlinLightField<KtEnumEntry, PsiEnumConstant>(manager, origin, enumConstant, containingClass), PsiEnumConstant {
override fun copy() = KotlinLightEnumConstant(getManager()!!, getOrigin(), getDelegate(), getContainingClass()!!, initializingClass)
// NOTE: we don't use "delegation by" because the compiler would generate method calls to ALL of PsiEnumConstant members,
@@ -28,10 +28,10 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.KotlinLanguage;
import org.jetbrains.kotlin.psi.JetDeclaration;
import org.jetbrains.kotlin.psi.KtDeclaration;
// Copied from com.intellij.psi.impl.light.LightField
public abstract class KotlinLightField<T extends JetDeclaration, D extends PsiField> extends LightElement
public abstract class KotlinLightField<T extends KtDeclaration, D extends PsiField> extends LightElement
implements PsiField, KotlinLightElement<T, D> {
private final T origin;
private final D delegate;
@@ -17,13 +17,13 @@
package org.jetbrains.kotlin.asJava
import com.intellij.psi.*
import org.jetbrains.kotlin.psi.JetDeclaration
import org.jetbrains.kotlin.psi.KtDeclaration
class KotlinLightFieldForDeclaration(
manager: PsiManager,
origin: JetDeclaration,
origin: KtDeclaration,
field: PsiField,
containingClass: PsiClass
) : KotlinLightField<JetDeclaration, PsiField>(manager, origin, field, containingClass) {
) : KotlinLightField<KtDeclaration, PsiField>(manager, origin, field, containingClass) {
override fun copy() = KotlinLightFieldForDeclaration(getManager()!!, getOrigin(), getDelegate(), getContainingClass()!!)
}
@@ -17,6 +17,6 @@
package org.jetbrains.kotlin.asJava
import com.intellij.psi.PsiMethod
import org.jetbrains.kotlin.psi.JetDeclaration
import org.jetbrains.kotlin.psi.KtDeclaration
public interface KotlinLightMethod: PsiMethod, KotlinLightElement<JetDeclaration, PsiMethod>
public interface KotlinLightMethod: PsiMethod, KotlinLightElement<KtDeclaration, PsiMethod>
@@ -18,14 +18,14 @@ package org.jetbrains.kotlin.asJava
import com.intellij.psi.impl.light.LightMethod
import com.intellij.psi.*
import org.jetbrains.kotlin.psi.JetDeclaration
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.idea.KotlinLanguage
import kotlin.properties.Delegates
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiModificationTracker
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValue
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.KtClassOrObject
import com.intellij.psi.search.SearchScope
import com.intellij.lang.Language
import com.intellij.psi.scope.PsiScopeProcessor
@@ -35,7 +35,7 @@ import com.intellij.psi.util.MethodSignatureBackedByPsiMethod
open public class KotlinLightMethodForDeclaration(
manager: PsiManager,
private val delegate: PsiMethod,
private val origin: JetDeclaration,
private val origin: KtDeclaration,
containingClass: PsiClass
): LightMethod(manager, delegate, containingClass), KotlinLightMethod {
@@ -55,7 +55,7 @@ open public class KotlinLightMethodForDeclaration(
private val typeParamsList: CachedValue<PsiTypeParameterList> by lazy {
val cacheManager = CachedValuesManager.getManager(delegate.getProject())
cacheManager.createCachedValue<PsiTypeParameterList>({
val list = if (origin is JetClassOrObject) {
val list = if (origin is KtClassOrObject) {
KotlinLightTypeParameterListBuilder(getManager())
}
else {
@@ -70,7 +70,7 @@ open public class KotlinLightMethodForDeclaration(
override fun getDelegate(): PsiMethod = delegate
override fun getOrigin(): JetDeclaration = origin
override fun getOrigin(): KtDeclaration = origin
override fun getParent(): PsiElement? = getContainingClass()
@@ -108,7 +108,7 @@ open public class KotlinLightMethodForDeclaration(
}
override fun copy(): PsiElement {
return KotlinLightMethodForDeclaration(getManager()!!, delegate, origin.copy() as JetDeclaration, getContainingClass()!!)
return KotlinLightMethodForDeclaration(getManager()!!, delegate, origin.copy() as KtDeclaration, getContainingClass()!!)
}
override fun getUseScope(): SearchScope = origin.getUseScope()
@@ -18,21 +18,21 @@ package org.jetbrains.kotlin.asJava
import com.intellij.psi.PsiManager
import com.intellij.psi.PsiMethod
import org.jetbrains.kotlin.psi.JetDeclaration
import org.jetbrains.kotlin.psi.KtDeclaration
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
public class KotlinLightMethodForTraitFakeOverride(
manager: PsiManager,
private val delegate: PsiMethod,
private val origin: JetDeclaration,
private val origin: KtDeclaration,
containingClass: PsiClass
) : KotlinLightMethodForDeclaration(manager, delegate, origin, containingClass) {
override fun getDelegate(): PsiMethod = delegate
override fun getOrigin(): JetDeclaration = origin
override fun getOrigin(): KtDeclaration = origin
override fun copy(): PsiElement {
return KotlinLightMethodForTraitFakeOverride(getManager(), delegate, origin.copy() as JetDeclaration, getContainingClass()!!)
return KotlinLightMethodForTraitFakeOverride(getManager(), delegate, origin.copy() as KtDeclaration, getContainingClass()!!)
}
}
@@ -23,12 +23,12 @@ import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.name.FqName;
public class JetLightPackage extends PsiPackageImpl {
public class KotlinLightPackage extends PsiPackageImpl {
private final FqName fqName;
private final GlobalSearchScope scope;
public JetLightPackage(PsiManager manager, FqName qualifiedName, GlobalSearchScope scope) {
public KotlinLightPackage(PsiManager manager, FqName qualifiedName, GlobalSearchScope scope) {
super(manager, qualifiedName.asString());
this.fqName = qualifiedName;
this.scope = scope;
@@ -37,7 +37,7 @@ public class JetLightPackage extends PsiPackageImpl {
@NotNull
@Override
public PsiElement copy() {
return new JetLightPackage(getManager(), fqName, scope);
return new KotlinLightPackage(getManager(), fqName, scope);
}
@Override
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.psiUtil.JetPsiUtilKt;
import java.util.List;
public class KotlinLightParameter extends LightParameter implements KotlinLightElement<JetParameter, PsiParameter> {
public class KotlinLightParameter extends LightParameter implements KotlinLightElement<KtParameter, PsiParameter> {
private static String getName(PsiParameter delegate, int index) {
String name = delegate.getName();
return name != null ? name : "p" + index;
@@ -71,27 +71,27 @@ public class KotlinLightParameter extends LightParameter implements KotlinLightE
@Nullable
@Override
public JetParameter getOrigin() {
JetDeclaration declaration = method.getOrigin();
public KtParameter getOrigin() {
KtDeclaration declaration = method.getOrigin();
if (declaration == null) return null;
int jetIndex = JetPsiUtilKt.isExtensionDeclaration(declaration) ? index - 1 : index;
if (jetIndex < 0) return null;
if (declaration instanceof JetFunction) {
List<JetParameter> paramList = ((JetFunction) declaration).getValueParameters();
if (declaration instanceof KtFunction) {
List<KtParameter> paramList = ((KtFunction) declaration).getValueParameters();
return jetIndex < paramList.size() ? paramList.get(jetIndex) : null;
}
if (jetIndex != 0) return null;
JetPropertyAccessor setter = null;
if (declaration instanceof JetPropertyAccessor) {
JetPropertyAccessor accessor = (JetPropertyAccessor) declaration;
KtPropertyAccessor setter = null;
if (declaration instanceof KtPropertyAccessor) {
KtPropertyAccessor accessor = (KtPropertyAccessor) declaration;
setter = accessor.isSetter() ? accessor : null;
}
else if (declaration instanceof JetProperty) {
setter = ((JetProperty) declaration).getSetter();
else if (declaration instanceof KtProperty) {
setter = ((KtProperty) declaration).getSetter();
}
return setter != null ? setter.getParameter() : null;
@@ -100,13 +100,13 @@ public class KotlinLightParameter extends LightParameter implements KotlinLightE
@NotNull
@Override
public PsiElement getNavigationElement() {
JetParameter origin = getOrigin();
KtParameter origin = getOrigin();
return origin != null ? origin : super.getNavigationElement();
}
@Override
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
JetParameter origin = getOrigin();
KtParameter origin = getOrigin();
if (origin != null) {
origin.setName(name);
}
@@ -115,7 +115,7 @@ public class KotlinLightParameter extends LightParameter implements KotlinLightE
@Override
public PsiFile getContainingFile() {
JetDeclaration declaration = method.getOrigin();
KtDeclaration declaration = method.getOrigin();
return declaration != null ? declaration.getContainingFile() : super.getContainingFile();
}
@@ -128,7 +128,7 @@ public class KotlinLightParameter extends LightParameter implements KotlinLightE
@NotNull
@Override
public SearchScope getUseScope() {
JetParameter origin = getOrigin();
KtParameter origin = getOrigin();
return origin != null ? origin.getUseScope() : GlobalSearchScope.EMPTY_SCOPE;
}
@@ -23,11 +23,11 @@ import com.intellij.psi.search.SearchScope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.KotlinLanguage;
import org.jetbrains.kotlin.psi.JetTypeParameter;
import org.jetbrains.kotlin.psi.JetTypeParameterListOwner;
import org.jetbrains.kotlin.psi.KtTypeParameter;
import org.jetbrains.kotlin.psi.KtTypeParameterListOwner;
public class KotlinLightTypeParameter
extends AbstractLightClass implements PsiTypeParameter, KotlinLightElement<JetTypeParameter, PsiTypeParameter> {
extends AbstractLightClass implements PsiTypeParameter, KotlinLightElement<KtTypeParameter, PsiTypeParameter> {
private final PsiTypeParameterListOwner owner;
private final int index;
private final String name;
@@ -50,8 +50,8 @@ public class KotlinLightTypeParameter
@NotNull
@Override
public JetTypeParameter getOrigin() {
JetTypeParameterListOwner jetOwner = (JetTypeParameterListOwner) LightClassUtilsKt.getUnwrapped(owner);
public KtTypeParameter getOrigin() {
KtTypeParameterListOwner jetOwner = (KtTypeParameterListOwner) LightClassUtilsKt.getUnwrapped(owner);
assert (jetOwner != null) : "Invalid type parameter owner: " + owner;
return jetOwner.getTypeParameters().get(index);
@@ -48,7 +48,7 @@ public abstract class KotlinWrappingLightClass extends AbstractLightClass implem
@Nullable
@Override
public abstract JetClassOrObject getOrigin();
public abstract KtClassOrObject getOrigin();
@NotNull
@Override
@@ -121,11 +121,11 @@ public abstract class KotlinWrappingLightClass extends AbstractLightClass implem
return ContainerUtil.map(getDelegate().getFields(), new Function<PsiField, PsiField>() {
@Override
public PsiField fun(PsiField field) {
JetDeclaration declaration = ClsWrapperStubPsiFactory.getOriginalDeclaration(field);
if (declaration instanceof JetEnumEntry) {
KtDeclaration declaration = ClsWrapperStubPsiFactory.getOriginalDeclaration(field);
if (declaration instanceof KtEnumEntry) {
assert field instanceof PsiEnumConstant : "Field delegate should be an enum constant (" + field.getName() + "):\n" +
PsiUtilsKt.getElementTextWithContext(declaration);
JetEnumEntry enumEntry = (JetEnumEntry) declaration;
KtEnumEntry enumEntry = (KtEnumEntry) declaration;
PsiEnumConstant enumConstant = (PsiEnumConstant) field;
FqName enumConstantFqName = new FqName(getFqName().asString() + "." + enumEntry.getName());
KotlinLightClassForEnumEntry initializingClass =
@@ -148,9 +148,9 @@ public abstract class KotlinWrappingLightClass extends AbstractLightClass implem
return ArraysKt.map(getDelegate().getMethods(), new Function1<PsiMethod, PsiMethod>() {
@Override
public PsiMethod invoke(PsiMethod method) {
JetDeclaration declaration = ClsWrapperStubPsiFactory.getOriginalDeclaration(method);
if (declaration instanceof JetPropertyAccessor) {
declaration = PsiTreeUtil.getParentOfType(declaration, JetProperty.class);
KtDeclaration declaration = ClsWrapperStubPsiFactory.getOriginalDeclaration(method);
if (declaration instanceof KtPropertyAccessor) {
declaration = PsiTreeUtil.getParentOfType(declaration, KtProperty.class);
}
if (declaration != null) {
@@ -177,7 +177,7 @@ public abstract class KotlinWrappingLightClass extends AbstractLightClass implem
@Override
public String getText() {
JetClassOrObject origin = getOrigin();
KtClassOrObject origin = getOrigin();
return origin == null ? null : origin.getText();
}
@@ -187,18 +187,18 @@ public abstract class KotlinWrappingLightClass extends AbstractLightClass implem
return KotlinLanguage.INSTANCE;
}
private boolean isTraitFakeOverride(@NotNull JetDeclaration originMethodDeclaration) {
if (!(originMethodDeclaration instanceof JetNamedFunction ||
originMethodDeclaration instanceof JetPropertyAccessor ||
originMethodDeclaration instanceof JetProperty)) {
private boolean isTraitFakeOverride(@NotNull KtDeclaration originMethodDeclaration) {
if (!(originMethodDeclaration instanceof KtNamedFunction ||
originMethodDeclaration instanceof KtPropertyAccessor ||
originMethodDeclaration instanceof KtProperty)) {
return false;
}
JetClassOrObject parentOfMethodOrigin = PsiTreeUtil.getParentOfType(originMethodDeclaration, JetClassOrObject.class);
JetClassOrObject thisClassDeclaration = getOrigin();
KtClassOrObject parentOfMethodOrigin = PsiTreeUtil.getParentOfType(originMethodDeclaration, KtClassOrObject.class);
KtClassOrObject thisClassDeclaration = getOrigin();
// Method was generated from declaration in some other trait
return (parentOfMethodOrigin != null && thisClassDeclaration != parentOfMethodOrigin && JetPsiUtil.isTrait(parentOfMethodOrigin));
return (parentOfMethodOrigin != null && thisClassDeclaration != parentOfMethodOrigin && KtPsiUtil.isTrait(parentOfMethodOrigin));
}
@Override
@@ -24,8 +24,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetClassOrObject;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtClassOrObject;
import org.jetbrains.kotlin.psi.KtFile;
import java.util.Collection;
@@ -37,13 +37,13 @@ public abstract class LightClassGenerationSupport {
}
@NotNull
public abstract LightClassConstructionContext getContextForPackage(@NotNull Collection<JetFile> files);
public abstract LightClassConstructionContext getContextForPackage(@NotNull Collection<KtFile> files);
@NotNull
public abstract LightClassConstructionContext getContextForClassOrObject(@NotNull JetClassOrObject classOrObject);
public abstract LightClassConstructionContext getContextForClassOrObject(@NotNull KtClassOrObject classOrObject);
@NotNull
public abstract Collection<JetClassOrObject> findClassOrObjectDeclarations(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope);
public abstract Collection<KtClassOrObject> findClassOrObjectDeclarations(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope);
/*
* Finds files whose package declaration is exactly {@code fqName}. For example, if a file declares
@@ -53,11 +53,11 @@ public abstract class LightClassGenerationSupport {
* If the resulting collection is empty, it means that this package has not other declarations than sub-packages
*/
@NotNull
public abstract Collection<JetFile> findFilesForPackage(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope);
public abstract Collection<KtFile> findFilesForPackage(@NotNull FqName fqName, @NotNull GlobalSearchScope searchScope);
// Returns only immediately declared classes/objects, package classes are not included (they have no declarations)
@NotNull
public abstract Collection<JetClassOrObject> findClassOrObjectDeclarationsInPackage(
public abstract Collection<KtClassOrObject> findClassOrObjectDeclarationsInPackage(
@NotNull FqName packageFqName,
@NotNull GlobalSearchScope searchScope
);
@@ -68,10 +68,10 @@ public abstract class LightClassGenerationSupport {
public abstract Collection<FqName> getSubPackages(@NotNull FqName fqn, @NotNull GlobalSearchScope scope);
@Nullable
public abstract PsiClass getPsiClass(@NotNull JetClassOrObject classOrObject);
public abstract PsiClass getPsiClass(@NotNull KtClassOrObject classOrObject);
@Nullable
public abstract ClassDescriptor resolveClassToDescriptor(@NotNull JetClassOrObject classOrObject);
public abstract ClassDescriptor resolveClassToDescriptor(@NotNull KtClassOrObject classOrObject);
@NotNull
public abstract Collection<PsiClass> getFacadeClasses(@NotNull FqName facadeFqName, @NotNull GlobalSearchScope scope);
@@ -83,9 +83,9 @@ public abstract class LightClassGenerationSupport {
public abstract Collection<String> getFacadeNames(@NotNull FqName packageFqName, @NotNull GlobalSearchScope scope);
@NotNull
public abstract Collection<JetFile> findFilesForFacade(@NotNull FqName facadeFqName, @NotNull GlobalSearchScope scope);
public abstract Collection<KtFile> findFilesForFacade(@NotNull FqName facadeFqName, @NotNull GlobalSearchScope scope);
@NotNull
public abstract LightClassConstructionContext getContextForFacade(@NotNull Collection<JetFile> files);
public abstract LightClassConstructionContext getContextForFacade(@NotNull Collection<KtFile> files);
}
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.asJava
import com.intellij.psi.impl.java.stubs.PsiJavaFileStub
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
interface LightClassData
@@ -29,7 +29,7 @@ interface WithFileStubAndExtraDiagnostics {
}
interface LightClassDataForKotlinClass: LightClassData {
val classOrObject: JetClassOrObject
val classOrObject: KtClassOrObject
val jvmQualifiedName: FqName
}
@@ -40,18 +40,18 @@ data class KotlinFacadeLightClassData(
data class InnerKotlinClassLightClassData(
override val jvmQualifiedName: FqName,
override val classOrObject: JetClassOrObject
override val classOrObject: KtClassOrObject
): LightClassDataForKotlinClass
data class OutermostKotlinClassLightClassData(
override val javaFileStub: PsiJavaFileStub,
override val extraDiagnostics: Diagnostics,
override val jvmQualifiedName: FqName,
override val classOrObject: JetClassOrObject,
val allInnerClasses: Map<JetClassOrObject, InnerKotlinClassLightClassData>
override val classOrObject: KtClassOrObject,
val allInnerClasses: Map<KtClassOrObject, InnerKotlinClassLightClassData>
): LightClassDataForKotlinClass, WithFileStubAndExtraDiagnostics {
fun dataForClass(cls: JetClassOrObject): LightClassDataForKotlinClass? =
fun dataForClass(cls: KtClassOrObject): LightClassDataForKotlinClass? =
if (cls == classOrObject) this else allInnerClasses[cls]
}
@@ -56,7 +56,7 @@ public object LightClassUtil {
* Used to skip JetLightClass creation for built-ins, because built-in classes have no Java counterparts
*/
public fun belongsToKotlinBuiltIns(file: JetFile): Boolean {
public fun belongsToKotlinBuiltIns(file: KtFile): Boolean {
val virtualFile = file.virtualFile
if (virtualFile != null) {
val parent = virtualFile.parent
@@ -125,22 +125,22 @@ public object LightClassUtil {
return null
}/*package*/
public fun getPsiClass(classOrObject: JetClassOrObject?): PsiClass? {
public fun getPsiClass(classOrObject: KtClassOrObject?): PsiClass? {
if (classOrObject == null) return null
return LightClassGenerationSupport.getInstance(classOrObject.project).getPsiClass(classOrObject)
}
public fun getLightClassAccessorMethod(accessor: JetPropertyAccessor): PsiMethod? =
public fun getLightClassAccessorMethod(accessor: KtPropertyAccessor): PsiMethod? =
getLightClassAccessorMethods(accessor).firstOrNull()
public fun getLightClassAccessorMethods(accessor: JetPropertyAccessor): List<PsiMethod> {
val property = accessor.getNonStrictParentOfType<JetProperty>() ?: return emptyList()
public fun getLightClassAccessorMethods(accessor: KtPropertyAccessor): List<PsiMethod> {
val property = accessor.getNonStrictParentOfType<KtProperty>() ?: return emptyList()
val wrappers = getPsiMethodWrappers(property, true)
return wrappers.filter { wrapper -> (accessor.isGetter && !JvmAbi.isSetterName(wrapper.name)) ||
(accessor.isSetter && JvmAbi.isSetterName(wrapper.name)) }
}
public fun getLightFieldForCompanionObject(companionObject: JetClassOrObject): PsiField? {
public fun getLightFieldForCompanionObject(companionObject: KtClassOrObject): PsiField? {
val outerPsiClass = getWrappingClass(companionObject, true)
if (outerPsiClass != null) {
for (fieldOfParent in outerPsiClass.fields) {
@@ -152,7 +152,7 @@ public object LightClassUtil {
return null
}
public fun getLightClassPropertyMethods(property: JetProperty): PropertyAccessorsPsiMethods {
public fun getLightClassPropertyMethods(property: KtProperty): PropertyAccessorsPsiMethods {
val getter = property.getter
val setter = property.setter
@@ -162,13 +162,13 @@ public object LightClassUtil {
return extractPropertyAccessors(property, getterWrapper, setterWrapper)
}
private fun getLightClassBackingField(declaration: JetDeclaration): PsiField? {
private fun getLightClassBackingField(declaration: KtDeclaration): PsiField? {
var psiClass: PsiClass = getWrappingClass(declaration, true) ?: return null
if (psiClass is KotlinLightClass) {
val origin = psiClass.getOrigin()
if (origin is JetObjectDeclaration && origin.isCompanion()) {
val containingClass = PsiTreeUtil.getParentOfType(origin, JetClass::class.java)
if (origin is KtObjectDeclaration && origin.isCompanion()) {
val containingClass = PsiTreeUtil.getParentOfType(origin, KtClass::class.java)
if (containingClass != null) {
val containingLightClass = getPsiClass(containingClass)
if (containingLightClass != null) {
@@ -186,23 +186,23 @@ public object LightClassUtil {
return null
}
public fun getLightClassPropertyMethods(parameter: JetParameter): PropertyAccessorsPsiMethods {
public fun getLightClassPropertyMethods(parameter: KtParameter): PropertyAccessorsPsiMethods {
return extractPropertyAccessors(parameter, null, null)
}
public fun getLightClassMethod(function: JetFunction): PsiMethod? {
public fun getLightClassMethod(function: KtFunction): PsiMethod? {
return getPsiMethodWrapper(function)
}
public fun getLightClassMethods(function: JetFunction): List<PsiMethod> {
public fun getLightClassMethods(function: KtFunction): List<PsiMethod> {
return getPsiMethodWrappers(function, true)
}
private fun getPsiMethodWrapper(declaration: JetDeclaration): PsiMethod? {
private fun getPsiMethodWrapper(declaration: KtDeclaration): PsiMethod? {
return getPsiMethodWrappers(declaration, false).firstOrNull()
}
private fun getPsiMethodWrappers(declaration: JetDeclaration, collectAll: Boolean): List<PsiMethod> {
private fun getPsiMethodWrappers(declaration: KtDeclaration, collectAll: Boolean): List<PsiMethod> {
val psiClasses = getWrappingClasses(declaration, collectAll)
val methods = SmartList<PsiMethod>()
@@ -227,9 +227,9 @@ public object LightClassUtil {
return methods
}
private fun getWrappingClasses(declaration: JetDeclaration, collectAll: Boolean): Collection<PsiClass> {
private fun getWrappingClasses(declaration: KtDeclaration, collectAll: Boolean): Collection<PsiClass> {
val wrappingClass = getWrappingClass(declaration, true)
val oldPackagePartWrappingClass = if (declaration.parent is JetFile && collectAll)
val oldPackagePartWrappingClass = if (declaration.parent is KtFile && collectAll)
getWrappingClass(declaration, false)
else
null
@@ -237,23 +237,23 @@ public object LightClassUtil {
return setOf(wrappingClass, oldPackagePartWrappingClass).filterNotNull()
}
private fun getWrappingClass(declaration: JetDeclaration, useNewPackageParts: Boolean): PsiClass? {
private fun getWrappingClass(declaration: KtDeclaration, useNewPackageParts: Boolean): PsiClass? {
var declaration = declaration
if (declaration is JetParameter) {
val constructorClass = JetPsiUtil.getClassIfParameterIsProperty(declaration)
if (declaration is KtParameter) {
val constructorClass = KtPsiUtil.getClassIfParameterIsProperty(declaration)
if (constructorClass != null) {
return getPsiClass(constructorClass)
}
}
if (declaration is JetPropertyAccessor) {
if (declaration is KtPropertyAccessor) {
val propertyParent = declaration.parent
assert(propertyParent is JetProperty) { "JetProperty is expected to be parent of accessor" }
assert(propertyParent is KtProperty) { "JetProperty is expected to be parent of accessor" }
declaration = propertyParent as JetProperty
declaration = propertyParent as KtProperty
}
if (declaration is JetConstructor<*>) {
if (declaration is KtConstructor<*>) {
return getPsiClass(declaration.getContainingClassOrObject())
}
@@ -265,7 +265,7 @@ public object LightClassUtil {
val parent = declaration.parent
if (parent is JetFile) {
if (parent is KtFile) {
// top-level declaration
val fqName = if (useNewPackageParts)
parent.javaFileFacadeFqName
@@ -275,27 +275,27 @@ public object LightClassUtil {
val project = declaration.project
return JavaElementFinder.getInstance(project).findClass(fqName.asString(), GlobalSearchScope.allScope(project))
}
else if (parent is JetClassBody) {
assert(parent.parent is JetClassOrObject)
return getPsiClass(parent.parent as JetClassOrObject)
else if (parent is KtClassBody) {
assert(parent.parent is KtClassOrObject)
return getPsiClass(parent.parent as KtClassOrObject)
}
return null
}
public fun canGenerateLightClass(declaration: JetDeclaration): Boolean {
public fun canGenerateLightClass(declaration: KtDeclaration): Boolean {
//noinspection unchecked
return PsiTreeUtil.getParentOfType(declaration, JetFunction::class.java, JetProperty::class.java) == null
return PsiTreeUtil.getParentOfType(declaration, KtFunction::class.java, KtProperty::class.java) == null
}
private fun extractPropertyAccessors(
jetDeclaration: JetDeclaration,
ktDeclaration: KtDeclaration,
specialGetter: PsiMethod?, specialSetter: PsiMethod?): PropertyAccessorsPsiMethods {
var getterWrapper = specialGetter
var setterWrapper = specialSetter
val additionalAccessors = arrayListOf<PsiMethod>()
val wrappers = getPsiMethodWrappers(jetDeclaration, true).filter {
val wrappers = getPsiMethodWrappers(ktDeclaration, true).filter {
JvmAbi.isGetterName(it.name) || JvmAbi.isSetterName(it.name)
}
@@ -318,15 +318,15 @@ public object LightClassUtil {
}
}
val backingField = getLightClassBackingField(jetDeclaration)
val backingField = getLightClassBackingField(ktDeclaration)
return PropertyAccessorsPsiMethods(getterWrapper, setterWrapper, backingField, additionalAccessors)
}
public fun buildLightTypeParameterList(
owner: PsiTypeParameterListOwner,
declaration: JetDeclaration): PsiTypeParameterList {
declaration: KtDeclaration): PsiTypeParameterList {
val builder = KotlinLightTypeParameterListBuilder(owner.manager)
if (declaration is JetTypeParameterListOwner) {
if (declaration is KtTypeParameterListOwner) {
val parameters = declaration.typeParameters
for (i in parameters.indices) {
val jetTypeParameter = parameters.get(i)
@@ -25,9 +25,6 @@ import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.AbstractClassBuilder;
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.org.objectweb.asm.ClassVisitor;
import org.jetbrains.org.objectweb.asm.FieldVisitor;
@@ -30,40 +30,40 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
public fun getJvmSignatureDiagnostics(element: PsiElement, otherDiagnostics: Diagnostics, moduleScope: GlobalSearchScope): Diagnostics? {
fun getDiagnosticsForPackage(file: JetFile): Diagnostics? {
fun getDiagnosticsForPackage(file: KtFile): Diagnostics? {
val project = file.getProject()
val cache = KotlinLightClassForFacade.PackageFacadeStubCache.getInstance(project)
return cache[file.getPackageFqName(), moduleScope].getValue()?.extraDiagnostics
}
fun getDiagnosticsForClass(jetClassOrObject: JetClassOrObject): Diagnostics {
return KotlinLightClassForExplicitDeclaration.getLightClassData(jetClassOrObject).extraDiagnostics
fun getDiagnosticsForClass(ktClassOrObject: KtClassOrObject): Diagnostics {
return KotlinLightClassForExplicitDeclaration.getLightClassData(ktClassOrObject).extraDiagnostics
}
fun doGetDiagnostics(): Diagnostics? {
var parent = element.getParent()
if (element is JetPropertyAccessor) {
if (element is KtPropertyAccessor) {
parent = parent?.getParent()
}
if (element is JetParameter && element.hasValOrVar()) {
if (element is KtParameter && element.hasValOrVar()) {
// property declared in constructor
val parentClass = (parent?.getParent()?.getParent() as? JetClass)
val parentClass = (parent?.getParent()?.getParent() as? KtClass)
if (parentClass != null) {
return getDiagnosticsForClass(parentClass)
}
}
if (element is JetClassOrObject) {
if (element is KtClassOrObject) {
return getDiagnosticsForClass(element)
}
when (parent) {
is JetFile -> {
is KtFile -> {
return getDiagnosticsForPackage(parent)
}
is JetClassBody -> {
is KtClassBody -> {
val parentsParent = parent.getParent()
if (parentsParent is JetClassOrObject) {
if (parentsParent is KtClassOrObject) {
return getDiagnosticsForClass(parentsParent)
}
}
@@ -83,7 +83,7 @@ class FilteredJvmDiagnostics(val jvmDiagnostics: Diagnostics, val otherDiagnosti
val higherPriority = setOf<DiagnosticFactory<*>>(
CONFLICTING_OVERLOADS, REDECLARATION, NOTHING_TO_OVERRIDE, MANY_IMPL_MEMBER_NOT_IMPLEMENTED)
return otherDiagnostics.forElement(psiElement).any { it.getFactory() in higherPriority }
|| psiElement is JetPropertyAccessor && alreadyReported(psiElement.getParent()!!)
|| psiElement is KtPropertyAccessor && alreadyReported(psiElement.getParent()!!)
}
override fun forElement(psiElement: PsiElement): Collection<Diagnostic> {
@@ -27,69 +27,69 @@ import org.jetbrains.kotlin.utils.addToStdlib.singletonList
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
import java.util.*
public fun JetClassOrObject.toLightClass(): KotlinLightClass? = LightClassUtil.getPsiClass(this) as KotlinLightClass?
public fun KtClassOrObject.toLightClass(): KotlinLightClass? = LightClassUtil.getPsiClass(this) as KotlinLightClass?
public fun JetDeclaration.toLightElements(): List<PsiNamedElement> =
public fun KtDeclaration.toLightElements(): List<PsiNamedElement> =
when (this) {
is JetClassOrObject -> LightClassUtil.getPsiClass(this).singletonOrEmptyList()
is JetNamedFunction,
is JetSecondaryConstructor -> LightClassUtil.getLightClassMethods(this as JetFunction)
is JetProperty -> LightClassUtil.getLightClassPropertyMethods(this).toList()
is JetPropertyAccessor -> LightClassUtil.getLightClassAccessorMethod(this).singletonOrEmptyList()
is JetParameter -> ArrayList<PsiNamedElement>().let { elements ->
is KtClassOrObject -> LightClassUtil.getPsiClass(this).singletonOrEmptyList()
is KtNamedFunction,
is KtSecondaryConstructor -> LightClassUtil.getLightClassMethods(this as KtFunction)
is KtProperty -> LightClassUtil.getLightClassPropertyMethods(this).toList()
is KtPropertyAccessor -> LightClassUtil.getLightClassAccessorMethod(this).singletonOrEmptyList()
is KtParameter -> ArrayList<PsiNamedElement>().let { elements ->
toPsiParameters().toCollection(elements)
LightClassUtil.getLightClassPropertyMethods(this).toCollection(elements)
elements
}
is JetTypeParameter -> toPsiTypeParameters()
is KtTypeParameter -> toPsiTypeParameters()
else -> listOf()
}
public fun PsiElement.toLightMethods(): List<PsiMethod> =
when (this) {
is JetFunction -> LightClassUtil.getLightClassMethods(this)
is JetProperty -> LightClassUtil.getLightClassPropertyMethods(this).toList()
is JetParameter -> LightClassUtil.getLightClassPropertyMethods(this).toList()
is JetPropertyAccessor -> LightClassUtil.getLightClassAccessorMethods(this)
is JetClass -> LightClassUtil.getPsiClass(this)?.getConstructors()?.first().singletonOrEmptyList()
is KtFunction -> LightClassUtil.getLightClassMethods(this)
is KtProperty -> LightClassUtil.getLightClassPropertyMethods(this).toList()
is KtParameter -> LightClassUtil.getLightClassPropertyMethods(this).toList()
is KtPropertyAccessor -> LightClassUtil.getLightClassAccessorMethods(this)
is KtClass -> LightClassUtil.getPsiClass(this)?.getConstructors()?.first().singletonOrEmptyList()
is PsiMethod -> this.singletonList()
else -> listOf()
}
public fun PsiElement.getRepresentativeLightMethod(): PsiMethod? =
when (this) {
is JetFunction -> LightClassUtil.getLightClassMethod(this)
is JetProperty -> LightClassUtil.getLightClassPropertyMethods(this).getter
is JetParameter -> LightClassUtil.getLightClassPropertyMethods(this).getter
is JetPropertyAccessor -> LightClassUtil.getLightClassAccessorMethod(this)
is KtFunction -> LightClassUtil.getLightClassMethod(this)
is KtProperty -> LightClassUtil.getLightClassPropertyMethods(this).getter
is KtParameter -> LightClassUtil.getLightClassPropertyMethods(this).getter
is KtPropertyAccessor -> LightClassUtil.getLightClassAccessorMethod(this)
is PsiMethod -> this
else -> null
}
public fun JetParameter.toPsiParameters(): Collection<PsiParameter> {
val paramList = getNonStrictParentOfType<JetParameterList>() ?: return emptyList()
public fun KtParameter.toPsiParameters(): Collection<PsiParameter> {
val paramList = getNonStrictParentOfType<KtParameterList>() ?: return emptyList()
val paramIndex = paramList.getParameters().indexOf(this)
val owner = paramList.getParent()
val lightParamIndex = if (owner is JetDeclaration && owner.isExtensionDeclaration()) paramIndex + 1 else paramIndex
val lightParamIndex = if (owner is KtDeclaration && owner.isExtensionDeclaration()) paramIndex + 1 else paramIndex
val methods: Collection<PsiMethod> =
when (owner) {
is JetFunction -> LightClassUtil.getLightClassMethods(owner)
is JetPropertyAccessor -> LightClassUtil.getLightClassAccessorMethods(owner)
is KtFunction -> LightClassUtil.getLightClassMethods(owner)
is KtPropertyAccessor -> LightClassUtil.getLightClassAccessorMethods(owner)
else -> null
} ?: return emptyList()
return methods.map { it.getParameterList().getParameters()[lightParamIndex] }
}
public fun JetTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
val paramList = getNonStrictParentOfType<JetTypeParameterList>()
public fun KtTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
val paramList = getNonStrictParentOfType<KtTypeParameterList>()
if (paramList == null) return listOf()
val paramIndex = paramList.getParameters().indexOf(this)
val jetDeclaration = paramList.getNonStrictParentOfType<JetDeclaration>() ?: return listOf()
val jetDeclaration = paramList.getNonStrictParentOfType<KtDeclaration>() ?: return listOf()
val lightOwners = jetDeclaration.toLightElements()
return lightOwners.map { lightOwner -> (lightOwner as PsiTypeParameterListOwner).getTypeParameters()[paramIndex] }
@@ -103,8 +103,8 @@ public val PsiElement.namedUnwrappedElement: PsiNamedElement?
get() = unwrapped?.getNonStrictParentOfType<PsiNamedElement>()
val JetClassOrObject.hasInterfaceDefaultImpls: Boolean
get() = this is JetClass && isInterface()
val KtClassOrObject.hasInterfaceDefaultImpls: Boolean
get() = this is KtClass && isInterface()
private val DEFAULT_IMPLS_CLASS_NAME = Name.identifier(JvmAbi.DEFAULT_IMPLS_CLASS_NAME)
fun FqName.defaultImplsChild() = child(DEFAULT_IMPLS_CLASS_NAME)