Switch to 201 platform
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
193
|
|
||||||
201
|
201
|
||||||
202_201
|
202
|
||||||
203_202_201
|
193
|
||||||
192
|
192_193
|
||||||
as36_192
|
as36_192_193
|
||||||
as40
|
as40_193
|
||||||
as41_201
|
as41
|
||||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.incremental.storage
|
|||||||
|
|
||||||
import com.intellij.util.io.DataExternalizer
|
import com.intellij.util.io.DataExternalizer
|
||||||
import com.intellij.util.io.KeyDescriptor
|
import com.intellij.util.io.KeyDescriptor
|
||||||
import com.intellij.util.io.JpsPersistentHashMap
|
import com.intellij.util.io.PersistentHashMap
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
@@ -28,10 +28,10 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
private val valueExternalizer: DataExternalizer<V>
|
private val valueExternalizer: DataExternalizer<V>
|
||||||
) : LazyStorage<K, V> {
|
) : LazyStorage<K, V> {
|
||||||
@Volatile
|
@Volatile
|
||||||
private var storage: JpsPersistentHashMap<K, V>? = null
|
private var storage: PersistentHashMap<K, V>? = null
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun getStorageIfExists(): JpsPersistentHashMap<K, V>? {
|
private fun getStorageIfExists(): PersistentHashMap<K, V>? {
|
||||||
if (storage != null) return storage
|
if (storage != null) return storage
|
||||||
|
|
||||||
if (storageFile.exists()) {
|
if (storageFile.exists()) {
|
||||||
@@ -43,7 +43,7 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun getStorageOrCreateNew(): JpsPersistentHashMap<K, V> {
|
private fun getStorageOrCreateNew(): PersistentHashMap<K, V> {
|
||||||
if (storage == null) {
|
if (storage == null) {
|
||||||
storage = createMap()
|
storage = createMap()
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun append(key: K, value: V) {
|
override fun append(key: K, value: V) {
|
||||||
getStorageOrCreateNew().appendDataWithoutCache(key, value)
|
getStorageOrCreateNew().appendData(key) { dataOutput -> valueExternalizer.save(dataOutput, value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@@ -79,7 +79,7 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
} catch (ignored: Throwable) {
|
} catch (ignored: Throwable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
JpsPersistentHashMap.deleteFilesStartingWith(storageFile)
|
PersistentHashMap.deleteFilesStartingWith(storageFile)
|
||||||
storage = null
|
storage = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +101,6 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
storage?.close()
|
storage?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createMap(): JpsPersistentHashMap<K, V> =
|
private fun createMap(): PersistentHashMap<K, V> =
|
||||||
JpsPersistentHashMap(storageFile, keyDescriptor, valueExternalizer)
|
PersistentHashMap(storageFile, keyDescriptor, valueExternalizer)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.incremental.storage
|
|||||||
|
|
||||||
import com.intellij.util.io.DataExternalizer
|
import com.intellij.util.io.DataExternalizer
|
||||||
import com.intellij.util.io.KeyDescriptor
|
import com.intellij.util.io.KeyDescriptor
|
||||||
import com.intellij.util.io.PersistentHashMap
|
import com.intellij.util.io.JpsPersistentHashMap
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
@@ -28,10 +28,10 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
private val valueExternalizer: DataExternalizer<V>
|
private val valueExternalizer: DataExternalizer<V>
|
||||||
) : LazyStorage<K, V> {
|
) : LazyStorage<K, V> {
|
||||||
@Volatile
|
@Volatile
|
||||||
private var storage: PersistentHashMap<K, V>? = null
|
private var storage: JpsPersistentHashMap<K, V>? = null
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun getStorageIfExists(): PersistentHashMap<K, V>? {
|
private fun getStorageIfExists(): JpsPersistentHashMap<K, V>? {
|
||||||
if (storage != null) return storage
|
if (storage != null) return storage
|
||||||
|
|
||||||
if (storageFile.exists()) {
|
if (storageFile.exists()) {
|
||||||
@@ -43,7 +43,7 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun getStorageOrCreateNew(): PersistentHashMap<K, V> {
|
private fun getStorageOrCreateNew(): JpsPersistentHashMap<K, V> {
|
||||||
if (storage == null) {
|
if (storage == null) {
|
||||||
storage = createMap()
|
storage = createMap()
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun append(key: K, value: V) {
|
override fun append(key: K, value: V) {
|
||||||
getStorageOrCreateNew().appendData(key) { dataOutput -> valueExternalizer.save(dataOutput, value) }
|
getStorageOrCreateNew().appendDataWithoutCache(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@@ -79,7 +79,7 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
} catch (ignored: Throwable) {
|
} catch (ignored: Throwable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistentHashMap.deleteFilesStartingWith(storageFile)
|
JpsPersistentHashMap.deleteFilesStartingWith(storageFile)
|
||||||
storage = null
|
storage = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +101,6 @@ class NonCachingLazyStorage<K, V>(
|
|||||||
storage?.close()
|
storage?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createMap(): PersistentHashMap<K, V> =
|
private fun createMap(): JpsPersistentHashMap<K, V> =
|
||||||
PersistentHashMap(storageFile, keyDescriptor, valueExternalizer)
|
JpsPersistentHashMap(storageFile, keyDescriptor, valueExternalizer)
|
||||||
}
|
}
|
||||||
+28
-123
@@ -4,147 +4,52 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.kotlin.cli.jvm.compiler;
|
package org.jetbrains.kotlin.cli.jvm.compiler;
|
||||||
|
|
||||||
|
import com.intellij.DynamicBundle;
|
||||||
import com.intellij.codeInsight.ContainerProvider;
|
import com.intellij.codeInsight.ContainerProvider;
|
||||||
import com.intellij.codeInsight.JavaContainerProvider;
|
|
||||||
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
|
|
||||||
import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsBase;
|
|
||||||
import com.intellij.codeInsight.folding.impl.JavaFoldingBuilderBase;
|
|
||||||
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
|
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
|
||||||
import com.intellij.core.CoreApplicationEnvironment;
|
import com.intellij.core.JavaCoreApplicationEnvironment;
|
||||||
import com.intellij.core.CoreJavaDirectoryService;
|
|
||||||
import com.intellij.core.CorePsiPackageImplementationHelper;
|
|
||||||
import com.intellij.ide.highlighter.ArchiveFileType;
|
|
||||||
import com.intellij.ide.highlighter.JavaClassFileType;
|
|
||||||
import com.intellij.ide.highlighter.JavaFileType;
|
|
||||||
import com.intellij.lang.LanguageASTFactory;
|
|
||||||
import com.intellij.lang.MetaLanguage;
|
import com.intellij.lang.MetaLanguage;
|
||||||
import com.intellij.lang.folding.LanguageFolding;
|
|
||||||
import com.intellij.lang.java.JavaLanguage;
|
|
||||||
import com.intellij.lang.java.JavaParserDefinition;
|
|
||||||
import com.intellij.navigation.ItemPresentationProviders;
|
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.extensions.Extensions;
|
import com.intellij.openapi.extensions.Extensions;
|
||||||
import com.intellij.openapi.extensions.ExtensionsArea;
|
|
||||||
import com.intellij.openapi.fileTypes.FileTypeExtensionPoint;
|
|
||||||
import com.intellij.openapi.fileTypes.PlainTextFileType;
|
|
||||||
import com.intellij.openapi.fileTypes.PlainTextLanguage;
|
|
||||||
import com.intellij.openapi.fileTypes.PlainTextParserDefinition;
|
|
||||||
import com.intellij.openapi.projectRoots.JavaVersionService;
|
|
||||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||||
import com.intellij.psi.*;
|
import com.intellij.psi.FileContextProvider;
|
||||||
import com.intellij.psi.augment.PsiAugmentProvider;
|
import com.intellij.psi.augment.PsiAugmentProvider;
|
||||||
import com.intellij.psi.augment.TypeAnnotationModifier;
|
|
||||||
import com.intellij.psi.compiled.ClassFileDecompilers;
|
import com.intellij.psi.compiled.ClassFileDecompilers;
|
||||||
import com.intellij.psi.impl.LanguageConstantExpressionEvaluator;
|
|
||||||
import com.intellij.psi.impl.PsiExpressionEvaluator;
|
|
||||||
import com.intellij.psi.impl.PsiSubstitutorFactoryImpl;
|
|
||||||
import com.intellij.psi.impl.compiled.ClassFileStubBuilder;
|
|
||||||
import com.intellij.psi.impl.file.PsiPackageImplementationHelper;
|
|
||||||
import com.intellij.psi.impl.search.MethodSuperSearcher;
|
|
||||||
import com.intellij.psi.impl.source.tree.JavaASTFactory;
|
|
||||||
import com.intellij.psi.impl.source.tree.PlainTextASTFactory;
|
|
||||||
import com.intellij.psi.meta.MetaDataContributor;
|
import com.intellij.psi.meta.MetaDataContributor;
|
||||||
import com.intellij.psi.presentation.java.*;
|
|
||||||
import com.intellij.psi.search.searches.SuperMethodsSearch;
|
|
||||||
import com.intellij.psi.stubs.BinaryFileStubBuilders;
|
|
||||||
import com.intellij.util.QueryExecutor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
|
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
|
||||||
|
|
||||||
/**
|
public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment {
|
||||||
* adapted from com.intellij.core.JavaCoreApplicationEnvironment
|
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||||
* TODO: initiate removal original from com.intellij.core since it seems that there are no usages left
|
KotlinCoreApplicationEnvironment environment = new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
|
||||||
*/
|
registerExtensionPoints();
|
||||||
public class KotlinCoreApplicationEnvironment extends CoreApplicationEnvironment {
|
return environment;
|
||||||
|
}
|
||||||
|
|
||||||
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||||
return new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
|
super(parentDisposable, unitTestMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
private static void registerExtensionPoints() {
|
||||||
super(parentDisposable, unitTestMode);
|
registerApplicationExtensionPoint(DynamicBundle.LanguageBundleEP.EP_NAME, DynamicBundle.LanguageBundleEP.class);
|
||||||
|
registerApplicationExtensionPoint(FileContextProvider.EP_NAME, FileContextProvider.class);
|
||||||
|
|
||||||
registerExtensionPoints();
|
registerApplicationExtensionPoint(MetaDataContributor.EP_NAME, MetaDataContributor.class);
|
||||||
|
registerApplicationExtensionPoint(PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
|
||||||
|
registerApplicationExtensionPoint(JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
|
||||||
|
|
||||||
registerExtensions();
|
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
|
||||||
}
|
registerApplicationExtensionPoint(ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
|
||||||
|
|
||||||
private void registerExtensionPoints() {
|
registerApplicationExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class);
|
||||||
ExtensionsArea area = Extensions.getRootArea();
|
|
||||||
|
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(area, BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
|
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(Extensions.getRootArea());
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(area, FileContextProvider.EP_NAME, FileContextProvider.class);
|
}
|
||||||
|
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(area, MetaDataContributor.EP_NAME, MetaDataContributor.class);
|
@Nullable
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(area, PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
|
@Override
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(area, JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
|
protected VirtualFileSystem createJrtFileSystem() {
|
||||||
|
return new CoreJrtFileSystem();
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(area, ContainerProvider.EP_NAME, ContainerProvider.class);
|
}
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(area, ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
|
|
||||||
|
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(area, TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier.class);
|
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(area, MetaLanguage.EP_NAME, MetaLanguage.class);
|
|
||||||
|
|
||||||
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(area);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerExtensions() {
|
|
||||||
registerFileType(JavaClassFileType.INSTANCE, "class");
|
|
||||||
registerFileType(JavaFileType.INSTANCE, "java");
|
|
||||||
registerFileType(ArchiveFileType.INSTANCE, "jar;zip");
|
|
||||||
registerFileType(PlainTextFileType.INSTANCE, "txt;sh;bat;cmd;policy;log;cgi;MF;jad;jam;htaccess");
|
|
||||||
|
|
||||||
addExplicitExtension(LanguageASTFactory.INSTANCE, PlainTextLanguage.INSTANCE, new PlainTextASTFactory());
|
|
||||||
registerParserDefinition(new PlainTextParserDefinition());
|
|
||||||
|
|
||||||
addExplicitExtension(FileTypeFileViewProviders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileViewProviderFactory());
|
|
||||||
addExplicitExtension(BinaryFileStubBuilders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileStubBuilder());
|
|
||||||
|
|
||||||
addExplicitExtension(LanguageASTFactory.INSTANCE, JavaLanguage.INSTANCE, new JavaASTFactory());
|
|
||||||
registerParserDefinition(new JavaParserDefinition());
|
|
||||||
addExplicitExtension(LanguageConstantExpressionEvaluator.INSTANCE, JavaLanguage.INSTANCE, new PsiExpressionEvaluator());
|
|
||||||
|
|
||||||
addExtension(ContainerProvider.EP_NAME, new JavaContainerProvider());
|
|
||||||
|
|
||||||
myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());
|
|
||||||
myApplication.registerService(PsiSubstitutorFactory.class, new PsiSubstitutorFactoryImpl());
|
|
||||||
|
|
||||||
myApplication.registerService(JavaDirectoryService.class, createJavaDirectoryService());
|
|
||||||
myApplication.registerService(JavaVersionService.class, new JavaVersionService());
|
|
||||||
|
|
||||||
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiPackage.class, new PackagePresentationProvider());
|
|
||||||
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiClass.class, new ClassPresentationProvider());
|
|
||||||
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiMethod.class, new MethodPresentationProvider());
|
|
||||||
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiField.class, new FieldPresentationProvider());
|
|
||||||
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiLocalVariable.class, new VariablePresentationProvider());
|
|
||||||
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiParameter.class, new VariablePresentationProvider());
|
|
||||||
|
|
||||||
registerApplicationService(JavaCodeFoldingSettings.class, new JavaCodeFoldingSettingsBase());
|
|
||||||
addExplicitExtension(LanguageFolding.INSTANCE, JavaLanguage.INSTANCE, new JavaFoldingBuilderBase() {
|
|
||||||
@Override
|
|
||||||
protected boolean shouldShowExplicitLambdaType(@NotNull PsiAnonymousClass anonymousClass, @NotNull PsiNewExpression expression) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isBelowRightMargin(@NotNull PsiFile file, int lineLength) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerApplicationExtensionPoint(SuperMethodsSearch.EP_NAME, QueryExecutor.class);
|
|
||||||
addExtension(SuperMethodsSearch.EP_NAME, new MethodSuperSearcher());
|
|
||||||
}
|
|
||||||
|
|
||||||
// overridden in upsource
|
|
||||||
protected CoreJavaDirectoryService createJavaDirectoryService() {
|
|
||||||
return new CoreJavaDirectoryService();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
protected VirtualFileSystem createJrtFileSystem() {
|
|
||||||
return new CoreJrtFileSystem();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+150
@@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
package org.jetbrains.kotlin.cli.jvm.compiler;
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.ContainerProvider;
|
||||||
|
import com.intellij.codeInsight.JavaContainerProvider;
|
||||||
|
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
|
||||||
|
import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsBase;
|
||||||
|
import com.intellij.codeInsight.folding.impl.JavaFoldingBuilderBase;
|
||||||
|
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
|
||||||
|
import com.intellij.core.CoreApplicationEnvironment;
|
||||||
|
import com.intellij.core.CoreJavaDirectoryService;
|
||||||
|
import com.intellij.core.CorePsiPackageImplementationHelper;
|
||||||
|
import com.intellij.ide.highlighter.ArchiveFileType;
|
||||||
|
import com.intellij.ide.highlighter.JavaClassFileType;
|
||||||
|
import com.intellij.ide.highlighter.JavaFileType;
|
||||||
|
import com.intellij.lang.LanguageASTFactory;
|
||||||
|
import com.intellij.lang.MetaLanguage;
|
||||||
|
import com.intellij.lang.folding.LanguageFolding;
|
||||||
|
import com.intellij.lang.java.JavaLanguage;
|
||||||
|
import com.intellij.lang.java.JavaParserDefinition;
|
||||||
|
import com.intellij.navigation.ItemPresentationProviders;
|
||||||
|
import com.intellij.openapi.Disposable;
|
||||||
|
import com.intellij.openapi.extensions.Extensions;
|
||||||
|
import com.intellij.openapi.extensions.ExtensionsArea;
|
||||||
|
import com.intellij.openapi.fileTypes.FileTypeExtensionPoint;
|
||||||
|
import com.intellij.openapi.fileTypes.PlainTextFileType;
|
||||||
|
import com.intellij.openapi.fileTypes.PlainTextLanguage;
|
||||||
|
import com.intellij.openapi.fileTypes.PlainTextParserDefinition;
|
||||||
|
import com.intellij.openapi.projectRoots.JavaVersionService;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||||
|
import com.intellij.psi.*;
|
||||||
|
import com.intellij.psi.augment.PsiAugmentProvider;
|
||||||
|
import com.intellij.psi.augment.TypeAnnotationModifier;
|
||||||
|
import com.intellij.psi.compiled.ClassFileDecompilers;
|
||||||
|
import com.intellij.psi.impl.LanguageConstantExpressionEvaluator;
|
||||||
|
import com.intellij.psi.impl.PsiExpressionEvaluator;
|
||||||
|
import com.intellij.psi.impl.PsiSubstitutorFactoryImpl;
|
||||||
|
import com.intellij.psi.impl.compiled.ClassFileStubBuilder;
|
||||||
|
import com.intellij.psi.impl.file.PsiPackageImplementationHelper;
|
||||||
|
import com.intellij.psi.impl.search.MethodSuperSearcher;
|
||||||
|
import com.intellij.psi.impl.source.tree.JavaASTFactory;
|
||||||
|
import com.intellij.psi.impl.source.tree.PlainTextASTFactory;
|
||||||
|
import com.intellij.psi.meta.MetaDataContributor;
|
||||||
|
import com.intellij.psi.presentation.java.*;
|
||||||
|
import com.intellij.psi.search.searches.SuperMethodsSearch;
|
||||||
|
import com.intellij.psi.stubs.BinaryFileStubBuilders;
|
||||||
|
import com.intellij.util.QueryExecutor;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adapted from com.intellij.core.JavaCoreApplicationEnvironment
|
||||||
|
* TODO: initiate removal original from com.intellij.core since it seems that there are no usages left
|
||||||
|
*/
|
||||||
|
public class KotlinCoreApplicationEnvironment extends CoreApplicationEnvironment {
|
||||||
|
|
||||||
|
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||||
|
return new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||||
|
super(parentDisposable, unitTestMode);
|
||||||
|
|
||||||
|
registerExtensionPoints();
|
||||||
|
|
||||||
|
registerExtensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerExtensionPoints() {
|
||||||
|
ExtensionsArea area = Extensions.getRootArea();
|
||||||
|
|
||||||
|
CoreApplicationEnvironment.registerExtensionPoint(area, BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
|
||||||
|
CoreApplicationEnvironment.registerExtensionPoint(area, FileContextProvider.EP_NAME, FileContextProvider.class);
|
||||||
|
|
||||||
|
CoreApplicationEnvironment.registerExtensionPoint(area, MetaDataContributor.EP_NAME, MetaDataContributor.class);
|
||||||
|
CoreApplicationEnvironment.registerExtensionPoint(area, PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
|
||||||
|
CoreApplicationEnvironment.registerExtensionPoint(area, JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
|
||||||
|
|
||||||
|
CoreApplicationEnvironment.registerExtensionPoint(area, ContainerProvider.EP_NAME, ContainerProvider.class);
|
||||||
|
CoreApplicationEnvironment.registerExtensionPoint(area, ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
|
||||||
|
|
||||||
|
CoreApplicationEnvironment.registerExtensionPoint(area, TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier.class);
|
||||||
|
CoreApplicationEnvironment.registerExtensionPoint(area, MetaLanguage.EP_NAME, MetaLanguage.class);
|
||||||
|
|
||||||
|
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(area);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerExtensions() {
|
||||||
|
registerFileType(JavaClassFileType.INSTANCE, "class");
|
||||||
|
registerFileType(JavaFileType.INSTANCE, "java");
|
||||||
|
registerFileType(ArchiveFileType.INSTANCE, "jar;zip");
|
||||||
|
registerFileType(PlainTextFileType.INSTANCE, "txt;sh;bat;cmd;policy;log;cgi;MF;jad;jam;htaccess");
|
||||||
|
|
||||||
|
addExplicitExtension(LanguageASTFactory.INSTANCE, PlainTextLanguage.INSTANCE, new PlainTextASTFactory());
|
||||||
|
registerParserDefinition(new PlainTextParserDefinition());
|
||||||
|
|
||||||
|
addExplicitExtension(FileTypeFileViewProviders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileViewProviderFactory());
|
||||||
|
addExplicitExtension(BinaryFileStubBuilders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileStubBuilder());
|
||||||
|
|
||||||
|
addExplicitExtension(LanguageASTFactory.INSTANCE, JavaLanguage.INSTANCE, new JavaASTFactory());
|
||||||
|
registerParserDefinition(new JavaParserDefinition());
|
||||||
|
addExplicitExtension(LanguageConstantExpressionEvaluator.INSTANCE, JavaLanguage.INSTANCE, new PsiExpressionEvaluator());
|
||||||
|
|
||||||
|
addExtension(ContainerProvider.EP_NAME, new JavaContainerProvider());
|
||||||
|
|
||||||
|
myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());
|
||||||
|
myApplication.registerService(PsiSubstitutorFactory.class, new PsiSubstitutorFactoryImpl());
|
||||||
|
|
||||||
|
myApplication.registerService(JavaDirectoryService.class, createJavaDirectoryService());
|
||||||
|
myApplication.registerService(JavaVersionService.class, new JavaVersionService());
|
||||||
|
|
||||||
|
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiPackage.class, new PackagePresentationProvider());
|
||||||
|
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiClass.class, new ClassPresentationProvider());
|
||||||
|
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiMethod.class, new MethodPresentationProvider());
|
||||||
|
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiField.class, new FieldPresentationProvider());
|
||||||
|
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiLocalVariable.class, new VariablePresentationProvider());
|
||||||
|
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiParameter.class, new VariablePresentationProvider());
|
||||||
|
|
||||||
|
registerApplicationService(JavaCodeFoldingSettings.class, new JavaCodeFoldingSettingsBase());
|
||||||
|
addExplicitExtension(LanguageFolding.INSTANCE, JavaLanguage.INSTANCE, new JavaFoldingBuilderBase() {
|
||||||
|
@Override
|
||||||
|
protected boolean shouldShowExplicitLambdaType(@NotNull PsiAnonymousClass anonymousClass, @NotNull PsiNewExpression expression) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isBelowRightMargin(@NotNull PsiFile file, int lineLength) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
registerApplicationExtensionPoint(SuperMethodsSearch.EP_NAME, QueryExecutor.class);
|
||||||
|
addExtension(SuperMethodsSearch.EP_NAME, new MethodSuperSearcher());
|
||||||
|
}
|
||||||
|
|
||||||
|
// overridden in upsource
|
||||||
|
protected CoreJavaDirectoryService createJavaDirectoryService() {
|
||||||
|
return new CoreJavaDirectoryService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
protected VirtualFileSystem createJrtFileSystem() {
|
||||||
|
return new CoreJrtFileSystem();
|
||||||
|
}
|
||||||
|
}
|
||||||
-55
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
package org.jetbrains.kotlin.cli.jvm.compiler;
|
|
||||||
|
|
||||||
import com.intellij.DynamicBundle;
|
|
||||||
import com.intellij.codeInsight.ContainerProvider;
|
|
||||||
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
|
|
||||||
import com.intellij.core.JavaCoreApplicationEnvironment;
|
|
||||||
import com.intellij.lang.MetaLanguage;
|
|
||||||
import com.intellij.openapi.Disposable;
|
|
||||||
import com.intellij.openapi.extensions.Extensions;
|
|
||||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
|
||||||
import com.intellij.psi.FileContextProvider;
|
|
||||||
import com.intellij.psi.augment.PsiAugmentProvider;
|
|
||||||
import com.intellij.psi.compiled.ClassFileDecompilers;
|
|
||||||
import com.intellij.psi.meta.MetaDataContributor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
|
|
||||||
|
|
||||||
public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment {
|
|
||||||
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
|
||||||
KotlinCoreApplicationEnvironment environment = new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
|
|
||||||
registerExtensionPoints();
|
|
||||||
return environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
|
||||||
super(parentDisposable, unitTestMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void registerExtensionPoints() {
|
|
||||||
registerApplicationExtensionPoint(DynamicBundle.LanguageBundleEP.EP_NAME, DynamicBundle.LanguageBundleEP.class);
|
|
||||||
registerApplicationExtensionPoint(FileContextProvider.EP_NAME, FileContextProvider.class);
|
|
||||||
|
|
||||||
registerApplicationExtensionPoint(MetaDataContributor.EP_NAME, MetaDataContributor.class);
|
|
||||||
registerApplicationExtensionPoint(PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
|
|
||||||
registerApplicationExtensionPoint(JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
|
|
||||||
|
|
||||||
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
|
|
||||||
registerApplicationExtensionPoint(ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
|
|
||||||
|
|
||||||
registerApplicationExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class);
|
|
||||||
|
|
||||||
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(Extensions.getRootArea());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
protected VirtualFileSystem createJrtFileSystem() {
|
|
||||||
return new CoreJrtFileSystem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
@@ -22,6 +22,7 @@ import com.intellij.psi.*
|
|||||||
|
|
||||||
class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
|
class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
|
||||||
override fun chooseAnnotationsPlace(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
|
override fun chooseAnnotationsPlace(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
|
||||||
|
override fun chooseAnnotationsPlaceNoUi(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
|
||||||
|
|
||||||
override fun isExternalAnnotationWritable(listOwner: PsiModifierListOwner, annotationFQN: String): Boolean = false
|
override fun isExternalAnnotationWritable(listOwner: PsiModifierListOwner, annotationFQN: String): Boolean = false
|
||||||
override fun isExternalAnnotation(annotation: PsiAnnotation): Boolean = false
|
override fun isExternalAnnotation(annotation: PsiAnnotation): Boolean = false
|
||||||
|
|||||||
-1
@@ -22,7 +22,6 @@ import com.intellij.psi.*
|
|||||||
|
|
||||||
class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
|
class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
|
||||||
override fun chooseAnnotationsPlace(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
|
override fun chooseAnnotationsPlace(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
|
||||||
override fun chooseAnnotationsPlaceNoUi(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
|
|
||||||
|
|
||||||
override fun isExternalAnnotationWritable(listOwner: PsiModifierListOwner, annotationFQN: String): Boolean = false
|
override fun isExternalAnnotationWritable(listOwner: PsiModifierListOwner, annotationFQN: String): Boolean = false
|
||||||
override fun isExternalAnnotation(annotation: PsiAnnotation): Boolean = false
|
override fun isExternalAnnotation(annotation: PsiAnnotation): Boolean = false
|
||||||
@@ -6,4 +6,10 @@
|
|||||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||||
|
|
||||||
fun setupIdeaStandaloneExecution() {
|
fun setupIdeaStandaloneExecution() {
|
||||||
|
System.getProperties().setProperty("idea.plugins.compatible.build", "201.6668.13")
|
||||||
|
System.getProperties().setProperty("project.structure.add.tools.jar.to.new.jdk", "false")
|
||||||
|
System.getProperties().setProperty("psi.track.invalidation", "true")
|
||||||
|
System.getProperties().setProperty("psi.incremental.reparse.depth.limit", "1000")
|
||||||
|
System.getProperties().setProperty("ide.hide.excluded.files", "false")
|
||||||
|
System.getProperties().setProperty("ast.loading.filter", "false")
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||||
|
|
||||||
|
fun setupIdeaStandaloneExecution() {
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
|
||||||
|
|
||||||
fun setupIdeaStandaloneExecution() {
|
|
||||||
System.getProperties().setProperty("idea.plugins.compatible.build", "201.6668.13")
|
|
||||||
System.getProperties().setProperty("project.structure.add.tools.jar.to.new.jdk", "false")
|
|
||||||
System.getProperties().setProperty("psi.track.invalidation", "true")
|
|
||||||
System.getProperties().setProperty("psi.incremental.reparse.depth.limit", "1000")
|
|
||||||
System.getProperties().setProperty("ide.hide.excluded.files", "false")
|
|
||||||
System.getProperties().setProperty("ast.loading.filter", "false")
|
|
||||||
}
|
|
||||||
+3
-1
@@ -8,9 +8,11 @@ package org.jetbrains.kotlin.cli.jvm.compiler
|
|||||||
import com.intellij.core.CoreApplicationEnvironment
|
import com.intellij.core.CoreApplicationEnvironment
|
||||||
import com.intellij.openapi.extensions.ExtensionsArea
|
import com.intellij.openapi.extensions.ExtensionsArea
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.nio.file.FileSystems
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun registerExtensionPointAndExtensionsEx(pluginFile: File, fileName: String, area: ExtensionsArea) {
|
fun registerExtensionPointAndExtensionsEx(pluginFile: File, fileName: String, area: ExtensionsArea) {
|
||||||
|
val pluginRoot = FileSystems.getDefault().getPath(pluginFile.path)
|
||||||
@Suppress("MissingRecentApi")
|
@Suppress("MissingRecentApi")
|
||||||
CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginFile, fileName, area)
|
CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginRoot, fileName, area)
|
||||||
}
|
}
|
||||||
+1
-3
@@ -8,11 +8,9 @@ package org.jetbrains.kotlin.cli.jvm.compiler
|
|||||||
import com.intellij.core.CoreApplicationEnvironment
|
import com.intellij.core.CoreApplicationEnvironment
|
||||||
import com.intellij.openapi.extensions.ExtensionsArea
|
import com.intellij.openapi.extensions.ExtensionsArea
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.FileSystems
|
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun registerExtensionPointAndExtensionsEx(pluginFile: File, fileName: String, area: ExtensionsArea) {
|
fun registerExtensionPointAndExtensionsEx(pluginFile: File, fileName: String, area: ExtensionsArea) {
|
||||||
val pluginRoot = FileSystems.getDefault().getPath(pluginFile.path)
|
|
||||||
@Suppress("MissingRecentApi")
|
@Suppress("MissingRecentApi")
|
||||||
CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginRoot, fileName, area)
|
CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginFile, fileName, area)
|
||||||
}
|
}
|
||||||
+276
-65
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.test.testFramework;
|
package org.jetbrains.kotlin.test.testFramework;
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.CodeInsightSettings;
|
||||||
|
import com.intellij.concurrency.IdeaForkJoinWorkerThreadFactory;
|
||||||
import com.intellij.diagnostic.PerformanceWatcher;
|
import com.intellij.diagnostic.PerformanceWatcher;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.application.Application;
|
import com.intellij.openapi.application.Application;
|
||||||
@@ -23,20 +25,33 @@ import com.intellij.openapi.application.ApplicationManager;
|
|||||||
import com.intellij.openapi.application.PathManager;
|
import com.intellij.openapi.application.PathManager;
|
||||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
|
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.util.Comparing;
|
import com.intellij.openapi.util.Comparing;
|
||||||
import com.intellij.openapi.util.Disposer;
|
import com.intellij.openapi.util.Disposer;
|
||||||
|
import com.intellij.openapi.util.IconLoader;
|
||||||
import com.intellij.openapi.util.JDOMUtil;
|
import com.intellij.openapi.util.JDOMUtil;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.openapi.vfs.*;
|
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||||
|
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFileVisitor;
|
||||||
|
import com.intellij.psi.PsiDocumentManager;
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||||
|
import com.intellij.psi.impl.DocumentCommitProcessor;
|
||||||
|
import com.intellij.psi.impl.DocumentCommitThread;
|
||||||
|
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||||
import com.intellij.rt.execution.junit.FileComparisonFailure;
|
import com.intellij.rt.execution.junit.FileComparisonFailure;
|
||||||
import com.intellij.testFramework.*;
|
import com.intellij.testFramework.*;
|
||||||
import com.intellij.testFramework.exceptionCases.AbstractExceptionCase;
|
import com.intellij.testFramework.exceptionCases.AbstractExceptionCase;
|
||||||
import com.intellij.util.Consumer;
|
import com.intellij.testFramework.fixtures.IdeaTestExecutionPolicy;
|
||||||
import com.intellij.util.ReflectionUtil;
|
import com.intellij.util.*;
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
import com.intellij.util.containers.hash.HashMap;
|
import com.intellij.util.containers.PeekableIterator;
|
||||||
|
import com.intellij.util.containers.PeekableIteratorWrapper;
|
||||||
|
import com.intellij.util.indexing.FileBasedIndex;
|
||||||
|
import com.intellij.util.indexing.FileBasedIndexImpl;
|
||||||
import com.intellij.util.lang.CompoundRuntimeException;
|
import com.intellij.util.lang.CompoundRuntimeException;
|
||||||
import com.intellij.util.ui.UIUtil;
|
import com.intellij.util.ui.UIUtil;
|
||||||
import gnu.trove.Equality;
|
import gnu.trove.Equality;
|
||||||
@@ -47,11 +62,11 @@ import org.jdom.Element;
|
|||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.test.IdeaSystemPropertiesForParallelRunConfigurator;
|
|
||||||
import org.jetbrains.kotlin.testFramework.MockComponentManagerCreationTracer;
|
import org.jetbrains.kotlin.testFramework.MockComponentManagerCreationTracer;
|
||||||
import org.jetbrains.kotlin.types.AbstractTypeChecker;
|
import org.jetbrains.kotlin.types.AbstractTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypeImpl;
|
import org.jetbrains.kotlin.types.FlexibleTypeImpl;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.ComparisonFailure;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -61,14 +76,16 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
@SuppressWarnings("ALL")
|
||||||
public abstract class KtUsefulTestCase extends TestCase {
|
public abstract class KtUsefulTestCase extends TestCase {
|
||||||
public static final boolean IS_UNDER_TEAMCITY = System.getenv("TEAMCITY_VERSION") != null;
|
public static final boolean IS_UNDER_TEAMCITY = System.getenv("TEAMCITY_VERSION") != null;
|
||||||
private static final String TEMP_DIR_MARKER = "unitTest_";
|
public static final String TEMP_DIR_MARKER = "unitTest_";
|
||||||
public static final boolean OVERWRITE_TESTDATA = Boolean.getBoolean("idea.tests.overwrite.data");
|
public static final boolean OVERWRITE_TESTDATA = Boolean.getBoolean("idea.tests.overwrite.data");
|
||||||
|
|
||||||
private static final String ORIGINAL_TEMP_DIR = FileUtil.getTempDirectory();
|
private static final String ORIGINAL_TEMP_DIR = FileUtil.getTempDirectory();
|
||||||
@@ -79,24 +96,34 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
private Application application;
|
private Application application;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
IdeaSystemPropertiesForParallelRunConfigurator.setProperties();
|
IdeaForkJoinWorkerThreadFactory.setupPoisonFactory();
|
||||||
//TODO: investigate and enable
|
|
||||||
//IdeaForkJoinWorkerThreadFactory.setupPoisonFactory();
|
|
||||||
Logger.setFactory(TestLoggerFactory.class);
|
Logger.setFactory(TestLoggerFactory.class);
|
||||||
}
|
}
|
||||||
|
protected static final Logger LOG = Logger.getInstance(KtUsefulTestCase.class);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected final Disposable myTestRootDisposable = new TestDisposable();
|
private final Disposable myTestRootDisposable = new TestDisposable();
|
||||||
|
|
||||||
private static final String ourPathToKeep = null;
|
static Path ourPathToKeep;
|
||||||
private final List<String> myPathsToKeep = new ArrayList<>();
|
private final List<String> myPathsToKeep = new ArrayList<>();
|
||||||
|
|
||||||
private File myTempDir;
|
private String myTempDir;
|
||||||
|
|
||||||
|
private static final String DEFAULT_SETTINGS_EXTERNALIZED;
|
||||||
|
private static final CodeInsightSettings defaultSettings = new CodeInsightSettings();
|
||||||
static {
|
static {
|
||||||
// Radar #5755208: Command line Java applications need a way to launch without a Dock icon.
|
// Radar #5755208: Command line Java applications need a way to launch without a Dock icon.
|
||||||
System.setProperty("apple.awt.UIElement", "true");
|
System.setProperty("apple.awt.UIElement", "true");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Element oldS = new Element("temp");
|
||||||
|
defaultSettings.writeExternal(oldS);
|
||||||
|
DEFAULT_SETTINGS_EXTERNALIZED = JDOMUtil.writeElement(oldS);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
// -- KOTLIN ADDITIONAL START --
|
// -- KOTLIN ADDITIONAL START --
|
||||||
|
|
||||||
FlexibleTypeImpl.RUN_SLOW_ASSERTIONS = true;
|
FlexibleTypeImpl.RUN_SLOW_ASSERTIONS = true;
|
||||||
@@ -105,6 +132,42 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
// -- KOTLIN ADDITIONAL END --
|
// -- KOTLIN ADDITIONAL END --
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass here the exception you want to be thrown first
|
||||||
|
* E.g.<pre>
|
||||||
|
* {@code
|
||||||
|
* void tearDown() {
|
||||||
|
* try {
|
||||||
|
* doTearDowns();
|
||||||
|
* }
|
||||||
|
* catch(Exception e) {
|
||||||
|
* addSuppressedException(e);
|
||||||
|
* }
|
||||||
|
* finally {
|
||||||
|
* super.tearDown();
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected void addSuppressedException(@NotNull Throwable e) {
|
||||||
|
List<Throwable> list = mySuppressedExceptions;
|
||||||
|
if (list == null) {
|
||||||
|
mySuppressedExceptions = list = new SmartList<>();
|
||||||
|
}
|
||||||
|
list.add(e);
|
||||||
|
}
|
||||||
|
private List<Throwable> mySuppressedExceptions;
|
||||||
|
|
||||||
|
|
||||||
|
public KtUsefulTestCase() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public KtUsefulTestCase(@NotNull String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean shouldContainTempFiles() {
|
protected boolean shouldContainTempFiles() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -122,11 +185,17 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
if (shouldContainTempFiles()) {
|
if (shouldContainTempFiles()) {
|
||||||
String testName = FileUtil.sanitizeFileName(getTestName(true));
|
IdeaTestExecutionPolicy policy = IdeaTestExecutionPolicy.current();
|
||||||
if (StringUtil.isEmptyOrSpaces(testName)) testName = "";
|
String testName = null;
|
||||||
|
if (policy != null) {
|
||||||
|
testName = policy.getPerTestTempDirName();
|
||||||
|
}
|
||||||
|
if (testName == null) {
|
||||||
|
testName = FileUtil.sanitizeFileName(getTestName(true));
|
||||||
|
}
|
||||||
testName = new File(testName).getName(); // in case the test name contains file separators
|
testName = new File(testName).getName(); // in case the test name contains file separators
|
||||||
myTempDir = FileUtil.createTempDirectory(TEMP_DIR_MARKER, testName, false);
|
myTempDir = FileUtil.createTempDirectory(TEMP_DIR_MARKER + testName, "", false).getPath();
|
||||||
FileUtil.resetCanonicalTempPathCache(myTempDir.getPath());
|
FileUtil.resetCanonicalTempPathCache(myTempDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isStressTest = isStressTest();
|
boolean isStressTest = isStressTest();
|
||||||
@@ -137,6 +206,16 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
|
|
||||||
// turn off Disposer debugging for performance tests
|
// turn off Disposer debugging for performance tests
|
||||||
Disposer.setDebugMode(!isStressTest);
|
Disposer.setDebugMode(!isStressTest);
|
||||||
|
|
||||||
|
if (isIconRequired()) {
|
||||||
|
// ensure that IconLoader will use dummy empty icon
|
||||||
|
IconLoader.deactivate();
|
||||||
|
//IconManager.activate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isIconRequired() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -145,6 +224,11 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
// don't use method references here to make stack trace reading easier
|
// don't use method references here to make stack trace reading easier
|
||||||
//noinspection Convert2MethodRef
|
//noinspection Convert2MethodRef
|
||||||
new RunAll(
|
new RunAll(
|
||||||
|
() -> {
|
||||||
|
if (isIconRequired()) {
|
||||||
|
//IconManager.deactivate();
|
||||||
|
}
|
||||||
|
},
|
||||||
() -> disposeRootDisposable(),
|
() -> disposeRootDisposable(),
|
||||||
() -> cleanupSwingDataStructures(),
|
() -> cleanupSwingDataStructures(),
|
||||||
() -> cleanupDeleteOnExitHookList(),
|
() -> cleanupDeleteOnExitHookList(),
|
||||||
@@ -153,7 +237,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
if (shouldContainTempFiles()) {
|
if (shouldContainTempFiles()) {
|
||||||
FileUtil.resetCanonicalTempPathCache(ORIGINAL_TEMP_DIR);
|
FileUtil.resetCanonicalTempPathCache(ORIGINAL_TEMP_DIR);
|
||||||
if (hasTmpFilesToKeep()) {
|
if (hasTmpFilesToKeep()) {
|
||||||
File[] files = myTempDir.listFiles();
|
File[] files = new File(myTempDir).listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (!shouldKeepTmpFile(file)) {
|
if (!shouldKeepTmpFile(file)) {
|
||||||
@@ -163,15 +247,14 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FileUtil.delete(myTempDir);
|
FileUtil.delete(new File(myTempDir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() -> UIUtil.removeLeakingAppleListeners()
|
() -> waitForAppLeakingThreads(10, TimeUnit.SECONDS)
|
||||||
).run();
|
).run(ObjectUtils.notNull(mySuppressedExceptions, Collections.emptyList()));
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
super.tearDown();
|
|
||||||
// -- KOTLIN ADDITIONAL START --
|
// -- KOTLIN ADDITIONAL START --
|
||||||
TestApplicationUtilKt.resetApplicationToNull(application);
|
TestApplicationUtilKt.resetApplicationToNull(application);
|
||||||
application = null;
|
application = null;
|
||||||
@@ -188,12 +271,12 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasTmpFilesToKeep() {
|
private boolean hasTmpFilesToKeep() {
|
||||||
return ourPathToKeep != null && FileUtil.isAncestor(myTempDir.getPath(), ourPathToKeep, false) || !myPathsToKeep.isEmpty();
|
return ourPathToKeep != null && FileUtil.isAncestor(myTempDir, ourPathToKeep.toString(), false) || !myPathsToKeep.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldKeepTmpFile(@NotNull File file) {
|
private boolean shouldKeepTmpFile(@NotNull File file) {
|
||||||
String path = file.getPath();
|
String path = file.getPath();
|
||||||
if (FileUtil.pathsEqual(path, ourPathToKeep)) return true;
|
if (FileUtil.pathsEqual(path, ourPathToKeep.toString())) return true;
|
||||||
for (String pathToKeep : myPathsToKeep) {
|
for (String pathToKeep : myPathsToKeep) {
|
||||||
if (FileUtil.pathsEqual(path, pathToKeep)) return true;
|
if (FileUtil.pathsEqual(path, pathToKeep)) return true;
|
||||||
}
|
}
|
||||||
@@ -201,7 +284,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<String> DELETE_ON_EXIT_HOOK_DOT_FILES;
|
private static final Set<String> DELETE_ON_EXIT_HOOK_DOT_FILES;
|
||||||
private static final Class DELETE_ON_EXIT_HOOK_CLASS;
|
private static final Class<?> DELETE_ON_EXIT_HOOK_CLASS;
|
||||||
static {
|
static {
|
||||||
Class<?> aClass;
|
Class<?> aClass;
|
||||||
try {
|
try {
|
||||||
@@ -237,12 +320,45 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
private static void cleanupSwingDataStructures() throws Exception {
|
private static void cleanupSwingDataStructures() throws Exception {
|
||||||
Object manager = ReflectionUtil.getDeclaredMethod(Class.forName("javax.swing.KeyboardManager"), "getCurrentManager").invoke(null);
|
Object manager = ReflectionUtil.getDeclaredMethod(Class.forName("javax.swing.KeyboardManager"), "getCurrentManager").invoke(null);
|
||||||
Map componentKeyStrokeMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "componentKeyStrokeMap");
|
Map<?, ?> componentKeyStrokeMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "componentKeyStrokeMap");
|
||||||
componentKeyStrokeMap.clear();
|
componentKeyStrokeMap.clear();
|
||||||
Map containerMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "containerMap");
|
Map<?, ?> containerMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "containerMap");
|
||||||
containerMap.clear();
|
containerMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void doCheckForSettingsDamage(@NotNull CodeStyleSettings oldCodeStyleSettings, @NotNull CodeStyleSettings currentCodeStyleSettings) {
|
||||||
|
final CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||||
|
// don't use method references here to make stack trace reading easier
|
||||||
|
//noinspection Convert2MethodRef
|
||||||
|
new RunAll()
|
||||||
|
.append(() -> {
|
||||||
|
try {
|
||||||
|
checkCodeInsightSettingsEqual(defaultSettings, settings);
|
||||||
|
}
|
||||||
|
catch (AssertionError error) {
|
||||||
|
CodeInsightSettings clean = new CodeInsightSettings();
|
||||||
|
for (Field field : clean.getClass().getFields()) {
|
||||||
|
try {
|
||||||
|
ReflectionUtil.copyFieldValue(clean, settings, field);
|
||||||
|
}
|
||||||
|
catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.append(() -> {
|
||||||
|
currentCodeStyleSettings.getIndentOptions(StdFileTypes.JAVA);
|
||||||
|
try {
|
||||||
|
checkCodeStyleSettingsEqual(oldCodeStyleSettings, currentCodeStyleSettings);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
currentCodeStyleSettings.clearCodeStyleSettings();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Disposable getTestRootDisposable() {
|
public Disposable getTestRootDisposable() {
|
||||||
return myTestRootDisposable;
|
return myTestRootDisposable;
|
||||||
@@ -252,13 +368,11 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
protected void runTest() throws Throwable {
|
protected void runTest() throws Throwable {
|
||||||
final Throwable[] throwables = new Throwable[1];
|
final Throwable[] throwables = new Throwable[1];
|
||||||
|
|
||||||
AtomicBoolean completed = new AtomicBoolean(false);
|
|
||||||
Runnable runnable = () -> {
|
Runnable runnable = () -> {
|
||||||
try {
|
try {
|
||||||
//TestLoggerFactory.onTestStarted();
|
TestLoggerFactory.onTestStarted();
|
||||||
super.runTest();
|
super.runTest();
|
||||||
TestLoggerFactory.onTestFinished(true);
|
TestLoggerFactory.onTestFinished(true);
|
||||||
completed.set(true);
|
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException e) {
|
catch (InvocationTargetException e) {
|
||||||
TestLoggerFactory.onTestFinished(false);
|
TestLoggerFactory.onTestFinished(false);
|
||||||
@@ -281,9 +395,6 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
if (throwables[0] != null) {
|
if (throwables[0] != null) {
|
||||||
throw throwables[0];
|
throw throwables[0];
|
||||||
}
|
}
|
||||||
if (!completed.get()) {
|
|
||||||
throw new IllegalStateException("test didn't start");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldRunTest() {
|
protected boolean shouldRunTest() {
|
||||||
@@ -291,19 +402,18 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void invokeTestRunnable(@NotNull Runnable runnable) throws Exception {
|
protected void invokeTestRunnable(@NotNull Runnable runnable) throws Exception {
|
||||||
//IdeaTestExecutionPolicy policy = IdeaTestExecutionPolicy.current();
|
if (runInDispatchThread()) {
|
||||||
//if (policy != null && !policy.runInDispatchThread()) {
|
|
||||||
// runnable.run();
|
|
||||||
//}
|
|
||||||
//else {
|
|
||||||
EdtTestUtilKt.runInEdtAndWait(() -> {
|
EdtTestUtilKt.runInEdtAndWait(() -> {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
//}
|
}
|
||||||
|
else {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void defaultRunBare() throws Throwable {
|
protected void defaultRunBare() throws Throwable {
|
||||||
Throwable exception = null;
|
Throwable exception = null;
|
||||||
try {
|
try {
|
||||||
long setupStart = System.nanoTime();
|
long setupStart = System.nanoTime();
|
||||||
@@ -324,11 +434,17 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
logPerClassCost(teardownCost, TOTAL_TEARDOWN_COST_MILLIS);
|
logPerClassCost(teardownCost, TOTAL_TEARDOWN_COST_MILLIS);
|
||||||
}
|
}
|
||||||
catch (Throwable tearingDown) {
|
catch (Throwable tearingDown) {
|
||||||
if (exception == null) exception = tearingDown;
|
if (exception == null) {
|
||||||
else exception = new CompoundRuntimeException(Arrays.asList(exception, tearingDown));
|
exception = tearingDown;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
exception = new CompoundRuntimeException(Arrays.asList(exception, tearingDown));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exception != null) throw exception;
|
if (exception != null) {
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -368,7 +484,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
|
|
||||||
if (runInDispatchThread()) {
|
if (runInDispatchThread()) {
|
||||||
TestRunnerUtil.replaceIdeEventQueueSafely();
|
TestRunnerUtil.replaceIdeEventQueueSafely();
|
||||||
com.intellij.testFramework.EdtTestUtil.runInEdtAndWait(this::defaultRunBare);
|
EdtTestUtil.runInEdtAndWait(this::defaultRunBare);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
defaultRunBare();
|
defaultRunBare();
|
||||||
@@ -376,13 +492,20 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean runInDispatchThread() {
|
protected boolean runInDispatchThread() {
|
||||||
//IdeaTestExecutionPolicy policy = IdeaTestExecutionPolicy.current();
|
IdeaTestExecutionPolicy policy = IdeaTestExecutionPolicy.current();
|
||||||
//if (policy != null) {
|
if (policy != null) {
|
||||||
// return policy.runInDispatchThread();
|
return policy.runInDispatchThread();
|
||||||
//}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If you want a more shorter name than runInEdtAndWait.
|
||||||
|
*/
|
||||||
|
protected void edt(@NotNull ThrowableRunnable<Throwable> runnable) {
|
||||||
|
EdtTestUtil.runInEdtAndWait(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String toString(@NotNull Iterable<?> collection) {
|
public static String toString(@NotNull Iterable<?> collection) {
|
||||||
if (!collection.iterator().hasNext()) {
|
if (!collection.iterator().hasNext()) {
|
||||||
@@ -515,9 +638,20 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void assertContainsOrdered(@NotNull Collection<? extends T> collection, @NotNull Collection<? extends T> expected) {
|
public static <T> void assertContainsOrdered(@NotNull Collection<? extends T> collection, @NotNull Collection<? extends T> expected) {
|
||||||
ArrayList<T> copy = new ArrayList<>(collection);
|
PeekableIterator<T> expectedIt = new PeekableIteratorWrapper<>(expected.iterator());
|
||||||
copy.retainAll(expected);
|
PeekableIterator<T> actualIt = new PeekableIteratorWrapper<>(collection.iterator());
|
||||||
assertOrderedEquals(toString(collection), copy, expected);
|
|
||||||
|
while (actualIt.hasNext() && expectedIt.hasNext()) {
|
||||||
|
T expectedElem = expectedIt.peek();
|
||||||
|
T actualElem = actualIt.peek();
|
||||||
|
if (expectedElem.equals(actualElem)) {
|
||||||
|
expectedIt.next();
|
||||||
|
}
|
||||||
|
actualIt.next();
|
||||||
|
}
|
||||||
|
if (expectedIt.hasNext()) {
|
||||||
|
throw new ComparisonFailure("", toString(expected), toString(collection));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
@@ -592,7 +726,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
if (collection.size() != checkers.length) {
|
if (collection.size() != checkers.length) {
|
||||||
Assert.fail(toString(collection));
|
Assert.fail(toString(collection));
|
||||||
}
|
}
|
||||||
Set<Consumer<T>> checkerSet = new HashSet<>(Arrays.asList(checkers));
|
Set<Consumer<T>> checkerSet = ContainerUtil.set(checkers);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Throwable lastError = null;
|
Throwable lastError = null;
|
||||||
for (final T actual : collection) {
|
for (final T actual : collection) {
|
||||||
@@ -767,7 +901,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
//noinspection UseOfSystemOutOrSystemErr
|
//noinspection UseOfSystemOutOrSystemErr
|
||||||
System.out.println("File " + filePath + " created.");
|
System.out.println("File " + filePath + " created.");
|
||||||
}
|
}
|
||||||
fileText = FileUtil.loadFile(new File(filePath), CharsetToolkit.UTF8_CHARSET);
|
fileText = FileUtil.loadFile(new File(filePath), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e) {
|
catch (FileNotFoundException e) {
|
||||||
VfsTestUtil.overwriteTestData(filePath, actualText);
|
VfsTestUtil.overwriteTestData(filePath, actualText);
|
||||||
@@ -784,14 +918,14 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void clearFields(@NotNull Object test) throws IllegalAccessException {
|
protected static void clearFields(@NotNull Object test) throws IllegalAccessException {
|
||||||
Class aClass = test.getClass();
|
Class<?> aClass = test.getClass();
|
||||||
while (aClass != null) {
|
while (aClass != null) {
|
||||||
clearDeclaredFields(test, aClass);
|
clearDeclaredFields(test, aClass);
|
||||||
aClass = aClass.getSuperclass();
|
aClass = aClass.getSuperclass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearDeclaredFields(@NotNull Object test, @NotNull Class aClass) throws IllegalAccessException {
|
public static void clearDeclaredFields(@NotNull Object test, @NotNull Class<?> aClass) throws IllegalAccessException {
|
||||||
for (final Field field : aClass.getDeclaredFields()) {
|
for (final Field field : aClass.getDeclaredFields()) {
|
||||||
final String name = field.getDeclaringClass().getName();
|
final String name = field.getDeclaringClass().getName();
|
||||||
if (!name.startsWith("junit.framework.") && !name.startsWith("com.intellij.testFramework.")) {
|
if (!name.startsWith("junit.framework.") && !name.startsWith("com.intellij.testFramework.")) {
|
||||||
@@ -817,6 +951,14 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkCodeInsightSettingsEqual(@NotNull CodeInsightSettings oldSettings, @NotNull CodeInsightSettings settings) {
|
||||||
|
if (!oldSettings.equals(settings)) {
|
||||||
|
Element newS = new Element("temp");
|
||||||
|
settings.writeExternal(newS);
|
||||||
|
Assert.assertEquals("Code insight settings damaged", DEFAULT_SETTINGS_EXTERNALIZED, JDOMUtil.writeElement(newS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPerformanceTest() {
|
public boolean isPerformanceTest() {
|
||||||
String testName = getName();
|
String testName = getName();
|
||||||
String className = getClass().getSimpleName();
|
String className = getClass().getSimpleName();
|
||||||
@@ -843,6 +985,21 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
return name != null && (name.contains("Stress") || name.contains("Slow"));
|
return name != null && (name.contains("Stress") || name.contains("Slow"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void doPostponedFormatting(@NotNull Project project) {
|
||||||
|
DocumentUtil.writeInRunUndoTransparentAction(() -> {
|
||||||
|
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||||
|
PostprocessReformattingAspect.getInstance(project).doPostponedFormatting();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that code block throw corresponding exception.
|
||||||
|
*
|
||||||
|
* @param exceptionCase Block annotated with some exception type
|
||||||
|
*/
|
||||||
|
protected void assertException(@NotNull AbstractExceptionCase<?> exceptionCase) {
|
||||||
|
assertException(exceptionCase, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that code block throw corresponding exception with expected error msg.
|
* Checks that code block throw corresponding exception with expected error msg.
|
||||||
@@ -856,6 +1013,42 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
assertExceptionOccurred(true, exceptionCase, expectedErrorMsg);
|
assertExceptionOccurred(true, exceptionCase, expectedErrorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that the code block throws an exception of the specified class.
|
||||||
|
*
|
||||||
|
* @param exceptionClass Expected exception type
|
||||||
|
* @param runnable Block annotated with some exception type
|
||||||
|
*/
|
||||||
|
public static <T extends Throwable> void assertThrows(@NotNull Class<? extends Throwable> exceptionClass,
|
||||||
|
@NotNull ThrowableRunnable<T> runnable) {
|
||||||
|
assertThrows(exceptionClass, null, runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that the code block throws an exception of the specified class with expected error msg.
|
||||||
|
* If expected error message is null it will not be checked.
|
||||||
|
*
|
||||||
|
* @param exceptionClass Expected exception type
|
||||||
|
* @param expectedErrorMsgPart expected error message, of any
|
||||||
|
* @param runnable Block annotated with some exception type
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"unchecked", "SameParameterValue"})
|
||||||
|
public static <T extends Throwable> void assertThrows(@NotNull Class<? extends Throwable> exceptionClass,
|
||||||
|
@Nullable String expectedErrorMsgPart,
|
||||||
|
@NotNull ThrowableRunnable<T> runnable) {
|
||||||
|
assertExceptionOccurred(true, new AbstractExceptionCase() {
|
||||||
|
@Override
|
||||||
|
public Class<Throwable> getExpectedExceptionClass() {
|
||||||
|
return (Class<Throwable>)exceptionClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tryClosure() throws Throwable {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
}, expectedErrorMsgPart);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that code block doesn't throw corresponding exception.
|
* Checks that code block doesn't throw corresponding exception.
|
||||||
*
|
*
|
||||||
@@ -878,21 +1071,23 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
|
|
||||||
private static <T extends Throwable> void assertExceptionOccurred(boolean shouldOccur,
|
private static <T extends Throwable> void assertExceptionOccurred(boolean shouldOccur,
|
||||||
@NotNull AbstractExceptionCase<T> exceptionCase,
|
@NotNull AbstractExceptionCase<T> exceptionCase,
|
||||||
String expectedErrorMsg) throws T {
|
String expectedErrorMsgPart) throws T {
|
||||||
boolean wasThrown = false;
|
boolean wasThrown = false;
|
||||||
try {
|
try {
|
||||||
exceptionCase.tryClosure();
|
exceptionCase.tryClosure();
|
||||||
}
|
}
|
||||||
catch (Throwable e) {
|
catch (Throwable e) {
|
||||||
|
Throwable cause = e;
|
||||||
|
|
||||||
if (shouldOccur) {
|
if (shouldOccur) {
|
||||||
wasThrown = true;
|
wasThrown = true;
|
||||||
final String errorMessage = exceptionCase.getAssertionErrorMessage();
|
final String errorMessage = exceptionCase.getAssertionErrorMessage();
|
||||||
assertEquals(errorMessage, exceptionCase.getExpectedExceptionClass(), e.getClass());
|
assertEquals(errorMessage, exceptionCase.getExpectedExceptionClass(), cause.getClass());
|
||||||
if (expectedErrorMsg != null) {
|
if (expectedErrorMsgPart != null) {
|
||||||
assertEquals("Compare error messages", expectedErrorMsg, e.getMessage());
|
assertTrue(cause.getMessage(), cause.getMessage().contains(expectedErrorMsgPart));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (exceptionCase.getExpectedExceptionClass().equals(e.getClass())) {
|
else if (exceptionCase.getExpectedExceptionClass().equals(cause.getClass())) {
|
||||||
wasThrown = true;
|
wasThrown = true;
|
||||||
|
|
||||||
//noinspection UseOfSystemOutOrSystemErr
|
//noinspection UseOfSystemOutOrSystemErr
|
||||||
@@ -900,7 +1095,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
//noinspection UseOfSystemOutOrSystemErr
|
//noinspection UseOfSystemOutOrSystemErr
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace(System.out);
|
||||||
|
|
||||||
fail("Exception isn't expected here. Exception message: " + e.getMessage());
|
fail("Exception isn't expected here. Exception message: " + cause.getMessage());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -937,7 +1132,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void refreshRecursively(@NotNull VirtualFile file) {
|
public static void refreshRecursively(@NotNull VirtualFile file) {
|
||||||
VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor() {
|
VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean visitFile(@NotNull VirtualFile file) {
|
public boolean visitFile(@NotNull VirtualFile file) {
|
||||||
file.getChildren();
|
file.getChildren();
|
||||||
@@ -947,11 +1142,27 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
file.refresh(false, true);
|
file.refresh(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static VirtualFile refreshAndFindFile(@NotNull final File file) {
|
public static VirtualFile refreshAndFindFile(@NotNull final File file) {
|
||||||
return UIUtil.invokeAndWaitIfNeeded(() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file));
|
return UIUtil.invokeAndWaitIfNeeded(() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void waitForAppLeakingThreads(long timeout, @NotNull TimeUnit timeUnit) {
|
||||||
|
EdtTestUtil.runInEdtAndWait(() -> {
|
||||||
|
Application app = ApplicationManager.getApplication();
|
||||||
|
if (app != null && !app.isDisposed()) {
|
||||||
|
FileBasedIndexImpl index = (FileBasedIndexImpl)app.getServiceIfCreated(FileBasedIndex.class);
|
||||||
|
if (index != null) {
|
||||||
|
index.getChangedFilesCollector().waitForVfsEventsExecuted(timeout, timeUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
DocumentCommitThread commitThread = (DocumentCommitThread)app.getServiceIfCreated(DocumentCommitProcessor.class);
|
||||||
|
if (commitThread != null) {
|
||||||
|
commitThread.waitForAllCommits(timeout, timeUnit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected class TestDisposable implements Disposable {
|
protected class TestDisposable implements Disposable {
|
||||||
private volatile boolean myDisposed;
|
private volatile boolean myDisposed;
|
||||||
|
|
||||||
@@ -972,5 +1183,5 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
String testName = getTestName(false);
|
String testName = getTestName(false);
|
||||||
return KtUsefulTestCase.this.getClass() + (StringUtil.isEmpty(testName) ? "" : ".test" + testName);
|
return KtUsefulTestCase.this.getClass() + (StringUtil.isEmpty(testName) ? "" : ".test" + testName);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
+65
-276
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.test.testFramework;
|
package org.jetbrains.kotlin.test.testFramework;
|
||||||
|
|
||||||
import com.intellij.codeInsight.CodeInsightSettings;
|
|
||||||
import com.intellij.concurrency.IdeaForkJoinWorkerThreadFactory;
|
|
||||||
import com.intellij.diagnostic.PerformanceWatcher;
|
import com.intellij.diagnostic.PerformanceWatcher;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.application.Application;
|
import com.intellij.openapi.application.Application;
|
||||||
@@ -25,33 +23,20 @@ import com.intellij.openapi.application.ApplicationManager;
|
|||||||
import com.intellij.openapi.application.PathManager;
|
import com.intellij.openapi.application.PathManager;
|
||||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.openapi.util.Comparing;
|
import com.intellij.openapi.util.Comparing;
|
||||||
import com.intellij.openapi.util.Disposer;
|
import com.intellij.openapi.util.Disposer;
|
||||||
import com.intellij.openapi.util.IconLoader;
|
|
||||||
import com.intellij.openapi.util.JDOMUtil;
|
import com.intellij.openapi.util.JDOMUtil;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
import com.intellij.openapi.vfs.*;
|
||||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
|
||||||
import com.intellij.openapi.vfs.VirtualFileVisitor;
|
|
||||||
import com.intellij.psi.PsiDocumentManager;
|
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||||
import com.intellij.psi.impl.DocumentCommitProcessor;
|
|
||||||
import com.intellij.psi.impl.DocumentCommitThread;
|
|
||||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
|
||||||
import com.intellij.rt.execution.junit.FileComparisonFailure;
|
import com.intellij.rt.execution.junit.FileComparisonFailure;
|
||||||
import com.intellij.testFramework.*;
|
import com.intellij.testFramework.*;
|
||||||
import com.intellij.testFramework.exceptionCases.AbstractExceptionCase;
|
import com.intellij.testFramework.exceptionCases.AbstractExceptionCase;
|
||||||
import com.intellij.testFramework.fixtures.IdeaTestExecutionPolicy;
|
import com.intellij.util.Consumer;
|
||||||
import com.intellij.util.*;
|
import com.intellij.util.ReflectionUtil;
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
import com.intellij.util.containers.PeekableIterator;
|
import com.intellij.util.containers.hash.HashMap;
|
||||||
import com.intellij.util.containers.PeekableIteratorWrapper;
|
|
||||||
import com.intellij.util.indexing.FileBasedIndex;
|
|
||||||
import com.intellij.util.indexing.FileBasedIndexImpl;
|
|
||||||
import com.intellij.util.lang.CompoundRuntimeException;
|
import com.intellij.util.lang.CompoundRuntimeException;
|
||||||
import com.intellij.util.ui.UIUtil;
|
import com.intellij.util.ui.UIUtil;
|
||||||
import gnu.trove.Equality;
|
import gnu.trove.Equality;
|
||||||
@@ -62,11 +47,11 @@ import org.jdom.Element;
|
|||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.kotlin.test.IdeaSystemPropertiesForParallelRunConfigurator;
|
||||||
import org.jetbrains.kotlin.testFramework.MockComponentManagerCreationTracer;
|
import org.jetbrains.kotlin.testFramework.MockComponentManagerCreationTracer;
|
||||||
import org.jetbrains.kotlin.types.AbstractTypeChecker;
|
import org.jetbrains.kotlin.types.AbstractTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypeImpl;
|
import org.jetbrains.kotlin.types.FlexibleTypeImpl;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.ComparisonFailure;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -76,16 +61,14 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
||||||
public abstract class KtUsefulTestCase extends TestCase {
|
public abstract class KtUsefulTestCase extends TestCase {
|
||||||
public static final boolean IS_UNDER_TEAMCITY = System.getenv("TEAMCITY_VERSION") != null;
|
public static final boolean IS_UNDER_TEAMCITY = System.getenv("TEAMCITY_VERSION") != null;
|
||||||
public static final String TEMP_DIR_MARKER = "unitTest_";
|
private static final String TEMP_DIR_MARKER = "unitTest_";
|
||||||
public static final boolean OVERWRITE_TESTDATA = Boolean.getBoolean("idea.tests.overwrite.data");
|
public static final boolean OVERWRITE_TESTDATA = Boolean.getBoolean("idea.tests.overwrite.data");
|
||||||
|
|
||||||
private static final String ORIGINAL_TEMP_DIR = FileUtil.getTempDirectory();
|
private static final String ORIGINAL_TEMP_DIR = FileUtil.getTempDirectory();
|
||||||
@@ -96,34 +79,24 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
private Application application;
|
private Application application;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
IdeaForkJoinWorkerThreadFactory.setupPoisonFactory();
|
IdeaSystemPropertiesForParallelRunConfigurator.setProperties();
|
||||||
|
//TODO: investigate and enable
|
||||||
|
//IdeaForkJoinWorkerThreadFactory.setupPoisonFactory();
|
||||||
Logger.setFactory(TestLoggerFactory.class);
|
Logger.setFactory(TestLoggerFactory.class);
|
||||||
}
|
}
|
||||||
protected static final Logger LOG = Logger.getInstance(KtUsefulTestCase.class);
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Disposable myTestRootDisposable = new TestDisposable();
|
protected final Disposable myTestRootDisposable = new TestDisposable();
|
||||||
|
|
||||||
static Path ourPathToKeep;
|
private static final String ourPathToKeep = null;
|
||||||
private final List<String> myPathsToKeep = new ArrayList<>();
|
private final List<String> myPathsToKeep = new ArrayList<>();
|
||||||
|
|
||||||
private String myTempDir;
|
private File myTempDir;
|
||||||
|
|
||||||
private static final String DEFAULT_SETTINGS_EXTERNALIZED;
|
|
||||||
private static final CodeInsightSettings defaultSettings = new CodeInsightSettings();
|
|
||||||
static {
|
static {
|
||||||
// Radar #5755208: Command line Java applications need a way to launch without a Dock icon.
|
// Radar #5755208: Command line Java applications need a way to launch without a Dock icon.
|
||||||
System.setProperty("apple.awt.UIElement", "true");
|
System.setProperty("apple.awt.UIElement", "true");
|
||||||
|
|
||||||
try {
|
|
||||||
Element oldS = new Element("temp");
|
|
||||||
defaultSettings.writeExternal(oldS);
|
|
||||||
DEFAULT_SETTINGS_EXTERNALIZED = JDOMUtil.writeElement(oldS);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -- KOTLIN ADDITIONAL START --
|
// -- KOTLIN ADDITIONAL START --
|
||||||
|
|
||||||
FlexibleTypeImpl.RUN_SLOW_ASSERTIONS = true;
|
FlexibleTypeImpl.RUN_SLOW_ASSERTIONS = true;
|
||||||
@@ -132,42 +105,6 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
// -- KOTLIN ADDITIONAL END --
|
// -- KOTLIN ADDITIONAL END --
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Pass here the exception you want to be thrown first
|
|
||||||
* E.g.<pre>
|
|
||||||
* {@code
|
|
||||||
* void tearDown() {
|
|
||||||
* try {
|
|
||||||
* doTearDowns();
|
|
||||||
* }
|
|
||||||
* catch(Exception e) {
|
|
||||||
* addSuppressedException(e);
|
|
||||||
* }
|
|
||||||
* finally {
|
|
||||||
* super.tearDown();
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void addSuppressedException(@NotNull Throwable e) {
|
|
||||||
List<Throwable> list = mySuppressedExceptions;
|
|
||||||
if (list == null) {
|
|
||||||
mySuppressedExceptions = list = new SmartList<>();
|
|
||||||
}
|
|
||||||
list.add(e);
|
|
||||||
}
|
|
||||||
private List<Throwable> mySuppressedExceptions;
|
|
||||||
|
|
||||||
|
|
||||||
public KtUsefulTestCase() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public KtUsefulTestCase(@NotNull String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean shouldContainTempFiles() {
|
protected boolean shouldContainTempFiles() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -185,17 +122,11 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
if (shouldContainTempFiles()) {
|
if (shouldContainTempFiles()) {
|
||||||
IdeaTestExecutionPolicy policy = IdeaTestExecutionPolicy.current();
|
String testName = FileUtil.sanitizeFileName(getTestName(true));
|
||||||
String testName = null;
|
if (StringUtil.isEmptyOrSpaces(testName)) testName = "";
|
||||||
if (policy != null) {
|
|
||||||
testName = policy.getPerTestTempDirName();
|
|
||||||
}
|
|
||||||
if (testName == null) {
|
|
||||||
testName = FileUtil.sanitizeFileName(getTestName(true));
|
|
||||||
}
|
|
||||||
testName = new File(testName).getName(); // in case the test name contains file separators
|
testName = new File(testName).getName(); // in case the test name contains file separators
|
||||||
myTempDir = FileUtil.createTempDirectory(TEMP_DIR_MARKER + testName, "", false).getPath();
|
myTempDir = FileUtil.createTempDirectory(TEMP_DIR_MARKER, testName, false);
|
||||||
FileUtil.resetCanonicalTempPathCache(myTempDir);
|
FileUtil.resetCanonicalTempPathCache(myTempDir.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isStressTest = isStressTest();
|
boolean isStressTest = isStressTest();
|
||||||
@@ -206,16 +137,6 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
|
|
||||||
// turn off Disposer debugging for performance tests
|
// turn off Disposer debugging for performance tests
|
||||||
Disposer.setDebugMode(!isStressTest);
|
Disposer.setDebugMode(!isStressTest);
|
||||||
|
|
||||||
if (isIconRequired()) {
|
|
||||||
// ensure that IconLoader will use dummy empty icon
|
|
||||||
IconLoader.deactivate();
|
|
||||||
//IconManager.activate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isIconRequired() {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -224,11 +145,6 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
// don't use method references here to make stack trace reading easier
|
// don't use method references here to make stack trace reading easier
|
||||||
//noinspection Convert2MethodRef
|
//noinspection Convert2MethodRef
|
||||||
new RunAll(
|
new RunAll(
|
||||||
() -> {
|
|
||||||
if (isIconRequired()) {
|
|
||||||
//IconManager.deactivate();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
() -> disposeRootDisposable(),
|
() -> disposeRootDisposable(),
|
||||||
() -> cleanupSwingDataStructures(),
|
() -> cleanupSwingDataStructures(),
|
||||||
() -> cleanupDeleteOnExitHookList(),
|
() -> cleanupDeleteOnExitHookList(),
|
||||||
@@ -237,7 +153,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
if (shouldContainTempFiles()) {
|
if (shouldContainTempFiles()) {
|
||||||
FileUtil.resetCanonicalTempPathCache(ORIGINAL_TEMP_DIR);
|
FileUtil.resetCanonicalTempPathCache(ORIGINAL_TEMP_DIR);
|
||||||
if (hasTmpFilesToKeep()) {
|
if (hasTmpFilesToKeep()) {
|
||||||
File[] files = new File(myTempDir).listFiles();
|
File[] files = myTempDir.listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (!shouldKeepTmpFile(file)) {
|
if (!shouldKeepTmpFile(file)) {
|
||||||
@@ -247,14 +163,15 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FileUtil.delete(new File(myTempDir));
|
FileUtil.delete(myTempDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() -> waitForAppLeakingThreads(10, TimeUnit.SECONDS)
|
() -> UIUtil.removeLeakingAppleListeners()
|
||||||
).run(ObjectUtils.notNull(mySuppressedExceptions, Collections.emptyList()));
|
).run();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
super.tearDown();
|
||||||
// -- KOTLIN ADDITIONAL START --
|
// -- KOTLIN ADDITIONAL START --
|
||||||
TestApplicationUtilKt.resetApplicationToNull(application);
|
TestApplicationUtilKt.resetApplicationToNull(application);
|
||||||
application = null;
|
application = null;
|
||||||
@@ -271,12 +188,12 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasTmpFilesToKeep() {
|
private boolean hasTmpFilesToKeep() {
|
||||||
return ourPathToKeep != null && FileUtil.isAncestor(myTempDir, ourPathToKeep.toString(), false) || !myPathsToKeep.isEmpty();
|
return ourPathToKeep != null && FileUtil.isAncestor(myTempDir.getPath(), ourPathToKeep, false) || !myPathsToKeep.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldKeepTmpFile(@NotNull File file) {
|
private boolean shouldKeepTmpFile(@NotNull File file) {
|
||||||
String path = file.getPath();
|
String path = file.getPath();
|
||||||
if (FileUtil.pathsEqual(path, ourPathToKeep.toString())) return true;
|
if (FileUtil.pathsEqual(path, ourPathToKeep)) return true;
|
||||||
for (String pathToKeep : myPathsToKeep) {
|
for (String pathToKeep : myPathsToKeep) {
|
||||||
if (FileUtil.pathsEqual(path, pathToKeep)) return true;
|
if (FileUtil.pathsEqual(path, pathToKeep)) return true;
|
||||||
}
|
}
|
||||||
@@ -284,7 +201,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<String> DELETE_ON_EXIT_HOOK_DOT_FILES;
|
private static final Set<String> DELETE_ON_EXIT_HOOK_DOT_FILES;
|
||||||
private static final Class<?> DELETE_ON_EXIT_HOOK_CLASS;
|
private static final Class DELETE_ON_EXIT_HOOK_CLASS;
|
||||||
static {
|
static {
|
||||||
Class<?> aClass;
|
Class<?> aClass;
|
||||||
try {
|
try {
|
||||||
@@ -320,45 +237,12 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
private static void cleanupSwingDataStructures() throws Exception {
|
private static void cleanupSwingDataStructures() throws Exception {
|
||||||
Object manager = ReflectionUtil.getDeclaredMethod(Class.forName("javax.swing.KeyboardManager"), "getCurrentManager").invoke(null);
|
Object manager = ReflectionUtil.getDeclaredMethod(Class.forName("javax.swing.KeyboardManager"), "getCurrentManager").invoke(null);
|
||||||
Map<?, ?> componentKeyStrokeMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "componentKeyStrokeMap");
|
Map componentKeyStrokeMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "componentKeyStrokeMap");
|
||||||
componentKeyStrokeMap.clear();
|
componentKeyStrokeMap.clear();
|
||||||
Map<?, ?> containerMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "containerMap");
|
Map containerMap = ReflectionUtil.getField(manager.getClass(), manager, Hashtable.class, "containerMap");
|
||||||
containerMap.clear();
|
containerMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doCheckForSettingsDamage(@NotNull CodeStyleSettings oldCodeStyleSettings, @NotNull CodeStyleSettings currentCodeStyleSettings) {
|
|
||||||
final CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
|
||||||
// don't use method references here to make stack trace reading easier
|
|
||||||
//noinspection Convert2MethodRef
|
|
||||||
new RunAll()
|
|
||||||
.append(() -> {
|
|
||||||
try {
|
|
||||||
checkCodeInsightSettingsEqual(defaultSettings, settings);
|
|
||||||
}
|
|
||||||
catch (AssertionError error) {
|
|
||||||
CodeInsightSettings clean = new CodeInsightSettings();
|
|
||||||
for (Field field : clean.getClass().getFields()) {
|
|
||||||
try {
|
|
||||||
ReflectionUtil.copyFieldValue(clean, settings, field);
|
|
||||||
}
|
|
||||||
catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.append(() -> {
|
|
||||||
currentCodeStyleSettings.getIndentOptions(StdFileTypes.JAVA);
|
|
||||||
try {
|
|
||||||
checkCodeStyleSettingsEqual(oldCodeStyleSettings, currentCodeStyleSettings);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
currentCodeStyleSettings.clearCodeStyleSettings();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Disposable getTestRootDisposable() {
|
public Disposable getTestRootDisposable() {
|
||||||
return myTestRootDisposable;
|
return myTestRootDisposable;
|
||||||
@@ -368,11 +252,13 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
protected void runTest() throws Throwable {
|
protected void runTest() throws Throwable {
|
||||||
final Throwable[] throwables = new Throwable[1];
|
final Throwable[] throwables = new Throwable[1];
|
||||||
|
|
||||||
|
AtomicBoolean completed = new AtomicBoolean(false);
|
||||||
Runnable runnable = () -> {
|
Runnable runnable = () -> {
|
||||||
try {
|
try {
|
||||||
TestLoggerFactory.onTestStarted();
|
//TestLoggerFactory.onTestStarted();
|
||||||
super.runTest();
|
super.runTest();
|
||||||
TestLoggerFactory.onTestFinished(true);
|
TestLoggerFactory.onTestFinished(true);
|
||||||
|
completed.set(true);
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException e) {
|
catch (InvocationTargetException e) {
|
||||||
TestLoggerFactory.onTestFinished(false);
|
TestLoggerFactory.onTestFinished(false);
|
||||||
@@ -395,6 +281,9 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
if (throwables[0] != null) {
|
if (throwables[0] != null) {
|
||||||
throw throwables[0];
|
throw throwables[0];
|
||||||
}
|
}
|
||||||
|
if (!completed.get()) {
|
||||||
|
throw new IllegalStateException("test didn't start");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldRunTest() {
|
protected boolean shouldRunTest() {
|
||||||
@@ -402,18 +291,19 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void invokeTestRunnable(@NotNull Runnable runnable) throws Exception {
|
protected void invokeTestRunnable(@NotNull Runnable runnable) throws Exception {
|
||||||
if (runInDispatchThread()) {
|
//IdeaTestExecutionPolicy policy = IdeaTestExecutionPolicy.current();
|
||||||
|
//if (policy != null && !policy.runInDispatchThread()) {
|
||||||
|
// runnable.run();
|
||||||
|
//}
|
||||||
|
//else {
|
||||||
EdtTestUtilKt.runInEdtAndWait(() -> {
|
EdtTestUtilKt.runInEdtAndWait(() -> {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
//}
|
||||||
else {
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void defaultRunBare() throws Throwable {
|
private void defaultRunBare() throws Throwable {
|
||||||
Throwable exception = null;
|
Throwable exception = null;
|
||||||
try {
|
try {
|
||||||
long setupStart = System.nanoTime();
|
long setupStart = System.nanoTime();
|
||||||
@@ -434,17 +324,11 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
logPerClassCost(teardownCost, TOTAL_TEARDOWN_COST_MILLIS);
|
logPerClassCost(teardownCost, TOTAL_TEARDOWN_COST_MILLIS);
|
||||||
}
|
}
|
||||||
catch (Throwable tearingDown) {
|
catch (Throwable tearingDown) {
|
||||||
if (exception == null) {
|
if (exception == null) exception = tearingDown;
|
||||||
exception = tearingDown;
|
else exception = new CompoundRuntimeException(Arrays.asList(exception, tearingDown));
|
||||||
}
|
|
||||||
else {
|
|
||||||
exception = new CompoundRuntimeException(Arrays.asList(exception, tearingDown));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exception != null) {
|
if (exception != null) throw exception;
|
||||||
throw exception;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -484,7 +368,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
|
|
||||||
if (runInDispatchThread()) {
|
if (runInDispatchThread()) {
|
||||||
TestRunnerUtil.replaceIdeEventQueueSafely();
|
TestRunnerUtil.replaceIdeEventQueueSafely();
|
||||||
EdtTestUtil.runInEdtAndWait(this::defaultRunBare);
|
com.intellij.testFramework.EdtTestUtil.runInEdtAndWait(this::defaultRunBare);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
defaultRunBare();
|
defaultRunBare();
|
||||||
@@ -492,20 +376,13 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean runInDispatchThread() {
|
protected boolean runInDispatchThread() {
|
||||||
IdeaTestExecutionPolicy policy = IdeaTestExecutionPolicy.current();
|
//IdeaTestExecutionPolicy policy = IdeaTestExecutionPolicy.current();
|
||||||
if (policy != null) {
|
//if (policy != null) {
|
||||||
return policy.runInDispatchThread();
|
// return policy.runInDispatchThread();
|
||||||
}
|
//}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* If you want a more shorter name than runInEdtAndWait.
|
|
||||||
*/
|
|
||||||
protected void edt(@NotNull ThrowableRunnable<Throwable> runnable) {
|
|
||||||
EdtTestUtil.runInEdtAndWait(runnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String toString(@NotNull Iterable<?> collection) {
|
public static String toString(@NotNull Iterable<?> collection) {
|
||||||
if (!collection.iterator().hasNext()) {
|
if (!collection.iterator().hasNext()) {
|
||||||
@@ -638,20 +515,9 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void assertContainsOrdered(@NotNull Collection<? extends T> collection, @NotNull Collection<? extends T> expected) {
|
public static <T> void assertContainsOrdered(@NotNull Collection<? extends T> collection, @NotNull Collection<? extends T> expected) {
|
||||||
PeekableIterator<T> expectedIt = new PeekableIteratorWrapper<>(expected.iterator());
|
ArrayList<T> copy = new ArrayList<>(collection);
|
||||||
PeekableIterator<T> actualIt = new PeekableIteratorWrapper<>(collection.iterator());
|
copy.retainAll(expected);
|
||||||
|
assertOrderedEquals(toString(collection), copy, expected);
|
||||||
while (actualIt.hasNext() && expectedIt.hasNext()) {
|
|
||||||
T expectedElem = expectedIt.peek();
|
|
||||||
T actualElem = actualIt.peek();
|
|
||||||
if (expectedElem.equals(actualElem)) {
|
|
||||||
expectedIt.next();
|
|
||||||
}
|
|
||||||
actualIt.next();
|
|
||||||
}
|
|
||||||
if (expectedIt.hasNext()) {
|
|
||||||
throw new ComparisonFailure("", toString(expected), toString(collection));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
@@ -726,7 +592,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
if (collection.size() != checkers.length) {
|
if (collection.size() != checkers.length) {
|
||||||
Assert.fail(toString(collection));
|
Assert.fail(toString(collection));
|
||||||
}
|
}
|
||||||
Set<Consumer<T>> checkerSet = ContainerUtil.set(checkers);
|
Set<Consumer<T>> checkerSet = new HashSet<>(Arrays.asList(checkers));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Throwable lastError = null;
|
Throwable lastError = null;
|
||||||
for (final T actual : collection) {
|
for (final T actual : collection) {
|
||||||
@@ -901,7 +767,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
//noinspection UseOfSystemOutOrSystemErr
|
//noinspection UseOfSystemOutOrSystemErr
|
||||||
System.out.println("File " + filePath + " created.");
|
System.out.println("File " + filePath + " created.");
|
||||||
}
|
}
|
||||||
fileText = FileUtil.loadFile(new File(filePath), StandardCharsets.UTF_8);
|
fileText = FileUtil.loadFile(new File(filePath), CharsetToolkit.UTF8_CHARSET);
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e) {
|
catch (FileNotFoundException e) {
|
||||||
VfsTestUtil.overwriteTestData(filePath, actualText);
|
VfsTestUtil.overwriteTestData(filePath, actualText);
|
||||||
@@ -918,14 +784,14 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void clearFields(@NotNull Object test) throws IllegalAccessException {
|
protected static void clearFields(@NotNull Object test) throws IllegalAccessException {
|
||||||
Class<?> aClass = test.getClass();
|
Class aClass = test.getClass();
|
||||||
while (aClass != null) {
|
while (aClass != null) {
|
||||||
clearDeclaredFields(test, aClass);
|
clearDeclaredFields(test, aClass);
|
||||||
aClass = aClass.getSuperclass();
|
aClass = aClass.getSuperclass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearDeclaredFields(@NotNull Object test, @NotNull Class<?> aClass) throws IllegalAccessException {
|
public static void clearDeclaredFields(@NotNull Object test, @NotNull Class aClass) throws IllegalAccessException {
|
||||||
for (final Field field : aClass.getDeclaredFields()) {
|
for (final Field field : aClass.getDeclaredFields()) {
|
||||||
final String name = field.getDeclaringClass().getName();
|
final String name = field.getDeclaringClass().getName();
|
||||||
if (!name.startsWith("junit.framework.") && !name.startsWith("com.intellij.testFramework.")) {
|
if (!name.startsWith("junit.framework.") && !name.startsWith("com.intellij.testFramework.")) {
|
||||||
@@ -951,14 +817,6 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkCodeInsightSettingsEqual(@NotNull CodeInsightSettings oldSettings, @NotNull CodeInsightSettings settings) {
|
|
||||||
if (!oldSettings.equals(settings)) {
|
|
||||||
Element newS = new Element("temp");
|
|
||||||
settings.writeExternal(newS);
|
|
||||||
Assert.assertEquals("Code insight settings damaged", DEFAULT_SETTINGS_EXTERNALIZED, JDOMUtil.writeElement(newS));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPerformanceTest() {
|
public boolean isPerformanceTest() {
|
||||||
String testName = getName();
|
String testName = getName();
|
||||||
String className = getClass().getSimpleName();
|
String className = getClass().getSimpleName();
|
||||||
@@ -985,21 +843,6 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
return name != null && (name.contains("Stress") || name.contains("Slow"));
|
return name != null && (name.contains("Stress") || name.contains("Slow"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doPostponedFormatting(@NotNull Project project) {
|
|
||||||
DocumentUtil.writeInRunUndoTransparentAction(() -> {
|
|
||||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
|
||||||
PostprocessReformattingAspect.getInstance(project).doPostponedFormatting();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks that code block throw corresponding exception.
|
|
||||||
*
|
|
||||||
* @param exceptionCase Block annotated with some exception type
|
|
||||||
*/
|
|
||||||
protected void assertException(@NotNull AbstractExceptionCase<?> exceptionCase) {
|
|
||||||
assertException(exceptionCase, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that code block throw corresponding exception with expected error msg.
|
* Checks that code block throw corresponding exception with expected error msg.
|
||||||
@@ -1013,42 +856,6 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
assertExceptionOccurred(true, exceptionCase, expectedErrorMsg);
|
assertExceptionOccurred(true, exceptionCase, expectedErrorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks that the code block throws an exception of the specified class.
|
|
||||||
*
|
|
||||||
* @param exceptionClass Expected exception type
|
|
||||||
* @param runnable Block annotated with some exception type
|
|
||||||
*/
|
|
||||||
public static <T extends Throwable> void assertThrows(@NotNull Class<? extends Throwable> exceptionClass,
|
|
||||||
@NotNull ThrowableRunnable<T> runnable) {
|
|
||||||
assertThrows(exceptionClass, null, runnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks that the code block throws an exception of the specified class with expected error msg.
|
|
||||||
* If expected error message is null it will not be checked.
|
|
||||||
*
|
|
||||||
* @param exceptionClass Expected exception type
|
|
||||||
* @param expectedErrorMsgPart expected error message, of any
|
|
||||||
* @param runnable Block annotated with some exception type
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({"unchecked", "SameParameterValue"})
|
|
||||||
public static <T extends Throwable> void assertThrows(@NotNull Class<? extends Throwable> exceptionClass,
|
|
||||||
@Nullable String expectedErrorMsgPart,
|
|
||||||
@NotNull ThrowableRunnable<T> runnable) {
|
|
||||||
assertExceptionOccurred(true, new AbstractExceptionCase() {
|
|
||||||
@Override
|
|
||||||
public Class<Throwable> getExpectedExceptionClass() {
|
|
||||||
return (Class<Throwable>)exceptionClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tryClosure() throws Throwable {
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
}, expectedErrorMsgPart);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that code block doesn't throw corresponding exception.
|
* Checks that code block doesn't throw corresponding exception.
|
||||||
*
|
*
|
||||||
@@ -1071,23 +878,21 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
|
|
||||||
private static <T extends Throwable> void assertExceptionOccurred(boolean shouldOccur,
|
private static <T extends Throwable> void assertExceptionOccurred(boolean shouldOccur,
|
||||||
@NotNull AbstractExceptionCase<T> exceptionCase,
|
@NotNull AbstractExceptionCase<T> exceptionCase,
|
||||||
String expectedErrorMsgPart) throws T {
|
String expectedErrorMsg) throws T {
|
||||||
boolean wasThrown = false;
|
boolean wasThrown = false;
|
||||||
try {
|
try {
|
||||||
exceptionCase.tryClosure();
|
exceptionCase.tryClosure();
|
||||||
}
|
}
|
||||||
catch (Throwable e) {
|
catch (Throwable e) {
|
||||||
Throwable cause = e;
|
|
||||||
|
|
||||||
if (shouldOccur) {
|
if (shouldOccur) {
|
||||||
wasThrown = true;
|
wasThrown = true;
|
||||||
final String errorMessage = exceptionCase.getAssertionErrorMessage();
|
final String errorMessage = exceptionCase.getAssertionErrorMessage();
|
||||||
assertEquals(errorMessage, exceptionCase.getExpectedExceptionClass(), cause.getClass());
|
assertEquals(errorMessage, exceptionCase.getExpectedExceptionClass(), e.getClass());
|
||||||
if (expectedErrorMsgPart != null) {
|
if (expectedErrorMsg != null) {
|
||||||
assertTrue(cause.getMessage(), cause.getMessage().contains(expectedErrorMsgPart));
|
assertEquals("Compare error messages", expectedErrorMsg, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (exceptionCase.getExpectedExceptionClass().equals(cause.getClass())) {
|
else if (exceptionCase.getExpectedExceptionClass().equals(e.getClass())) {
|
||||||
wasThrown = true;
|
wasThrown = true;
|
||||||
|
|
||||||
//noinspection UseOfSystemOutOrSystemErr
|
//noinspection UseOfSystemOutOrSystemErr
|
||||||
@@ -1095,7 +900,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
//noinspection UseOfSystemOutOrSystemErr
|
//noinspection UseOfSystemOutOrSystemErr
|
||||||
e.printStackTrace(System.out);
|
e.printStackTrace(System.out);
|
||||||
|
|
||||||
fail("Exception isn't expected here. Exception message: " + cause.getMessage());
|
fail("Exception isn't expected here. Exception message: " + e.getMessage());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -1132,7 +937,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void refreshRecursively(@NotNull VirtualFile file) {
|
public static void refreshRecursively(@NotNull VirtualFile file) {
|
||||||
VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor<Void>() {
|
VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public boolean visitFile(@NotNull VirtualFile file) {
|
public boolean visitFile(@NotNull VirtualFile file) {
|
||||||
file.getChildren();
|
file.getChildren();
|
||||||
@@ -1142,27 +947,11 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
file.refresh(false, true);
|
file.refresh(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static VirtualFile refreshAndFindFile(@NotNull final File file) {
|
public static VirtualFile refreshAndFindFile(@NotNull final File file) {
|
||||||
return UIUtil.invokeAndWaitIfNeeded(() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file));
|
return UIUtil.invokeAndWaitIfNeeded(() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void waitForAppLeakingThreads(long timeout, @NotNull TimeUnit timeUnit) {
|
|
||||||
EdtTestUtil.runInEdtAndWait(() -> {
|
|
||||||
Application app = ApplicationManager.getApplication();
|
|
||||||
if (app != null && !app.isDisposed()) {
|
|
||||||
FileBasedIndexImpl index = (FileBasedIndexImpl)app.getServiceIfCreated(FileBasedIndex.class);
|
|
||||||
if (index != null) {
|
|
||||||
index.getChangedFilesCollector().waitForVfsEventsExecuted(timeout, timeUnit);
|
|
||||||
}
|
|
||||||
|
|
||||||
DocumentCommitThread commitThread = (DocumentCommitThread)app.getServiceIfCreated(DocumentCommitProcessor.class);
|
|
||||||
if (commitThread != null) {
|
|
||||||
commitThread.waitForAllCommits(timeout, timeUnit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected class TestDisposable implements Disposable {
|
protected class TestDisposable implements Disposable {
|
||||||
private volatile boolean myDisposed;
|
private volatile boolean myDisposed;
|
||||||
|
|
||||||
@@ -1183,5 +972,5 @@ public abstract class KtUsefulTestCase extends TestCase {
|
|||||||
String testName = getTestName(false);
|
String testName = getTestName(false);
|
||||||
return KtUsefulTestCase.this.getClass() + (StringUtil.isEmpty(testName) ? "" : ".test" + testName);
|
return KtUsefulTestCase.this.getClass() + (StringUtil.isEmpty(testName) ? "" : ".test" + testName);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
versions.intellijSdk=193.6494.35
|
versions.intellijSdk=201.7223.91
|
||||||
versions.androidBuildTools=r23.0.1
|
versions.androidBuildTools=r23.0.1
|
||||||
versions.idea.NodeJS=181.3494.12
|
versions.idea.NodeJS=193.6494.7
|
||||||
versions.jar.asm-all=7.0.1
|
versions.jar.asm-all=7.0.1
|
||||||
versions.jar.guava=27.1-jre
|
versions.jar.guava=28.2-jre
|
||||||
versions.jar.groovy-all=2.4.17
|
versions.jar.groovy-all=2.4.17
|
||||||
versions.jar.lombok-ast=0.2.3
|
versions.jar.lombok-ast=0.2.3
|
||||||
versions.jar.swingx-core=1.6.2-2
|
versions.jar.swingx-core=1.6.2-2
|
||||||
versions.jar.kxml2=2.3.0
|
versions.jar.kxml2=2.3.0
|
||||||
versions.jar.streamex=0.6.8
|
versions.jar.streamex=0.7.2
|
||||||
versions.jar.gson=2.8.5
|
versions.jar.gson=2.8.6
|
||||||
versions.jar.oro=2.0.8
|
versions.jar.oro=2.0.8
|
||||||
versions.jar.picocontainer=1.2
|
versions.jar.picocontainer=1.2
|
||||||
versions.jar.serviceMessages=2019.1.4
|
versions.jar.serviceMessages=2019.1.4
|
||||||
versions.jar.lz4-java=1.6.0
|
versions.jar.lz4-java=1.7.1
|
||||||
ignore.jar.snappy-in-java=true
|
ignore.jar.snappy-in-java=true
|
||||||
versions.gradle-api=4.5.1
|
versions.gradle-api=4.5.1
|
||||||
versions.shadow=5.2.0
|
versions.shadow=5.2.0
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
versions.intellijSdk=201.7223.91
|
versions.intellijSdk=193.6494.35
|
||||||
versions.androidBuildTools=r23.0.1
|
versions.androidBuildTools=r23.0.1
|
||||||
versions.idea.NodeJS=193.6494.7
|
versions.idea.NodeJS=181.3494.12
|
||||||
versions.jar.asm-all=7.0.1
|
versions.jar.asm-all=7.0.1
|
||||||
versions.jar.guava=28.2-jre
|
versions.jar.guava=27.1-jre
|
||||||
versions.jar.groovy-all=2.4.17
|
versions.jar.groovy-all=2.4.17
|
||||||
versions.jar.lombok-ast=0.2.3
|
versions.jar.lombok-ast=0.2.3
|
||||||
versions.jar.swingx-core=1.6.2-2
|
versions.jar.swingx-core=1.6.2-2
|
||||||
versions.jar.kxml2=2.3.0
|
versions.jar.kxml2=2.3.0
|
||||||
versions.jar.streamex=0.7.2
|
versions.jar.streamex=0.6.8
|
||||||
versions.jar.gson=2.8.6
|
versions.jar.gson=2.8.5
|
||||||
versions.jar.oro=2.0.8
|
versions.jar.oro=2.0.8
|
||||||
versions.jar.picocontainer=1.2
|
versions.jar.picocontainer=1.2
|
||||||
versions.jar.serviceMessages=2019.1.4
|
versions.jar.serviceMessages=2019.1.4
|
||||||
versions.jar.lz4-java=1.7.1
|
versions.jar.lz4-java=1.6.0
|
||||||
ignore.jar.snappy-in-java=true
|
ignore.jar.snappy-in-java=true
|
||||||
versions.gradle-api=4.5.1
|
versions.gradle-api=4.5.1
|
||||||
versions.shadow=5.2.0
|
versions.shadow=5.2.0
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.util
|
package org.jetbrains.kotlin.util
|
||||||
|
|
||||||
import com.intellij.AbstractBundle
|
import com.intellij.DynamicBundle
|
||||||
|
|
||||||
abstract class AbstractKotlinBundle protected constructor(pathToBundle: String) : AbstractBundle(pathToBundle) {
|
abstract class AbstractKotlinBundle protected constructor(pathToBundle: String) : DynamicBundle(pathToBundle) {
|
||||||
protected fun String.withHtml(): String = "<html>$this</html>"
|
protected fun String.withHtml(): String = "<html>$this</html>"
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.util
|
package org.jetbrains.kotlin.util
|
||||||
|
|
||||||
import com.intellij.DynamicBundle
|
import com.intellij.AbstractBundle
|
||||||
|
|
||||||
abstract class AbstractKotlinBundle protected constructor(pathToBundle: String) : DynamicBundle(pathToBundle) {
|
abstract class AbstractKotlinBundle protected constructor(pathToBundle: String) : AbstractBundle(pathToBundle) {
|
||||||
protected fun String.withHtml(): String = "<html>$this</html>"
|
protected fun String.withHtml(): String = "<html>$this</html>"
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,6 @@ import com.intellij.psi.PsiMethod
|
|||||||
import com.intellij.util.Processor
|
import com.intellij.util.Processor
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
typealias StringProcessor = Processor<String>
|
typealias StringProcessor = Processor<in String>
|
||||||
typealias PsiMethodProcessor = Processor<PsiMethod>
|
typealias PsiMethodProcessor = Processor<in PsiMethod>
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -9,6 +9,6 @@ import com.intellij.psi.PsiMethod
|
|||||||
import com.intellij.util.Processor
|
import com.intellij.util.Processor
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
typealias StringProcessor = Processor<in String>
|
typealias StringProcessor = Processor<String>
|
||||||
typealias PsiMethodProcessor = Processor<in PsiMethod>
|
typealias PsiMethodProcessor = Processor<PsiMethod>
|
||||||
|
|
||||||
+59
-23
@@ -8,13 +8,17 @@ package org.jetbrains.kotlin.idea.highlighter
|
|||||||
import com.intellij.codeInsight.intention.EmptyIntentionAction
|
import com.intellij.codeInsight.intention.EmptyIntentionAction
|
||||||
import com.intellij.codeInsight.intention.IntentionAction
|
import com.intellij.codeInsight.intention.IntentionAction
|
||||||
import com.intellij.codeInspection.ProblemHighlightType
|
import com.intellij.codeInspection.ProblemHighlightType
|
||||||
import com.intellij.lang.annotation.Annotation
|
import com.intellij.lang.annotation.AnnotationBuilder
|
||||||
import com.intellij.lang.annotation.AnnotationHolder
|
import com.intellij.lang.annotation.AnnotationHolder
|
||||||
|
import com.intellij.lang.annotation.HighlightSeverity
|
||||||
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.editor.colors.TextAttributesKey
|
import com.intellij.openapi.editor.colors.TextAttributesKey
|
||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.util.TextRange
|
||||||
import com.intellij.util.containers.MultiMap
|
import com.intellij.util.containers.MultiMap
|
||||||
|
import com.intellij.xml.util.XmlStringUtil
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
import org.jetbrains.kotlin.diagnostics.Severity
|
import org.jetbrains.kotlin.diagnostics.Severity
|
||||||
|
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||||
import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix
|
import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix
|
||||||
|
|
||||||
class AnnotationPresentationInfo(
|
class AnnotationPresentationInfo(
|
||||||
@@ -28,35 +32,67 @@ class AnnotationPresentationInfo(
|
|||||||
for (range in ranges) {
|
for (range in ranges) {
|
||||||
for (diagnostic in diagnostics) {
|
for (diagnostic in diagnostics) {
|
||||||
val fixes = fixesMap[diagnostic]
|
val fixes = fixesMap[diagnostic]
|
||||||
val annotation = create(diagnostic, range, holder)
|
create(diagnostic, range, holder) { annotation ->
|
||||||
|
fixes.forEach {
|
||||||
fixes.forEach {
|
when (it) {
|
||||||
when (it) {
|
is KotlinUniversalQuickFix -> annotation.newFix(it).universal().registerFix()
|
||||||
is KotlinUniversalQuickFix -> annotation.registerUniversalFix(it, null, null)
|
is IntentionAction -> annotation.newFix(it).registerFix()
|
||||||
is IntentionAction -> annotation.registerFix(it)
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (diagnostic.severity == Severity.WARNING) {
|
if (diagnostic.severity == Severity.WARNING) {
|
||||||
annotation.problemGroup = KotlinSuppressableWarningProblemGroup(diagnostic.factory)
|
annotation.problemGroup(KotlinSuppressableWarningProblemGroup(diagnostic.factory))
|
||||||
|
|
||||||
if (fixes.isEmpty()) {
|
if (fixes.isEmpty()) {
|
||||||
// if there are no quick fixes we need to register an EmptyIntentionAction to enable 'suppress' actions
|
// if there are no quick fixes we need to register an EmptyIntentionAction to enable 'suppress' actions
|
||||||
annotation.registerFix(EmptyIntentionAction(diagnostic.factory.name))
|
annotation.newFix(EmptyIntentionAction(diagnostic.factory.name)).registerFix()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun create(diagnostic: Diagnostic, range: TextRange, holder: AnnotationHolder): Annotation =
|
private fun create(diagnostic: Diagnostic, range: TextRange, holder: AnnotationHolder, consumer: (AnnotationBuilder) -> Unit) {
|
||||||
Diagnostic2Annotation.createAnnotation(
|
val severity = when (diagnostic.severity) {
|
||||||
diagnostic,
|
Severity.ERROR -> HighlightSeverity.ERROR
|
||||||
range,
|
Severity.WARNING -> if (highlightType == ProblemHighlightType.WEAK_WARNING) {
|
||||||
holder,
|
HighlightSeverity.WEAK_WARNING
|
||||||
nonDefaultMessage,
|
} else HighlightSeverity.WARNING
|
||||||
textAttributes,
|
Severity.INFO -> HighlightSeverity.WEAK_WARNING
|
||||||
highlightType,
|
}
|
||||||
IdeErrorMessages::render
|
|
||||||
)
|
holder.newAnnotation(severity, nonDefaultMessage ?: getDefaultMessage(diagnostic))
|
||||||
|
.range(range)
|
||||||
|
.tooltip(getMessage(diagnostic))
|
||||||
|
.also { builder -> highlightType?.let { builder.highlightType(it) } }
|
||||||
|
.also { builder -> textAttributes?.let { builder.textAttributes(it) } }
|
||||||
|
.also { consumer(it) }
|
||||||
|
.create()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getMessage(diagnostic: Diagnostic): String {
|
||||||
|
var message = IdeErrorMessages.render(diagnostic)
|
||||||
|
if (ApplicationManager.getApplication().isInternal || ApplicationManager.getApplication().isUnitTestMode) {
|
||||||
|
val factoryName = diagnostic.factory.name
|
||||||
|
message = if (message.startsWith("<html>")) {
|
||||||
|
"<html>[$factoryName] ${message.substring("<html>".length)}"
|
||||||
|
} else {
|
||||||
|
"[$factoryName] $message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!message.startsWith("<html>")) {
|
||||||
|
message = "<html><body>${XmlStringUtil.escapeString(message)}</body></html>"
|
||||||
|
}
|
||||||
|
return message
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getDefaultMessage(diagnostic: Diagnostic): String {
|
||||||
|
val message = DefaultErrorMessages.render(diagnostic)
|
||||||
|
if (ApplicationManager.getApplication().isInternal || ApplicationManager.getApplication().isUnitTestMode) {
|
||||||
|
return "[${diagnostic.factory.name}] $message"
|
||||||
|
}
|
||||||
|
return message
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.highlighter
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.intention.EmptyIntentionAction
|
||||||
|
import com.intellij.codeInsight.intention.IntentionAction
|
||||||
|
import com.intellij.codeInspection.ProblemHighlightType
|
||||||
|
import com.intellij.lang.annotation.Annotation
|
||||||
|
import com.intellij.lang.annotation.AnnotationHolder
|
||||||
|
import com.intellij.openapi.editor.colors.TextAttributesKey
|
||||||
|
import com.intellij.openapi.util.TextRange
|
||||||
|
import com.intellij.util.containers.MultiMap
|
||||||
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
|
import org.jetbrains.kotlin.diagnostics.Severity
|
||||||
|
import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix
|
||||||
|
|
||||||
|
class AnnotationPresentationInfo(
|
||||||
|
val ranges: List<TextRange>,
|
||||||
|
val nonDefaultMessage: String? = null,
|
||||||
|
val highlightType: ProblemHighlightType? = null,
|
||||||
|
val textAttributes: TextAttributesKey? = null
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun processDiagnostics(holder: AnnotationHolder, diagnostics: List<Diagnostic>, fixesMap: MultiMap<Diagnostic, IntentionAction>) {
|
||||||
|
for (range in ranges) {
|
||||||
|
for (diagnostic in diagnostics) {
|
||||||
|
val fixes = fixesMap[diagnostic]
|
||||||
|
val annotation = create(diagnostic, range, holder)
|
||||||
|
|
||||||
|
fixes.forEach {
|
||||||
|
when (it) {
|
||||||
|
is KotlinUniversalQuickFix -> annotation.registerUniversalFix(it, null, null)
|
||||||
|
is IntentionAction -> annotation.registerFix(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diagnostic.severity == Severity.WARNING) {
|
||||||
|
annotation.problemGroup = KotlinSuppressableWarningProblemGroup(diagnostic.factory)
|
||||||
|
|
||||||
|
if (fixes.isEmpty()) {
|
||||||
|
// if there are no quick fixes we need to register an EmptyIntentionAction to enable 'suppress' actions
|
||||||
|
annotation.registerFix(EmptyIntentionAction(diagnostic.factory.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun create(diagnostic: Diagnostic, range: TextRange, holder: AnnotationHolder): Annotation =
|
||||||
|
Diagnostic2Annotation.createAnnotation(
|
||||||
|
diagnostic,
|
||||||
|
range,
|
||||||
|
holder,
|
||||||
|
nonDefaultMessage,
|
||||||
|
textAttributes,
|
||||||
|
highlightType,
|
||||||
|
IdeErrorMessages::render
|
||||||
|
)
|
||||||
|
}
|
||||||
-98
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.highlighter
|
|
||||||
|
|
||||||
import com.intellij.codeInsight.intention.EmptyIntentionAction
|
|
||||||
import com.intellij.codeInsight.intention.IntentionAction
|
|
||||||
import com.intellij.codeInspection.ProblemHighlightType
|
|
||||||
import com.intellij.lang.annotation.AnnotationBuilder
|
|
||||||
import com.intellij.lang.annotation.AnnotationHolder
|
|
||||||
import com.intellij.lang.annotation.HighlightSeverity
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
|
||||||
import com.intellij.openapi.editor.colors.TextAttributesKey
|
|
||||||
import com.intellij.openapi.util.TextRange
|
|
||||||
import com.intellij.util.containers.MultiMap
|
|
||||||
import com.intellij.xml.util.XmlStringUtil
|
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
|
||||||
import org.jetbrains.kotlin.diagnostics.Severity
|
|
||||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
|
||||||
import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix
|
|
||||||
|
|
||||||
class AnnotationPresentationInfo(
|
|
||||||
val ranges: List<TextRange>,
|
|
||||||
val nonDefaultMessage: String? = null,
|
|
||||||
val highlightType: ProblemHighlightType? = null,
|
|
||||||
val textAttributes: TextAttributesKey? = null
|
|
||||||
) {
|
|
||||||
|
|
||||||
fun processDiagnostics(holder: AnnotationHolder, diagnostics: List<Diagnostic>, fixesMap: MultiMap<Diagnostic, IntentionAction>) {
|
|
||||||
for (range in ranges) {
|
|
||||||
for (diagnostic in diagnostics) {
|
|
||||||
val fixes = fixesMap[diagnostic]
|
|
||||||
create(diagnostic, range, holder) { annotation ->
|
|
||||||
fixes.forEach {
|
|
||||||
when (it) {
|
|
||||||
is KotlinUniversalQuickFix -> annotation.newFix(it).universal().registerFix()
|
|
||||||
is IntentionAction -> annotation.newFix(it).registerFix()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diagnostic.severity == Severity.WARNING) {
|
|
||||||
annotation.problemGroup(KotlinSuppressableWarningProblemGroup(diagnostic.factory))
|
|
||||||
|
|
||||||
if (fixes.isEmpty()) {
|
|
||||||
// if there are no quick fixes we need to register an EmptyIntentionAction to enable 'suppress' actions
|
|
||||||
annotation.newFix(EmptyIntentionAction(diagnostic.factory.name)).registerFix()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun create(diagnostic: Diagnostic, range: TextRange, holder: AnnotationHolder, consumer: (AnnotationBuilder) -> Unit) {
|
|
||||||
val severity = when (diagnostic.severity) {
|
|
||||||
Severity.ERROR -> HighlightSeverity.ERROR
|
|
||||||
Severity.WARNING -> if (highlightType == ProblemHighlightType.WEAK_WARNING) {
|
|
||||||
HighlightSeverity.WEAK_WARNING
|
|
||||||
} else HighlightSeverity.WARNING
|
|
||||||
Severity.INFO -> HighlightSeverity.WEAK_WARNING
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.newAnnotation(severity, nonDefaultMessage ?: getDefaultMessage(diagnostic))
|
|
||||||
.range(range)
|
|
||||||
.tooltip(getMessage(diagnostic))
|
|
||||||
.also { builder -> highlightType?.let { builder.highlightType(it) } }
|
|
||||||
.also { builder -> textAttributes?.let { builder.textAttributes(it) } }
|
|
||||||
.also { consumer(it) }
|
|
||||||
.create()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getMessage(diagnostic: Diagnostic): String {
|
|
||||||
var message = IdeErrorMessages.render(diagnostic)
|
|
||||||
if (ApplicationManager.getApplication().isInternal || ApplicationManager.getApplication().isUnitTestMode) {
|
|
||||||
val factoryName = diagnostic.factory.name
|
|
||||||
message = if (message.startsWith("<html>")) {
|
|
||||||
"<html>[$factoryName] ${message.substring("<html>".length)}"
|
|
||||||
} else {
|
|
||||||
"[$factoryName] $message"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!message.startsWith("<html>")) {
|
|
||||||
message = "<html><body>${XmlStringUtil.escapeString(message)}</body></html>"
|
|
||||||
}
|
|
||||||
return message
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getDefaultMessage(diagnostic: Diagnostic): String {
|
|
||||||
val message = DefaultErrorMessages.render(diagnostic)
|
|
||||||
if (ApplicationManager.getApplication().isInternal || ApplicationManager.getApplication().isUnitTestMode) {
|
|
||||||
return "[${diagnostic.factory.name}] $message"
|
|
||||||
}
|
|
||||||
return message
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -64,7 +64,7 @@ public class ModuleHighlightUtil2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (root.getFileSystem() instanceof JarFileSystem && "jar".equalsIgnoreCase(root.getExtension())) {
|
else if (root.getFileSystem() instanceof JarFileSystem && "jar".equalsIgnoreCase(root.getExtension())) {
|
||||||
return LightJavaModule.getModule(PsiManager.getInstance(project), root);
|
return LightJavaModule.findModule(PsiManager.getInstance(project), root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((root = index.getSourceRootForFile(file)) != null) {
|
else if ((root = index.getSourceRootForFile(file)) != null) {
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ public class ModuleHighlightUtil2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (root.getFileSystem() instanceof JarFileSystem && "jar".equalsIgnoreCase(root.getExtension())) {
|
else if (root.getFileSystem() instanceof JarFileSystem && "jar".equalsIgnoreCase(root.getExtension())) {
|
||||||
return LightJavaModule.findModule(PsiManager.getInstance(project), root);
|
return LightJavaModule.getModule(PsiManager.getInstance(project), root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((root = index.getSourceRootForFile(file)) != null) {
|
else if ((root = index.getSourceRootForFile(file)) != null) {
|
||||||
+12
-12
@@ -6,12 +6,9 @@
|
|||||||
package org.jetbrains.kotlin.idea.search.ideaExtensions
|
package org.jetbrains.kotlin.idea.search.ideaExtensions
|
||||||
|
|
||||||
import com.intellij.ide.highlighter.JavaFileType
|
import com.intellij.ide.highlighter.JavaFileType
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.impl.cache.CacheManager
|
import com.intellij.psi.search.*
|
||||||
import com.intellij.psi.search.GlobalSearchScope
|
|
||||||
import com.intellij.psi.search.ScopeOptimizer
|
|
||||||
import com.intellij.psi.search.SearchScope
|
|
||||||
import com.intellij.psi.search.UsageSearchContext
|
|
||||||
import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
|
import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||||
import org.jetbrains.kotlin.idea.search.excludeFileTypes
|
import org.jetbrains.kotlin.idea.search.excludeFileTypes
|
||||||
@@ -31,19 +28,22 @@ class KotlinReferenceScopeOptimizer : ScopeOptimizer {
|
|||||||
val file = callable.parent as KtFile
|
val file = callable.parent as KtFile
|
||||||
val packageName = file.packageFqName.takeUnless { it.isRoot } ?: return null
|
val packageName = file.packageFqName.takeUnless { it.isRoot } ?: return null
|
||||||
val project = file.project
|
val project = file.project
|
||||||
val cacheManager = CacheManager.SERVICE.getInstance(project)
|
val searchHelper = PsiSearchHelper.getInstance(project)
|
||||||
|
|
||||||
val kotlinScope = GlobalSearchScope.getScopeRestrictedByFileTypes(useScope, KotlinFileType.INSTANCE)
|
val kotlinScope = GlobalSearchScope.getScopeRestrictedByFileTypes(useScope, KotlinFileType.INSTANCE)
|
||||||
val javaScope = GlobalSearchScope.getScopeRestrictedByFileTypes(useScope, JavaFileType.INSTANCE)
|
val javaScope = GlobalSearchScope.getScopeRestrictedByFileTypes(useScope, JavaFileType.INSTANCE)
|
||||||
val restScope = useScope.excludeFileTypes(KotlinFileType.INSTANCE, JavaFileType.INSTANCE) as GlobalSearchScope
|
val restScope = useScope.excludeFileTypes(KotlinFileType.INSTANCE, JavaFileType.INSTANCE) as GlobalSearchScope
|
||||||
|
|
||||||
//TODO: use all components of package name?
|
val kotlinFiles = mutableListOf<VirtualFile>()
|
||||||
val shortPackageName = packageName.shortName().identifier
|
searchHelper.processCandidateFilesForText(kotlinScope, UsageSearchContext.IN_CODE, true, packageName.asString()) {
|
||||||
val kotlinFiles = cacheManager.getVirtualFilesWithWord(shortPackageName, UsageSearchContext.IN_CODE, kotlinScope, true)
|
kotlinFiles.add(it)
|
||||||
|
}
|
||||||
|
|
||||||
val javaFacadeName = file.javaFileFacadeFqName.shortName().identifier
|
val javaFiles = mutableListOf<VirtualFile>()
|
||||||
val javaFiles = cacheManager.getVirtualFilesWithWord(javaFacadeName, UsageSearchContext.IN_CODE, javaScope, true)
|
searchHelper.processCandidateFilesForText(javaScope, UsageSearchContext.IN_CODE, true, file.javaFileFacadeFqName.asString()) {
|
||||||
|
javaFiles.add(it)
|
||||||
|
}
|
||||||
|
|
||||||
return GlobalSearchScope.filesScope(project, (kotlinFiles + javaFiles).asList()).uniteWith(restScope)
|
return GlobalSearchScope.filesScope(project, kotlinFiles + javaFiles).uniteWith(restScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-12
@@ -6,9 +6,12 @@
|
|||||||
package org.jetbrains.kotlin.idea.search.ideaExtensions
|
package org.jetbrains.kotlin.idea.search.ideaExtensions
|
||||||
|
|
||||||
import com.intellij.ide.highlighter.JavaFileType
|
import com.intellij.ide.highlighter.JavaFileType
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.search.*
|
import com.intellij.psi.impl.cache.CacheManager
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
|
import com.intellij.psi.search.ScopeOptimizer
|
||||||
|
import com.intellij.psi.search.SearchScope
|
||||||
|
import com.intellij.psi.search.UsageSearchContext
|
||||||
import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
|
import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||||
import org.jetbrains.kotlin.idea.search.excludeFileTypes
|
import org.jetbrains.kotlin.idea.search.excludeFileTypes
|
||||||
@@ -28,22 +31,19 @@ class KotlinReferenceScopeOptimizer : ScopeOptimizer {
|
|||||||
val file = callable.parent as KtFile
|
val file = callable.parent as KtFile
|
||||||
val packageName = file.packageFqName.takeUnless { it.isRoot } ?: return null
|
val packageName = file.packageFqName.takeUnless { it.isRoot } ?: return null
|
||||||
val project = file.project
|
val project = file.project
|
||||||
val searchHelper = PsiSearchHelper.getInstance(project)
|
val cacheManager = CacheManager.SERVICE.getInstance(project)
|
||||||
|
|
||||||
val kotlinScope = GlobalSearchScope.getScopeRestrictedByFileTypes(useScope, KotlinFileType.INSTANCE)
|
val kotlinScope = GlobalSearchScope.getScopeRestrictedByFileTypes(useScope, KotlinFileType.INSTANCE)
|
||||||
val javaScope = GlobalSearchScope.getScopeRestrictedByFileTypes(useScope, JavaFileType.INSTANCE)
|
val javaScope = GlobalSearchScope.getScopeRestrictedByFileTypes(useScope, JavaFileType.INSTANCE)
|
||||||
val restScope = useScope.excludeFileTypes(KotlinFileType.INSTANCE, JavaFileType.INSTANCE) as GlobalSearchScope
|
val restScope = useScope.excludeFileTypes(KotlinFileType.INSTANCE, JavaFileType.INSTANCE) as GlobalSearchScope
|
||||||
|
|
||||||
val kotlinFiles = mutableListOf<VirtualFile>()
|
//TODO: use all components of package name?
|
||||||
searchHelper.processCandidateFilesForText(kotlinScope, UsageSearchContext.IN_CODE, true, packageName.asString()) {
|
val shortPackageName = packageName.shortName().identifier
|
||||||
kotlinFiles.add(it)
|
val kotlinFiles = cacheManager.getVirtualFilesWithWord(shortPackageName, UsageSearchContext.IN_CODE, kotlinScope, true)
|
||||||
}
|
|
||||||
|
|
||||||
val javaFiles = mutableListOf<VirtualFile>()
|
val javaFacadeName = file.javaFileFacadeFqName.shortName().identifier
|
||||||
searchHelper.processCandidateFilesForText(javaScope, UsageSearchContext.IN_CODE, true, file.javaFileFacadeFqName.asString()) {
|
val javaFiles = cacheManager.getVirtualFilesWithWord(javaFacadeName, UsageSearchContext.IN_CODE, javaScope, true)
|
||||||
javaFiles.add(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
return GlobalSearchScope.filesScope(project, kotlinFiles + javaFiles).uniteWith(restScope)
|
return GlobalSearchScope.filesScope(project, (kotlinFiles + javaFiles).asList()).uniteWith(restScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -5,9 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.completion.test.handlers
|
package org.jetbrains.kotlin.idea.completion.test.handlers
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.lookup.LookupFocusDegree
|
||||||
import com.intellij.codeInsight.lookup.impl.LookupImpl
|
import com.intellij.codeInsight.lookup.impl.LookupImpl
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun LookupImpl.setFocusedFocusDegree() {
|
fun LookupImpl.setFocusedFocusDegree() {
|
||||||
focusDegree = LookupImpl.FocusDegree.FOCUSED
|
this.lookupFocusDegree = LookupFocusDegree.FOCUSED
|
||||||
}
|
}
|
||||||
+1
-2
@@ -5,10 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.completion.test.handlers
|
package org.jetbrains.kotlin.idea.completion.test.handlers
|
||||||
|
|
||||||
import com.intellij.codeInsight.lookup.LookupFocusDegree
|
|
||||||
import com.intellij.codeInsight.lookup.impl.LookupImpl
|
import com.intellij.codeInsight.lookup.impl.LookupImpl
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun LookupImpl.setFocusedFocusDegree() {
|
fun LookupImpl.setFocusedFocusDegree() {
|
||||||
this.lookupFocusDegree = LookupFocusDegree.FOCUSED
|
focusDegree = LookupImpl.FocusDegree.FOCUSED
|
||||||
}
|
}
|
||||||
+7
-10
@@ -1,28 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.caches.trackers
|
package org.jetbrains.kotlin.idea.caches.trackers
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.SimpleModificationTracker
|
import com.intellij.openapi.util.SimpleModificationTracker
|
||||||
import com.intellij.pom.tree.TreeAspect
|
import com.intellij.pom.tree.TreeAspect
|
||||||
|
import com.intellij.psi.util.PsiModificationTracker
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
|
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
||||||
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tested in OutOfBlockModificationTestGenerated
|
* Tested in OutOfBlockModificationTestGenerated
|
||||||
*/
|
*/
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
class KotlinCodeBlockModificationListener(
|
class KotlinCodeBlockModificationListener(project: Project) : KotlinCodeBlockModificationListenerCompat(project) {
|
||||||
project: Project,
|
|
||||||
treeAspect: TreeAspect
|
|
||||||
) : KotlinCodeBlockModificationListenerCompat(project) {
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
init(
|
init(
|
||||||
treeAspect,
|
TreeAspect.getInstance(project),
|
||||||
incOCBCounter = { ktFile ->
|
incOCBCounter = { ktFile ->
|
||||||
kotlinOutOfCodeBlockTrackerImpl.incModificationCount()
|
kotlinOutOfCodeBlockTrackerImpl.incModificationCount()
|
||||||
perModuleOutOfCodeBlockTrackerUpdater.onKotlinPhysicalFileOutOfBlockChange(ktFile, true)
|
perModuleOutOfCodeBlockTrackerUpdater.onKotlinPhysicalFileOutOfBlockChange(ktFile, true)
|
||||||
@@ -31,7 +30,6 @@ class KotlinCodeBlockModificationListener(
|
|||||||
SimpleModificationTracker()
|
SimpleModificationTracker()
|
||||||
},
|
},
|
||||||
psiModificationTrackerListener = {
|
psiModificationTrackerListener = {
|
||||||
@Suppress("UnstableApiUsage")
|
|
||||||
val kotlinTrackerInternalIDECount =
|
val kotlinTrackerInternalIDECount =
|
||||||
modificationTrackerImpl.forLanguage(KotlinLanguage.INSTANCE).modificationCount
|
modificationTrackerImpl.forLanguage(KotlinLanguage.INSTANCE).modificationCount
|
||||||
if (kotlinModificationTracker == kotlinTrackerInternalIDECount) {
|
if (kotlinModificationTracker == kotlinTrackerInternalIDECount) {
|
||||||
@@ -47,7 +45,6 @@ class KotlinCodeBlockModificationListener(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getInstance(project: Project): KotlinCodeBlockModificationListener =
|
fun getInstance(project: Project): KotlinCodeBlockModificationListener = project.getServiceSafe()
|
||||||
project.getComponent(KotlinCodeBlockModificationListener::class.java)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
-7
@@ -1,27 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.caches.trackers
|
package org.jetbrains.kotlin.idea.caches.trackers
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.SimpleModificationTracker
|
import com.intellij.openapi.util.SimpleModificationTracker
|
||||||
import com.intellij.pom.tree.TreeAspect
|
import com.intellij.pom.tree.TreeAspect
|
||||||
import com.intellij.psi.util.PsiModificationTracker
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tested in OutOfBlockModificationTestGenerated
|
* Tested in OutOfBlockModificationTestGenerated
|
||||||
*/
|
*/
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
class KotlinCodeBlockModificationListener(project: Project) : KotlinCodeBlockModificationListenerCompat(project) {
|
class KotlinCodeBlockModificationListener(
|
||||||
|
project: Project,
|
||||||
|
treeAspect: TreeAspect
|
||||||
|
) : KotlinCodeBlockModificationListenerCompat(project) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
init(
|
init(
|
||||||
TreeAspect.getInstance(project),
|
treeAspect,
|
||||||
incOCBCounter = { ktFile ->
|
incOCBCounter = { ktFile ->
|
||||||
kotlinOutOfCodeBlockTrackerImpl.incModificationCount()
|
kotlinOutOfCodeBlockTrackerImpl.incModificationCount()
|
||||||
perModuleOutOfCodeBlockTrackerUpdater.onKotlinPhysicalFileOutOfBlockChange(ktFile, true)
|
perModuleOutOfCodeBlockTrackerUpdater.onKotlinPhysicalFileOutOfBlockChange(ktFile, true)
|
||||||
@@ -30,6 +31,7 @@ class KotlinCodeBlockModificationListener(project: Project) : KotlinCodeBlockMod
|
|||||||
SimpleModificationTracker()
|
SimpleModificationTracker()
|
||||||
},
|
},
|
||||||
psiModificationTrackerListener = {
|
psiModificationTrackerListener = {
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
val kotlinTrackerInternalIDECount =
|
val kotlinTrackerInternalIDECount =
|
||||||
modificationTrackerImpl.forLanguage(KotlinLanguage.INSTANCE).modificationCount
|
modificationTrackerImpl.forLanguage(KotlinLanguage.INSTANCE).modificationCount
|
||||||
if (kotlinModificationTracker == kotlinTrackerInternalIDECount) {
|
if (kotlinModificationTracker == kotlinTrackerInternalIDECount) {
|
||||||
@@ -45,6 +47,7 @@ class KotlinCodeBlockModificationListener(project: Project) : KotlinCodeBlockMod
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getInstance(project: Project): KotlinCodeBlockModificationListener = project.getServiceSafe()
|
fun getInstance(project: Project): KotlinCodeBlockModificationListener =
|
||||||
|
project.getComponent(KotlinCodeBlockModificationListener::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+18
-7
@@ -1,6 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.util.application
|
package org.jetbrains.kotlin.idea.util.application
|
||||||
@@ -8,8 +19,8 @@ package org.jetbrains.kotlin.idea.util.application
|
|||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.command.CommandProcessor
|
import com.intellij.openapi.command.CommandProcessor
|
||||||
import com.intellij.openapi.components.ComponentManager
|
import com.intellij.openapi.components.ComponentManager
|
||||||
|
import com.intellij.openapi.progress.impl.CancellationCheck
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import org.jetbrains.annotations.Nls
|
|
||||||
|
|
||||||
fun <T> runReadAction(action: () -> T): T {
|
fun <T> runReadAction(action: () -> T): T {
|
||||||
return ApplicationManager.getApplication().runReadAction<T>(action)
|
return ApplicationManager.getApplication().runReadAction<T>(action)
|
||||||
@@ -19,22 +30,22 @@ fun <T> runWriteAction(action: () -> T): T {
|
|||||||
return ApplicationManager.getApplication().runWriteAction<T>(action)
|
return ApplicationManager.getApplication().runWriteAction<T>(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.executeWriteCommand(@Nls name: String, command: () -> Unit) {
|
fun Project.executeWriteCommand(name: String, command: () -> Unit) {
|
||||||
CommandProcessor.getInstance().executeCommand(this, { runWriteAction(command) }, name, null)
|
CommandProcessor.getInstance().executeCommand(this, { runWriteAction(command) }, name, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Project.executeWriteCommand(@Nls name: String, groupId: Any? = null, command: () -> T): T {
|
fun <T> Project.executeWriteCommand(name: String, groupId: Any? = null, command: () -> T): T {
|
||||||
return executeCommand<T>(name, groupId) { runWriteAction(command) }
|
return executeCommand<T>(name, groupId) { runWriteAction(command) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Project.executeCommand(@Nls name: String, groupId: Any? = null, command: () -> T): T {
|
fun <T> Project.executeCommand(name: String, groupId: Any? = null, command: () -> T): T {
|
||||||
@Suppress("UNCHECKED_CAST") var result: T = null as T
|
@Suppress("UNCHECKED_CAST") var result: T = null as T
|
||||||
CommandProcessor.getInstance().executeCommand(this, { result = command() }, name, groupId)
|
CommandProcessor.getInstance().executeCommand(this, { result = command() }, name, groupId)
|
||||||
@Suppress("USELESS_CAST")
|
@Suppress("USELESS_CAST")
|
||||||
return result as T
|
return result as T
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> runWithCancellationCheck(block: () -> T): T = block()
|
fun <T> runWithCancellationCheck(block: () -> T): T = CancellationCheck.runWithCancellationCheck(block)
|
||||||
|
|
||||||
inline fun executeOnPooledThread(crossinline action: () -> Unit) =
|
inline fun executeOnPooledThread(crossinline action: () -> Unit) =
|
||||||
ApplicationManager.getApplication().executeOnPooledThread { action() }
|
ApplicationManager.getApplication().executeOnPooledThread { action() }
|
||||||
|
|||||||
+7
-18
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.util.application
|
package org.jetbrains.kotlin.idea.util.application
|
||||||
@@ -19,8 +8,8 @@ package org.jetbrains.kotlin.idea.util.application
|
|||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.command.CommandProcessor
|
import com.intellij.openapi.command.CommandProcessor
|
||||||
import com.intellij.openapi.components.ComponentManager
|
import com.intellij.openapi.components.ComponentManager
|
||||||
import com.intellij.openapi.progress.impl.CancellationCheck
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
|
import org.jetbrains.annotations.Nls
|
||||||
|
|
||||||
fun <T> runReadAction(action: () -> T): T {
|
fun <T> runReadAction(action: () -> T): T {
|
||||||
return ApplicationManager.getApplication().runReadAction<T>(action)
|
return ApplicationManager.getApplication().runReadAction<T>(action)
|
||||||
@@ -30,22 +19,22 @@ fun <T> runWriteAction(action: () -> T): T {
|
|||||||
return ApplicationManager.getApplication().runWriteAction<T>(action)
|
return ApplicationManager.getApplication().runWriteAction<T>(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.executeWriteCommand(name: String, command: () -> Unit) {
|
fun Project.executeWriteCommand(@Nls name: String, command: () -> Unit) {
|
||||||
CommandProcessor.getInstance().executeCommand(this, { runWriteAction(command) }, name, null)
|
CommandProcessor.getInstance().executeCommand(this, { runWriteAction(command) }, name, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Project.executeWriteCommand(name: String, groupId: Any? = null, command: () -> T): T {
|
fun <T> Project.executeWriteCommand(@Nls name: String, groupId: Any? = null, command: () -> T): T {
|
||||||
return executeCommand<T>(name, groupId) { runWriteAction(command) }
|
return executeCommand<T>(name, groupId) { runWriteAction(command) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> Project.executeCommand(name: String, groupId: Any? = null, command: () -> T): T {
|
fun <T> Project.executeCommand(@Nls name: String, groupId: Any? = null, command: () -> T): T {
|
||||||
@Suppress("UNCHECKED_CAST") var result: T = null as T
|
@Suppress("UNCHECKED_CAST") var result: T = null as T
|
||||||
CommandProcessor.getInstance().executeCommand(this, { result = command() }, name, groupId)
|
CommandProcessor.getInstance().executeCommand(this, { result = command() }, name, groupId)
|
||||||
@Suppress("USELESS_CAST")
|
@Suppress("USELESS_CAST")
|
||||||
return result as T
|
return result as T
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> runWithCancellationCheck(block: () -> T): T = CancellationCheck.runWithCancellationCheck(block)
|
fun <T> runWithCancellationCheck(block: () -> T): T = block()
|
||||||
|
|
||||||
inline fun executeOnPooledThread(crossinline action: () -> Unit) =
|
inline fun executeOnPooledThread(crossinline action: () -> Unit) =
|
||||||
ApplicationManager.getApplication().executeOnPooledThread { action() }
|
ApplicationManager.getApplication().executeOnPooledThread { action() }
|
||||||
+2
-2
@@ -13,8 +13,8 @@ import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExten
|
|||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
abstract class AbstractProjectResolverExtensionCompat : AbstractProjectResolverExtension() {
|
abstract class AbstractProjectResolverExtensionCompat : AbstractProjectResolverExtension() {
|
||||||
override fun createModule(gradleModule: IdeaModule, projectDataNode: DataNode<ProjectData>): DataNode<ModuleData> {
|
override fun createModule(gradleModule: IdeaModule, projectDataNode: DataNode<ProjectData>): DataNode<ModuleData>? {
|
||||||
return super.createModule(gradleModule, projectDataNode).also {
|
return super.createModule(gradleModule, projectDataNode)?.also {
|
||||||
initializeModuleNode(gradleModule, it, projectDataNode)
|
initializeModuleNode(gradleModule, it, projectDataNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -13,8 +13,8 @@ import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExten
|
|||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
abstract class AbstractProjectResolverExtensionCompat : AbstractProjectResolverExtension() {
|
abstract class AbstractProjectResolverExtensionCompat : AbstractProjectResolverExtension() {
|
||||||
override fun createModule(gradleModule: IdeaModule, projectDataNode: DataNode<ProjectData>): DataNode<ModuleData>? {
|
override fun createModule(gradleModule: IdeaModule, projectDataNode: DataNode<ProjectData>): DataNode<ModuleData> {
|
||||||
return super.createModule(gradleModule, projectDataNode)?.also {
|
return super.createModule(gradleModule, projectDataNode).also {
|
||||||
initializeModuleNode(gradleModule, it, projectDataNode)
|
initializeModuleNode(gradleModule, it, projectDataNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+16
-7
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.scripting.gradle
|
package org.jetbrains.kotlin.idea.scripting.gradle
|
||||||
|
|
||||||
import com.intellij.openapi.externalSystem.service.project.autoimport.AsyncFileChangeListenerBase
|
import com.intellij.openapi.externalSystem.autoimport.AsyncFileChangeListenerBase
|
||||||
|
import com.intellij.openapi.vfs.LocalFileSystem
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.openapi.vfs.VirtualFileManager
|
import com.intellij.openapi.vfs.VirtualFileManager
|
||||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
|
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
|
||||||
@@ -17,19 +18,27 @@ fun addVfsListener(
|
|||||||
) {
|
) {
|
||||||
VirtualFileManager.getInstance().addAsyncFileListener(
|
VirtualFileManager.getInstance().addAsyncFileListener(
|
||||||
object : AsyncFileChangeListenerBase() {
|
object : AsyncFileChangeListenerBase() {
|
||||||
|
val changedFiles = mutableListOf<String>()
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
changedFiles.clear()
|
||||||
|
}
|
||||||
|
|
||||||
override fun isRelevant(path: String): Boolean {
|
override fun isRelevant(path: String): Boolean {
|
||||||
return buildRootsManager.maybeAffectedGradleProjectFile(path)
|
return buildRootsManager.maybeAffectedGradleProjectFile(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateFile(file: VirtualFile, event: VFileEvent) {
|
override fun updateFile(file: VirtualFile, event: VFileEvent) {
|
||||||
watcher.fileChanged(event.path, file.timeStamp)
|
changedFiles.add(event.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// do nothing
|
override fun apply() {
|
||||||
override fun prepareFileDeletion(file: VirtualFile) {}
|
changedFiles.forEach {
|
||||||
override fun apply() {}
|
LocalFileSystem.getInstance().findFileByPath(it)?.let { f ->
|
||||||
override fun reset() {}
|
watcher.fileChanged(f.path, f.timeStamp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watcher.project
|
watcher.project
|
||||||
)
|
)
|
||||||
|
|||||||
+7
-16
@@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.scripting.gradle
|
package org.jetbrains.kotlin.idea.scripting.gradle
|
||||||
|
|
||||||
import com.intellij.openapi.externalSystem.autoimport.AsyncFileChangeListenerBase
|
import com.intellij.openapi.externalSystem.service.project.autoimport.AsyncFileChangeListenerBase
|
||||||
import com.intellij.openapi.vfs.LocalFileSystem
|
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.openapi.vfs.VirtualFileManager
|
import com.intellij.openapi.vfs.VirtualFileManager
|
||||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
|
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
|
||||||
@@ -18,27 +17,19 @@ fun addVfsListener(
|
|||||||
) {
|
) {
|
||||||
VirtualFileManager.getInstance().addAsyncFileListener(
|
VirtualFileManager.getInstance().addAsyncFileListener(
|
||||||
object : AsyncFileChangeListenerBase() {
|
object : AsyncFileChangeListenerBase() {
|
||||||
val changedFiles = mutableListOf<String>()
|
|
||||||
|
|
||||||
override fun init() {
|
|
||||||
changedFiles.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isRelevant(path: String): Boolean {
|
override fun isRelevant(path: String): Boolean {
|
||||||
return buildRootsManager.maybeAffectedGradleProjectFile(path)
|
return buildRootsManager.maybeAffectedGradleProjectFile(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateFile(file: VirtualFile, event: VFileEvent) {
|
override fun updateFile(file: VirtualFile, event: VFileEvent) {
|
||||||
changedFiles.add(event.path)
|
watcher.fileChanged(event.path, file.timeStamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply() {
|
// do nothing
|
||||||
changedFiles.forEach {
|
override fun prepareFileDeletion(file: VirtualFile) {}
|
||||||
LocalFileSystem.getInstance().findFileByPath(it)?.let { f ->
|
override fun apply() {}
|
||||||
watcher.fileChanged(f.path, f.timeStamp)
|
override fun reset() {}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
watcher.project
|
watcher.project
|
||||||
)
|
)
|
||||||
+78
-91
@@ -7,31 +7,32 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.scripting.gradle
|
package org.jetbrains.kotlin.idea.scripting.gradle
|
||||||
|
|
||||||
import com.intellij.notification.*
|
import com.intellij.diff.util.DiffUtil
|
||||||
import com.intellij.openapi.actionSystem.AnAction
|
import com.intellij.openapi.actionSystem.AnAction
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||||
import com.intellij.openapi.components.ServiceManager
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder
|
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder
|
||||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
|
||||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
|
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
|
||||||
|
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.Key
|
|
||||||
import com.intellij.openapi.util.registry.Registry
|
import com.intellij.openapi.util.registry.Registry
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import org.gradle.util.GradleVersion
|
import com.intellij.testFramework.LightVirtualFileBase
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||||
import org.jetbrains.kotlin.idea.KotlinIcons
|
import org.jetbrains.kotlin.idea.KotlinIcons
|
||||||
import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle
|
import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle
|
||||||
|
import org.jetbrains.kotlin.idea.core.script.settings.KotlinScriptingSettings
|
||||||
|
import org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslScriptModelResolver
|
||||||
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRoot
|
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRoot
|
||||||
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager
|
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager
|
||||||
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
import org.jetbrains.kotlin.scripting.definitions.findScriptDefinition
|
||||||
import org.jetbrains.kotlin.psi.UserDataProperty
|
import org.jetbrains.plugins.gradle.service.project.GradlePartialResolverPolicy
|
||||||
import org.jetbrains.plugins.gradle.service.GradleInstallationManager
|
|
||||||
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings
|
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings
|
||||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||||
|
|
||||||
val scriptConfigurationsNeedToBeUpdatedBalloon
|
val scriptConfigurationsNeedToBeUpdatedBalloon
|
||||||
get() = Registry.`is`("kotlin.gradle.scripts.scriptConfigurationsNeedToBeUpdatedBalloon", false)
|
get() = Registry.`is`("kotlin.gradle.scripts.scriptConfigurationsNeedToBeUpdatedFloatingNotification", true)
|
||||||
|
|
||||||
fun runPartialGradleImportForAllRoots(project: Project) {
|
fun runPartialGradleImportForAllRoots(project: Project) {
|
||||||
GradleBuildRootsManager.getInstance(project).getAllRoots().forEach { root ->
|
GradleBuildRootsManager.getInstance(project).getAllRoots().forEach { root ->
|
||||||
@@ -45,97 +46,83 @@ fun runPartialGradleImport(project: Project, root: GradleBuildRoot) {
|
|||||||
ExternalSystemUtil.refreshProject(
|
ExternalSystemUtil.refreshProject(
|
||||||
root.pathPrefix,
|
root.pathPrefix,
|
||||||
ImportSpecBuilder(project, GradleConstants.SYSTEM_ID)
|
ImportSpecBuilder(project, GradleConstants.SYSTEM_ID)
|
||||||
.build()
|
.projectResolverPolicy(
|
||||||
|
GradlePartialResolverPolicy { it is KotlinDslScriptModelResolver }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMissingConfigurationActionText() = KotlinIdeaGradleBundle.message("action.label.import.project")
|
fun getMissingConfigurationActionText() = KotlinIdeaGradleBundle.message("action.text.load.script.configurations")
|
||||||
|
|
||||||
fun autoReloadScriptConfigurations(project: Project, root: GradleBuildRoot): Boolean {
|
fun autoReloadScriptConfigurations(project: Project, file: VirtualFile): Boolean {
|
||||||
return ExternalSystemApiUtil
|
val definition = file.findScriptDefinition(project) ?: return false
|
||||||
.getSettings(project, GradleConstants.SYSTEM_ID)
|
|
||||||
.getLinkedProjectSettings(root.pathPrefix)
|
return KotlinScriptingSettings.getInstance(project).autoReloadConfigurations(definition)
|
||||||
?.isUseAutoImport ?: false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val kotlinDslNotificationGroupId = "Gradle Kotlin DSL Scripts"
|
|
||||||
private var Project.notificationPanel: ScriptConfigurationChangedNotification?
|
|
||||||
by UserDataProperty<Project, ScriptConfigurationChangedNotification>(Key.create("load.script.configuration.panel"))
|
|
||||||
|
|
||||||
fun scriptConfigurationsNeedToBeUpdated(project: Project, file: VirtualFile) {
|
fun scriptConfigurationsNeedToBeUpdated(project: Project, file: VirtualFile) {
|
||||||
if (!scriptConfigurationsNeedToBeUpdatedBalloon) return
|
if (autoReloadScriptConfigurations(project, file)) {
|
||||||
|
GradleBuildRootsManager.getInstance(project).getScriptInfo(file)?.buildRoot?.let {
|
||||||
val root = GradleBuildRootsManager.getInstance(project).getScriptInfo(file)?.buildRoot ?: return
|
runPartialGradleImport(project, it)
|
||||||
if (autoReloadScriptConfigurations(project, root)) {
|
|
||||||
// import should be run automatically by Gradle plugin
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val existingPanel = project.notificationPanel
|
|
||||||
if (existingPanel != null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val notificationGroup = NotificationGroup.findRegisteredGroup(kotlinDslNotificationGroupId)
|
|
||||||
if (notificationGroup == null) {
|
|
||||||
NotificationsConfiguration.getNotificationsConfiguration().register(
|
|
||||||
kotlinDslNotificationGroupId, NotificationDisplayType.STICKY_BALLOON, false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val notification = ScriptConfigurationChangedNotification(project)
|
|
||||||
project.notificationPanel = notification
|
|
||||||
notification.notify(project)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun scriptConfigurationsAreUpToDate(project: Project): Boolean {
|
|
||||||
if (project.notificationPanel == null) return false
|
|
||||||
project.notificationPanel?.expire()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ScriptConfigurationChangedNotification(val project: Project) :
|
|
||||||
Notification(
|
|
||||||
kotlinDslNotificationGroupId,
|
|
||||||
KotlinIcons.LOAD_SCRIPT_CONFIGURATION,
|
|
||||||
KotlinIdeaGradleBundle.message("notification.title.script.configuration.has.been.changed"),
|
|
||||||
null,
|
|
||||||
KotlinIdeaGradleBundle.message("notification.text.script.configuration.has.been.changed"),
|
|
||||||
NotificationType.INFORMATION,
|
|
||||||
null
|
|
||||||
) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
addAction(LoadConfigurationAction())
|
|
||||||
addAction(NotificationAction.createSimple(KotlinIdeaGradleBundle.message("action.label.enable.auto.import")) {
|
|
||||||
GradleBuildRootsManager.getInstance(project).getAllRoots().forEach { root ->
|
|
||||||
val projectSettings = getGradleProjectSettings(project).find { it.externalProjectPath == root.pathPrefix }
|
|
||||||
if (projectSettings != null) {
|
|
||||||
projectSettings.isUseAutoImport = true
|
|
||||||
}
|
|
||||||
runPartialGradleImport(project, root)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun expire() {
|
|
||||||
super.expire()
|
|
||||||
|
|
||||||
project.notificationPanel = null
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LoadConfigurationAction : AnAction(KotlinIdeaGradleBundle.message("action.label.import.project")) {
|
|
||||||
override fun actionPerformed(e: AnActionEvent) {
|
|
||||||
val project = e.project ?: return
|
|
||||||
runPartialGradleImportForAllRoots(project)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// notification is shown in LoadConfigurationAction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun scriptConfigurationsAreUpToDate(project: Project): Boolean = true
|
||||||
|
|
||||||
|
class LoadConfigurationAction : AnAction(
|
||||||
|
KotlinIdeaGradleBundle.message("action.text.load.script.configurations"),
|
||||||
|
KotlinIdeaGradleBundle.message("action.description.load.script.configurations"),
|
||||||
|
KotlinIcons.LOAD_SCRIPT_CONFIGURATION
|
||||||
|
) {
|
||||||
|
override fun actionPerformed(e: AnActionEvent) {
|
||||||
|
val project = e.project ?: return
|
||||||
|
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
|
||||||
|
val file = getKotlinScriptFile(editor) ?: return
|
||||||
|
val root = GradleBuildRootsManager.getInstance(project).getScriptInfo(file)?.buildRoot ?: return
|
||||||
|
|
||||||
|
runPartialGradleImport(project, root)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun update(e: AnActionEvent) {
|
||||||
|
ensureValidActionVisibility(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ensureValidActionVisibility(e: AnActionEvent) {
|
||||||
|
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
|
||||||
|
|
||||||
|
e.presentation.isVisible = getNotificationVisibility(editor)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getNotificationVisibility(editor: Editor): Boolean {
|
||||||
|
if (!scriptConfigurationsNeedToBeUpdatedBalloon) return false
|
||||||
|
|
||||||
|
if (DiffUtil.isDiffEditor(editor)) return false
|
||||||
|
|
||||||
|
val project = editor.project ?: return false
|
||||||
|
val file = getKotlinScriptFile(editor) ?: return false
|
||||||
|
|
||||||
|
if (autoReloadScriptConfigurations(project, file)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return GradleBuildRootsManager.getInstance(project).isConfigurationOutOfDate(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getKotlinScriptFile(editor: Editor): VirtualFile? {
|
||||||
|
return FileDocumentManager.getInstance()
|
||||||
|
.getFile(editor.document)
|
||||||
|
?.takeIf {
|
||||||
|
it !is LightVirtualFileBase
|
||||||
|
&& it.isValid
|
||||||
|
&& it.fileType == KotlinFileType.INSTANCE
|
||||||
|
&& isGradleKotlinScript(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getGradleVersion(project: Project, settings: GradleProjectSettings): String {
|
fun getGradleVersion(project: Project, settings: GradleProjectSettings): String {
|
||||||
// workaround for bug in settings.resolveGradleVersion().version (fixed in 201)
|
return settings.resolveGradleVersion().version
|
||||||
return GradleInstallationManager.getGradleVersion(
|
|
||||||
ServiceManager.getService(GradleInstallationManager::class.java)
|
|
||||||
.getGradleHome(project, settings.externalProjectPath)?.path
|
|
||||||
) ?: GradleVersion.current().version
|
|
||||||
}
|
}
|
||||||
+141
@@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.scripting.gradle
|
||||||
|
|
||||||
|
import com.intellij.notification.*
|
||||||
|
import com.intellij.openapi.actionSystem.AnAction
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
|
import com.intellij.openapi.components.ServiceManager
|
||||||
|
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder
|
||||||
|
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||||
|
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.openapi.util.Key
|
||||||
|
import com.intellij.openapi.util.registry.Registry
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
|
import org.gradle.util.GradleVersion
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinIcons
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle
|
||||||
|
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRoot
|
||||||
|
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager
|
||||||
|
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
||||||
|
import org.jetbrains.kotlin.psi.UserDataProperty
|
||||||
|
import org.jetbrains.plugins.gradle.service.GradleInstallationManager
|
||||||
|
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings
|
||||||
|
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||||
|
|
||||||
|
val scriptConfigurationsNeedToBeUpdatedBalloon
|
||||||
|
get() = Registry.`is`("kotlin.gradle.scripts.scriptConfigurationsNeedToBeUpdatedBalloon", false)
|
||||||
|
|
||||||
|
fun runPartialGradleImportForAllRoots(project: Project) {
|
||||||
|
GradleBuildRootsManager.getInstance(project).getAllRoots().forEach { root ->
|
||||||
|
runPartialGradleImport(project, root)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun runPartialGradleImport(project: Project, root: GradleBuildRoot) {
|
||||||
|
if (root.isImportingInProgress()) return
|
||||||
|
|
||||||
|
ExternalSystemUtil.refreshProject(
|
||||||
|
root.pathPrefix,
|
||||||
|
ImportSpecBuilder(project, GradleConstants.SYSTEM_ID)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getMissingConfigurationActionText() = KotlinIdeaGradleBundle.message("action.label.import.project")
|
||||||
|
|
||||||
|
fun autoReloadScriptConfigurations(project: Project, root: GradleBuildRoot): Boolean {
|
||||||
|
return ExternalSystemApiUtil
|
||||||
|
.getSettings(project, GradleConstants.SYSTEM_ID)
|
||||||
|
.getLinkedProjectSettings(root.pathPrefix)
|
||||||
|
?.isUseAutoImport ?: false
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val kotlinDslNotificationGroupId = "Gradle Kotlin DSL Scripts"
|
||||||
|
private var Project.notificationPanel: ScriptConfigurationChangedNotification?
|
||||||
|
by UserDataProperty<Project, ScriptConfigurationChangedNotification>(Key.create("load.script.configuration.panel"))
|
||||||
|
|
||||||
|
fun scriptConfigurationsNeedToBeUpdated(project: Project, file: VirtualFile) {
|
||||||
|
if (!scriptConfigurationsNeedToBeUpdatedBalloon) return
|
||||||
|
|
||||||
|
val root = GradleBuildRootsManager.getInstance(project).getScriptInfo(file)?.buildRoot ?: return
|
||||||
|
if (autoReloadScriptConfigurations(project, root)) {
|
||||||
|
// import should be run automatically by Gradle plugin
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val existingPanel = project.notificationPanel
|
||||||
|
if (existingPanel != null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val notificationGroup = NotificationGroup.findRegisteredGroup(kotlinDslNotificationGroupId)
|
||||||
|
if (notificationGroup == null) {
|
||||||
|
NotificationsConfiguration.getNotificationsConfiguration().register(
|
||||||
|
kotlinDslNotificationGroupId, NotificationDisplayType.STICKY_BALLOON, false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val notification = ScriptConfigurationChangedNotification(project)
|
||||||
|
project.notificationPanel = notification
|
||||||
|
notification.notify(project)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun scriptConfigurationsAreUpToDate(project: Project): Boolean {
|
||||||
|
if (project.notificationPanel == null) return false
|
||||||
|
project.notificationPanel?.expire()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ScriptConfigurationChangedNotification(val project: Project) :
|
||||||
|
Notification(
|
||||||
|
kotlinDslNotificationGroupId,
|
||||||
|
KotlinIcons.LOAD_SCRIPT_CONFIGURATION,
|
||||||
|
KotlinIdeaGradleBundle.message("notification.title.script.configuration.has.been.changed"),
|
||||||
|
null,
|
||||||
|
KotlinIdeaGradleBundle.message("notification.text.script.configuration.has.been.changed"),
|
||||||
|
NotificationType.INFORMATION,
|
||||||
|
null
|
||||||
|
) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
addAction(LoadConfigurationAction())
|
||||||
|
addAction(NotificationAction.createSimple(KotlinIdeaGradleBundle.message("action.label.enable.auto.import")) {
|
||||||
|
GradleBuildRootsManager.getInstance(project).getAllRoots().forEach { root ->
|
||||||
|
val projectSettings = getGradleProjectSettings(project).find { it.externalProjectPath == root.pathPrefix }
|
||||||
|
if (projectSettings != null) {
|
||||||
|
projectSettings.isUseAutoImport = true
|
||||||
|
}
|
||||||
|
runPartialGradleImport(project, root)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun expire() {
|
||||||
|
super.expire()
|
||||||
|
|
||||||
|
project.notificationPanel = null
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LoadConfigurationAction : AnAction(KotlinIdeaGradleBundle.message("action.label.import.project")) {
|
||||||
|
override fun actionPerformed(e: AnActionEvent) {
|
||||||
|
val project = e.project ?: return
|
||||||
|
runPartialGradleImportForAllRoots(project)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getGradleVersion(project: Project, settings: GradleProjectSettings): String {
|
||||||
|
// workaround for bug in settings.resolveGradleVersion().version (fixed in 201)
|
||||||
|
return GradleInstallationManager.getGradleVersion(
|
||||||
|
ServiceManager.getService(GradleInstallationManager::class.java)
|
||||||
|
.getGradleHome(project, settings.externalProjectPath)?.path
|
||||||
|
) ?: GradleVersion.current().version
|
||||||
|
}
|
||||||
-128
@@ -1,128 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@file:Suppress("UnstableApiUsage")
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.scripting.gradle
|
|
||||||
|
|
||||||
import com.intellij.diff.util.DiffUtil
|
|
||||||
import com.intellij.openapi.actionSystem.AnAction
|
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
|
||||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
|
||||||
import com.intellij.openapi.editor.Editor
|
|
||||||
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder
|
|
||||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
|
|
||||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
|
||||||
import com.intellij.openapi.project.Project
|
|
||||||
import com.intellij.openapi.util.registry.Registry
|
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
|
||||||
import com.intellij.testFramework.LightVirtualFileBase
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinIcons
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle
|
|
||||||
import org.jetbrains.kotlin.idea.core.script.settings.KotlinScriptingSettings
|
|
||||||
import org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslScriptModelResolver
|
|
||||||
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRoot
|
|
||||||
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager
|
|
||||||
import org.jetbrains.kotlin.scripting.definitions.findScriptDefinition
|
|
||||||
import org.jetbrains.plugins.gradle.service.project.GradlePartialResolverPolicy
|
|
||||||
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings
|
|
||||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
|
||||||
|
|
||||||
val scriptConfigurationsNeedToBeUpdatedBalloon
|
|
||||||
get() = Registry.`is`("kotlin.gradle.scripts.scriptConfigurationsNeedToBeUpdatedFloatingNotification", true)
|
|
||||||
|
|
||||||
fun runPartialGradleImportForAllRoots(project: Project) {
|
|
||||||
GradleBuildRootsManager.getInstance(project).getAllRoots().forEach { root ->
|
|
||||||
runPartialGradleImport(project, root)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun runPartialGradleImport(project: Project, root: GradleBuildRoot) {
|
|
||||||
if (root.isImportingInProgress()) return
|
|
||||||
|
|
||||||
ExternalSystemUtil.refreshProject(
|
|
||||||
root.pathPrefix,
|
|
||||||
ImportSpecBuilder(project, GradleConstants.SYSTEM_ID)
|
|
||||||
.projectResolverPolicy(
|
|
||||||
GradlePartialResolverPolicy { it is KotlinDslScriptModelResolver }
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getMissingConfigurationActionText() = KotlinIdeaGradleBundle.message("action.text.load.script.configurations")
|
|
||||||
|
|
||||||
fun autoReloadScriptConfigurations(project: Project, file: VirtualFile): Boolean {
|
|
||||||
val definition = file.findScriptDefinition(project) ?: return false
|
|
||||||
|
|
||||||
return KotlinScriptingSettings.getInstance(project).autoReloadConfigurations(definition)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun scriptConfigurationsNeedToBeUpdated(project: Project, file: VirtualFile) {
|
|
||||||
if (autoReloadScriptConfigurations(project, file)) {
|
|
||||||
GradleBuildRootsManager.getInstance(project).getScriptInfo(file)?.buildRoot?.let {
|
|
||||||
runPartialGradleImport(project, it)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// notification is shown in LoadConfigurationAction
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun scriptConfigurationsAreUpToDate(project: Project): Boolean = true
|
|
||||||
|
|
||||||
class LoadConfigurationAction : AnAction(
|
|
||||||
KotlinIdeaGradleBundle.message("action.text.load.script.configurations"),
|
|
||||||
KotlinIdeaGradleBundle.message("action.description.load.script.configurations"),
|
|
||||||
KotlinIcons.LOAD_SCRIPT_CONFIGURATION
|
|
||||||
) {
|
|
||||||
override fun actionPerformed(e: AnActionEvent) {
|
|
||||||
val project = e.project ?: return
|
|
||||||
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
|
|
||||||
val file = getKotlinScriptFile(editor) ?: return
|
|
||||||
val root = GradleBuildRootsManager.getInstance(project).getScriptInfo(file)?.buildRoot ?: return
|
|
||||||
|
|
||||||
runPartialGradleImport(project, root)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun update(e: AnActionEvent) {
|
|
||||||
ensureValidActionVisibility(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ensureValidActionVisibility(e: AnActionEvent) {
|
|
||||||
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
|
|
||||||
|
|
||||||
e.presentation.isVisible = getNotificationVisibility(editor)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getNotificationVisibility(editor: Editor): Boolean {
|
|
||||||
if (!scriptConfigurationsNeedToBeUpdatedBalloon) return false
|
|
||||||
|
|
||||||
if (DiffUtil.isDiffEditor(editor)) return false
|
|
||||||
|
|
||||||
val project = editor.project ?: return false
|
|
||||||
val file = getKotlinScriptFile(editor) ?: return false
|
|
||||||
|
|
||||||
if (autoReloadScriptConfigurations(project, file)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return GradleBuildRootsManager.getInstance(project).isConfigurationOutOfDate(file)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getKotlinScriptFile(editor: Editor): VirtualFile? {
|
|
||||||
return FileDocumentManager.getInstance()
|
|
||||||
.getFile(editor.document)
|
|
||||||
?.takeIf {
|
|
||||||
it !is LightVirtualFileBase
|
|
||||||
&& it.isValid
|
|
||||||
&& it.fileType == KotlinFileType.INSTANCE
|
|
||||||
&& isGradleKotlinScript(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getGradleVersion(project: Project, settings: GradleProjectSettings): String {
|
|
||||||
return settings.resolveGradleVersion().version
|
|
||||||
}
|
|
||||||
+1
-1
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition
|
|||||||
import org.jetbrains.kotlin.scripting.resolve.KotlinScriptDefinitionFromAnnotatedTemplate
|
import org.jetbrains.kotlin.scripting.resolve.KotlinScriptDefinitionFromAnnotatedTemplate
|
||||||
import kotlin.script.experimental.api.*
|
import kotlin.script.experimental.api.*
|
||||||
import kotlin.script.experimental.host.ScriptingHostConfiguration
|
import kotlin.script.experimental.host.ScriptingHostConfiguration
|
||||||
|
import kotlin.script.experimental.location.ScriptExpectedLocation
|
||||||
|
|
||||||
class GradleKotlinScriptDefinitionWrapper(
|
class GradleKotlinScriptDefinitionWrapper(
|
||||||
hostConfiguration: ScriptingHostConfiguration,
|
hostConfiguration: ScriptingHostConfiguration,
|
||||||
@@ -25,6 +26,5 @@ class GradleKotlinScriptDefinitionWrapper(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val canAutoReloadScriptConfigurationsBeSwitchedOff = !kotlinDslScriptsModelImportSupported(gradleVersion)
|
|
||||||
override val canDefinitionBeSwitchedOff: Boolean = false
|
override val canDefinitionBeSwitchedOff: Boolean = false
|
||||||
}
|
}
|
||||||
+1
-1
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition
|
|||||||
import org.jetbrains.kotlin.scripting.resolve.KotlinScriptDefinitionFromAnnotatedTemplate
|
import org.jetbrains.kotlin.scripting.resolve.KotlinScriptDefinitionFromAnnotatedTemplate
|
||||||
import kotlin.script.experimental.api.*
|
import kotlin.script.experimental.api.*
|
||||||
import kotlin.script.experimental.host.ScriptingHostConfiguration
|
import kotlin.script.experimental.host.ScriptingHostConfiguration
|
||||||
import kotlin.script.experimental.location.ScriptExpectedLocation
|
|
||||||
|
|
||||||
class GradleKotlinScriptDefinitionWrapper(
|
class GradleKotlinScriptDefinitionWrapper(
|
||||||
hostConfiguration: ScriptingHostConfiguration,
|
hostConfiguration: ScriptingHostConfiguration,
|
||||||
@@ -26,5 +25,6 @@ class GradleKotlinScriptDefinitionWrapper(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val canAutoReloadScriptConfigurationsBeSwitchedOff = !kotlinDslScriptsModelImportSupported(gradleVersion)
|
||||||
override val canDefinitionBeSwitchedOff: Boolean = false
|
override val canDefinitionBeSwitchedOff: Boolean = false
|
||||||
}
|
}
|
||||||
+17
-21
@@ -5,16 +5,16 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.scripting.gradle.importing
|
package org.jetbrains.kotlin.idea.scripting.gradle.importing
|
||||||
|
|
||||||
import com.intellij.openapi.externalSystem.model.DataNode
|
|
||||||
import com.intellij.openapi.externalSystem.model.project.ProjectData
|
|
||||||
import org.gradle.tooling.model.idea.IdeaProject
|
|
||||||
import org.gradle.tooling.model.kotlin.dsl.KotlinDslScriptsModel
|
import org.gradle.tooling.model.kotlin.dsl.KotlinDslScriptsModel
|
||||||
import org.jetbrains.kotlin.gradle.KotlinDslScriptAdditionalTask
|
import org.jetbrains.kotlin.gradle.KotlinDslScriptAdditionalTask
|
||||||
import org.jetbrains.kotlin.gradle.KotlinDslScriptModelProvider
|
import org.jetbrains.kotlin.gradle.KotlinDslScriptModelProvider
|
||||||
import org.jetbrains.kotlin.idea.scripting.gradle.kotlinDslScriptsModelImportSupported
|
import org.jetbrains.kotlin.idea.scripting.gradle.kotlinDslScriptsModelImportSupported
|
||||||
import org.jetbrains.plugins.gradle.model.Build
|
|
||||||
import org.jetbrains.plugins.gradle.model.ClassSetImportModelProvider
|
import org.jetbrains.plugins.gradle.model.ClassSetImportModelProvider
|
||||||
import org.jetbrains.plugins.gradle.model.ProjectImportModelProvider
|
import org.jetbrains.plugins.gradle.model.ProjectImportModelProvider
|
||||||
|
import org.jetbrains.plugins.gradle.service.project.ModifiableGradleProjectModel
|
||||||
|
import org.jetbrains.plugins.gradle.service.project.ProjectModelContributor
|
||||||
|
import org.jetbrains.plugins.gradle.service.project.ProjectResolverContext
|
||||||
|
import org.jetbrains.plugins.gradle.service.project.ToolingModelsProvider
|
||||||
|
|
||||||
class KotlinDslScriptModelResolver : KotlinDslScriptModelResolverCommon() {
|
class KotlinDslScriptModelResolver : KotlinDslScriptModelResolverCommon() {
|
||||||
override fun requiresTaskRunning() = true
|
override fun requiresTaskRunning() = true
|
||||||
@@ -27,26 +27,22 @@ class KotlinDslScriptModelResolver : KotlinDslScriptModelResolverCommon() {
|
|||||||
setOf(KotlinDslScriptAdditionalTask::class.java)
|
setOf(KotlinDslScriptAdditionalTask::class.java)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun populateProjectExtraModels(gradleProject: IdeaProject, ideProject: DataNode<ProjectData>) {
|
@Suppress("UnstableApiUsage")
|
||||||
super.populateProjectExtraModels(gradleProject, ideProject)
|
class KotlinDslScriptModelContributor : ProjectModelContributor {
|
||||||
|
override fun accept(
|
||||||
populateBuildModels(resolverCtx.models.mainBuild, ideProject)
|
projectModelBuilder: ModifiableGradleProjectModel,
|
||||||
|
toolingModelsProvider: ToolingModelsProvider,
|
||||||
resolverCtx.models.includedBuilds.forEach { includedRoot ->
|
resolverCtx: ProjectResolverContext
|
||||||
populateBuildModels(includedRoot, ideProject)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun populateBuildModels(
|
|
||||||
root: Build,
|
|
||||||
ideProject: DataNode<ProjectData>
|
|
||||||
) {
|
) {
|
||||||
root.projects.forEach {
|
toolingModelsProvider.projects().forEach {
|
||||||
if (it.projectIdentifier.projectPath == ":") {
|
val projectIdentifier = it.projectIdentifier.projectPath
|
||||||
|
if (projectIdentifier == ":") {
|
||||||
if (kotlinDslScriptsModelImportSupported(resolverCtx.projectGradleVersion)) {
|
if (kotlinDslScriptsModelImportSupported(resolverCtx.projectGradleVersion)) {
|
||||||
resolverCtx.models.getModel(it, KotlinDslScriptsModel::class.java)?.let { model ->
|
val model = toolingModelsProvider.getProjectModel(it, KotlinDslScriptsModel::class.java)
|
||||||
processScriptModel(resolverCtx, model, it.projectIdentifier.projectPath)
|
if (model != null) {
|
||||||
|
processScriptModel(resolverCtx, model, projectIdentifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-17
@@ -5,16 +5,16 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.scripting.gradle.importing
|
package org.jetbrains.kotlin.idea.scripting.gradle.importing
|
||||||
|
|
||||||
|
import com.intellij.openapi.externalSystem.model.DataNode
|
||||||
|
import com.intellij.openapi.externalSystem.model.project.ProjectData
|
||||||
|
import org.gradle.tooling.model.idea.IdeaProject
|
||||||
import org.gradle.tooling.model.kotlin.dsl.KotlinDslScriptsModel
|
import org.gradle.tooling.model.kotlin.dsl.KotlinDslScriptsModel
|
||||||
import org.jetbrains.kotlin.gradle.KotlinDslScriptAdditionalTask
|
import org.jetbrains.kotlin.gradle.KotlinDslScriptAdditionalTask
|
||||||
import org.jetbrains.kotlin.gradle.KotlinDslScriptModelProvider
|
import org.jetbrains.kotlin.gradle.KotlinDslScriptModelProvider
|
||||||
import org.jetbrains.kotlin.idea.scripting.gradle.kotlinDslScriptsModelImportSupported
|
import org.jetbrains.kotlin.idea.scripting.gradle.kotlinDslScriptsModelImportSupported
|
||||||
|
import org.jetbrains.plugins.gradle.model.Build
|
||||||
import org.jetbrains.plugins.gradle.model.ClassSetImportModelProvider
|
import org.jetbrains.plugins.gradle.model.ClassSetImportModelProvider
|
||||||
import org.jetbrains.plugins.gradle.model.ProjectImportModelProvider
|
import org.jetbrains.plugins.gradle.model.ProjectImportModelProvider
|
||||||
import org.jetbrains.plugins.gradle.service.project.ModifiableGradleProjectModel
|
|
||||||
import org.jetbrains.plugins.gradle.service.project.ProjectModelContributor
|
|
||||||
import org.jetbrains.plugins.gradle.service.project.ProjectResolverContext
|
|
||||||
import org.jetbrains.plugins.gradle.service.project.ToolingModelsProvider
|
|
||||||
|
|
||||||
class KotlinDslScriptModelResolver : KotlinDslScriptModelResolverCommon() {
|
class KotlinDslScriptModelResolver : KotlinDslScriptModelResolverCommon() {
|
||||||
override fun requiresTaskRunning() = true
|
override fun requiresTaskRunning() = true
|
||||||
@@ -27,22 +27,26 @@ class KotlinDslScriptModelResolver : KotlinDslScriptModelResolverCommon() {
|
|||||||
setOf(KotlinDslScriptAdditionalTask::class.java)
|
setOf(KotlinDslScriptAdditionalTask::class.java)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("UnstableApiUsage")
|
override fun populateProjectExtraModels(gradleProject: IdeaProject, ideProject: DataNode<ProjectData>) {
|
||||||
class KotlinDslScriptModelContributor : ProjectModelContributor {
|
super.populateProjectExtraModels(gradleProject, ideProject)
|
||||||
override fun accept(
|
|
||||||
projectModelBuilder: ModifiableGradleProjectModel,
|
populateBuildModels(resolverCtx.models.mainBuild, ideProject)
|
||||||
toolingModelsProvider: ToolingModelsProvider,
|
|
||||||
resolverCtx: ProjectResolverContext
|
resolverCtx.models.includedBuilds.forEach { includedRoot ->
|
||||||
|
populateBuildModels(includedRoot, ideProject)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun populateBuildModels(
|
||||||
|
root: Build,
|
||||||
|
ideProject: DataNode<ProjectData>
|
||||||
) {
|
) {
|
||||||
toolingModelsProvider.projects().forEach {
|
root.projects.forEach {
|
||||||
val projectIdentifier = it.projectIdentifier.projectPath
|
if (it.projectIdentifier.projectPath == ":") {
|
||||||
if (projectIdentifier == ":") {
|
|
||||||
if (kotlinDslScriptsModelImportSupported(resolverCtx.projectGradleVersion)) {
|
if (kotlinDslScriptsModelImportSupported(resolverCtx.projectGradleVersion)) {
|
||||||
val model = toolingModelsProvider.getProjectModel(it, KotlinDslScriptsModel::class.java)
|
resolverCtx.models.getModel(it, KotlinDslScriptsModel::class.java)?.let { model ->
|
||||||
if (model != null) {
|
processScriptModel(resolverCtx, model, it.projectIdentifier.projectPath)
|
||||||
processScriptModel(resolverCtx, model, projectIdentifier)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+4
-4
@@ -147,8 +147,8 @@ public abstract class AbstractModelBuilderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Set<Class> getToolingExtensionClasses() {
|
private static Set<Class<?>> getToolingExtensionClasses() {
|
||||||
Set<Class> classes = ContainerUtil.<Class>set(
|
Set<Class<?>> classes = ContainerUtil.set(
|
||||||
ExternalProject.class,
|
ExternalProject.class,
|
||||||
// gradle-tooling-extension-api jar
|
// gradle-tooling-extension-api jar
|
||||||
ProjectImportAction.class,
|
ProjectImportAction.class,
|
||||||
@@ -163,7 +163,7 @@ public abstract class AbstractModelBuilderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Set<Class> doGetToolingExtensionClasses() {
|
private static Set<Class<?>> doGetToolingExtensionClasses() {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ public abstract class AbstractModelBuilderTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Set<Class> getModels();
|
protected abstract Set<Class<?>> getModels();
|
||||||
|
|
||||||
|
|
||||||
private static void ensureTempDirCreated() throws IOException {
|
private static void ensureTempDirCreated() throws IOException {
|
||||||
|
|||||||
+4
-4
@@ -147,8 +147,8 @@ public abstract class AbstractModelBuilderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Set<Class<?>> getToolingExtensionClasses() {
|
private static Set<Class> getToolingExtensionClasses() {
|
||||||
Set<Class<?>> classes = ContainerUtil.set(
|
Set<Class> classes = ContainerUtil.<Class>set(
|
||||||
ExternalProject.class,
|
ExternalProject.class,
|
||||||
// gradle-tooling-extension-api jar
|
// gradle-tooling-extension-api jar
|
||||||
ProjectImportAction.class,
|
ProjectImportAction.class,
|
||||||
@@ -163,7 +163,7 @@ public abstract class AbstractModelBuilderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Set<Class<?>> doGetToolingExtensionClasses() {
|
private static Set<Class> doGetToolingExtensionClasses() {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ public abstract class AbstractModelBuilderTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Set<Class<?>> getModels();
|
protected abstract Set<Class> getModels();
|
||||||
|
|
||||||
|
|
||||||
private static void ensureTempDirCreated() throws IOException {
|
private static void ensureTempDirCreated() throws IOException {
|
||||||
@@ -30,15 +30,18 @@ class ShowKotlinBytecodeAction : AnAction() {
|
|||||||
override fun actionPerformed(e: AnActionEvent) {
|
override fun actionPerformed(e: AnActionEvent) {
|
||||||
val project = e.project ?: return
|
val project = e.project ?: return
|
||||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||||
var toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID)
|
|
||||||
if (toolWindow == null) {
|
|
||||||
toolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, false, ToolWindowAnchor.RIGHT)
|
|
||||||
toolWindow.icon = KotlinIcons.SMALL_LOGO_13
|
|
||||||
|
|
||||||
val contentManager = toolWindow.contentManager
|
val toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID) ?: toolWindowManager.registerToolWindow(
|
||||||
val contentFactory = ContentFactory.SERVICE.getInstance()
|
TOOLWINDOW_ID,
|
||||||
contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, toolWindow), "", false))
|
false,
|
||||||
}
|
ToolWindowAnchor.RIGHT,
|
||||||
|
)
|
||||||
|
.apply {
|
||||||
|
setIcon(KotlinIcons.SMALL_LOGO_13)
|
||||||
|
val contentFactory = ContentFactory.SERVICE.getInstance()
|
||||||
|
contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, this), "", false))
|
||||||
|
}
|
||||||
|
|
||||||
toolWindow.activate(null)
|
toolWindow.activate(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-11
@@ -30,18 +30,15 @@ class ShowKotlinBytecodeAction : AnAction() {
|
|||||||
override fun actionPerformed(e: AnActionEvent) {
|
override fun actionPerformed(e: AnActionEvent) {
|
||||||
val project = e.project ?: return
|
val project = e.project ?: return
|
||||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||||
|
var toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID)
|
||||||
|
if (toolWindow == null) {
|
||||||
|
toolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, false, ToolWindowAnchor.RIGHT)
|
||||||
|
toolWindow.icon = KotlinIcons.SMALL_LOGO_13
|
||||||
|
|
||||||
val toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID) ?: toolWindowManager.registerToolWindow(
|
val contentManager = toolWindow.contentManager
|
||||||
TOOLWINDOW_ID,
|
val contentFactory = ContentFactory.SERVICE.getInstance()
|
||||||
false,
|
contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, toolWindow), "", false))
|
||||||
ToolWindowAnchor.RIGHT,
|
}
|
||||||
)
|
|
||||||
.apply {
|
|
||||||
setIcon(KotlinIcons.SMALL_LOGO_13)
|
|
||||||
val contentFactory = ContentFactory.SERVICE.getInstance()
|
|
||||||
contentManager.addContent(contentFactory.createContent(KotlinBytecodeToolWindow(project, this), "", false))
|
|
||||||
}
|
|
||||||
|
|
||||||
toolWindow.activate(null)
|
toolWindow.activate(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
+32
-42
@@ -20,12 +20,12 @@ import com.intellij.execution.filters.OpenFileHyperlinkInfo
|
|||||||
import com.intellij.execution.impl.ConsoleViewImpl
|
import com.intellij.execution.impl.ConsoleViewImpl
|
||||||
import com.intellij.execution.runners.ExecutionUtil
|
import com.intellij.execution.runners.ExecutionUtil
|
||||||
import com.intellij.execution.ui.ConsoleViewContentType
|
import com.intellij.execution.ui.ConsoleViewContentType
|
||||||
|
import com.intellij.ide.scratch.ScratchFileType
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.application.TransactionGuard
|
import com.intellij.openapi.application.TransactionGuard
|
||||||
import com.intellij.openapi.command.WriteCommandAction
|
import com.intellij.openapi.command.WriteCommandAction
|
||||||
import com.intellij.openapi.editor.ex.EditorEx
|
import com.intellij.openapi.editor.ex.EditorEx
|
||||||
import com.intellij.openapi.fileTypes.PlainTextFileType
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.Disposer
|
import com.intellij.openapi.util.Disposer
|
||||||
import com.intellij.openapi.wm.ToolWindow
|
import com.intellij.openapi.wm.ToolWindow
|
||||||
@@ -113,8 +113,8 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
|||||||
OpenFileHyperlinkInfo(
|
OpenFileHyperlinkInfo(
|
||||||
project,
|
project,
|
||||||
psiFile.virtualFile,
|
psiFile.virtualFile,
|
||||||
expression.lineStart,
|
expression.lineStart
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
print(" ", ConsoleViewContentType.NORMAL_OUTPUT)
|
print(" ", ConsoleViewContentType.NORMAL_OUTPUT)
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
|||||||
toolWindow.show(null)
|
toolWindow.show(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
toolWindow.icon = ExecutionUtil.getLiveIndicator(scratchIcon())
|
toolWindow.setIcon(ExecutionUtil.getLiveIndicator(ScratchFileType.INSTANCE.icon))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
|||||||
toolWindow.hide(null)
|
toolWindow.hide(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
toolWindow.icon = scratchIcon()
|
toolWindow.setIcon(ScratchFileType.INSTANCE.icon ?: error("Text icon is expected to be present"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,22 +187,18 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
|||||||
val project = file.project
|
val project = file.project
|
||||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||||
toolWindowManager.registerToolWindow(ScratchToolWindowFactory.ID, true, ToolWindowAnchor.BOTTOM)
|
toolWindowManager.registerToolWindow(ScratchToolWindowFactory.ID, true, ToolWindowAnchor.BOTTOM)
|
||||||
val window = toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID)
|
val window =
|
||||||
|
toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID) ?: error("ScratchToolWindowFactory.ID should be registered")
|
||||||
ScratchToolWindowFactory().createToolWindowContent(project, window)
|
ScratchToolWindowFactory().createToolWindowContent(project, window)
|
||||||
|
|
||||||
Disposer.register(
|
Disposer.register(parentDisposable, Disposable {
|
||||||
parentDisposable,
|
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID)
|
||||||
Disposable {
|
})
|
||||||
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
return window
|
return window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scratchIcon() = PlainTextFileType.INSTANCE.icon
|
|
||||||
|
|
||||||
private fun getLineInfo(psiFile: PsiFile, expression: ScratchExpression) =
|
private fun getLineInfo(psiFile: PsiFile, expression: ScratchExpression) =
|
||||||
"${psiFile.name}:${expression.lineStart + 1}"
|
"${psiFile.name}:${expression.lineStart + 1}"
|
||||||
|
|
||||||
@@ -213,8 +209,8 @@ private class ScratchToolWindowFactory : ToolWindowFactory {
|
|||||||
|
|
||||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||||
val consoleView = ConsoleViewImpl(project, true)
|
val consoleView = ConsoleViewImpl(project, true)
|
||||||
toolWindow.isToHideOnEmptyContent = true
|
toolWindow.setToHideOnEmptyContent(true)
|
||||||
toolWindow.icon = scratchIcon()
|
toolWindow.setIcon(ScratchFileType.INSTANCE.icon ?: error("Text icon should be present"))
|
||||||
toolWindow.hide(null)
|
toolWindow.hide(null)
|
||||||
|
|
||||||
val contentManager = toolWindow.contentManager
|
val contentManager = toolWindow.contentManager
|
||||||
@@ -242,33 +238,27 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinish(file: ScratchFile) {
|
override fun onFinish(file: ScratchFile) {
|
||||||
TransactionGuard.submitTransaction(
|
TransactionGuard.submitTransaction(file.project, Runnable {
|
||||||
file.project,
|
val psiFile = file.getPsiFile()
|
||||||
Runnable {
|
?: error(
|
||||||
val psiFile = file.getPsiFile()
|
"PsiFile cannot be found for scratch to render inlays in tests:\n" +
|
||||||
?: error(
|
"project.isDisposed = ${file.project.isDisposed}\n" +
|
||||||
"PsiFile cannot be found for scratch to render inlays in tests:\n" +
|
"inlays = ${inlays.joinToString { it.second }}\n" +
|
||||||
"project.isDisposed = ${file.project.isDisposed}\n" +
|
"errors = ${errors.joinToString()}"
|
||||||
"inlays = ${inlays.joinToString { it.second }}\n" +
|
)
|
||||||
"errors = ${errors.joinToString()}",
|
|
||||||
)
|
|
||||||
|
|
||||||
if (inlays.isNotEmpty()) {
|
if (inlays.isNotEmpty()) {
|
||||||
testPrint(
|
testPrint(psiFile, inlays.map { (expression, text) ->
|
||||||
psiFile,
|
"/** ${getLineInfo(psiFile, expression)} $text */"
|
||||||
inlays.map { (expression, text) ->
|
})
|
||||||
"/** ${getLineInfo(psiFile, expression)} $text */"
|
inlays.clear()
|
||||||
},
|
}
|
||||||
)
|
|
||||||
inlays.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errors.isNotEmpty()) {
|
if (errors.isNotEmpty()) {
|
||||||
testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */")))
|
testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */")))
|
||||||
errors.clear()
|
errors.clear()
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun testPrint(file: PsiFile, comments: List<String>) {
|
private fun testPrint(file: PsiFile, comments: List<String>) {
|
||||||
@@ -276,7 +266,7 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
|
|||||||
for (comment in comments) {
|
for (comment in comments) {
|
||||||
file.addAfter(
|
file.addAfter(
|
||||||
KtPsiFactory(file.project).createComment(comment),
|
KtPsiFactory(file.project).createComment(comment),
|
||||||
file.lastChild,
|
file.lastChild
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-32
@@ -20,12 +20,12 @@ import com.intellij.execution.filters.OpenFileHyperlinkInfo
|
|||||||
import com.intellij.execution.impl.ConsoleViewImpl
|
import com.intellij.execution.impl.ConsoleViewImpl
|
||||||
import com.intellij.execution.runners.ExecutionUtil
|
import com.intellij.execution.runners.ExecutionUtil
|
||||||
import com.intellij.execution.ui.ConsoleViewContentType
|
import com.intellij.execution.ui.ConsoleViewContentType
|
||||||
import com.intellij.ide.scratch.ScratchFileType
|
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.application.TransactionGuard
|
import com.intellij.openapi.application.TransactionGuard
|
||||||
import com.intellij.openapi.command.WriteCommandAction
|
import com.intellij.openapi.command.WriteCommandAction
|
||||||
import com.intellij.openapi.editor.ex.EditorEx
|
import com.intellij.openapi.editor.ex.EditorEx
|
||||||
|
import com.intellij.openapi.fileTypes.PlainTextFileType
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.Disposer
|
import com.intellij.openapi.util.Disposer
|
||||||
import com.intellij.openapi.wm.ToolWindow
|
import com.intellij.openapi.wm.ToolWindow
|
||||||
@@ -113,8 +113,8 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
|||||||
OpenFileHyperlinkInfo(
|
OpenFileHyperlinkInfo(
|
||||||
project,
|
project,
|
||||||
psiFile.virtualFile,
|
psiFile.virtualFile,
|
||||||
expression.lineStart
|
expression.lineStart,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
print(" ", ConsoleViewContentType.NORMAL_OUTPUT)
|
print(" ", ConsoleViewContentType.NORMAL_OUTPUT)
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
|||||||
toolWindow.show(null)
|
toolWindow.show(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
toolWindow.setIcon(ExecutionUtil.getLiveIndicator(ScratchFileType.INSTANCE.icon))
|
toolWindow.icon = ExecutionUtil.getLiveIndicator(scratchIcon())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
|||||||
toolWindow.hide(null)
|
toolWindow.hide(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
toolWindow.setIcon(ScratchFileType.INSTANCE.icon ?: error("Text icon is expected to be present"))
|
toolWindow.icon = scratchIcon()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,18 +187,22 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
|
|||||||
val project = file.project
|
val project = file.project
|
||||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||||
toolWindowManager.registerToolWindow(ScratchToolWindowFactory.ID, true, ToolWindowAnchor.BOTTOM)
|
toolWindowManager.registerToolWindow(ScratchToolWindowFactory.ID, true, ToolWindowAnchor.BOTTOM)
|
||||||
val window =
|
val window = toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID)
|
||||||
toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID) ?: error("ScratchToolWindowFactory.ID should be registered")
|
|
||||||
ScratchToolWindowFactory().createToolWindowContent(project, window)
|
ScratchToolWindowFactory().createToolWindowContent(project, window)
|
||||||
|
|
||||||
Disposer.register(parentDisposable, Disposable {
|
Disposer.register(
|
||||||
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID)
|
parentDisposable,
|
||||||
})
|
Disposable {
|
||||||
|
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
return window
|
return window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun scratchIcon() = PlainTextFileType.INSTANCE.icon
|
||||||
|
|
||||||
private fun getLineInfo(psiFile: PsiFile, expression: ScratchExpression) =
|
private fun getLineInfo(psiFile: PsiFile, expression: ScratchExpression) =
|
||||||
"${psiFile.name}:${expression.lineStart + 1}"
|
"${psiFile.name}:${expression.lineStart + 1}"
|
||||||
|
|
||||||
@@ -209,8 +213,8 @@ private class ScratchToolWindowFactory : ToolWindowFactory {
|
|||||||
|
|
||||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||||
val consoleView = ConsoleViewImpl(project, true)
|
val consoleView = ConsoleViewImpl(project, true)
|
||||||
toolWindow.setToHideOnEmptyContent(true)
|
toolWindow.isToHideOnEmptyContent = true
|
||||||
toolWindow.setIcon(ScratchFileType.INSTANCE.icon ?: error("Text icon should be present"))
|
toolWindow.icon = scratchIcon()
|
||||||
toolWindow.hide(null)
|
toolWindow.hide(null)
|
||||||
|
|
||||||
val contentManager = toolWindow.contentManager
|
val contentManager = toolWindow.contentManager
|
||||||
@@ -238,27 +242,33 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinish(file: ScratchFile) {
|
override fun onFinish(file: ScratchFile) {
|
||||||
TransactionGuard.submitTransaction(file.project, Runnable {
|
TransactionGuard.submitTransaction(
|
||||||
val psiFile = file.getPsiFile()
|
file.project,
|
||||||
?: error(
|
Runnable {
|
||||||
"PsiFile cannot be found for scratch to render inlays in tests:\n" +
|
val psiFile = file.getPsiFile()
|
||||||
"project.isDisposed = ${file.project.isDisposed}\n" +
|
?: error(
|
||||||
"inlays = ${inlays.joinToString { it.second }}\n" +
|
"PsiFile cannot be found for scratch to render inlays in tests:\n" +
|
||||||
"errors = ${errors.joinToString()}"
|
"project.isDisposed = ${file.project.isDisposed}\n" +
|
||||||
)
|
"inlays = ${inlays.joinToString { it.second }}\n" +
|
||||||
|
"errors = ${errors.joinToString()}",
|
||||||
|
)
|
||||||
|
|
||||||
if (inlays.isNotEmpty()) {
|
if (inlays.isNotEmpty()) {
|
||||||
testPrint(psiFile, inlays.map { (expression, text) ->
|
testPrint(
|
||||||
"/** ${getLineInfo(psiFile, expression)} $text */"
|
psiFile,
|
||||||
})
|
inlays.map { (expression, text) ->
|
||||||
inlays.clear()
|
"/** ${getLineInfo(psiFile, expression)} $text */"
|
||||||
}
|
},
|
||||||
|
)
|
||||||
|
inlays.clear()
|
||||||
|
}
|
||||||
|
|
||||||
if (errors.isNotEmpty()) {
|
if (errors.isNotEmpty()) {
|
||||||
testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */")))
|
testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */")))
|
||||||
errors.clear()
|
errors.clear()
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun testPrint(file: PsiFile, comments: List<String>) {
|
private fun testPrint(file: PsiFile, comments: List<String>) {
|
||||||
@@ -266,7 +276,7 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
|
|||||||
for (comment in comments) {
|
for (comment in comments) {
|
||||||
file.addAfter(
|
file.addAfter(
|
||||||
KtPsiFactory(file.project).createComment(comment),
|
KtPsiFactory(file.project).createComment(comment),
|
||||||
file.lastChild
|
file.lastChild,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
|||||||
import com.intellij.ui.JBSplitter;
|
import com.intellij.ui.JBSplitter;
|
||||||
import com.intellij.util.ui.JBUI;
|
import com.intellij.util.ui.JBUI;
|
||||||
import com.intellij.util.ui.UIUtil;
|
import com.intellij.util.ui.UIUtil;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.idea.KotlinJvmBundle;
|
import org.jetbrains.kotlin.idea.KotlinJvmBundle;
|
||||||
@@ -473,7 +472,6 @@ class SplitEditorToolbar extends JPanel implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ApiStatus.ScheduledForRemoval
|
|
||||||
public void addGutterToTrack(@NotNull EditorGutterComponentEx gutterComponentEx) {}
|
public void addGutterToTrack(@NotNull EditorGutterComponentEx gutterComponentEx) {}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
@@ -481,7 +479,6 @@ class SplitEditorToolbar extends JPanel implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ApiStatus.ScheduledForRemoval
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {}
|
public void dispose() {}
|
||||||
}
|
}
|
||||||
+3
@@ -22,6 +22,7 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
|||||||
import com.intellij.ui.JBSplitter;
|
import com.intellij.ui.JBSplitter;
|
||||||
import com.intellij.util.ui.JBUI;
|
import com.intellij.util.ui.JBUI;
|
||||||
import com.intellij.util.ui.UIUtil;
|
import com.intellij.util.ui.UIUtil;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.idea.KotlinJvmBundle;
|
import org.jetbrains.kotlin.idea.KotlinJvmBundle;
|
||||||
@@ -472,6 +473,7 @@ class SplitEditorToolbar extends JPanel implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval
|
||||||
public void addGutterToTrack(@NotNull EditorGutterComponentEx gutterComponentEx) {}
|
public void addGutterToTrack(@NotNull EditorGutterComponentEx gutterComponentEx) {}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
@@ -479,6 +481,7 @@ class SplitEditorToolbar extends JPanel implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {}
|
public void dispose() {}
|
||||||
}
|
}
|
||||||
@@ -11,5 +11,5 @@ import com.intellij.openapi.project.Project
|
|||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun setTemplateTestingCompat(project: Project, disposable: Disposable) {
|
fun setTemplateTestingCompat(project: Project, disposable: Disposable) {
|
||||||
TemplateManagerImpl.setTemplateTesting(project, disposable)
|
TemplateManagerImpl.setTemplateTesting(disposable)
|
||||||
}
|
}
|
||||||
+1
-1
@@ -11,5 +11,5 @@ import com.intellij.openapi.project.Project
|
|||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun setTemplateTestingCompat(project: Project, disposable: Disposable) {
|
fun setTemplateTestingCompat(project: Project, disposable: Disposable) {
|
||||||
TemplateManagerImpl.setTemplateTesting(disposable)
|
TemplateManagerImpl.setTemplateTesting(project, disposable)
|
||||||
}
|
}
|
||||||
+1
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.isGradle
|
|||||||
import org.jetbrains.plugins.gradle.service.project.open.linkAndRefreshGradleProject
|
import org.jetbrains.plugins.gradle.service.project.open.linkAndRefreshGradleProject
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
// FIX ME WHEN BUNCH 201 REMOVED
|
||||||
class IdeaGradleWizardService(private val project: Project) : ProjectImportingWizardService,
|
class IdeaGradleWizardService(private val project: Project) : ProjectImportingWizardService,
|
||||||
IdeaWizardService {
|
IdeaWizardService {
|
||||||
override fun isSuitableFor(buildSystemType: BuildSystemType): Boolean =
|
override fun isSuitableFor(buildSystemType: BuildSystemType): Boolean =
|
||||||
|
|||||||
-1
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.isGradle
|
|||||||
import org.jetbrains.plugins.gradle.service.project.open.linkAndRefreshGradleProject
|
import org.jetbrains.plugins.gradle.service.project.open.linkAndRefreshGradleProject
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 201 REMOVED
|
|
||||||
class IdeaGradleWizardService(private val project: Project) : ProjectImportingWizardService,
|
class IdeaGradleWizardService(private val project: Project) : ProjectImportingWizardService,
|
||||||
IdeaWizardService {
|
IdeaWizardService {
|
||||||
override fun isSuitableFor(buildSystemType: BuildSystemType): Boolean =
|
override fun isSuitableFor(buildSystemType: BuildSystemType): Boolean =
|
||||||
@@ -41,12 +41,14 @@ class ConsoleCompilerHelper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun compileModule() {
|
fun compileModule() {
|
||||||
if (ExecutionManager.getInstance(project).contentManager.removeRunContent(executor, contentDescriptor)) {
|
if (ExecutionManager.getInstance(project).getContentManager().removeRunContent(executor, contentDescriptor)) {
|
||||||
ProjectTaskManager.getInstance(project).build(module).onSuccess { executionResult ->
|
ProjectTaskManager.getInstance(project).build(arrayOf(module), object : ProjectTaskNotification {
|
||||||
if (!module.isDisposed) {
|
override fun finished(context: ProjectTaskContext, executionResult: ProjectTaskResult) {
|
||||||
KotlinConsoleKeeper.getInstance(project).run(module, previousCompilationFailed = executionResult.hasErrors())
|
if (!module.isDisposed) {
|
||||||
|
KotlinConsoleKeeper.getInstance(project).run(module, previousCompilationFailed = executionResult.errors > 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-7
@@ -41,14 +41,12 @@ class ConsoleCompilerHelper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun compileModule() {
|
fun compileModule() {
|
||||||
if (ExecutionManager.getInstance(project).getContentManager().removeRunContent(executor, contentDescriptor)) {
|
if (ExecutionManager.getInstance(project).contentManager.removeRunContent(executor, contentDescriptor)) {
|
||||||
ProjectTaskManager.getInstance(project).build(arrayOf(module), object : ProjectTaskNotification {
|
ProjectTaskManager.getInstance(project).build(module).onSuccess { executionResult ->
|
||||||
override fun finished(context: ProjectTaskContext, executionResult: ProjectTaskResult) {
|
if (!module.isDisposed) {
|
||||||
if (!module.isDisposed) {
|
KotlinConsoleKeeper.getInstance(project).run(module, previousCompilationFailed = executionResult.hasErrors())
|
||||||
KotlinConsoleKeeper.getInstance(project).run(module, previousCompilationFailed = executionResult.errors > 0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,5 +17,5 @@ fun editorTrackerProjectOpened(project: Project) {
|
|||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun runPostStartupActivitiesOnce(project: Project) {
|
fun runPostStartupActivitiesOnce(project: Project) {
|
||||||
(StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities()
|
(StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivitiesRegisteredDynamically()
|
||||||
}
|
}
|
||||||
+1
-1
@@ -17,5 +17,5 @@ fun editorTrackerProjectOpened(project: Project) {
|
|||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun runPostStartupActivitiesOnce(project: Project) {
|
fun runPostStartupActivitiesOnce(project: Project) {
|
||||||
(StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivitiesRegisteredDynamically()
|
(StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities()
|
||||||
}
|
}
|
||||||
+79
-53
@@ -6,20 +6,22 @@
|
|||||||
package org.jetbrains.kotlin.idea.debugger.coroutine.data
|
package org.jetbrains.kotlin.idea.debugger.coroutine.data
|
||||||
|
|
||||||
import com.intellij.debugger.engine.DebugProcessImpl
|
import com.intellij.debugger.engine.DebugProcessImpl
|
||||||
import com.intellij.debugger.engine.JVMStackFrameInfoProvider
|
import com.intellij.debugger.engine.JavaStackFrame
|
||||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
|
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
|
||||||
import com.intellij.debugger.jdi.StackFrameProxyImpl
|
import com.intellij.debugger.jdi.StackFrameProxyImpl
|
||||||
import com.intellij.debugger.memory.utils.StackFrameItem
|
import com.intellij.debugger.memory.utils.StackFrameItem
|
||||||
|
import com.intellij.debugger.ui.tree.render.DescriptorLabelListener
|
||||||
|
import com.intellij.xdebugger.XSourcePosition
|
||||||
import com.intellij.xdebugger.frame.XCompositeNode
|
import com.intellij.xdebugger.frame.XCompositeNode
|
||||||
import com.intellij.xdebugger.frame.XNamedValue
|
import com.intellij.xdebugger.frame.XNamedValue
|
||||||
import com.intellij.xdebugger.frame.XStackFrame
|
import com.intellij.xdebugger.frame.XStackFrame
|
||||||
import com.intellij.xdebugger.frame.XValueChildrenList
|
import com.intellij.xdebugger.frame.XValueChildrenList
|
||||||
|
import com.intellij.xdebugger.impl.frame.XDebuggerFramesList
|
||||||
import com.sun.jdi.Location
|
import com.sun.jdi.Location
|
||||||
import org.jetbrains.kotlin.idea.debugger.*
|
import org.jetbrains.kotlin.idea.debugger.*
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.KotlinDebuggerCoroutinesBundle
|
import org.jetbrains.kotlin.idea.debugger.coroutine.KotlinDebuggerCoroutinesBundle
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.proxy.LocationStackFrameProxyImpl
|
import org.jetbrains.kotlin.idea.debugger.coroutine.proxy.LocationStackFrameProxyImpl
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.util.findPosition
|
import org.jetbrains.kotlin.idea.debugger.coroutine.util.findPosition
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.util.isFilteredInvokeSuspend
|
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.util.logger
|
import org.jetbrains.kotlin.idea.debugger.coroutine.util.logger
|
||||||
import org.jetbrains.kotlin.idea.debugger.stackFrame.KotlinStackFrame
|
import org.jetbrains.kotlin.idea.debugger.stackFrame.KotlinStackFrame
|
||||||
|
|
||||||
@@ -32,12 +34,12 @@ class CreationCoroutineStackFrameItem(
|
|||||||
val first: Boolean
|
val first: Boolean
|
||||||
) : CoroutineStackFrameItem(location, emptyList()) {
|
) : CoroutineStackFrameItem(location, emptyList()) {
|
||||||
|
|
||||||
override fun createFrame(debugProcess: DebugProcessImpl): CoroutineGeneratedFrame? {
|
override fun createFrame(debugProcess: DebugProcessImpl): XStackFrame? {
|
||||||
return debugProcess.invokeInManagerThread {
|
return debugProcess.invokeInManagerThread {
|
||||||
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
||||||
val locationFrame = LocationStackFrameProxyImpl(location, frame)
|
val locationFrame = LocationStackFrameProxyImpl(location, frame)
|
||||||
val position = location.findPosition(debugProcess.project)
|
val position = location.findPosition(debugProcess.project)
|
||||||
CreationCoroutineStackFrame(debugProcess, this, first)
|
CreationCoroutineStackFrame(locationFrame, position, first)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,18 +53,19 @@ class SuspendCoroutineStackFrameItem(
|
|||||||
spilledVariables: List<XNamedValue> = emptyList()
|
spilledVariables: List<XNamedValue> = emptyList()
|
||||||
) : CoroutineStackFrameItem(location, spilledVariables)
|
) : CoroutineStackFrameItem(location, spilledVariables)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restored from memory dump
|
* Restored from memory dump
|
||||||
*/
|
*/
|
||||||
class DefaultCoroutineStackFrameItem(location: Location, spilledVariables: List<XNamedValue>) :
|
class DefaultCoroutineStackFrameItem(location: Location, spilledVariables: List<XNamedValue>) :
|
||||||
CoroutineStackFrameItem(location, spilledVariables) {
|
CoroutineStackFrameItem(location, spilledVariables) {
|
||||||
|
|
||||||
override fun createFrame(debugProcess: DebugProcessImpl): CoroutineGeneratedFrame? {
|
override fun createFrame(debugProcess: DebugProcessImpl): XStackFrame? {
|
||||||
return debugProcess.invokeInManagerThread {
|
return debugProcess.invokeInManagerThread {
|
||||||
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
||||||
val locationStackFrameProxyImpl = LocationStackFrameProxyImpl(location, frame)
|
val locationStackFrameProxyImpl = LocationStackFrameProxyImpl(location, frame)
|
||||||
val position = location.findPosition(debugProcess.project) ?: return@invokeInManagerThread null
|
val position = location.findPosition(debugProcess.project) ?: return@invokeInManagerThread null
|
||||||
CoroutineStackFrame(debugProcess, this)
|
CoroutineStackFrame(locationStackFrameProxyImpl, position, spilledVariables, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,24 +85,25 @@ class DefaultCoroutineStackFrameItem(location: Location, spilledVariables: List<
|
|||||||
open class RunningCoroutineStackFrameItem(
|
open class RunningCoroutineStackFrameItem(
|
||||||
val frame: StackFrameProxyImpl,
|
val frame: StackFrameProxyImpl,
|
||||||
spilledVariables: List<XNamedValue> = emptyList()
|
spilledVariables: List<XNamedValue> = emptyList()
|
||||||
) : CoroutineStackFrameItem(frame.location(), spilledVariables), FrameProvider {
|
) : CoroutineStackFrameItem(frame.location(), spilledVariables) {
|
||||||
override fun createFrame(debugProcess: DebugProcessImpl): CoroutineGeneratedFrame? {
|
override fun createFrame(debugProcess: DebugProcessImpl): XStackFrame? {
|
||||||
return debugProcess.invokeInManagerThread {
|
return debugProcess.invokeInManagerThread {
|
||||||
CoroutineStackFrame(debugProcess, this)
|
val position = frame.location().findPosition(debugProcess.project)
|
||||||
|
CoroutineStackFrame(frame, position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun provideFrame(debugProcess: DebugProcessImpl): XStackFrame? =
|
|
||||||
debugProcess.invokeInManagerThread { KotlinStackFrame(frame) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class CoroutineStackFrameItem(val location: Location, val spilledVariables: List<XNamedValue>) :
|
sealed class CoroutineStackFrameItem(val location: Location, val spilledVariables: List<XNamedValue>) :
|
||||||
StackFrameItem(location, spilledVariables) {
|
StackFrameItem(location, spilledVariables) {
|
||||||
val log by logger
|
val log by logger
|
||||||
|
|
||||||
override fun createFrame(debugProcess: DebugProcessImpl): CoroutineGeneratedFrame? {
|
override fun createFrame(debugProcess: DebugProcessImpl): XStackFrame? {
|
||||||
return debugProcess.invokeInManagerThread {
|
return debugProcess.invokeInManagerThread {
|
||||||
CoroutineStackFrame(debugProcess, this)
|
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
||||||
|
val locationFrame = LocationStackFrameProxyImpl(location, frame)
|
||||||
|
val position = location.findPosition(debugProcess.project)
|
||||||
|
CoroutineStackFrame(locationFrame, position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,10 +112,6 @@ sealed class CoroutineStackFrameItem(val location: Location, val spilledVariable
|
|||||||
location.safeLineNumber() + ":" + location.safeKotlinPreferredLineNumber()
|
location.safeLineNumber() + ":" + location.safeKotlinPreferredLineNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FrameProvider {
|
|
||||||
fun provideFrame(debugProcess: DebugProcessImpl): XStackFrame?
|
|
||||||
}
|
|
||||||
|
|
||||||
fun DebugProcessImpl.findFirstFrame(): StackFrameProxyImpl? =
|
fun DebugProcessImpl.findFirstFrame(): StackFrameProxyImpl? =
|
||||||
suspendManager.pausedContext.thread?.forceFrames()?.firstOrNull()
|
suspendManager.pausedContext.thread?.forceFrames()?.firstOrNull()
|
||||||
|
|
||||||
@@ -123,19 +123,71 @@ fun DebugProcessImpl.findFirstFrame(): StackFrameProxyImpl? =
|
|||||||
*/
|
*/
|
||||||
class CoroutinePreflightFrame(
|
class CoroutinePreflightFrame(
|
||||||
val coroutineInfoData: CoroutineInfoData,
|
val coroutineInfoData: CoroutineInfoData,
|
||||||
private val frame: StackFrameProxyImpl,
|
val frame: StackFrameProxyImpl,
|
||||||
val threadPreCoroutineFrames: List<StackFrameProxyImpl>,
|
val threadPreCoroutineFrames: List<StackFrameProxyImpl>,
|
||||||
val mode: SuspendExitMode
|
val mode: SuspendExitMode,
|
||||||
) : KotlinStackFrame(frame), JVMStackFrameInfoProvider {
|
private val firstFrameVariables: List<XNamedValue> = coroutineInfoData.topFrameVariables()
|
||||||
|
) : CoroutineStackFrame(frame, null, firstFrameVariables) {
|
||||||
|
|
||||||
|
override fun isInLibraryContent() = false
|
||||||
|
|
||||||
|
override fun isSynthetic() = false
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class CreationCoroutineStackFrame(
|
||||||
|
frame: StackFrameProxyImpl,
|
||||||
|
sourcePosition: XSourcePosition?,
|
||||||
|
val first: Boolean
|
||||||
|
) : CoroutineStackFrame(frame, sourcePosition, emptyList(), false), XDebuggerFramesList.ItemWithSeparatorAbove {
|
||||||
|
|
||||||
|
override fun getCaptionAboveOf() =
|
||||||
|
KotlinDebuggerCoroutinesBundle.message("coroutine.dump.creation.trace")
|
||||||
|
|
||||||
|
override fun hasSeparatorAbove() =
|
||||||
|
first
|
||||||
|
}
|
||||||
|
|
||||||
|
open class CoroutineStackFrame(
|
||||||
|
frame: StackFrameProxyImpl,
|
||||||
|
val position: XSourcePosition?,
|
||||||
|
private val spilledVariables: List<XNamedValue>? = null,
|
||||||
|
private val includeFrameVariables: Boolean = true,
|
||||||
|
) : KotlinStackFrame(frame) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
descriptor.updateRepresentation(null, DescriptorLabelListener.DUMMY_LISTENER)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
|
||||||
|
val frame = other as? JavaStackFrame ?: return false
|
||||||
|
|
||||||
|
return descriptor.frameProxy == frame.descriptor.frameProxy
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return descriptor.frameProxy.hashCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun computeChildren(node: XCompositeNode) {
|
||||||
|
if (includeFrameVariables || spilledVariables == null) {
|
||||||
|
super.computeChildren(node)
|
||||||
|
} else {
|
||||||
|
// ignore original frame variables
|
||||||
|
val list = XValueChildrenList()
|
||||||
|
spilledVariables.forEach { list.add(it) }
|
||||||
|
node.addChildren(list, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun superBuildVariables(evaluationContext: EvaluationContextImpl, children: XValueChildrenList) {
|
override fun superBuildVariables(evaluationContext: EvaluationContextImpl, children: XValueChildrenList) {
|
||||||
super.superBuildVariables(evaluationContext, children)
|
super.superBuildVariables(evaluationContext, children)
|
||||||
val topRestoredFrame = coroutineInfoData.stackTrace.firstOrNull()
|
if (spilledVariables != null) {
|
||||||
if (topRestoredFrame != null && topRestoredFrame.location.isFilteredInvokeSuspend()) {
|
|
||||||
val firstFrameVariables: List<XNamedValue> = topRestoredFrame.spilledVariables
|
|
||||||
children.let {
|
children.let {
|
||||||
val varNames = (0 until children.size()).map { children.getName(it) }.toSet()
|
val varNames = (0 until children.size()).map { children.getName(it) }.toSet()
|
||||||
firstFrameVariables.forEach {
|
spilledVariables.forEach {
|
||||||
if (!varNames.contains(it.name))
|
if (!varNames.contains(it.name))
|
||||||
children.add(it)
|
children.add(it)
|
||||||
}
|
}
|
||||||
@@ -143,32 +195,6 @@ class CoroutinePreflightFrame(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isInLibraryContent() = false
|
override fun getSourcePosition() =
|
||||||
|
position ?: super.getSourcePosition()
|
||||||
override fun isSynthetic() = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CreationCoroutineStackFrame(debugProcess: DebugProcessImpl, item: CoroutineStackFrameItem, val first: Boolean) : CoroutineStackFrame(debugProcess, item) {
|
|
||||||
override fun getCaptionAboveOf() = KotlinDebuggerCoroutinesBundle.message("coroutine.dump.creation.trace")
|
|
||||||
|
|
||||||
override fun hasSeparatorAbove(): Boolean =
|
|
||||||
first
|
|
||||||
}
|
|
||||||
|
|
||||||
open class CoroutineStackFrame(val debugProcess: DebugProcessImpl, val item: CoroutineStackFrameItem) :
|
|
||||||
StackFrameItem.CapturedStackFrame(debugProcess, item) {
|
|
||||||
|
|
||||||
override fun computeChildren(node: XCompositeNode) {
|
|
||||||
if (item is FrameProvider)
|
|
||||||
item.provideFrame(debugProcess)?.computeChildren(node)
|
|
||||||
else
|
|
||||||
super.computeChildren(node)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getCaptionAboveOf() = "CoroutineExit"
|
|
||||||
|
|
||||||
override fun hasSeparatorAbove(): Boolean =
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
typealias CoroutineGeneratedFrame = StackFrameItem.CapturedStackFrame
|
|
||||||
+53
-79
@@ -6,22 +6,20 @@
|
|||||||
package org.jetbrains.kotlin.idea.debugger.coroutine.data
|
package org.jetbrains.kotlin.idea.debugger.coroutine.data
|
||||||
|
|
||||||
import com.intellij.debugger.engine.DebugProcessImpl
|
import com.intellij.debugger.engine.DebugProcessImpl
|
||||||
import com.intellij.debugger.engine.JavaStackFrame
|
import com.intellij.debugger.engine.JVMStackFrameInfoProvider
|
||||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
|
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
|
||||||
import com.intellij.debugger.jdi.StackFrameProxyImpl
|
import com.intellij.debugger.jdi.StackFrameProxyImpl
|
||||||
import com.intellij.debugger.memory.utils.StackFrameItem
|
import com.intellij.debugger.memory.utils.StackFrameItem
|
||||||
import com.intellij.debugger.ui.tree.render.DescriptorLabelListener
|
|
||||||
import com.intellij.xdebugger.XSourcePosition
|
|
||||||
import com.intellij.xdebugger.frame.XCompositeNode
|
import com.intellij.xdebugger.frame.XCompositeNode
|
||||||
import com.intellij.xdebugger.frame.XNamedValue
|
import com.intellij.xdebugger.frame.XNamedValue
|
||||||
import com.intellij.xdebugger.frame.XStackFrame
|
import com.intellij.xdebugger.frame.XStackFrame
|
||||||
import com.intellij.xdebugger.frame.XValueChildrenList
|
import com.intellij.xdebugger.frame.XValueChildrenList
|
||||||
import com.intellij.xdebugger.impl.frame.XDebuggerFramesList
|
|
||||||
import com.sun.jdi.Location
|
import com.sun.jdi.Location
|
||||||
import org.jetbrains.kotlin.idea.debugger.*
|
import org.jetbrains.kotlin.idea.debugger.*
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.KotlinDebuggerCoroutinesBundle
|
import org.jetbrains.kotlin.idea.debugger.coroutine.KotlinDebuggerCoroutinesBundle
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.proxy.LocationStackFrameProxyImpl
|
import org.jetbrains.kotlin.idea.debugger.coroutine.proxy.LocationStackFrameProxyImpl
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.util.findPosition
|
import org.jetbrains.kotlin.idea.debugger.coroutine.util.findPosition
|
||||||
|
import org.jetbrains.kotlin.idea.debugger.coroutine.util.isFilteredInvokeSuspend
|
||||||
import org.jetbrains.kotlin.idea.debugger.coroutine.util.logger
|
import org.jetbrains.kotlin.idea.debugger.coroutine.util.logger
|
||||||
import org.jetbrains.kotlin.idea.debugger.stackFrame.KotlinStackFrame
|
import org.jetbrains.kotlin.idea.debugger.stackFrame.KotlinStackFrame
|
||||||
|
|
||||||
@@ -34,12 +32,12 @@ class CreationCoroutineStackFrameItem(
|
|||||||
val first: Boolean
|
val first: Boolean
|
||||||
) : CoroutineStackFrameItem(location, emptyList()) {
|
) : CoroutineStackFrameItem(location, emptyList()) {
|
||||||
|
|
||||||
override fun createFrame(debugProcess: DebugProcessImpl): XStackFrame? {
|
override fun createFrame(debugProcess: DebugProcessImpl): CoroutineGeneratedFrame? {
|
||||||
return debugProcess.invokeInManagerThread {
|
return debugProcess.invokeInManagerThread {
|
||||||
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
||||||
val locationFrame = LocationStackFrameProxyImpl(location, frame)
|
val locationFrame = LocationStackFrameProxyImpl(location, frame)
|
||||||
val position = location.findPosition(debugProcess.project)
|
val position = location.findPosition(debugProcess.project)
|
||||||
CreationCoroutineStackFrame(locationFrame, position, first)
|
CreationCoroutineStackFrame(debugProcess, this, first)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,19 +51,18 @@ class SuspendCoroutineStackFrameItem(
|
|||||||
spilledVariables: List<XNamedValue> = emptyList()
|
spilledVariables: List<XNamedValue> = emptyList()
|
||||||
) : CoroutineStackFrameItem(location, spilledVariables)
|
) : CoroutineStackFrameItem(location, spilledVariables)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restored from memory dump
|
* Restored from memory dump
|
||||||
*/
|
*/
|
||||||
class DefaultCoroutineStackFrameItem(location: Location, spilledVariables: List<XNamedValue>) :
|
class DefaultCoroutineStackFrameItem(location: Location, spilledVariables: List<XNamedValue>) :
|
||||||
CoroutineStackFrameItem(location, spilledVariables) {
|
CoroutineStackFrameItem(location, spilledVariables) {
|
||||||
|
|
||||||
override fun createFrame(debugProcess: DebugProcessImpl): XStackFrame? {
|
override fun createFrame(debugProcess: DebugProcessImpl): CoroutineGeneratedFrame? {
|
||||||
return debugProcess.invokeInManagerThread {
|
return debugProcess.invokeInManagerThread {
|
||||||
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
||||||
val locationStackFrameProxyImpl = LocationStackFrameProxyImpl(location, frame)
|
val locationStackFrameProxyImpl = LocationStackFrameProxyImpl(location, frame)
|
||||||
val position = location.findPosition(debugProcess.project) ?: return@invokeInManagerThread null
|
val position = location.findPosition(debugProcess.project) ?: return@invokeInManagerThread null
|
||||||
CoroutineStackFrame(locationStackFrameProxyImpl, position, spilledVariables, false)
|
CoroutineStackFrame(debugProcess, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,25 +82,24 @@ class DefaultCoroutineStackFrameItem(location: Location, spilledVariables: List<
|
|||||||
open class RunningCoroutineStackFrameItem(
|
open class RunningCoroutineStackFrameItem(
|
||||||
val frame: StackFrameProxyImpl,
|
val frame: StackFrameProxyImpl,
|
||||||
spilledVariables: List<XNamedValue> = emptyList()
|
spilledVariables: List<XNamedValue> = emptyList()
|
||||||
) : CoroutineStackFrameItem(frame.location(), spilledVariables) {
|
) : CoroutineStackFrameItem(frame.location(), spilledVariables), FrameProvider {
|
||||||
override fun createFrame(debugProcess: DebugProcessImpl): XStackFrame? {
|
override fun createFrame(debugProcess: DebugProcessImpl): CoroutineGeneratedFrame? {
|
||||||
return debugProcess.invokeInManagerThread {
|
return debugProcess.invokeInManagerThread {
|
||||||
val position = frame.location().findPosition(debugProcess.project)
|
CoroutineStackFrame(debugProcess, this)
|
||||||
CoroutineStackFrame(frame, position)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun provideFrame(debugProcess: DebugProcessImpl): XStackFrame? =
|
||||||
|
debugProcess.invokeInManagerThread { KotlinStackFrame(frame) }
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class CoroutineStackFrameItem(val location: Location, val spilledVariables: List<XNamedValue>) :
|
sealed class CoroutineStackFrameItem(val location: Location, val spilledVariables: List<XNamedValue>) :
|
||||||
StackFrameItem(location, spilledVariables) {
|
StackFrameItem(location, spilledVariables) {
|
||||||
val log by logger
|
val log by logger
|
||||||
|
|
||||||
override fun createFrame(debugProcess: DebugProcessImpl): XStackFrame? {
|
override fun createFrame(debugProcess: DebugProcessImpl): CoroutineGeneratedFrame? {
|
||||||
return debugProcess.invokeInManagerThread {
|
return debugProcess.invokeInManagerThread {
|
||||||
val frame = debugProcess.findFirstFrame() ?: return@invokeInManagerThread null
|
CoroutineStackFrame(debugProcess, this)
|
||||||
val locationFrame = LocationStackFrameProxyImpl(location, frame)
|
|
||||||
val position = location.findPosition(debugProcess.project)
|
|
||||||
CoroutineStackFrame(locationFrame, position)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +108,10 @@ sealed class CoroutineStackFrameItem(val location: Location, val spilledVariable
|
|||||||
location.safeLineNumber() + ":" + location.safeKotlinPreferredLineNumber()
|
location.safeLineNumber() + ":" + location.safeKotlinPreferredLineNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface FrameProvider {
|
||||||
|
fun provideFrame(debugProcess: DebugProcessImpl): XStackFrame?
|
||||||
|
}
|
||||||
|
|
||||||
fun DebugProcessImpl.findFirstFrame(): StackFrameProxyImpl? =
|
fun DebugProcessImpl.findFirstFrame(): StackFrameProxyImpl? =
|
||||||
suspendManager.pausedContext.thread?.forceFrames()?.firstOrNull()
|
suspendManager.pausedContext.thread?.forceFrames()?.firstOrNull()
|
||||||
|
|
||||||
@@ -123,71 +123,19 @@ fun DebugProcessImpl.findFirstFrame(): StackFrameProxyImpl? =
|
|||||||
*/
|
*/
|
||||||
class CoroutinePreflightFrame(
|
class CoroutinePreflightFrame(
|
||||||
val coroutineInfoData: CoroutineInfoData,
|
val coroutineInfoData: CoroutineInfoData,
|
||||||
val frame: StackFrameProxyImpl,
|
private val frame: StackFrameProxyImpl,
|
||||||
val threadPreCoroutineFrames: List<StackFrameProxyImpl>,
|
val threadPreCoroutineFrames: List<StackFrameProxyImpl>,
|
||||||
val mode: SuspendExitMode,
|
val mode: SuspendExitMode
|
||||||
private val firstFrameVariables: List<XNamedValue> = coroutineInfoData.topFrameVariables()
|
) : KotlinStackFrame(frame), JVMStackFrameInfoProvider {
|
||||||
) : CoroutineStackFrame(frame, null, firstFrameVariables) {
|
|
||||||
|
|
||||||
override fun isInLibraryContent() = false
|
|
||||||
|
|
||||||
override fun isSynthetic() = false
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class CreationCoroutineStackFrame(
|
|
||||||
frame: StackFrameProxyImpl,
|
|
||||||
sourcePosition: XSourcePosition?,
|
|
||||||
val first: Boolean
|
|
||||||
) : CoroutineStackFrame(frame, sourcePosition, emptyList(), false), XDebuggerFramesList.ItemWithSeparatorAbove {
|
|
||||||
|
|
||||||
override fun getCaptionAboveOf() =
|
|
||||||
KotlinDebuggerCoroutinesBundle.message("coroutine.dump.creation.trace")
|
|
||||||
|
|
||||||
override fun hasSeparatorAbove() =
|
|
||||||
first
|
|
||||||
}
|
|
||||||
|
|
||||||
open class CoroutineStackFrame(
|
|
||||||
frame: StackFrameProxyImpl,
|
|
||||||
val position: XSourcePosition?,
|
|
||||||
private val spilledVariables: List<XNamedValue>? = null,
|
|
||||||
private val includeFrameVariables: Boolean = true,
|
|
||||||
) : KotlinStackFrame(frame) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
descriptor.updateRepresentation(null, DescriptorLabelListener.DUMMY_LISTENER)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
if (this === other) return true
|
|
||||||
|
|
||||||
val frame = other as? JavaStackFrame ?: return false
|
|
||||||
|
|
||||||
return descriptor.frameProxy == frame.descriptor.frameProxy
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
return descriptor.frameProxy.hashCode()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun computeChildren(node: XCompositeNode) {
|
|
||||||
if (includeFrameVariables || spilledVariables == null) {
|
|
||||||
super.computeChildren(node)
|
|
||||||
} else {
|
|
||||||
// ignore original frame variables
|
|
||||||
val list = XValueChildrenList()
|
|
||||||
spilledVariables.forEach { list.add(it) }
|
|
||||||
node.addChildren(list, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun superBuildVariables(evaluationContext: EvaluationContextImpl, children: XValueChildrenList) {
|
override fun superBuildVariables(evaluationContext: EvaluationContextImpl, children: XValueChildrenList) {
|
||||||
super.superBuildVariables(evaluationContext, children)
|
super.superBuildVariables(evaluationContext, children)
|
||||||
if (spilledVariables != null) {
|
val topRestoredFrame = coroutineInfoData.stackTrace.firstOrNull()
|
||||||
|
if (topRestoredFrame != null && topRestoredFrame.location.isFilteredInvokeSuspend()) {
|
||||||
|
val firstFrameVariables: List<XNamedValue> = topRestoredFrame.spilledVariables
|
||||||
children.let {
|
children.let {
|
||||||
val varNames = (0 until children.size()).map { children.getName(it) }.toSet()
|
val varNames = (0 until children.size()).map { children.getName(it) }.toSet()
|
||||||
spilledVariables.forEach {
|
firstFrameVariables.forEach {
|
||||||
if (!varNames.contains(it.name))
|
if (!varNames.contains(it.name))
|
||||||
children.add(it)
|
children.add(it)
|
||||||
}
|
}
|
||||||
@@ -195,6 +143,32 @@ open class CoroutineStackFrame(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSourcePosition() =
|
override fun isInLibraryContent() = false
|
||||||
position ?: super.getSourcePosition()
|
|
||||||
|
override fun isSynthetic() = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CreationCoroutineStackFrame(debugProcess: DebugProcessImpl, item: CoroutineStackFrameItem, val first: Boolean) : CoroutineStackFrame(debugProcess, item) {
|
||||||
|
override fun getCaptionAboveOf() = KotlinDebuggerCoroutinesBundle.message("coroutine.dump.creation.trace")
|
||||||
|
|
||||||
|
override fun hasSeparatorAbove(): Boolean =
|
||||||
|
first
|
||||||
|
}
|
||||||
|
|
||||||
|
open class CoroutineStackFrame(val debugProcess: DebugProcessImpl, val item: CoroutineStackFrameItem) :
|
||||||
|
StackFrameItem.CapturedStackFrame(debugProcess, item) {
|
||||||
|
|
||||||
|
override fun computeChildren(node: XCompositeNode) {
|
||||||
|
if (item is FrameProvider)
|
||||||
|
item.provideFrame(debugProcess)?.computeChildren(node)
|
||||||
|
else
|
||||||
|
super.computeChildren(node)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCaptionAboveOf() = "CoroutineExit"
|
||||||
|
|
||||||
|
override fun hasSeparatorAbove(): Boolean =
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias CoroutineGeneratedFrame = StackFrameItem.CapturedStackFrame
|
||||||
@@ -11,8 +11,8 @@ import com.intellij.openapi.project.ex.ProjectManagerEx
|
|||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun ProjectManagerEx.forceCloseProjectEx(project: Project, dispose: Boolean): Boolean {
|
fun ProjectManagerEx.forceCloseProjectEx(project: Project, dispose: Boolean): Boolean {
|
||||||
if (!dispose) error("dispose should be true")
|
if (!dispose) error("dispose should be true")
|
||||||
return this.forceCloseProject(project, true)
|
return this.forceCloseProject(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
typealias TestApplicationManager = com.intellij.idea.IdeaTestApplication
|
typealias TestApplicationManager = com.intellij.testFramework.TestApplicationManager
|
||||||
+2
-2
@@ -11,8 +11,8 @@ import com.intellij.openapi.project.ex.ProjectManagerEx
|
|||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun ProjectManagerEx.forceCloseProjectEx(project: Project, dispose: Boolean): Boolean {
|
fun ProjectManagerEx.forceCloseProjectEx(project: Project, dispose: Boolean): Boolean {
|
||||||
if (!dispose) error("dispose should be true")
|
if (!dispose) error("dispose should be true")
|
||||||
return this.forceCloseProject(project)
|
return this.forceCloseProject(project, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
typealias TestApplicationManager = com.intellij.testFramework.TestApplicationManager
|
typealias TestApplicationManager = com.intellij.idea.IdeaTestApplication
|
||||||
@@ -65,8 +65,6 @@ private fun _attachGradleProjectAndRefresh(
|
|||||||
ExternalSystemUtil.ensureToolWindowInitialized(project, GradleConstants.SYSTEM_ID)
|
ExternalSystemUtil.ensureToolWindowInitialized(project, GradleConstants.SYSTEM_ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalProjectsManagerImpl.disableProjectWatcherAutoUpdate(project)
|
|
||||||
val settings = ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID)
|
val settings = ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID)
|
||||||
if (settings.getLinkedProjectSettings(externalProjectPath) == null) {
|
if (settings.getLinkedProjectSettings(externalProjectPath) == null) {
|
||||||
settings.linkProject(gradleProjectSettings)
|
settings.linkProject(gradleProjectSettings)
|
||||||
|
|||||||
+2
@@ -65,6 +65,8 @@ private fun _attachGradleProjectAndRefresh(
|
|||||||
ExternalSystemUtil.ensureToolWindowInitialized(project, GradleConstants.SYSTEM_ID)
|
ExternalSystemUtil.ensureToolWindowInitialized(project, GradleConstants.SYSTEM_ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExternalProjectsManagerImpl.disableProjectWatcherAutoUpdate(project)
|
||||||
val settings = ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID)
|
val settings = ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID)
|
||||||
if (settings.getLinkedProjectSettings(externalProjectPath) == null) {
|
if (settings.getLinkedProjectSettings(externalProjectPath) == null) {
|
||||||
settings.linkProject(gradleProjectSettings)
|
settings.linkProject(gradleProjectSettings)
|
||||||
@@ -13,7 +13,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<version>@snapshot@</version>
|
<version>@snapshot@</version>
|
||||||
<vendor url="http://www.jetbrains.com">JetBrains</vendor>
|
<vendor url="http://www.jetbrains.com">JetBrains</vendor>
|
||||||
|
|
||||||
<idea-version since-build="193.4099.13" until-build="193.*"/>
|
<idea-version since-build="201.7223.91" until-build="201.*"/>
|
||||||
|
|
||||||
<depends>com.intellij.modules.platform</depends>
|
<depends>com.intellij.modules.platform</depends>
|
||||||
|
|
||||||
@@ -60,12 +60,6 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<xi:include href="scripting-support.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
<xi:include href="scripting-support.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||||
|
|
||||||
<project-components>
|
|
||||||
<component>
|
|
||||||
<implementation-class>org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener</implementation-class>
|
|
||||||
</component>
|
|
||||||
</project-components>
|
|
||||||
|
|
||||||
<extensionPoints>
|
<extensionPoints>
|
||||||
<xi:include href="extensions/compiler.xml" xpointer="xpointer(/idea-plugin/extensionPoints/*)"/>
|
<xi:include href="extensions/compiler.xml" xpointer="xpointer(/idea-plugin/extensionPoints/*)"/>
|
||||||
|
|
||||||
@@ -97,6 +91,8 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<highlightingPassFactory implementation="org.jetbrains.kotlin.idea.parameterInfo.custom.KotlinCodeHintsPass$Registrar"/>
|
<highlightingPassFactory implementation="org.jetbrains.kotlin.idea.parameterInfo.custom.KotlinCodeHintsPass$Registrar"/>
|
||||||
<highlightingPassFactory implementation="org.jetbrains.kotlin.idea.refactoring.cutPaste.MoveDeclarationsPassFactory$Registrar"/>
|
<highlightingPassFactory implementation="org.jetbrains.kotlin.idea.refactoring.cutPaste.MoveDeclarationsPassFactory$Registrar"/>
|
||||||
|
|
||||||
|
<projectService serviceImplementation="org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener"/>
|
||||||
|
|
||||||
<statistics.counterUsagesCollector groupId="kotlin.gradle.target" version="2"/>
|
<statistics.counterUsagesCollector groupId="kotlin.gradle.target" version="2"/>
|
||||||
<statistics.counterUsagesCollector groupId="kotlin.maven.target" version="3"/>
|
<statistics.counterUsagesCollector groupId="kotlin.maven.target" version="3"/>
|
||||||
<statistics.counterUsagesCollector groupId="kotlin.jps.target" version="3"/>
|
<statistics.counterUsagesCollector groupId="kotlin.jps.target" version="3"/>
|
||||||
@@ -118,8 +114,12 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<completion.ml.model implementation="org.jetbrains.kotlin.idea.completion.ml.KotlinMLRankingProvider"/>
|
<completion.ml.model implementation="org.jetbrains.kotlin.idea.completion.ml.KotlinMLRankingProvider"/>
|
||||||
<completion.ml.contextFeatures language="kotlin" implementationClass="org.jetbrains.kotlin.idea.completion.ml.KotlinContextFeatureProvider"/>
|
<completion.ml.contextFeatures language="kotlin" implementationClass="org.jetbrains.kotlin.idea.completion.ml.KotlinContextFeatureProvider"/>
|
||||||
|
<suggestedRefactoringSupport language="kotlin" implementationClass="org.jetbrains.kotlin.idea.refactoring.suggested.KotlinSuggestedRefactoringSupport"/>
|
||||||
|
|
||||||
<defaultLiveTemplatesProvider implementation="org.jetbrains.kotlin.idea.liveTemplates.KotlinLiveTemplatesProvider"/>
|
<refactoring.moveInnerHandler language="kotlin"
|
||||||
|
implementationClass="org.jetbrains.kotlin.idea.refactoring.move.MoveKotlinInnerHandler"/>
|
||||||
|
|
||||||
|
<defaultLiveTemplates file="liveTemplates/Kotlin.xml"/>
|
||||||
|
|
||||||
<fileType name="Kotlin"
|
<fileType name="Kotlin"
|
||||||
implementationClass="org.jetbrains.kotlin.idea.KotlinFileType"
|
implementationClass="org.jetbrains.kotlin.idea.KotlinFileType"
|
||||||
|
|||||||
+8
-8
@@ -13,7 +13,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<version>@snapshot@</version>
|
<version>@snapshot@</version>
|
||||||
<vendor url="http://www.jetbrains.com">JetBrains</vendor>
|
<vendor url="http://www.jetbrains.com">JetBrains</vendor>
|
||||||
|
|
||||||
<idea-version since-build="201.7223.91" until-build="201.*"/>
|
<idea-version since-build="193.4099.13" until-build="193.*"/>
|
||||||
|
|
||||||
<depends>com.intellij.modules.platform</depends>
|
<depends>com.intellij.modules.platform</depends>
|
||||||
|
|
||||||
@@ -60,6 +60,12 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<xi:include href="scripting-support.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
<xi:include href="scripting-support.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||||
|
|
||||||
|
<project-components>
|
||||||
|
<component>
|
||||||
|
<implementation-class>org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener</implementation-class>
|
||||||
|
</component>
|
||||||
|
</project-components>
|
||||||
|
|
||||||
<extensionPoints>
|
<extensionPoints>
|
||||||
<xi:include href="extensions/compiler.xml" xpointer="xpointer(/idea-plugin/extensionPoints/*)"/>
|
<xi:include href="extensions/compiler.xml" xpointer="xpointer(/idea-plugin/extensionPoints/*)"/>
|
||||||
|
|
||||||
@@ -91,8 +97,6 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<highlightingPassFactory implementation="org.jetbrains.kotlin.idea.parameterInfo.custom.KotlinCodeHintsPass$Registrar"/>
|
<highlightingPassFactory implementation="org.jetbrains.kotlin.idea.parameterInfo.custom.KotlinCodeHintsPass$Registrar"/>
|
||||||
<highlightingPassFactory implementation="org.jetbrains.kotlin.idea.refactoring.cutPaste.MoveDeclarationsPassFactory$Registrar"/>
|
<highlightingPassFactory implementation="org.jetbrains.kotlin.idea.refactoring.cutPaste.MoveDeclarationsPassFactory$Registrar"/>
|
||||||
|
|
||||||
<projectService serviceImplementation="org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener"/>
|
|
||||||
|
|
||||||
<statistics.counterUsagesCollector groupId="kotlin.gradle.target" version="2"/>
|
<statistics.counterUsagesCollector groupId="kotlin.gradle.target" version="2"/>
|
||||||
<statistics.counterUsagesCollector groupId="kotlin.maven.target" version="3"/>
|
<statistics.counterUsagesCollector groupId="kotlin.maven.target" version="3"/>
|
||||||
<statistics.counterUsagesCollector groupId="kotlin.jps.target" version="3"/>
|
<statistics.counterUsagesCollector groupId="kotlin.jps.target" version="3"/>
|
||||||
@@ -114,12 +118,8 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<completion.ml.model implementation="org.jetbrains.kotlin.idea.completion.ml.KotlinMLRankingProvider"/>
|
<completion.ml.model implementation="org.jetbrains.kotlin.idea.completion.ml.KotlinMLRankingProvider"/>
|
||||||
<completion.ml.contextFeatures language="kotlin" implementationClass="org.jetbrains.kotlin.idea.completion.ml.KotlinContextFeatureProvider"/>
|
<completion.ml.contextFeatures language="kotlin" implementationClass="org.jetbrains.kotlin.idea.completion.ml.KotlinContextFeatureProvider"/>
|
||||||
<suggestedRefactoringSupport language="kotlin" implementationClass="org.jetbrains.kotlin.idea.refactoring.suggested.KotlinSuggestedRefactoringSupport"/>
|
|
||||||
|
|
||||||
<refactoring.moveInnerHandler language="kotlin"
|
<defaultLiveTemplatesProvider implementation="org.jetbrains.kotlin.idea.liveTemplates.KotlinLiveTemplatesProvider"/>
|
||||||
implementationClass="org.jetbrains.kotlin.idea.refactoring.move.MoveKotlinInnerHandler"/>
|
|
||||||
|
|
||||||
<defaultLiveTemplates file="liveTemplates/Kotlin.xml"/>
|
|
||||||
|
|
||||||
<fileType name="Kotlin"
|
<fileType name="Kotlin"
|
||||||
implementationClass="org.jetbrains.kotlin.idea.KotlinFileType"
|
implementationClass="org.jetbrains.kotlin.idea.KotlinFileType"
|
||||||
@@ -1,64 +1,58 @@
|
|||||||
<idea-plugin>
|
<idea-plugin>
|
||||||
<extensions defaultExtensionNs="org.jetbrains.plugins.gradle">
|
<extensions defaultExtensionNs="org.jetbrains.plugins.gradle">
|
||||||
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinMPPSourceSetsFrameworkSupportProvider"/>
|
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinMPPSourceSetsFrameworkSupportProvider"/>
|
||||||
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJavaFrameworkSupportProvider"/>
|
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJavaFrameworkSupportProvider"/>
|
||||||
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJSBrowserFrameworkSupportProvider"/>
|
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJSBrowserFrameworkSupportProvider"/>
|
||||||
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJSNodeFrameworkSupportProvider"/>
|
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJSNodeFrameworkSupportProvider"/>
|
||||||
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinMPPFrameworkSupportProvider"/>
|
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinMPPFrameworkSupportProvider"/>
|
||||||
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJavaFrameworkSupportProvider"/>
|
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJavaFrameworkSupportProvider"/>
|
||||||
<kotlinDslFrameworkSupport
|
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJSBrowserFrameworkSupportProvider"/>
|
||||||
implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJSBrowserFrameworkSupportProvider"/>
|
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJSNodeFrameworkSupportProvider"/>
|
||||||
<kotlinDslFrameworkSupport
|
<pluginDescriptions implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradlePluginDescription"/>
|
||||||
implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJSNodeFrameworkSupportProvider"/>
|
<projectResolve implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslScriptModelResolver" order="first"/>
|
||||||
<pluginDescriptions implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradlePluginDescription"/>
|
<projectResolve implementation="org.jetbrains.kotlin.idea.commonizer.KotlinCommonizerModelResolver" order="first"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinNonJvmGutterConfigurator"/>
|
<projectResolve implementation="org.jetbrains.kotlin.idea.cocoapods.KotlinCocoaPodsModelResolver" order="last"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslScriptModelResolver" order="first"/>
|
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectResolverExtension" order="first"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.cocoapods.KotlinCocoaPodsModelResolver" order="first"/>
|
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleCoroutineDebugProjectResolver" order="last"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.commonizer.KotlinCommonizerModelResolver" order="first"/>
|
<projectResolve implementation="org.jetbrains.kotlin.kapt.idea.KaptProjectResolverExtension" order="last"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.cocoapods.KotlinCocoaPodsModelResolver" order="last"/>
|
<projectResolve implementation="org.jetbrains.kotlin.allopen.ide.AllOpenProjectResolverExtension" order="last"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectResolverExtension" order="first"/>
|
<projectResolve implementation="org.jetbrains.kotlin.noarg.ide.NoArgProjectResolverExtension" order="last"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleCoroutineDebugProjectResolver" order="last"/>
|
<projectResolve implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverProjectResolverExtension" order="last"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.kapt.idea.KaptProjectResolverExtension" order="last"/>
|
</extensions>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.allopen.ide.AllOpenProjectResolverExtension" order="last"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.noarg.ide.NoArgProjectResolverExtension" order="last"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverProjectResolverExtension" order="last"/>
|
|
||||||
</extensions>
|
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleSourceSetDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleSourceSetDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinTargetDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinTargetDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.KotlinJavaMPPSourceSetDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.KotlinJavaMPPSourceSetDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryDataService"/>
|
||||||
<externalSystemTaskNotificationListener
|
<externalSystemTaskNotificationListener
|
||||||
implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslSyncListener"
|
implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslSyncListener"
|
||||||
/>
|
/>
|
||||||
<editorNotificationProvider implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptNotificationProvider"/>
|
<editorNotificationProvider implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptNotificationProvider"/>
|
||||||
|
|
||||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinJvmTestClassGradleConfigurationProducer"/>
|
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinJvmTestClassGradleConfigurationProducer"/>
|
||||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinMultiplatformJvmTestClassGradleConfigurationProducer"/>
|
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinMultiplatformJvmTestClassGradleConfigurationProducer"/>
|
||||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinJvmTestMethodGradleConfigurationProducer"/>
|
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinJvmTestMethodGradleConfigurationProducer"/>
|
||||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinMultiplatformJvmTestMethodGradleConfigurationProducer"/>
|
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinMultiplatformJvmTestMethodGradleConfigurationProducer"/>
|
||||||
|
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.allopen.ide.AllOpenGradleProjectImportHandler"/>
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.allopen.ide.AllOpenGradleProjectImportHandler"/>
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.scripting.idea.plugin.ScriptingGradleProjectImportHandler"/>
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.scripting.idea.plugin.ScriptingGradleProjectImportHandler"/>
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.kapt.idea.KaptGradleProjectImportHandler"/>
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.kapt.idea.KaptGradleProjectImportHandler"/>
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.noarg.ide.NoArgGradleProjectImportHandler"/>
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.noarg.ide.NoArgGradleProjectImportHandler"/>
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverGradleProjectImportHandler"/>
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverGradleProjectImportHandler"/>
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlinx.serialization.idea.KotlinSerializationGradleImportHandler"/>
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlinx.serialization.idea.KotlinSerializationGradleImportHandler"/>
|
||||||
|
|
||||||
<projectConfigurator implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleModuleConfigurator"/>
|
<projectConfigurator implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleModuleConfigurator"/>
|
||||||
<projectConfigurator implementation="org.jetbrains.kotlin.idea.configuration.KotlinJsGradleModuleConfigurator"/>
|
<projectConfigurator implementation="org.jetbrains.kotlin.idea.configuration.KotlinJsGradleModuleConfigurator"/>
|
||||||
<gradleModelFacade implementation="org.jetbrains.kotlin.idea.inspections.gradle.DefaultGradleModelFacade"/>
|
<gradleModelFacade implementation="org.jetbrains.kotlin.idea.inspections.gradle.DefaultGradleModelFacade"/>
|
||||||
|
|
||||||
<scriptDefinitionContributor implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptDefinitionsContributor"
|
<scriptDefinitionContributor implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptDefinitionsContributor" order="first"/>
|
||||||
order="first"/>
|
<scriptAdditionalIdeaDependenciesProvider implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptAdditionalIdeaDependenciesProvider"/>
|
||||||
<scriptAdditionalIdeaDependenciesProvider
|
|
||||||
implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptAdditionalIdeaDependenciesProvider"/>
|
|
||||||
|
|
||||||
</extensions>
|
</extensions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<idea-plugin>
|
||||||
|
<extensions defaultExtensionNs="org.jetbrains.plugins.gradle">
|
||||||
|
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinMPPSourceSetsFrameworkSupportProvider"/>
|
||||||
|
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJavaFrameworkSupportProvider"/>
|
||||||
|
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJSBrowserFrameworkSupportProvider"/>
|
||||||
|
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJSNodeFrameworkSupportProvider"/>
|
||||||
|
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinMPPFrameworkSupportProvider"/>
|
||||||
|
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJavaFrameworkSupportProvider"/>
|
||||||
|
<kotlinDslFrameworkSupport
|
||||||
|
implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJSBrowserFrameworkSupportProvider"/>
|
||||||
|
<kotlinDslFrameworkSupport
|
||||||
|
implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJSNodeFrameworkSupportProvider"/>
|
||||||
|
<pluginDescriptions implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradlePluginDescription"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinNonJvmGutterConfigurator"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslScriptModelResolver" order="first"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.idea.cocoapods.KotlinCocoaPodsModelResolver" order="first"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.idea.commonizer.KotlinCommonizerModelResolver" order="first"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.idea.cocoapods.KotlinCocoaPodsModelResolver" order="last"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectResolverExtension" order="first"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleCoroutineDebugProjectResolver" order="last"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.kapt.idea.KaptProjectResolverExtension" order="last"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.allopen.ide.AllOpenProjectResolverExtension" order="last"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.noarg.ide.NoArgProjectResolverExtension" order="last"/>
|
||||||
|
<projectResolve implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverProjectResolverExtension" order="last"/>
|
||||||
|
</extensions>
|
||||||
|
|
||||||
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleSourceSetDataService"/>
|
||||||
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectDataService"/>
|
||||||
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
||||||
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinTargetDataService"/>
|
||||||
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.KotlinJavaMPPSourceSetDataService"/>
|
||||||
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryDataService"/>
|
||||||
|
<externalSystemTaskNotificationListener
|
||||||
|
implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslSyncListener"
|
||||||
|
/>
|
||||||
|
<editorNotificationProvider implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptNotificationProvider"/>
|
||||||
|
|
||||||
|
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinJvmTestClassGradleConfigurationProducer"/>
|
||||||
|
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinMultiplatformJvmTestClassGradleConfigurationProducer"/>
|
||||||
|
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinJvmTestMethodGradleConfigurationProducer"/>
|
||||||
|
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinMultiplatformJvmTestMethodGradleConfigurationProducer"/>
|
||||||
|
|
||||||
|
</extensions>
|
||||||
|
|
||||||
|
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||||
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.allopen.ide.AllOpenGradleProjectImportHandler"/>
|
||||||
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.scripting.idea.plugin.ScriptingGradleProjectImportHandler"/>
|
||||||
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.kapt.idea.KaptGradleProjectImportHandler"/>
|
||||||
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.noarg.ide.NoArgGradleProjectImportHandler"/>
|
||||||
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverGradleProjectImportHandler"/>
|
||||||
|
<gradleProjectImportHandler implementation="org.jetbrains.kotlinx.serialization.idea.KotlinSerializationGradleImportHandler"/>
|
||||||
|
|
||||||
|
<projectConfigurator implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleModuleConfigurator"/>
|
||||||
|
<projectConfigurator implementation="org.jetbrains.kotlin.idea.configuration.KotlinJsGradleModuleConfigurator"/>
|
||||||
|
<gradleModelFacade implementation="org.jetbrains.kotlin.idea.inspections.gradle.DefaultGradleModelFacade"/>
|
||||||
|
|
||||||
|
<scriptDefinitionContributor implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptDefinitionsContributor"
|
||||||
|
order="first"/>
|
||||||
|
<scriptAdditionalIdeaDependenciesProvider
|
||||||
|
implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptAdditionalIdeaDependenciesProvider"/>
|
||||||
|
|
||||||
|
</extensions>
|
||||||
|
</idea-plugin>
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<idea-plugin>
|
|
||||||
<extensions defaultExtensionNs="org.jetbrains.plugins.gradle">
|
|
||||||
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinMPPSourceSetsFrameworkSupportProvider"/>
|
|
||||||
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJavaFrameworkSupportProvider"/>
|
|
||||||
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJSBrowserFrameworkSupportProvider"/>
|
|
||||||
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJSNodeFrameworkSupportProvider"/>
|
|
||||||
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinMPPFrameworkSupportProvider"/>
|
|
||||||
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJavaFrameworkSupportProvider"/>
|
|
||||||
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJSBrowserFrameworkSupportProvider"/>
|
|
||||||
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJSNodeFrameworkSupportProvider"/>
|
|
||||||
<pluginDescriptions implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradlePluginDescription"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslScriptModelResolver" order="first"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.commonizer.KotlinCommonizerModelResolver" order="first"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.cocoapods.KotlinCocoaPodsModelResolver" order="last"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectResolverExtension" order="first"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleCoroutineDebugProjectResolver" order="last"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.kapt.idea.KaptProjectResolverExtension" order="last"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.allopen.ide.AllOpenProjectResolverExtension" order="last"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.noarg.ide.NoArgProjectResolverExtension" order="last"/>
|
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverProjectResolverExtension" order="last"/>
|
|
||||||
</extensions>
|
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleSourceSetDataService"/>
|
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectDataService"/>
|
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinTargetDataService"/>
|
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.KotlinJavaMPPSourceSetDataService"/>
|
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryDataService"/>
|
|
||||||
<externalSystemTaskNotificationListener
|
|
||||||
implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslSyncListener"
|
|
||||||
/>
|
|
||||||
<editorNotificationProvider implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptNotificationProvider"/>
|
|
||||||
|
|
||||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinJvmTestClassGradleConfigurationProducer"/>
|
|
||||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinMultiplatformJvmTestClassGradleConfigurationProducer"/>
|
|
||||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinJvmTestMethodGradleConfigurationProducer"/>
|
|
||||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinMultiplatformJvmTestMethodGradleConfigurationProducer"/>
|
|
||||||
|
|
||||||
</extensions>
|
|
||||||
|
|
||||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.allopen.ide.AllOpenGradleProjectImportHandler"/>
|
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.scripting.idea.plugin.ScriptingGradleProjectImportHandler"/>
|
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.kapt.idea.KaptGradleProjectImportHandler"/>
|
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.noarg.ide.NoArgGradleProjectImportHandler"/>
|
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverGradleProjectImportHandler"/>
|
|
||||||
<gradleProjectImportHandler implementation="org.jetbrains.kotlinx.serialization.idea.KotlinSerializationGradleImportHandler"/>
|
|
||||||
|
|
||||||
<projectConfigurator implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleModuleConfigurator"/>
|
|
||||||
<projectConfigurator implementation="org.jetbrains.kotlin.idea.configuration.KotlinJsGradleModuleConfigurator"/>
|
|
||||||
<gradleModelFacade implementation="org.jetbrains.kotlin.idea.inspections.gradle.DefaultGradleModelFacade"/>
|
|
||||||
|
|
||||||
<scriptDefinitionContributor implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptDefinitionsContributor" order="first"/>
|
|
||||||
<scriptAdditionalIdeaDependenciesProvider implementation="org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptAdditionalIdeaDependenciesProvider"/>
|
|
||||||
|
|
||||||
</extensions>
|
|
||||||
</idea-plugin>
|
|
||||||
@@ -25,6 +25,8 @@
|
|||||||
<orderEnumerationHandlerFactory implementation="org.jetbrains.kotlin.idea.gradle.execution.KotlinGradleOrderEnumerationHandler$Factory" order="first"/>
|
<orderEnumerationHandlerFactory implementation="org.jetbrains.kotlin.idea.gradle.execution.KotlinGradleOrderEnumerationHandler$Factory" order="first"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinMPPGradleProjectResolver"/>
|
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinMPPGradleProjectResolver"/>
|
||||||
<testTasksProvider implementation="org.jetbrains.kotlin.idea.run.KotlinMPPGradleTestTasksProvider"/>
|
<testTasksProvider implementation="org.jetbrains.kotlin.idea.run.KotlinMPPGradleTestTasksProvider"/>
|
||||||
|
|
||||||
|
<projectModelContributor implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslScriptModelContributor"/>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
@@ -39,9 +41,9 @@
|
|||||||
defaultValue="true"
|
defaultValue="true"
|
||||||
restartRequired="false"/>
|
restartRequired="false"/>
|
||||||
|
|
||||||
<registryKey key="kotlin.gradle.scripts.scriptConfigurationsNeedToBeUpdatedBalloon"
|
<registryKey key="kotlin.gradle.scripts.scriptConfigurationsNeedToBeUpdatedFloatingNotification"
|
||||||
description="Show balloon when script configuration need to be updated along with project need to be imported balloon"
|
description="Show floating notification in the editor when script configuration need to be updated"
|
||||||
defaultValue="false"
|
defaultValue="true"
|
||||||
restartRequired="false"/>
|
restartRequired="false"/>
|
||||||
|
|
||||||
<projectService serviceImplementation="org.jetbrains.kotlin.idea.scripting.gradle.legacy.GradleStandaloneScriptActionsManager"/>
|
<projectService serviceImplementation="org.jetbrains.kotlin.idea.scripting.gradle.legacy.GradleStandaloneScriptActionsManager"/>
|
||||||
@@ -51,5 +53,9 @@
|
|||||||
<action id="Kotlin.Gradle.ShowDslLogs" class="org.jetbrains.kotlin.idea.actions.ShowKotlinGradleDslLogs"
|
<action id="Kotlin.Gradle.ShowDslLogs" class="org.jetbrains.kotlin.idea.actions.ShowKotlinGradleDslLogs"
|
||||||
text="Show Kotlin Gradle DSL Logs" description="Show Kotlin Gradle DSL logs">
|
text="Show Kotlin Gradle DSL Logs" description="Show Kotlin Gradle DSL logs">
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
<action id="LoadConfigurationAction" class="org.jetbrains.kotlin.idea.scripting.gradle.LoadConfigurationAction">
|
||||||
|
<add-to-group group-id="ExternalSystem.ProjectRefreshActionGroup" anchor="first"/>
|
||||||
|
</action>
|
||||||
</actions>
|
</actions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
<orderEnumerationHandlerFactory implementation="org.jetbrains.kotlin.idea.gradle.execution.KotlinGradleOrderEnumerationHandler$Factory" order="first"/>
|
<orderEnumerationHandlerFactory implementation="org.jetbrains.kotlin.idea.gradle.execution.KotlinGradleOrderEnumerationHandler$Factory" order="first"/>
|
||||||
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinMPPGradleProjectResolver"/>
|
<projectResolve implementation="org.jetbrains.kotlin.idea.configuration.KotlinMPPGradleProjectResolver"/>
|
||||||
<testTasksProvider implementation="org.jetbrains.kotlin.idea.run.KotlinMPPGradleTestTasksProvider"/>
|
<testTasksProvider implementation="org.jetbrains.kotlin.idea.run.KotlinMPPGradleTestTasksProvider"/>
|
||||||
|
|
||||||
<projectModelContributor implementation="org.jetbrains.kotlin.idea.scripting.gradle.importing.KotlinDslScriptModelContributor"/>
|
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
@@ -41,9 +39,9 @@
|
|||||||
defaultValue="true"
|
defaultValue="true"
|
||||||
restartRequired="false"/>
|
restartRequired="false"/>
|
||||||
|
|
||||||
<registryKey key="kotlin.gradle.scripts.scriptConfigurationsNeedToBeUpdatedFloatingNotification"
|
<registryKey key="kotlin.gradle.scripts.scriptConfigurationsNeedToBeUpdatedBalloon"
|
||||||
description="Show floating notification in the editor when script configuration need to be updated"
|
description="Show balloon when script configuration need to be updated along with project need to be imported balloon"
|
||||||
defaultValue="true"
|
defaultValue="false"
|
||||||
restartRequired="false"/>
|
restartRequired="false"/>
|
||||||
|
|
||||||
<projectService serviceImplementation="org.jetbrains.kotlin.idea.scripting.gradle.legacy.GradleStandaloneScriptActionsManager"/>
|
<projectService serviceImplementation="org.jetbrains.kotlin.idea.scripting.gradle.legacy.GradleStandaloneScriptActionsManager"/>
|
||||||
@@ -53,9 +51,5 @@
|
|||||||
<action id="Kotlin.Gradle.ShowDslLogs" class="org.jetbrains.kotlin.idea.actions.ShowKotlinGradleDslLogs"
|
<action id="Kotlin.Gradle.ShowDslLogs" class="org.jetbrains.kotlin.idea.actions.ShowKotlinGradleDslLogs"
|
||||||
text="Show Kotlin Gradle DSL Logs" description="Show Kotlin Gradle DSL logs">
|
text="Show Kotlin Gradle DSL Logs" description="Show Kotlin Gradle DSL logs">
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
<action id="LoadConfigurationAction" class="org.jetbrains.kotlin.idea.scripting.gradle.LoadConfigurationAction">
|
|
||||||
<add-to-group group-id="ExternalSystem.ProjectRefreshActionGroup" anchor="first"/>
|
|
||||||
</action>
|
|
||||||
</actions>
|
</actions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
<idea-plugin>
|
<idea-plugin>
|
||||||
|
|
||||||
|
<extensions defaultExtensionNs="org.jetbrains.uast">
|
||||||
|
<generate.uastCodeGenerationPlugin implementation="org.jetbrains.uast.kotlin.generate.KotlinUastCodeGenerationPlugin"/>
|
||||||
|
</extensions>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<postStartupActivity implementation="org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerStartupActivity"/>
|
<postStartupActivity implementation="org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerStartupActivity"/>
|
||||||
<postStartupActivity implementation="org.jetbrains.kotlin.idea.JvmPluginStartupActivity"/>
|
<postStartupActivity implementation="org.jetbrains.kotlin.idea.JvmPluginStartupActivity"/>
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
<idea-plugin>
|
<idea-plugin>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="org.jetbrains.uast">
|
|
||||||
<generate.uastCodeGenerationPlugin implementation="org.jetbrains.uast.kotlin.generate.KotlinUastCodeGenerationPlugin"/>
|
|
||||||
</extensions>
|
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<postStartupActivity implementation="org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerStartupActivity"/>
|
<postStartupActivity implementation="org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerStartupActivity"/>
|
||||||
<postStartupActivity implementation="org.jetbrains.kotlin.idea.JvmPluginStartupActivity"/>
|
<postStartupActivity implementation="org.jetbrains.kotlin.idea.JvmPluginStartupActivity"/>
|
||||||
@@ -5,5 +5,35 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea
|
package org.jetbrains.kotlin.idea
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.javadoc.JavaDocExternalFilter
|
||||||
|
import com.intellij.psi.PsiDocCommentBase
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.PsiFile
|
||||||
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
|
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||||
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
|
import java.util.function.Consumer
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 201 REMOVED
|
// FIX ME WHEN BUNCH 201 REMOVED
|
||||||
class KotlinDocumentationProvider : KotlinDocumentationProviderCompatBase()
|
class KotlinDocumentationProvider : KotlinDocumentationProviderCompatBase() {
|
||||||
|
|
||||||
|
override fun collectDocComments(file: PsiFile, sink: Consumer<PsiDocCommentBase>) {
|
||||||
|
if (file !is KtFile) return
|
||||||
|
|
||||||
|
PsiTreeUtil.processElements(file) {
|
||||||
|
val comment = (it as? KtDeclaration)?.docComment
|
||||||
|
if (comment != null) sink.accept(comment)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun generateRenderedDoc(element: PsiElement): String? {
|
||||||
|
val docComment = (element as? KtDeclaration)?.docComment ?: return null
|
||||||
|
|
||||||
|
val result = StringBuilder().also {
|
||||||
|
it.renderKDoc(docComment.getDefaultSection(), docComment.getAllSections())
|
||||||
|
}
|
||||||
|
|
||||||
|
return JavaDocExternalFilter.filterInternalDocInfo(result.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea
|
||||||
|
|
||||||
|
// FIX ME WHEN BUNCH 201 REMOVED
|
||||||
|
class KotlinDocumentationProvider : KotlinDocumentationProviderCompatBase()
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea
|
|
||||||
|
|
||||||
import com.intellij.codeInsight.javadoc.JavaDocExternalFilter
|
|
||||||
import com.intellij.psi.PsiDocCommentBase
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import com.intellij.psi.PsiFile
|
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
|
||||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
import java.util.function.Consumer
|
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 201 REMOVED
|
|
||||||
class KotlinDocumentationProvider : KotlinDocumentationProviderCompatBase() {
|
|
||||||
|
|
||||||
override fun collectDocComments(file: PsiFile, sink: Consumer<PsiDocCommentBase>) {
|
|
||||||
if (file !is KtFile) return
|
|
||||||
|
|
||||||
PsiTreeUtil.processElements(file) {
|
|
||||||
val comment = (it as? KtDeclaration)?.docComment
|
|
||||||
if (comment != null) sink.accept(comment)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun generateRenderedDoc(element: PsiElement): String? {
|
|
||||||
val docComment = (element as? KtDeclaration)?.docComment ?: return null
|
|
||||||
|
|
||||||
val result = StringBuilder().also {
|
|
||||||
it.renderKDoc(docComment.getDefaultSection(), docComment.getAllSections())
|
|
||||||
}
|
|
||||||
|
|
||||||
return JavaDocExternalFilter.filterInternalDocInfo(result.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,11 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.codeInsight
|
package org.jetbrains.kotlin.idea.codeInsight
|
||||||
|
|
||||||
import com.intellij.xml.breadcrumbs.BreadcrumbsInfoProvider
|
import com.intellij.ide.ui.UISettings
|
||||||
|
import com.intellij.ui.breadcrumbs.BreadcrumbsProvider
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 201 REMOVED
|
// FIX ME WHEN BUNCH 201 REMOVED
|
||||||
typealias BreadcrumbsProviderCompatBase = BreadcrumbsInfoProvider
|
abstract class BreadcrumbsProviderCompatBase : BreadcrumbsProvider {
|
||||||
|
override fun isShownByDefault(): Boolean =
|
||||||
|
!UISettings.instance.showMembersInNavigationBar
|
||||||
|
}
|
||||||
+2
-6
@@ -5,11 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.codeInsight
|
package org.jetbrains.kotlin.idea.codeInsight
|
||||||
|
|
||||||
import com.intellij.ide.ui.UISettings
|
import com.intellij.xml.breadcrumbs.BreadcrumbsInfoProvider
|
||||||
import com.intellij.ui.breadcrumbs.BreadcrumbsProvider
|
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 201 REMOVED
|
// FIX ME WHEN BUNCH 201 REMOVED
|
||||||
abstract class BreadcrumbsProviderCompatBase : BreadcrumbsProvider {
|
typealias BreadcrumbsProviderCompatBase = BreadcrumbsInfoProvider
|
||||||
override fun isShownByDefault(): Boolean =
|
|
||||||
!UISettings.instance.showMembersInNavigationBar
|
|
||||||
}
|
|
||||||
+2
-2
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.idea.codeInsight.shorten.prepareDelayedRequests
|
|||||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||||
|
|
||||||
class KotlinRefactoringHelperForDelayedRequests : RefactoringHelper<Any> {
|
class KotlinRefactoringHelperForDelayedRequests : RefactoringHelper<Any> {
|
||||||
override fun prepareOperation(usages: Array<out UsageInfo>?): Any? {
|
override fun prepareOperation(usages: Array<out UsageInfo>): Any? {
|
||||||
if (usages != null && usages.isNotEmpty()) {
|
if (usages.isNotEmpty()) {
|
||||||
val project = usages[0].project
|
val project = usages[0].project
|
||||||
prepareDelayedRequests(project)
|
prepareDelayedRequests(project)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.idea.codeInsight.shorten.prepareDelayedRequests
|
|||||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||||
|
|
||||||
class KotlinRefactoringHelperForDelayedRequests : RefactoringHelper<Any> {
|
class KotlinRefactoringHelperForDelayedRequests : RefactoringHelper<Any> {
|
||||||
override fun prepareOperation(usages: Array<out UsageInfo>): Any? {
|
override fun prepareOperation(usages: Array<out UsageInfo>?): Any? {
|
||||||
if (usages.isNotEmpty()) {
|
if (usages != null && usages.isNotEmpty()) {
|
||||||
val project = usages[0].project
|
val project = usages[0].project
|
||||||
prepareDelayedRequests(project)
|
prepareDelayedRequests(project)
|
||||||
}
|
}
|
||||||
@@ -75,35 +75,35 @@ object KotlinUsageTypeProvider : UsageTypeProviderEx {
|
|||||||
|
|
||||||
object KotlinUsageTypes {
|
object KotlinUsageTypes {
|
||||||
// types
|
// types
|
||||||
val TYPE_CONSTRAINT = UsageType(KotlinBundle.message("find.usages.type.type.constraint"))
|
val TYPE_CONSTRAINT = UsageType(KotlinBundle.lazyMessage("find.usages.type.type.constraint"))
|
||||||
val VALUE_PARAMETER_TYPE = UsageType(KotlinBundle.message("find.usages.type.value.parameter.type"))
|
val VALUE_PARAMETER_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.value.parameter.type"))
|
||||||
val NON_LOCAL_PROPERTY_TYPE = UsageType(KotlinBundle.message("find.usages.type.nonLocal.property.type"))
|
val NON_LOCAL_PROPERTY_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.nonLocal.property.type"))
|
||||||
val FUNCTION_RETURN_TYPE = UsageType(KotlinBundle.message("find.usages.type.function.return.type"))
|
val FUNCTION_RETURN_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.function.return.type"))
|
||||||
val SUPER_TYPE = UsageType(KotlinBundle.message("find.usages.type.superType"))
|
val SUPER_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.superType"))
|
||||||
val IS = UsageType(KotlinBundle.message("find.usages.type.is"))
|
val IS = UsageType(KotlinBundle.lazyMessage("find.usages.type.is"))
|
||||||
val CLASS_OBJECT_ACCESS = UsageType(KotlinBundle.message("find.usages.type.class.object"))
|
val CLASS_OBJECT_ACCESS = UsageType(KotlinBundle.lazyMessage("find.usages.type.class.object"))
|
||||||
val COMPANION_OBJECT_ACCESS = UsageType(KotlinBundle.message("find.usages.type.companion.object"))
|
val COMPANION_OBJECT_ACCESS = UsageType(KotlinBundle.lazyMessage("find.usages.type.companion.object"))
|
||||||
val EXTENSION_RECEIVER_TYPE = UsageType(KotlinBundle.message("find.usages.type.extension.receiver.type"))
|
val EXTENSION_RECEIVER_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.extension.receiver.type"))
|
||||||
val SUPER_TYPE_QUALIFIER = UsageType(KotlinBundle.message("find.usages.type.super.type.qualifier"))
|
val SUPER_TYPE_QUALIFIER = UsageType(KotlinBundle.lazyMessage("find.usages.type.super.type.qualifier"))
|
||||||
val TYPE_ALIAS = UsageType(KotlinBundle.message("find.usages.type.type.alias"))
|
val TYPE_ALIAS = UsageType(KotlinBundle.lazyMessage("find.usages.type.type.alias"))
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
val FUNCTION_CALL = UsageType(KotlinBundle.message("find.usages.type.function.call"))
|
val FUNCTION_CALL = UsageType(KotlinBundle.lazyMessage("find.usages.type.function.call"))
|
||||||
val IMPLICIT_GET = UsageType(KotlinBundle.message("find.usages.type.implicit.get"))
|
val IMPLICIT_GET = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.get"))
|
||||||
val IMPLICIT_SET = UsageType(KotlinBundle.message("find.usages.type.implicit.set"))
|
val IMPLICIT_SET = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.set"))
|
||||||
val IMPLICIT_INVOKE = UsageType(KotlinBundle.message("find.usages.type.implicit.invoke"))
|
val IMPLICIT_INVOKE = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.invoke"))
|
||||||
val IMPLICIT_ITERATION = UsageType(KotlinBundle.message("find.usages.type.implicit.iteration"))
|
val IMPLICIT_ITERATION = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.iteration"))
|
||||||
val PROPERTY_DELEGATION = UsageType(KotlinBundle.message("find.usages.type.property.delegation"))
|
val PROPERTY_DELEGATION = UsageType(KotlinBundle.lazyMessage("find.usages.type.property.delegation"))
|
||||||
|
|
||||||
// values
|
// values
|
||||||
val RECEIVER = UsageType(KotlinBundle.message("find.usages.type.receiver"))
|
val RECEIVER = UsageType(KotlinBundle.lazyMessage("find.usages.type.receiver"))
|
||||||
val DELEGATE = UsageType(KotlinBundle.message("find.usages.type.delegate"))
|
val DELEGATE = UsageType(KotlinBundle.lazyMessage("find.usages.type.delegate"))
|
||||||
|
|
||||||
// packages
|
// packages
|
||||||
val PACKAGE_DIRECTIVE = UsageType(KotlinBundle.message("find.usages.type.packageDirective"))
|
val PACKAGE_DIRECTIVE = UsageType(KotlinBundle.lazyMessage("find.usages.type.packageDirective"))
|
||||||
val PACKAGE_MEMBER_ACCESS = UsageType(KotlinBundle.message("find.usages.type.packageMemberAccess"))
|
val PACKAGE_MEMBER_ACCESS = UsageType(KotlinBundle.lazyMessage("find.usages.type.packageMemberAccess"))
|
||||||
|
|
||||||
// common usage types
|
// common usage types
|
||||||
val CALLABLE_REFERENCE = UsageType(KotlinBundle.message("find.usages.type.callable.reference"))
|
val CALLABLE_REFERENCE = UsageType(KotlinBundle.lazyMessage("find.usages.type.callable.reference"))
|
||||||
val NAMED_ARGUMENT = UsageType(KotlinBundle.message("find.usages.type.named.argument"))
|
val NAMED_ARGUMENT = UsageType(KotlinBundle.lazyMessage("find.usages.type.named.argument"))
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-23
@@ -75,35 +75,35 @@ object KotlinUsageTypeProvider : UsageTypeProviderEx {
|
|||||||
|
|
||||||
object KotlinUsageTypes {
|
object KotlinUsageTypes {
|
||||||
// types
|
// types
|
||||||
val TYPE_CONSTRAINT = UsageType(KotlinBundle.lazyMessage("find.usages.type.type.constraint"))
|
val TYPE_CONSTRAINT = UsageType(KotlinBundle.message("find.usages.type.type.constraint"))
|
||||||
val VALUE_PARAMETER_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.value.parameter.type"))
|
val VALUE_PARAMETER_TYPE = UsageType(KotlinBundle.message("find.usages.type.value.parameter.type"))
|
||||||
val NON_LOCAL_PROPERTY_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.nonLocal.property.type"))
|
val NON_LOCAL_PROPERTY_TYPE = UsageType(KotlinBundle.message("find.usages.type.nonLocal.property.type"))
|
||||||
val FUNCTION_RETURN_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.function.return.type"))
|
val FUNCTION_RETURN_TYPE = UsageType(KotlinBundle.message("find.usages.type.function.return.type"))
|
||||||
val SUPER_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.superType"))
|
val SUPER_TYPE = UsageType(KotlinBundle.message("find.usages.type.superType"))
|
||||||
val IS = UsageType(KotlinBundle.lazyMessage("find.usages.type.is"))
|
val IS = UsageType(KotlinBundle.message("find.usages.type.is"))
|
||||||
val CLASS_OBJECT_ACCESS = UsageType(KotlinBundle.lazyMessage("find.usages.type.class.object"))
|
val CLASS_OBJECT_ACCESS = UsageType(KotlinBundle.message("find.usages.type.class.object"))
|
||||||
val COMPANION_OBJECT_ACCESS = UsageType(KotlinBundle.lazyMessage("find.usages.type.companion.object"))
|
val COMPANION_OBJECT_ACCESS = UsageType(KotlinBundle.message("find.usages.type.companion.object"))
|
||||||
val EXTENSION_RECEIVER_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.extension.receiver.type"))
|
val EXTENSION_RECEIVER_TYPE = UsageType(KotlinBundle.message("find.usages.type.extension.receiver.type"))
|
||||||
val SUPER_TYPE_QUALIFIER = UsageType(KotlinBundle.lazyMessage("find.usages.type.super.type.qualifier"))
|
val SUPER_TYPE_QUALIFIER = UsageType(KotlinBundle.message("find.usages.type.super.type.qualifier"))
|
||||||
val TYPE_ALIAS = UsageType(KotlinBundle.lazyMessage("find.usages.type.type.alias"))
|
val TYPE_ALIAS = UsageType(KotlinBundle.message("find.usages.type.type.alias"))
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
val FUNCTION_CALL = UsageType(KotlinBundle.lazyMessage("find.usages.type.function.call"))
|
val FUNCTION_CALL = UsageType(KotlinBundle.message("find.usages.type.function.call"))
|
||||||
val IMPLICIT_GET = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.get"))
|
val IMPLICIT_GET = UsageType(KotlinBundle.message("find.usages.type.implicit.get"))
|
||||||
val IMPLICIT_SET = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.set"))
|
val IMPLICIT_SET = UsageType(KotlinBundle.message("find.usages.type.implicit.set"))
|
||||||
val IMPLICIT_INVOKE = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.invoke"))
|
val IMPLICIT_INVOKE = UsageType(KotlinBundle.message("find.usages.type.implicit.invoke"))
|
||||||
val IMPLICIT_ITERATION = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.iteration"))
|
val IMPLICIT_ITERATION = UsageType(KotlinBundle.message("find.usages.type.implicit.iteration"))
|
||||||
val PROPERTY_DELEGATION = UsageType(KotlinBundle.lazyMessage("find.usages.type.property.delegation"))
|
val PROPERTY_DELEGATION = UsageType(KotlinBundle.message("find.usages.type.property.delegation"))
|
||||||
|
|
||||||
// values
|
// values
|
||||||
val RECEIVER = UsageType(KotlinBundle.lazyMessage("find.usages.type.receiver"))
|
val RECEIVER = UsageType(KotlinBundle.message("find.usages.type.receiver"))
|
||||||
val DELEGATE = UsageType(KotlinBundle.lazyMessage("find.usages.type.delegate"))
|
val DELEGATE = UsageType(KotlinBundle.message("find.usages.type.delegate"))
|
||||||
|
|
||||||
// packages
|
// packages
|
||||||
val PACKAGE_DIRECTIVE = UsageType(KotlinBundle.lazyMessage("find.usages.type.packageDirective"))
|
val PACKAGE_DIRECTIVE = UsageType(KotlinBundle.message("find.usages.type.packageDirective"))
|
||||||
val PACKAGE_MEMBER_ACCESS = UsageType(KotlinBundle.lazyMessage("find.usages.type.packageMemberAccess"))
|
val PACKAGE_MEMBER_ACCESS = UsageType(KotlinBundle.message("find.usages.type.packageMemberAccess"))
|
||||||
|
|
||||||
// common usage types
|
// common usage types
|
||||||
val CALLABLE_REFERENCE = UsageType(KotlinBundle.lazyMessage("find.usages.type.callable.reference"))
|
val CALLABLE_REFERENCE = UsageType(KotlinBundle.message("find.usages.type.callable.reference"))
|
||||||
val NAMED_ARGUMENT = UsageType(KotlinBundle.lazyMessage("find.usages.type.named.argument"))
|
val NAMED_ARGUMENT = UsageType(KotlinBundle.message("find.usages.type.named.argument"))
|
||||||
}
|
}
|
||||||
@@ -10,5 +10,5 @@ import com.intellij.usageView.UsageInfo
|
|||||||
import com.intellij.util.Processor
|
import com.intellij.util.Processor
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
typealias UsageInfoProcessor = Processor<UsageInfo>
|
typealias UsageInfoProcessor = Processor<in UsageInfo>
|
||||||
typealias SliceUsageProcessor = Processor<SliceUsage>
|
typealias SliceUsageProcessor = Processor<in SliceUsage>
|
||||||
+2
-2
@@ -10,5 +10,5 @@ import com.intellij.usageView.UsageInfo
|
|||||||
import com.intellij.util.Processor
|
import com.intellij.util.Processor
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
typealias UsageInfoProcessor = Processor<in UsageInfo>
|
typealias UsageInfoProcessor = Processor<UsageInfo>
|
||||||
typealias SliceUsageProcessor = Processor<in SliceUsage>
|
typealias SliceUsageProcessor = Processor<SliceUsage>
|
||||||
@@ -3,21 +3,22 @@
|
|||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("TYPEALIAS_EXPANSION_DEPRECATION", "DEPRECATION", "UnstableApiUsage")
|
@file:Suppress("TYPEALIAS_EXPANSION_DEPRECATION", "DEPRECATION")
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.hierarchy.calls
|
package org.jetbrains.kotlin.idea.hierarchy.calls
|
||||||
|
|
||||||
import com.intellij.ide.hierarchy.call.CalleeMethodsTreeStructure
|
import com.intellij.ide.hierarchy.call.CalleeMethodsTreeStructure
|
||||||
import com.intellij.ide.hierarchy.call.CallerMethodsTreeStructure
|
import com.intellij.ide.hierarchy.call.CallerMethodsTreeStructure
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.psi.PsiMember
|
||||||
import com.intellij.psi.PsiMethod
|
import com.intellij.psi.PsiMethod
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun createCallerMethodsTreeStructure(project: Project, method: PsiMethod, scopeType: String): CallerMethodsTreeStructure {
|
fun createCallerMethodsTreeStructure(project: Project, method: PsiMethod, scopeType: String): CallerMethodsTreeStructure {
|
||||||
return CallerMethodsTreeStructure(project, method, scopeType)
|
return CallerMethodsTreeStructure(project, method as PsiMember, scopeType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun createCalleeMethodsTreeStructure(project: Project, method: PsiMethod, scopeType: String): CalleeMethodsTreeStructure {
|
fun createCalleeMethodsTreeStructure(project: Project, method: PsiMethod, scopeType: String): CalleeMethodsTreeStructure {
|
||||||
return CalleeMethodsTreeStructure(project, method, scopeType)
|
return CalleeMethodsTreeStructure(project, method as PsiMember, scopeType)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -3,22 +3,21 @@
|
|||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("TYPEALIAS_EXPANSION_DEPRECATION", "DEPRECATION")
|
@file:Suppress("TYPEALIAS_EXPANSION_DEPRECATION", "DEPRECATION", "UnstableApiUsage")
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.hierarchy.calls
|
package org.jetbrains.kotlin.idea.hierarchy.calls
|
||||||
|
|
||||||
import com.intellij.ide.hierarchy.call.CalleeMethodsTreeStructure
|
import com.intellij.ide.hierarchy.call.CalleeMethodsTreeStructure
|
||||||
import com.intellij.ide.hierarchy.call.CallerMethodsTreeStructure
|
import com.intellij.ide.hierarchy.call.CallerMethodsTreeStructure
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.psi.PsiMember
|
|
||||||
import com.intellij.psi.PsiMethod
|
import com.intellij.psi.PsiMethod
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun createCallerMethodsTreeStructure(project: Project, method: PsiMethod, scopeType: String): CallerMethodsTreeStructure {
|
fun createCallerMethodsTreeStructure(project: Project, method: PsiMethod, scopeType: String): CallerMethodsTreeStructure {
|
||||||
return CallerMethodsTreeStructure(project, method as PsiMember, scopeType)
|
return CallerMethodsTreeStructure(project, method, scopeType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
fun createCalleeMethodsTreeStructure(project: Project, method: PsiMethod, scopeType: String): CalleeMethodsTreeStructure {
|
fun createCalleeMethodsTreeStructure(project: Project, method: PsiMethod, scopeType: String): CalleeMethodsTreeStructure {
|
||||||
return CalleeMethodsTreeStructure(project, method as PsiMember, scopeType)
|
return CalleeMethodsTreeStructure(project, method, scopeType)
|
||||||
}
|
}
|
||||||
+16
-2
@@ -5,14 +5,28 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.navigationToolbar
|
package org.jetbrains.kotlin.idea.navigationToolbar
|
||||||
|
|
||||||
import com.intellij.ide.navigationToolbar.AbstractNavBarModelExtension
|
import com.intellij.ide.navigationToolbar.StructureAwareNavBarModelExtension
|
||||||
|
import com.intellij.lang.Language
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinIconProvider
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
abstract class AbstractNavBarModelExtensionCompatBase : AbstractNavBarModelExtension() {
|
abstract class AbstractNavBarModelExtensionCompatBase : StructureAwareNavBarModelExtension() {
|
||||||
|
|
||||||
protected abstract fun adjustElementImpl(psiElement: PsiElement?): PsiElement?
|
protected abstract fun adjustElementImpl(psiElement: PsiElement?): PsiElement?
|
||||||
|
|
||||||
override fun adjustElement(psiElement: PsiElement): PsiElement? =
|
override fun adjustElement(psiElement: PsiElement): PsiElement? =
|
||||||
adjustElementImpl(psiElement)
|
adjustElementImpl(psiElement)
|
||||||
|
|
||||||
|
override val language: Language
|
||||||
|
get() = KotlinLanguage.INSTANCE
|
||||||
|
|
||||||
|
override fun acceptParentFromModel(psiElement: PsiElement?): Boolean {
|
||||||
|
if (psiElement is KtFile) {
|
||||||
|
return KotlinIconProvider.getSingleClass(psiElement) == null
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.navigationToolbar
|
||||||
|
|
||||||
|
import com.intellij.ide.navigationToolbar.AbstractNavBarModelExtension
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
|
||||||
|
// FIX ME WHEN BUNCH 193 REMOVED
|
||||||
|
abstract class AbstractNavBarModelExtensionCompatBase : AbstractNavBarModelExtension() {
|
||||||
|
|
||||||
|
protected abstract fun adjustElementImpl(psiElement: PsiElement?): PsiElement?
|
||||||
|
|
||||||
|
override fun adjustElement(psiElement: PsiElement): PsiElement? =
|
||||||
|
adjustElementImpl(psiElement)
|
||||||
|
}
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.navigationToolbar
|
|
||||||
|
|
||||||
import com.intellij.ide.navigationToolbar.StructureAwareNavBarModelExtension
|
|
||||||
import com.intellij.lang.Language
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinIconProvider
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
|
|
||||||
// FIX ME WHEN BUNCH 193 REMOVED
|
|
||||||
abstract class AbstractNavBarModelExtensionCompatBase : StructureAwareNavBarModelExtension() {
|
|
||||||
|
|
||||||
protected abstract fun adjustElementImpl(psiElement: PsiElement?): PsiElement?
|
|
||||||
|
|
||||||
override fun adjustElement(psiElement: PsiElement): PsiElement? =
|
|
||||||
adjustElementImpl(psiElement)
|
|
||||||
|
|
||||||
override val language: Language
|
|
||||||
get() = KotlinLanguage.INSTANCE
|
|
||||||
|
|
||||||
override fun acceptParentFromModel(psiElement: PsiElement?): Boolean {
|
|
||||||
if (psiElement is KtFile) {
|
|
||||||
return KotlinIconProvider.getSingleClass(psiElement) == null
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user