Compare commits

...

91 Commits

Author SHA1 Message Date
Vyacheslav Gerasimov
7e64c577a5 Build against Android plugin 3.0 2017-12-18 15:20:45 +03:00
Nicolay Mitropolsky
f277f2828a update_dependencies.xml: getting trove4j.jar from @{idea.dir}/lib 2017-12-16 11:18:05 +03:00
Nicolay Mitropolsky
4fbd9ebca8 KotlinTestUtils compilation fix: ShutDownTracker.invokeAndWait removed 2017-12-16 11:17:03 +03:00
Vyacheslav Gerasimov
b25d43b427 Set correct since-build for Idea 181 plugin 2017-12-16 11:17:02 +03:00
Nicolay Mitropolsky
f9bc41ab7b Using setText instead of text = in EditorTextField after nullability changes in platform 2017-12-16 11:17:01 +03:00
Nicolay Mitropolsky
77f318a672 compilation fix when access progressIndicator in ProgressManager by adding !! 2017-12-16 11:17:00 +03:00
Nicolay Mitropolsky
3a267879b3 compilation fixes related to BackspaceHandlerDelegate and DocumentWindowImpl changes in IDEA 181 2017-12-16 11:16:59 +03:00
Nicolay Mitropolsky
4fa7bdca21 kapt/build.gradle.kts: dependencies fixes after refactorings in platform 2017-12-15 14:47:32 +03:00
Nicolay Mitropolsky
d731de67aa build.gradle.kts: a lot of dependencies fixes after refactorings in platform 2017-12-15 14:47:32 +03:00
Nicolay Mitropolsky
e19c3d753e fix for KotlinDebuggerTestCase compilation 2017-12-15 14:47:31 +03:00
Nicolay Mitropolsky
19697d4ca8 fix after ExtendWordSelectionHandlerBase nullability change in platform 2017-12-15 14:47:31 +03:00
Nicolay Mitropolsky
1b643787df Build: IDEA 173 -> 181 and corresponding dependencies fixes 2017-12-15 14:47:31 +03:00
Nicolay Mitropolsky
bae6de336a UAST: lazy computation made SYNCHRONIZED in UAST
because of UElement caching in platform, which leads to multithreaded usage
2017-12-15 14:47:30 +03:00
Nicolay Mitropolsky
70189dc10f == 173 -> 181 ^^^ == 2017-12-15 14:47:30 +03:00
Nicolay Mitropolsky
989aa38707 Uast: handling @receiver annotations 2017-12-15 14:14:16 +03:00
Nicolay Mitropolsky
4d1e0eaaa6 Uast: Constructors.kt testdata fixes 2017-12-15 14:14:16 +03:00
Nicolay Mitropolsky
b62cecba4a Uast: uastParent made final in KotlinAbstractUElement 2017-12-15 14:14:16 +03:00
Nicolay Mitropolsky
3d7102afc8 Uast: no more need to exclude UIdentifier from JvmDeclarationUElement check 2017-12-15 14:14:15 +03:00
Nicolay Mitropolsky
84015f6c8d Uast: making AbstractKotlinUClass not inherit from AbstractJavaUClass 2017-12-15 14:14:15 +03:00
Nicolay Mitropolsky
65291a388c Uast: removing java-uast usage from KotlinUastLanguagePlugin and KotlinEnumConstantClassReference 2017-12-15 14:14:15 +03:00
Nicolay Mitropolsky
dc6d7b71b5 Uast: AbstractKotlinUVariable annotations now are retrieved from Kotlin Psi, not from compiled (KT-21025)
and `KotlinNullabilityUAnnotation` now is created for every `AbstractKotlinUVariable`
2017-12-15 14:14:14 +03:00
Nicolay Mitropolsky
a360d6d75e Uast: WrappedUAnnotation as replacement for usage of JavaUAnnotation (KT-21025) 2017-12-15 13:57:02 +03:00
Vyacheslav Gerasimov
62891b2918 Set correct until-build for Idea 173 plugin 2017-12-15 13:57:02 +03:00
Nicolay Mitropolsky
298c68d865 Fixing non-running tests, that used MockApplication environment 2017-12-15 13:57:01 +03:00
Alexey Sedunov
d29c7d4a1a Data Inflow: Support grouping by expression nullability 2017-12-15 13:57:00 +03:00
Nicolay Mitropolsky
fd56e49123 Uast: Constructors.kt testData fixes 2017-12-15 13:57:00 +03:00
Alexey Sedunov
cba7df5ce6 Data Inflow: Support grouping by leaf expressions 2017-12-15 13:57:00 +03:00
Alexey Sedunov
a69bbf2ed5 Safe Delete: Suppress walking through light field initializer
This fixes some tests failing in 173 branch

 #KT-21508 Fixed
2017-12-15 13:56:59 +03:00
Nikolay Krasko
57dfd10e57 Fix inAnnotation test in 173 branch 2017-12-15 13:56:58 +03:00
Nikolay Krasko
58af99dba2 Update file name replace in QuickFix tests 2017-12-15 13:56:58 +03:00
Nicolay Mitropolsky
e08eefc37d Uast: SuperCalls.render.txt testdata fix 2017-12-15 13:56:58 +03:00
Nicolay Mitropolsky
589055bbf1 Uast: AbstractKotlinUClass compilation fix 2017-12-15 13:56:58 +03:00
Nicolay Mitropolsky
1b2f10d8d9 Spring: fix for package-completion tests
because otherwise `java` package name interfere with `java` directory name completion from somewhere
2017-12-15 13:56:57 +03:00
Nicolay Mitropolsky
bec496aab6 Spring: removing needless EP-s because they ported to UAST in platform 2017-12-15 13:56:57 +03:00
Nicolay Mitropolsky
d30304c129 KotlinSpringComponentScanInspection made to support platform JamReferenceContributor 2017-12-15 13:56:57 +03:00
Vyacheslav Gerasimov
5ca1b8d8e9 Drop missing gradle extensions from gradle.xml 2017-12-15 13:56:56 +03:00
Nikolay Krasko
08c313ebaa Update test data because of changed action name in 173 2017-12-15 13:56:56 +03:00
Nicolay Mitropolsky
30e30f0330 Idea version set to 173.3727.22(RC1) 2017-12-15 13:56:56 +03:00
Nicolay Mitropolsky
dcb5645493 UAST: StringTemplateComplex testdata fix 2017-12-15 13:56:55 +03:00
Alexey Sedunov
7e9f526c7c Line Markers: Respect subclass module when filtering out duplicates
#KT-21010 Fixed
2017-12-15 13:56:55 +03:00
Alexey Sedunov
fd266532ec Move: Fix applicability check in IDEA 173 2017-12-15 13:56:54 +03:00
Vyacheslav Gerasimov
c0a64432f9 Fix formatting for new kotlin dsl gradle project build script 2017-12-15 13:56:54 +03:00
Vyacheslav Gerasimov
1aadfc9cf3 Drop new Kotlin Dsl gradle project wizard which has been merged to idea 2017-12-15 13:56:54 +03:00
Nicolay Mitropolsky
f886abc79e SpringTestFixtureExtension: option to forbid facet autoconfigure added 2017-12-15 13:56:53 +03:00
Nicolay Mitropolsky
9abe01e14c SpringKotlinAutowiringInspection: getting rid of SpringJavaInjectionPointsAutowiringInspection 2017-12-15 13:56:53 +03:00
Nicolay Mitropolsky
9e21bb6945 AbstractIntentionTest: isApplicableOnPooled made run under ProgressIndicator 2017-12-15 13:56:53 +03:00
Vyacheslav Gerasimov
dc33633076 Update ideaVersion to 173.3415.22 2017-12-15 13:56:52 +03:00
Nicolay Mitropolsky
58e8eafb83 Ultimate-plugin: UAST added as dependency 2017-12-15 13:56:51 +03:00
Nicolay Mitropolsky
a0bf196835 Ultimate-plugin: multiplePropertiesAnnotationConfig.kt test data fixes
`@Qualifier` should not be there. It was a bug in platform
2017-12-15 13:56:51 +03:00
Nicolay Mitropolsky
8c7c812ca9 AbstractQuickFixTest: FORCE_PACKAGE_FOLDER directive added
It was added as workaround for IDEA-176033 (IDEA-176032 in particular)
2017-12-15 13:56:51 +03:00
Nicolay Mitropolsky
7ca871b64a AbstractExtractionTest: fix for invalid files
`configureByFile` should be run after other configurations (like `configureKotlinRuntimeAndSdk`) because they could make configured file invalid
2017-12-15 13:56:51 +03:00
Nicolay Mitropolsky
5548d9f0d0 RecursiveMethodCallMarkerInfo and SuspendCallMarkerInfo forced to target Leaf-elements
because of restriction added in IDEA 173
2017-12-15 13:56:50 +03:00
Nicolay Mitropolsky
6e0d8ae768 AbstractNavigateToLibraryTest: fix for invalid files
otherwise current file is invalidated by `configureAs` and `additionalConfig`
2017-12-15 13:56:50 +03:00
Nicolay Mitropolsky
60c798e896 EdtTestUtil.runInEdtAndWait fix for proper user action emulation
changed because `com.intellij.ide.IdeEventQueue` doesn't consider events from `SwingUtilities.invokeAndWait` as user interaction
2017-12-15 13:56:50 +03:00
Nicolay Mitropolsky
340097be8c KotlinCoreEnvironment: set ideaCompatibleBuildNumber = "173.1" 2017-12-15 13:56:49 +03:00
Nicolay Mitropolsky
5b1905cb63 UAST: SimpleKotlinRenderLogTest.testWhenAndDestructing testdata fix 2017-12-15 13:56:49 +03:00
Nicolay Mitropolsky
0ec968b926 AbstractJavaToKotlinConverterForWebDemoTest: setup fix: JvmElementProvider and JavaModuleSystem added 2017-12-15 13:56:49 +03:00
Mikhail Glukhikh
dce6e6d66e ExpressionOfTypeProcessor: get member name in read action 2017-12-15 13:56:49 +03:00
Mikhail Glukhikh
4ae15455e8 Fix find usages tests in 173 (run via ProgressIndicator) 2017-12-15 13:56:48 +03:00
Nicolay Mitropolsky
1e353cfe56 Workaround for CoreEnvironment initialization: explicitly setting versions for extensions 2017-12-15 13:56:48 +03:00
Nicolay Mitropolsky
ceb968602e Spring gutter icons SpringApiIcons -> SpringApiIcons.Gutter fix.
Following the patch in idea https://upsource.jetbrains.com/IDEA/revision/ultimate-527b9189219f191b62eed59d699f57acccda05c3
2017-12-15 13:56:48 +03:00
Nicolay Mitropolsky
012b00fa18 Idea version set to 173.3302.8 2017-12-15 13:56:47 +03:00
Nikolay Krasko
47230e1dab Update file structure tests as FileStructurePopup api was changed in 173 2017-12-15 13:56:46 +03:00
Nicolay Mitropolsky
a7371ee319 Spring-Kotlin: Gutter repaired (KT-20550, KT-20566)
Platform now allows Gutter to be placed only on leafs elements, this patch fixes it for `KotlinSpringClassAnnotator`.
2017-12-15 13:56:46 +03:00
Ilya Gorbunov
fb090265ed streamex version was changed in 173-snapshot to 0.6.5 2017-12-15 13:56:46 +03:00
Nicolay Mitropolsky
859f3dda92 UAST: support for JvmDeclarationUElement 2017-12-15 13:56:46 +03:00
Nicolay Mitropolsky
c4a46aad3b UAST test data fixes: LocalVariableWithAnnotationKt fix for variable type
it is not clear for me why it was not `String`
2017-12-15 13:56:45 +03:00
Nicolay Mitropolsky
91a980f1a5 UAST test data fixes: @null in render
as a "nullability" annotation for primitive types
2017-12-15 13:56:45 +03:00
Nicolay Mitropolsky
d9834ca17c idea-version set to since-build="173.1" until-build="181.*" 2017-12-15 13:56:45 +03:00
Vyacheslav Gerasimov
d5b9c51361 Fix GradleNoduleBuilder use qualified names check 2017-12-15 13:56:44 +03:00
Nicolay Mitropolsky
757b17334a JvmFacade-related tests repair 2017-12-15 13:56:43 +03:00
Simon Ogorodnik
467ff34b6a Fix proguard settings for 173 2017-12-15 13:56:43 +03:00
Simon Ogorodnik
e880f5e01c Fix compilation in 173 2017-12-15 13:56:43 +03:00
Anton Bannykh
ce27c0b87e Fix compilation (MockParameterInfoUIContext.java)
(cherry picked from commit 21b0956)
2017-12-15 13:56:43 +03:00
Nicolay Mitropolsky
c3f5d68439 KotlinLanguageInjector using Registry to enable annotation injections
(cherry picked from commit 8bdfeb7)
2017-12-15 13:56:42 +03:00
Simon Ogorodnik
74203fa108 Fix compilation 2017-12-15 13:56:42 +03:00
Dmitry Jemerov
327edd4a09 Fix compatibility with BuildScriptDataBuilder API changes 2017-12-15 13:56:42 +03:00
Nicolay Mitropolsky
133b50e4de KotlinLanguageInjector#injectInAnnotationCall optimization: using PsiClassNamePatternCondition to avoid calling getResolvedCall 2017-12-15 13:56:42 +03:00
Nicolay Mitropolsky
795c2b4cd5 KotlinLanguageInjector can inject into files modified for autocompletion 2017-12-15 13:56:41 +03:00
Nicolay Mitropolsky
d9fe2a2fd7 KotlinLanguageInjector understands patterns-injections into Java annotations 2017-12-15 13:56:41 +03:00
xiexed
025d3f5f57 KtLightAbstractAnnotation build fix for 173 (#1283) 2017-12-15 13:56:41 +03:00
Dmitry Jemerov
8c747d721e Register new service and EPs added in 173 2017-12-15 13:56:41 +03:00
xiexed
25504cd74f Fixes for 173 after 28.08.17 changes in IDEA (#1271)
* `JarFileSystem.getJarRootForLocalFile` now is nullable in IDEA

* Spring-related renamings following ones in IDEA
2017-12-15 13:56:40 +03:00
Nicolay Mitropolsky
4c5a3b3aae Build fix for KotlinSpringClassAnnotator after collectNavigationMarkers nullability changes in IDEA 173 2017-12-15 13:56:40 +03:00
Vyacheslav Gerasimov
ba6d2a6a3a UAST: Fix testPropertyWithAnnotation 2017-12-15 13:56:40 +03:00
Vyacheslav Gerasimov
5393962ec7 UAST: Add testConvertTypeInAnnotation 2017-12-15 13:56:39 +03:00
Vyacheslav Gerasimov
c65aebbafb UAST: override getFunctionalInterfaceType + test 2017-12-15 13:56:39 +03:00
Vyacheslav Gerasimov
d73b7fa40f UAST: Properly handle annotations on local variables 2017-12-15 13:56:39 +03:00
Vyacheslav Gerasimov
3943affffc Fix compilation 2017-12-15 13:56:39 +03:00
Vyacheslav Gerasimov
1fbb44757e Download IDEA 173.3188.16 2017-12-15 13:56:38 +03:00
Nikolay Krasko
767beeb7ad == 172 -> 173 ^^^ == 2017-12-15 13:56:37 +03:00
473 changed files with 3234 additions and 63137 deletions

View File

@@ -28,6 +28,9 @@ import com.intellij.ide.highlighter.JavaFileType
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.lang.MetaLanguage
import com.intellij.lang.java.JavaParserDefinition
import com.intellij.lang.jvm.facade.JvmElementProvider
import com.intellij.lang.jvm.facade.JvmFacade
import com.intellij.lang.jvm.facade.JvmFacadeImpl
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.TransactionGuard
import com.intellij.openapi.application.TransactionGuardImpl
@@ -43,6 +46,7 @@ import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.*
import com.intellij.openapi.vfs.impl.ZipHandler
import com.intellij.psi.FileContextProvider
import com.intellij.psi.JavaModuleSystem
import com.intellij.psi.PsiElementFinder
import com.intellij.psi.PsiManager
import com.intellij.psi.augment.PsiAugmentProvider
@@ -377,7 +381,7 @@ class KotlinCoreEnvironment private constructor(
}
companion object {
private val ideaCompatibleBuildNumber = "172.9999"
private val ideaCompatibleBuildNumber = "173.1"
init {
setCompatibleBuild()
@@ -500,6 +504,8 @@ class KotlinCoreEnvironment private constructor(
//
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier::class.java)
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), MetaLanguage.EP_NAME, MetaLanguage::class.java)
//
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), JavaModuleSystem.EP_NAME, JavaModuleSystem::class.java)
}
private fun registerApplicationExtensionPointsAndExtensionsFrom(configuration: CompilerConfiguration, configFilePath: String) {
@@ -549,6 +555,7 @@ class KotlinCoreEnvironment private constructor(
private fun registerProjectExtensionPoints(area: ExtensionsArea) {
CoreApplicationEnvironment.registerExtensionPoint(area, PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor::class.java)
CoreApplicationEnvironment.registerExtensionPoint(area, PsiElementFinder.EP_NAME, PsiElementFinder::class.java)
CoreApplicationEnvironment.registerExtensionPoint(area, JvmElementProvider.EP_NAME, JvmElementProvider::class.java)
}
// made public for Upsource

View File

@@ -61,6 +61,7 @@ messages/**)
-dontwarn net.jpountz.lz4.LZ4Factory
-dontwarn org.jetbrains.annotations.ReadOnly
-dontwarn org.jetbrains.annotations.Mutable
-dontwarn com.intellij.util.io.TarUtil
#-libraryjars '<rtjar>'
#-libraryjars '<jssejar>'

View File

@@ -53,6 +53,12 @@ abstract class KtLightAbstractAnnotation(parent: PsiElement, computeDelegate: ()
override fun getParameterList() = clsDelegate.parameterList
override fun canNavigate(): Boolean = super<KtLightElementBase>.canNavigate()
override fun canNavigateToSource(): Boolean = super<KtLightElementBase>.canNavigateToSource()
override fun navigate(requestFocus: Boolean) = super<KtLightElementBase>.navigate(requestFocus)
open fun fqNameMatches(fqName: String): Boolean = qualifiedName == fqName
}
@@ -283,6 +289,12 @@ class KtLightNonExistentAnnotation(parent: KtLightElement<*, *>) : KtLightElemen
override fun findDeclaredAttributeValue(attributeName: String?) = null
override fun getMetaData() = null
override fun getParameterList() = KtLightEmptyAnnotationParameterList(this)
override fun canNavigate(): Boolean = super<KtLightElementBase>.canNavigate()
override fun canNavigateToSource(): Boolean = super<KtLightElementBase>.canNavigateToSource()
override fun navigate(requestFocus: Boolean) = super<KtLightElementBase>.navigate(requestFocus)
}
class KtLightEmptyAnnotationParameterList(parent: PsiElement) : KtLightElementBase(parent), PsiAnnotationParameterList {

View File

@@ -26,7 +26,7 @@ dependencies {
testCompileOnly(project(":kotlin-reflect-api"))
testCompile(commonDep("junit:junit"))
testCompile(ideaSdkCoreDeps("intellij-core"))
testCompile(ideaSdkDeps("openapi", "idea", "idea_rt"))
testCompile(ideaSdkDeps("openapi", "idea", "idea_rt", "platform-api"))
testCompile(preloadedDeps("dx", subdir = "android-5.0/lib"))
}

View File

@@ -409,11 +409,11 @@ public class KotlinTestUtils {
private static void deleteOnShutdown(File file) {
if (filesToDelete.isEmpty()) {
ShutDownTracker.getInstance().registerShutdownTask(() -> ShutDownTracker.invokeAndWait(true, true, () -> {
ShutDownTracker.getInstance().registerShutdownTask(() -> {
for (File victim : filesToDelete) {
FileUtil.delete(victim);
}
}));
});
}
filesToDelete.add(file);

View File

@@ -16,6 +16,8 @@
package org.jetbrains.kotlin.test.testFramework
import com.intellij.mock.MockApplication
import com.intellij.openapi.application.ApplicationManager
import org.jetbrains.annotations.TestOnly
import java.lang.reflect.InvocationTargetException
import javax.swing.SwingUtilities
@@ -39,7 +41,12 @@ fun runInEdtAndWait(runnable: () -> Unit) {
}
else {
try {
SwingUtilities.invokeAndWait(runnable)
val application = ApplicationManager.getApplication()
.takeIf { it !is MockApplication } // because MockApplication do nothing instead of `invokeAndWait`
if (application != null)
application.invokeAndWait(runnable)
else
SwingUtilities.invokeAndWait(runnable)
}
catch (e: InvocationTargetException) {
throw e.cause ?: e

View File

@@ -52,6 +52,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public abstract class KtUsefulTestCase extends TestCase {
@@ -217,9 +218,11 @@ public abstract class KtUsefulTestCase extends TestCase {
protected void runTest() throws Throwable {
Throwable[] throwables = new Throwable[1];
AtomicBoolean completed = new AtomicBoolean(false);
Runnable runnable = () -> {
try {
super.runTest();
completed.set(true);
}
catch (InvocationTargetException e) {
e.fillInStackTrace();
@@ -239,6 +242,9 @@ public abstract class KtUsefulTestCase extends TestCase {
if (throwables[0] != null) {
throw throwables[0];
}
if (!completed.get()) {
throw new IllegalStateException("test didn't start");
}
}
private static void invokeTestRunnable(@NotNull Runnable runnable) throws Exception {

View File

@@ -30,14 +30,15 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
public class MockFileManager implements FileManager {
private final PsiManagerEx myManager;
// in mock tests it's LightVirtualFile, they're only alive when they're referenced,
// and there can not be several instances representing the same file
private final FactoryMap<VirtualFile, FileViewProvider> myViewProviders = new ConcurrentWeakFactoryMap<VirtualFile, FileViewProvider>() {
private final ConcurrentMap<VirtualFile, FileViewProvider> myViewProviders = new ConcurrentWeakFactoryMap<VirtualFile, FileViewProvider>() {
@Override
protected Map<VirtualFile, FileViewProvider> createMap() {
protected ConcurrentMap<VirtualFile, FileViewProvider> createMap() {
return ContainerUtil.createConcurrentWeakKeyWeakValueMap();
}

View File

@@ -130,7 +130,9 @@ import org.jetbrains.kotlin.idea.repl.AbstractIdeReplCompletionTest
import org.jetbrains.kotlin.idea.resolve.*
import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationHighlightingTest
import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationNavigationTest
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerTest
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerLeafGroupingTest
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerNullnessGroupingTest
import org.jetbrains.kotlin.idea.slicer.AbstractSlicerTreeTest
import org.jetbrains.kotlin.idea.structureView.AbstractKotlinFileStructureTest
import org.jetbrains.kotlin.idea.stubs.AbstractMultiFileHighlightingTest
import org.jetbrains.kotlin.idea.stubs.AbstractResolveByStubTest
@@ -709,9 +711,17 @@ fun main(args: Array<String>) {
model("refactoring/nameSuggestionProvider")
}
testClass<AbstractSlicerTest> {
testClass<AbstractSlicerTreeTest> {
model("slicer", singleClass = true)
}
testClass<AbstractSlicerLeafGroupingTest> {
model("slicer/inflow", singleClass = true)
}
testClass<AbstractSlicerNullnessGroupingTest> {
model("slicer/inflow", singleClass = true)
}
}
testGroup("idea/idea-maven/test", "idea/idea-maven/testData") {

View File

@@ -51,7 +51,7 @@ dependencies {
testCompile(project(":idea:idea-maven")) { isTransitive = false }
testCompile(commonDep("junit:junit"))
testCompileOnly(ideaPluginDeps("gradle-base-services", "gradle-tooling-extension-impl", "gradle-wrapper", plugin = "gradle"))
testCompileOnly(ideaPluginDeps("gradle-api", "gradle-tooling-extension-impl", "gradle-wrapper", plugin = "gradle"))
testCompileOnly(ideaPluginDeps("Groovy", plugin = "Groovy"))
testCompileOnly(ideaPluginDeps("maven", "maven-server-api", plugin = "maven"))

View File

@@ -5,6 +5,7 @@ dependencies {
compile(project(":compiler:util"))
compile(project(":compiler:frontend"))
compile(ideaSdkDeps("openapi"))
compile(ideaSdkDeps("platform-api"))
}
sourceSets {

View File

@@ -31,7 +31,7 @@ fun KtUserType.aliasImportMap(): Multimap<String, String> {
return (file as KtFile).aliasImportMap()
}
private fun KtFile.aliasImportMap(): Multimap<String, String> {
fun KtFile.aliasImportMap(): Multimap<String, String> {
val cached = getUserData(ALIAS_IMPORT_DATA_KEY)
val modificationStamp = modificationStamp
if (cached != null && modificationStamp == cached.fileModificationStamp) {

View File

@@ -33,7 +33,7 @@ class KtLightClassForDecompiledDeclaration(
override val kotlinOrigin: KtClassOrObject?,
private val file: KtClsFile
) : KtLightClassBase(clsDelegate.manager) {
val fqName = kotlinOrigin?.fqName ?: FqName(clsDelegate.qualifiedName)
val fqName = kotlinOrigin?.fqName ?: FqName(clsDelegate.qualifiedName.orEmpty())
override fun copy() = this

View File

@@ -335,10 +335,11 @@ class ExpressionsOfTypeProcessor(
val searchRequestCollector = SearchRequestCollector(SearchSession())
val resultProcessor = StaticMemberRequestResultProcessor(member, classes)
val memberName = runReadAction { member.name }
for (klass in classes) {
val request = klass.name + "." + declarationName
testLog { "Searched references to static ${member.name} in non-Java files by request $request" }
testLog { "Searched references to static $memberName in non-Java files by request $request" }
searchRequestCollector.searchWord(
request,
classUseScope(klass).intersectWith(memberScope), UsageSearchContext.IN_CODE, true, member, resultProcessor)
@@ -347,7 +348,7 @@ class ExpressionsOfTypeProcessor(
if (qualifiedName != null) {
val importAllUnderRequest = qualifiedName + ".*"
testLog { "Searched references to static ${member.name} in non-Java files by request $importAllUnderRequest" }
testLog { "Searched references to static $memberName in non-Java files by request $importAllUnderRequest" }
searchRequestCollector.searchWord(
importAllUnderRequest,
classUseScope(klass).intersectWith(memberScope), UsageSearchContext.IN_CODE, true, member, resultProcessor)

View File

@@ -13,8 +13,8 @@ dependencies {
compile(project(":idea:idea-gradle"))
compile(ideaSdkDeps("openapi", "idea"))
compile(ideaPluginDeps("gradle-tooling-api", plugin = "gradle"))
compile(ideaPluginDeps("android", "android-common", "sdklib", "sdk-common", "sdk-tools", "layoutlib-api", plugin = "android"))
compile(ideaPluginDeps("gradle-api", plugin = "gradle"))
compile(ideaPluginDeps("android", "android-common", "android-base-common", "sdklib", "sdk-common", "sdk-tools", "layoutlib-api", plugin = "android"))
compile(preloadedDeps("dx", subdir = "android-5.0/lib"))
testCompile(projectDist(":kotlin-test:kotlin-test-jvm"))

View File

@@ -4,8 +4,8 @@ apply { plugin("kotlin") }
dependencies {
compile(project(":compiler:util"))
compile(ideaSdkCoreDeps("intellij-core"))
compile(ideaPluginDeps("gradle-tooling-api", plugin = "gradle"))
compile(ideaPluginDeps("android", "android-common", "sdk-common", plugin = "android"))
compile(ideaPluginDeps("gradle-api", plugin = "gradle"))
compile(ideaPluginDeps("android", "android-common", "android-base-common", "sdk-common", plugin = "android"))
}
sourceSets {

View File

@@ -34,6 +34,7 @@ import com.intellij.ui.awt.RelativePoint
import com.intellij.util.Function
import org.jetbrains.android.dom.manifest.Manifest
import org.jetbrains.android.facet.AndroidFacet
import org.jetbrains.android.resourceManagers.ModuleResourceManagers
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
import org.jetbrains.kotlin.psi.*
@@ -95,7 +96,8 @@ class KotlinAndroidLineMarkerProvider : LineMarkerProvider {
return
}
val files = androidFacet
val files = ModuleResourceManagers
.getInstance(androidFacet)
.localResourceManager
.findResourcesByFieldName(resClassName, info.fieldName)
.filterIsInstance<PsiFile>()

View File

@@ -23,8 +23,8 @@ import com.android.ide.common.resources.ResourceRepository;
import com.android.ide.common.resources.ResourceResolver;
import com.android.resources.ResourceType;
import com.android.tools.idea.configurations.Configuration;
import com.android.tools.idea.configurations.ConfigurationManager;
import com.android.tools.idea.res.AppResourceRepository;
import com.android.tools.idea.res.LocalResourceRepository;
import com.android.tools.idea.res.ResourceHelper;
import com.android.tools.idea.ui.resourcechooser.ColorPicker;
import com.android.utils.XmlUtils;
@@ -61,15 +61,14 @@ import java.awt.*;
import java.io.File;
import static com.android.SdkConstants.*;
import static com.android.SdkConstants.ANDROID_URI;
import static com.android.SdkConstants.ATTR_DRAWABLE;
import static com.android.tools.idea.uibuilder.property.renderer.NlDefaultRenderer.ICON_SIZE;
import static org.jetbrains.android.AndroidColorAnnotator.pickLayoutFile;
/**
* Contains copied privates from AndroidColorAnnotator, so we could use them for Kotlin AndroidResourceReferenceAnnotator
*/
public class ResourceReferenceAnnotatorUtil {
public static final int ICON_SIZE = 8;
@Nullable
public static File pickBitmapFromXml(@NotNull File file, @NotNull ResourceResolver resourceResolver, @NotNull Project project) {
try {
@@ -146,7 +145,7 @@ public class ResourceReferenceAnnotatorUtil {
ResourceItem item = frameworkResources.getResourceItem(type, name);
return item.getResourceValue(type, configuration.getFullConfig(), false);
} else {
LocalResourceRepository appResources = AppResourceRepository.getAppResources(module, true);
AppResourceRepository appResources = AppResourceRepository.getOrCreateInstance(module);
if (appResources == null) {
return null;
}
@@ -161,26 +160,27 @@ public class ResourceReferenceAnnotatorUtil {
@Nullable
public static Configuration pickConfiguration(AndroidFacet facet, Module module, PsiFile file) {
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
if(virtualFile == null) {
return null;
}
VirtualFile parent = virtualFile.getParent();
if (parent == null) {
return null;
}
VirtualFile layout;
String parentName = parent.getName();
if (!parentName.startsWith(FD_RES_LAYOUT)) {
layout = pickLayoutFile(module, facet);
if (layout == null) {
return null;
}
} else {
layout = virtualFile;
}
VirtualFile parent = virtualFile.getParent();
if(parent == null) {
return null;
} else {
String parentName = parent.getName();
VirtualFile layout;
if(!parentName.startsWith("layout")) {
layout = ResourceHelper.pickAnyLayoutFile(module, facet);
if(layout == null) {
return null;
}
} else {
layout = virtualFile;
}
return facet.getConfigurationManager().getConfiguration(layout);
return ConfigurationManager.getOrCreateInstance(module).getConfiguration(layout);
}
}
}
public static class ColorRenderer extends GutterIconRenderer {

View File

@@ -22,6 +22,7 @@ import com.intellij.openapi.roots.ProjectRootModificationTracker
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import org.jetbrains.android.facet.AndroidFacet
import org.jetbrains.android.sdk.AndroidSdkData
import org.jetbrains.kotlin.idea.debugger.evaluate.classLoading.AndroidDexer
import org.jetbrains.kotlin.idea.debugger.evaluate.classLoading.ClassToLoad
import java.io.File
@@ -56,7 +57,7 @@ class AndroidDexerImpl(val project: Project) : AndroidDexer {
private fun doGetAndroidDexFile(): File? {
for (module in ModuleManager.getInstance(project).modules) {
val androidFacet = AndroidFacet.getInstance(module) ?: continue
val sdkData = androidFacet.sdkData ?: continue
val sdkData = AndroidSdkData.getSdkData(androidFacet) ?: continue
val latestBuildTool = sdkData.getLatestBuildTool(/* allowPreview = */ false)
?: sdkData.getLatestBuildTool(/* allowPreview = */ true)
?: continue

View File

@@ -47,7 +47,6 @@ class ResourceFoldingBuilder : FoldingBuilderEx() {
// See lint's StringFormatDetector
private val FORMAT = Pattern.compile("%(\\d+\\$)?([-+#, 0(<]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])")
private val FOLD_MAX_LENGTH = 60
private val FORCE_PROJECT_RESOURCE_LOADING = true
private val UNIT_TEST_MODE: Boolean = ApplicationManager.getApplication().isUnitTestMode
private val RESOURCE_TYPES = listOf(ResourceType.STRING,
ResourceType.DIMEN,
@@ -254,6 +253,6 @@ class ResourceFoldingBuilder : FoldingBuilderEx() {
}
private fun getAppResources(element: PsiElement): LocalResourceRepository? = ModuleUtilCore.findModuleForPsiElement(element)?.let {
AppResourceRepository.getAppResources(it, FORCE_PROJECT_RESOURCE_LOADING)
AppResourceRepository.findExistingInstance(it)
}
}

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.android.inspection
import com.android.tools.idea.model.AndroidModuleInfo
import com.intellij.codeInspection.*
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElementVisitor
@@ -29,7 +30,11 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
class TypeParameterFindViewByIdInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool {
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
val compileSdk = AndroidFacet.getInstance(session.file)?.androidModuleInfo?.buildSdkVersion?.apiLevel
val compileSdk = AndroidFacet.getInstance(session.file)
?.let { facet -> AndroidModuleInfo.getInstance(facet) }
?.buildSdkVersion
?.apiLevel
if (compileSdk == null || compileSdk < 26) {
return KtVisitorVoid()
}

View File

@@ -29,6 +29,7 @@ import org.jetbrains.android.dom.resources.Attr;
import org.jetbrains.android.dom.resources.DeclareStyleable;
import org.jetbrains.android.facet.AndroidFacet;
import org.jetbrains.android.resourceManagers.LocalResourceManager;
import org.jetbrains.android.resourceManagers.ModuleResourceManagers;
import org.jetbrains.android.resourceManagers.ResourceManager;
import org.jetbrains.android.util.AndroidResourceUtil;
import org.jetbrains.android.util.AndroidUtils;
@@ -68,9 +69,10 @@ public class KotlinAndroidGotoDeclarationHandler implements GotoDeclarationHandl
collectManifestElements(nestedClassName, fieldName, facet, resourceList);
}
else {
ModuleResourceManagers managers = ModuleResourceManagers.getInstance(facet);
ResourceManager manager = info.isSystem()
? facet.getSystemResourceManager(false)
: facet.getLocalResourceManager();
? managers.getSystemResourceManager(false)
: managers.getLocalResourceManager();
if (manager == null) {
return null;
}

View File

@@ -15,8 +15,8 @@ dependencies {
compile(project(":idea:idea-jps-common"))
compile(project(":plugins:android-extensions-compiler"))
compile(ideaSdkCoreDeps("intellij-core", "util"))
compile(ideaSdkDeps("openapi", "idea"))
compile(ideaPluginDeps("gradle-tooling-api", "gradle", plugin = "gradle"))
compile(ideaSdkDeps("openapi", "idea", "platform-api", "platform-impl", "java-api", "java-impl"))
compile(ideaPluginDeps("gradle-api", "gradle", plugin = "gradle"))
compile(preloadedDeps("kotlinx-coroutines-core", "kotlinx-coroutines-jdk8"))
}

View File

@@ -3,7 +3,7 @@ apply { plugin("kotlin") }
dependencies {
compileOnly(ideaSdkDeps("openapi", "idea", "external-system-rt", "forms_rt"))
compileOnly(ideaPluginDeps("gradle-tooling-api", "gradle", "gradle-base-services", plugin = "gradle"))
compileOnly(ideaPluginDeps("gradle-api", "gradle", plugin = "gradle"))
compileOnly(ideaPluginDeps("Groovy", plugin = "Groovy"))
compileOnly(project(":idea"))
@@ -18,7 +18,7 @@ dependencies {
testCompile(projectTests(":idea"))
testCompile(project(":idea:idea-test-framework"))
testCompile(ideaPluginDeps("gradle-wrapper", "gradle-base-services", "gradle-tooling-extension-impl", "gradle-tooling-api", "gradle", plugin = "gradle"))
testCompile(ideaPluginDeps("gradle-wrapper", "gradle-tooling-extension-impl", "gradle-api", "gradle", plugin = "gradle"))
testCompile(ideaPluginDeps("Groovy", plugin = "Groovy"))
testCompileOnly(ideaSdkDeps("groovy-all", "idea_rt"))

View File

@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.kotlin.gradle.kdsl.GradleFrameworksWizardStep">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="22e59" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="ad16" binding="myOptionsPanel" layout-manager="CardLayout" hgap="0" vgap="0">
<constraints border-constraint="Center"/>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
</clientProperties>
<border type="none"/>
<children>
<grid id="27a92" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<card name="templates card"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="b50ee" binding="myFrameworksPanelPlaceholder" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<card name="frameworks card"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="916d9" class="com.intellij.ui.components.JBLabel" binding="myFrameworksLabel">
<constraints border-constraint="North"/>
<properties>
<text value="Additional Libraries and &amp;Frameworks:"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</children>
</grid>
</children>
</grid>
</form>

View File

@@ -1,101 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* 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.gradle.kdsl;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleFrameworkSupportProvider;
import org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleJavaFrameworkSupportProvider;
import javax.swing.*;
import java.awt.*;
import java.util.Collections;
import java.util.List;
public class GradleFrameworksWizardStep extends ModuleWizardStep implements Disposable {
private JPanel myPanel;
private final AddSupportForFrameworksPanel myFrameworksPanel;
private JPanel myFrameworksPanelPlaceholder;
private JPanel myOptionsPanel;
@SuppressWarnings("unused") private JBLabel myFrameworksLabel;
public GradleFrameworksWizardStep(WizardContext context, final ModuleBuilder builder) {
Project project = context.getProject();
final LibrariesContainer container = LibrariesContainerFactory.createContainer(context.getProject());
FrameworkSupportModelBase model = new FrameworkSupportModelBase(project, null, container) {
@NotNull
@Override
public String getBaseDirectoryForLibrariesPath() {
return StringUtil.notNullize(builder.getContentEntryPath());
}
};
myFrameworksPanel =
new AddSupportForFrameworksPanel(Collections.emptyList(), model, true, null);
List<FrameworkSupportInModuleProvider> providers = ContainerUtil.newArrayList();
Collections.addAll(providers, GradleFrameworkSupportProvider.EP_NAME.getExtensions());
myFrameworksPanel.setProviders(providers, Collections.emptySet(), Collections.singleton(GradleJavaFrameworkSupportProvider.ID));
Disposer.register(this, myFrameworksPanel);
myFrameworksPanelPlaceholder.add(myFrameworksPanel.getMainPanel());
ModuleBuilder.ModuleConfigurationUpdater configurationUpdater = new ModuleBuilder.ModuleConfigurationUpdater() {
@Override
public void update(@NotNull Module module, @NotNull ModifiableRootModel rootModel) {
myFrameworksPanel.addSupport(module, rootModel);
}
};
builder.addModuleConfigurationUpdater(configurationUpdater);
((CardLayout)myOptionsPanel.getLayout()).show(myOptionsPanel, "frameworks card");
}
@Override
public JComponent getComponent() {
return myPanel;
}
@Override
public void updateDataModel() {
}
@Override
public void dispose() {
}
@Override
public void disposeUIResources() {
Disposer.dispose(this);
}
}

View File

@@ -1,491 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* 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.gradle.kdsl;
import com.intellij.ide.fileTemplates.FileTemplate;
import com.intellij.ide.fileTemplates.FileTemplateManager;
import com.intellij.ide.highlighter.ModuleFileType;
import com.intellij.ide.projectWizard.ProjectSettingsStep;
import com.intellij.ide.util.EditorHelper;
import com.intellij.ide.util.projectWizard.JavaModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.SettingsStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.components.StorageScheme;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.importing.ImportSpec;
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder;
import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.model.project.ProjectId;
import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode;
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl;
import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalModuleBuilder;
import com.intellij.openapi.externalSystem.service.project.wizard.ExternalModuleSettingsStep;
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
import com.intellij.openapi.module.*;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.projectRoots.JavaSdkType;
import com.intellij.openapi.projectRoots.SdkTypeId;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.util.containers.ContainerUtil;
import org.gradle.util.GradleVersion;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.BuildScriptDataBuilder;
import org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.KotlinBuildScriptDataBuilder;
import org.jetbrains.plugins.gradle.service.settings.GradleProjectSettingsControl;
import org.jetbrains.plugins.gradle.settings.DistributionType;
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings;
import org.jetbrains.plugins.gradle.util.GradleConstants;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import static org.jetbrains.kotlin.gradle.kdsl.GradleKotlinDSLConstants.DEFAULT_SCRIPT_NAME;
public class GradleModuleBuilder extends AbstractExternalModuleBuilder<GradleProjectSettings> {
private static final Logger LOG = Logger.getInstance(GradleModuleBuilder.class);
private static final String TEMPLATE_GRADLE_SETTINGS = "Gradle Kotlin DSL Settings.gradle";
private static final String TEMPLATE_GRADLE_SETTINGS_MERGE = "Gradle Settings merge.gradle";
private static final String TEMPLATE_GRADLE_BUILD_WITH_WRAPPER = "Gradle Build Script with wrapper.gradle";
private static final String DEFAULT_TEMPLATE_GRADLE_BUILD = "Gradle Kotlin DSL Build Script.gradle";
private static final String TEMPLATE_ATTRIBUTE_PROJECT_NAME = "PROJECT_NAME";
private static final String TEMPLATE_ATTRIBUTE_MODULE_PATH = "MODULE_PATH";
private static final String TEMPLATE_ATTRIBUTE_MODULE_FLAT_DIR = "MODULE_FLAT_DIR";
private static final String TEMPLATE_ATTRIBUTE_MODULE_NAME = "MODULE_NAME";
private static final String TEMPLATE_ATTRIBUTE_MODULE_GROUP = "MODULE_GROUP";
private static final String TEMPLATE_ATTRIBUTE_MODULE_VERSION = "MODULE_VERSION";
private static final String TEMPLATE_ATTRIBUTE_GRADLE_VERSION = "GRADLE_VERSION";
private static final String TEMPLATE_ATTRIBUTE_BUILD_FILE_NAME = "BUILD_FILE_NAME";
private static final Key<KotlinBuildScriptDataBuilder> BUILD_SCRIPT_DATA =
Key.create("gradle.module.kotlinBuildScriptData");
private WizardContext myWizardContext;
@Nullable
private ProjectData myParentProject;
private boolean myInheritGroupId;
private boolean myInheritVersion;
private ProjectId myProjectId;
private String rootProjectPath;
public GradleModuleBuilder() {
super(GradleConstants.SYSTEM_ID, new GradleProjectSettings());
}
@Override
public String getPresentableName() {
return "Gradle (Kotlin DSL)";
}
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
LOG.assertTrue(getName() != null);
final String originModuleFilePath = getModuleFilePath();
LOG.assertTrue(originModuleFilePath != null);
String moduleName;
if (myProjectId == null) {
moduleName = getName();
}
else {
moduleName = ModuleGrouperKt.isQualifiedModuleNamesEnabled() && StringUtil.isNotEmpty(myProjectId.getGroupId())
? (myProjectId.getGroupId() + '.' + myProjectId.getArtifactId())
: myProjectId.getArtifactId();
}
Project contextProject = myWizardContext.getProject();
String projectFileDirectory = null;
if (myWizardContext.isCreatingNewProject() || contextProject == null || contextProject.getBasePath() == null) {
projectFileDirectory = myWizardContext.getProjectFileDirectory();
}
else if (myWizardContext.getProjectStorageFormat() == StorageScheme.DEFAULT) {
String moduleFileDirectory = getModuleFileDirectory();
if (moduleFileDirectory != null) {
projectFileDirectory = moduleFileDirectory;
}
}
if (projectFileDirectory == null) {
projectFileDirectory = contextProject.getBasePath();
}
if (myWizardContext.getProjectStorageFormat() == StorageScheme.DIRECTORY_BASED) {
projectFileDirectory += "/.idea/modules";
}
String moduleFilePath = projectFileDirectory + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION;
deleteModuleFile(moduleFilePath);
final ModuleType moduleType = getModuleType();
final Module module = moduleModel.newModule(moduleFilePath, moduleType.getId());
setupModule(module);
return module;
}
@Override
public void setupRootModel(final ModifiableRootModel modifiableRootModel) throws ConfigurationException {
String contentEntryPath = getContentEntryPath();
if (StringUtil.isEmpty(contentEntryPath)) {
return;
}
File contentRootDir = new File(contentEntryPath);
FileUtilRt.createDirectory(contentRootDir);
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
VirtualFile modelContentRootDir = fileSystem.refreshAndFindFileByIoFile(contentRootDir);
if (modelContentRootDir == null) {
return;
}
modifiableRootModel.addContentEntry(modelContentRootDir);
// todo this should be moved to generic ModuleBuilder
if (myJdk != null) {
modifiableRootModel.setSdk(myJdk);
}
else {
modifiableRootModel.inheritSdk();
}
final Project project = modifiableRootModel.getProject();
if (myParentProject != null) {
rootProjectPath = myParentProject.getLinkedExternalProjectPath();
}
else {
rootProjectPath =
FileUtil.toCanonicalPath(myWizardContext.isCreatingNewProject() ? project.getBasePath() : modelContentRootDir.getPath());
}
assert rootProjectPath != null;
final VirtualFile gradleBuildFile = setupGradleBuildFile(modelContentRootDir);
setupGradleSettingsFile(
rootProjectPath, modelContentRootDir, modifiableRootModel.getProject().getName(),
myProjectId == null ? modifiableRootModel.getModule().getName() : myProjectId.getArtifactId(),
myWizardContext.isCreatingNewProject() || myParentProject == null
);
if (gradleBuildFile != null) {
modifiableRootModel.getModule().putUserData(
BUILD_SCRIPT_DATA, new KotlinBuildScriptDataBuilder(gradleBuildFile));
}
}
@Override
protected void setupModule(Module module) throws ConfigurationException {
super.setupModule(module);
assert rootProjectPath != null;
VirtualFile buildScriptFile = null;
final BuildScriptDataBuilder buildScriptDataBuilder = getBuildScriptData(module);
try {
if (buildScriptDataBuilder != null) {
buildScriptFile = buildScriptDataBuilder.getBuildScriptFile();
String lineSeparator = lineSeparator(buildScriptFile);
String configurationPart = StringUtil.convertLineSeparators(buildScriptDataBuilder.buildConfigurationPart(), lineSeparator);
String existingText = StringUtil.trimTrailing(VfsUtilCore.loadText(buildScriptFile));
String content = (!configurationPart.isEmpty() ? configurationPart + lineSeparator : "") +
(!existingText.isEmpty() ? existingText + lineSeparator : "") +
lineSeparator +
StringUtil.convertLineSeparators(buildScriptDataBuilder.buildMainPart(), lineSeparator);
VfsUtil.saveText(buildScriptFile, content);
}
}
catch (IOException e) {
LOG.warn("Unexpected exception on applying frameworks templates", e);
}
final Project project = module.getProject();
if (myWizardContext.isCreatingNewProject()) {
getExternalProjectSettings().setExternalProjectPath(rootProjectPath);
AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID);
project.putUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT, Boolean.TRUE);
//noinspection unchecked
settings.linkProject(getExternalProjectSettings());
}
else {
FileDocumentManager.getInstance().saveAllDocuments();
final GradleProjectSettings gradleProjectSettings = getExternalProjectSettings();
final VirtualFile finalBuildScriptFile = buildScriptFile;
Runnable runnable = () -> {
if (myParentProject == null) {
gradleProjectSettings.setExternalProjectPath(rootProjectPath);
AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID);
//noinspection unchecked
settings.linkProject(gradleProjectSettings);
}
ImportSpec importSpec = new ImportSpecBuilder(project, GradleConstants.SYSTEM_ID)
.use(ProgressExecutionMode.IN_BACKGROUND_ASYNC)
.createDirectoriesForEmptyContentRoots()
.useDefaultCallback()
.build();
ExternalSystemUtil.refreshProject(rootProjectPath, importSpec);
final PsiFile psiFile;
if (finalBuildScriptFile != null) {
psiFile = PsiManager.getInstance(project).findFile(finalBuildScriptFile);
if (psiFile != null) {
EditorHelper.openInEditor(psiFile);
}
}
};
// execute when current dialog is closed
ExternalSystemUtil.invokeLater(project, ModalityState.NON_MODAL, runnable);
}
}
@Override
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
myWizardContext = wizardContext;
return new ModuleWizardStep[]{
new GradleModuleWizardStep(this, wizardContext),
new ExternalModuleSettingsStep<>(
wizardContext, this, new GradleProjectSettingsControl(getExternalProjectSettings()))
};
}
@Nullable
@Override
public ModuleWizardStep getCustomOptionsStep(WizardContext context, Disposable parentDisposable) {
final GradleFrameworksWizardStep step = new GradleFrameworksWizardStep(context, this);
Disposer.register(parentDisposable, step);
return step;
}
@Override
public boolean isSuitableSdkType(SdkTypeId sdk) {
return sdk instanceof JavaSdkType;
}
@Override
public String getParentGroup() {
return JavaModuleType.BUILD_TOOLS_GROUP;
}
@Override
public int getWeight() {
return JavaModuleBuilder.BUILD_SYSTEM_WEIGHT;
}
@Override
public ModuleType getModuleType() {
return StdModuleTypes.JAVA;
}
@Nullable
private VirtualFile setupGradleBuildFile(@NotNull VirtualFile modelContentRootDir)
throws ConfigurationException {
final VirtualFile file = getOrCreateExternalProjectConfigFile(modelContentRootDir.getPath(), GradleKotlinDSLConstants.DEFAULT_SCRIPT_NAME);
if (file != null) {
final String templateName = getExternalProjectSettings().getDistributionType() == DistributionType.WRAPPED
? TEMPLATE_GRADLE_BUILD_WITH_WRAPPER
: DEFAULT_TEMPLATE_GRADLE_BUILD;
Map<String, String> attributes = ContainerUtil.newHashMap();
if (myProjectId != null) {
attributes.put(TEMPLATE_ATTRIBUTE_MODULE_VERSION, myProjectId.getVersion());
attributes.put(TEMPLATE_ATTRIBUTE_MODULE_GROUP, myProjectId.getGroupId());
attributes.put(TEMPLATE_ATTRIBUTE_GRADLE_VERSION, GradleVersion.current().getVersion());
}
saveFile(file, templateName, attributes);
}
return file;
}
@Nullable
public static VirtualFile setupGradleSettingsFile(@NotNull String rootProjectPath,
@NotNull VirtualFile modelContentRootDir,
String projectName,
String moduleName,
boolean renderNewFile)
throws ConfigurationException {
final VirtualFile file = getOrCreateExternalProjectConfigFile(rootProjectPath, GradleConstants.SETTINGS_FILE_NAME);
if (file == null) return null;
if (renderNewFile) {
final String moduleDirName = VfsUtilCore.getRelativePath(modelContentRootDir, file.getParent(), '/');
Map<String, String> attributes = ContainerUtil.newHashMap();
attributes.put(TEMPLATE_ATTRIBUTE_PROJECT_NAME, projectName);
attributes.put(TEMPLATE_ATTRIBUTE_MODULE_PATH, moduleDirName);
attributes.put(TEMPLATE_ATTRIBUTE_MODULE_NAME, moduleName);
attributes.put(TEMPLATE_ATTRIBUTE_BUILD_FILE_NAME, DEFAULT_SCRIPT_NAME); // TODO: gradle > 4.0 doesn't need this
saveFile(file, TEMPLATE_GRADLE_SETTINGS, attributes);
}
else {
char separatorChar = file.getParent() == null || !VfsUtilCore.isAncestor(file.getParent(), modelContentRootDir, true) ? '/' : ':';
String modulePath = VfsUtil.getPath(file, modelContentRootDir, separatorChar);
Map<String, String> attributes = ContainerUtil.newHashMap();
attributes.put(TEMPLATE_ATTRIBUTE_MODULE_NAME, moduleName);
// check for flat structure
final String flatStructureModulePath =
modulePath != null && StringUtil.startsWith(modulePath, "../") ? StringUtil.trimStart(modulePath, "../") : null;
if (StringUtil.equals(flatStructureModulePath, modelContentRootDir.getName())) {
attributes.put(TEMPLATE_ATTRIBUTE_MODULE_FLAT_DIR, "true");
attributes.put(TEMPLATE_ATTRIBUTE_MODULE_PATH, flatStructureModulePath);
}
else {
attributes.put(TEMPLATE_ATTRIBUTE_MODULE_PATH, modulePath);
}
appendToFile(file, TEMPLATE_GRADLE_SETTINGS_MERGE, attributes);
}
return file;
}
private static void saveFile(@NotNull VirtualFile file, @NotNull String templateName, @Nullable Map templateAttributes)
throws ConfigurationException {
FileTemplateManager manager = FileTemplateManager.getDefaultInstance();
FileTemplate template = manager.getInternalTemplate(templateName);
try {
appendToFile(file, templateAttributes != null ? template.getText(templateAttributes) : template.getText());
}
catch (IOException e) {
LOG.warn(String.format("Unexpected exception on applying template %s config", GradleConstants.SYSTEM_ID.getReadableName()), e);
throw new ConfigurationException(
e.getMessage(), String.format("Can't apply %s template config text", GradleConstants.SYSTEM_ID.getReadableName())
);
}
}
private static void appendToFile(@NotNull VirtualFile file, @NotNull String templateName, @Nullable Map templateAttributes)
throws ConfigurationException {
FileTemplateManager manager = FileTemplateManager.getDefaultInstance();
FileTemplate template = manager.getInternalTemplate(templateName);
try {
appendToFile(file, templateAttributes != null ? template.getText(templateAttributes) : template.getText());
}
catch (IOException e) {
LOG.warn(String.format("Unexpected exception on appending template %s config", GradleConstants.SYSTEM_ID.getReadableName()), e);
throw new ConfigurationException(
e.getMessage(), String.format("Can't append %s template config text", GradleConstants.SYSTEM_ID.getReadableName())
);
}
}
@Nullable
private static VirtualFile getOrCreateExternalProjectConfigFile(@NotNull String parent, @NotNull String fileName) {
File file = new File(parent, fileName);
FileUtilRt.createIfNotExists(file);
return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
}
public void setParentProject(@Nullable ProjectData parentProject) {
myParentProject = parentProject;
}
public boolean isInheritGroupId() {
return myInheritGroupId;
}
public void setInheritGroupId(boolean inheritGroupId) {
myInheritGroupId = inheritGroupId;
}
public boolean isInheritVersion() {
return myInheritVersion;
}
public void setInheritVersion(boolean inheritVersion) {
myInheritVersion = inheritVersion;
}
public ProjectId getProjectId() {
return myProjectId;
}
public void setProjectId(@NotNull ProjectId projectId) {
myProjectId = projectId;
}
@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
if (settingsStep instanceof ProjectSettingsStep) {
final ProjectSettingsStep projectSettingsStep = (ProjectSettingsStep)settingsStep;
if (myProjectId != null) {
final JTextField moduleNameField = settingsStep.getModuleNameField();
if (moduleNameField != null) {
moduleNameField.setText(myProjectId.getArtifactId());
}
projectSettingsStep.setModuleName(myProjectId.getArtifactId());
}
projectSettingsStep.bindModuleSettings();
}
return super.modifySettingsStep(settingsStep);
}
public static void appendToFile(@NotNull VirtualFile file, @NotNull String text) throws IOException {
String lineSeparator = lineSeparator(file);
final String existingText = StringUtil.trimTrailing(VfsUtilCore.loadText(file));
String content = (StringUtil.isNotEmpty(existingText) ? existingText + lineSeparator : "") +
StringUtil.convertLineSeparators(text, lineSeparator);
VfsUtil.saveText(file, content);
}
@NotNull
private static String lineSeparator(@NotNull VirtualFile file) {
String lineSeparator = LoadTextUtil.detectLineSeparator(file, true);
if (lineSeparator == null) {
lineSeparator = CodeStyleSettingsManager.getSettings(ProjectManagerEx.getInstanceEx().getDefaultProject()).getLineSeparator();
}
return lineSeparator;
}
@Nullable
public static BuildScriptDataBuilder getBuildScriptData(@Nullable Module module) {
return module == null ? null : module.getUserData(BUILD_SCRIPT_DATA);
}
@Nullable
@Override
public Project createProject(String name, String path) {
Project project = super.createProject(name, path);
if (project != null) {
GradleProjectSettings settings = getExternalProjectSettings();
ExternalProjectsManagerImpl.getInstance(project).setStoreExternally(settings.isStoreProjectFilesExternally());
}
return project;
}
}

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.kotlin.gradle.kdsl.GradleModuleWizardStep">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="529" height="386"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="ddae6" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="d7d25"/>
<text value="GroupId"/>
</properties>
</component>
<component id="bbb74" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="efb5e"/>
<text value="ArtifactId"/>
</properties>
</component>
<component id="4eb56" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="b1344"/>
<text value="Version"/>
</properties>
</component>
<component id="d7d25" class="javax.swing.JTextField" binding="myGroupIdField">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="efb5e" class="javax.swing.JTextField" binding="myArtifactIdField">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="b1344" class="javax.swing.JTextField" binding="myVersionField">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="d0095" class="javax.swing.JCheckBox" binding="myInheritGroupIdCheckBox">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Inherit"/>
</properties>
</component>
<component id="897ff" class="javax.swing.JCheckBox" binding="myInheritVersionCheckBox">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Inherit"/>
</properties>
</component>
<grid id="102d8" binding="myAddToPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<grid id="90185" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
</properties>
<border type="none"/>
<children>
<vspacer id="f04b8">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</children>
</grid>
</form>

View File

@@ -1,257 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* 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.gradle.kdsl;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.model.project.ProjectId;
import com.intellij.openapi.externalSystem.service.project.wizard.ExternalModuleSettingsStep;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFocusManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.gradle.service.project.wizard.GradleParentProjectForm;
import org.jetbrains.plugins.gradle.util.GradleConstants;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class GradleModuleWizardStep extends ModuleWizardStep {
private static final Icon WIZARD_ICON = null;
private static final String INHERIT_GROUP_ID_KEY = "GradleModuleWizard.inheritGroupId";
private static final String INHERIT_VERSION_KEY = "GradleModuleWizard.inheritVersion";
private static final String DEFAULT_VERSION = "1.0-SNAPSHOT";
@Nullable
private final Project myProjectOrNull;
@NotNull
private final GradleModuleBuilder myBuilder;
@NotNull
private final WizardContext myContext;
@NotNull
private final GradleParentProjectForm myParentProjectForm;
private String myInheritedGroupId;
private String myInheritedVersion;
private JPanel myMainPanel;
private JTextField myGroupIdField;
private JCheckBox myInheritGroupIdCheckBox;
private JTextField myArtifactIdField;
private JTextField myVersionField;
private JCheckBox myInheritVersionCheckBox;
private JPanel myAddToPanel;
public GradleModuleWizardStep(@NotNull GradleModuleBuilder builder, @NotNull WizardContext context) {
myProjectOrNull = context.getProject();
myBuilder = builder;
myContext = context;
myParentProjectForm = new GradleParentProjectForm(context, parentProject -> updateComponents());
initComponents();
loadSettings();
}
private void initComponents() {
myAddToPanel.add(myParentProjectForm.getComponent());
ActionListener updatingListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateComponents();
}
};
myInheritGroupIdCheckBox.addActionListener(updatingListener);
myInheritVersionCheckBox.addActionListener(updatingListener);
}
@Override
public JComponent getPreferredFocusedComponent() {
return myGroupIdField;
}
@Override
public void onStepLeaving() {
saveSettings();
}
private void loadSettings() {
myBuilder.setInheritGroupId(getSavedValue(INHERIT_GROUP_ID_KEY, true));
myBuilder.setInheritVersion(getSavedValue(INHERIT_VERSION_KEY, true));
}
private void saveSettings() {
saveValue(INHERIT_GROUP_ID_KEY, myInheritGroupIdCheckBox.isSelected());
saveValue(INHERIT_VERSION_KEY, myInheritVersionCheckBox.isSelected());
}
private static boolean getSavedValue(String key, boolean defaultValue) {
return getSavedValue(key, String.valueOf(defaultValue)).equals(String.valueOf(true));
}
private static String getSavedValue(String key, String defaultValue) {
String value = PropertiesComponent.getInstance().getValue(key);
return value == null ? defaultValue : value;
}
private static void saveValue(String key, boolean value) {
saveValue(key, String.valueOf(value));
}
private static void saveValue(String key, String value) {
PropertiesComponent.getInstance().setValue(key, value);
}
public JComponent getComponent() {
return myMainPanel;
}
@Override
public boolean validate() throws ConfigurationException {
if (StringUtil.isEmptyOrSpaces(myArtifactIdField.getText())) {
ApplicationManager.getApplication().invokeLater(
() -> IdeFocusManager.getInstance(myProjectOrNull).requestFocus(myArtifactIdField, true));
throw new ConfigurationException("Please, specify artifactId");
}
return true;
}
@Override
public void updateStep() {
ProjectData parentProject = myParentProjectForm.getParentProject();
ProjectId projectId = myBuilder.getProjectId();
if (projectId == null) {
setTestIfEmpty(myArtifactIdField, myBuilder.getName());
setTestIfEmpty(myGroupIdField, parentProject == null ? myBuilder.getName() : parentProject.getGroup());
setTestIfEmpty(myVersionField, parentProject == null ? DEFAULT_VERSION : parentProject.getVersion());
}
else {
setTestIfEmpty(myArtifactIdField, projectId.getArtifactId());
setTestIfEmpty(myGroupIdField, projectId.getGroupId());
setTestIfEmpty(myVersionField, projectId.getVersion());
}
myInheritGroupIdCheckBox.setSelected(myBuilder.isInheritGroupId());
myInheritVersionCheckBox.setSelected(myBuilder.isInheritVersion());
updateComponents();
}
private void updateComponents() {
final boolean isAddToVisible = myParentProjectForm.isVisible();
myInheritGroupIdCheckBox.setVisible(isAddToVisible);
myInheritVersionCheckBox.setVisible(isAddToVisible);
myParentProjectForm.updateComponents();
ProjectData parentProject = myParentProjectForm.getParentProject();
if (parentProject == null) {
myContext.putUserData(ExternalModuleSettingsStep.SKIP_STEP_KEY, Boolean.FALSE);
myGroupIdField.setEnabled(true);
myVersionField.setEnabled(true);
myInheritGroupIdCheckBox.setEnabled(false);
myInheritVersionCheckBox.setEnabled(false);
setTestIfEmpty(myArtifactIdField, myBuilder.getName());
setTestIfEmpty(myGroupIdField, "");
setTestIfEmpty(myVersionField, DEFAULT_VERSION);
}
else {
myContext.putUserData(ExternalModuleSettingsStep.SKIP_STEP_KEY, Boolean.TRUE);
myGroupIdField.setEnabled(!myInheritGroupIdCheckBox.isSelected());
myVersionField.setEnabled(!myInheritVersionCheckBox.isSelected());
if (myInheritGroupIdCheckBox.isSelected()
|| myGroupIdField.getText().equals(myInheritedGroupId)) {
myGroupIdField.setText(parentProject.getGroup());
}
if (myInheritVersionCheckBox.isSelected()
|| myVersionField.getText().equals(myInheritedVersion)) {
myVersionField.setText(parentProject.getVersion());
}
myInheritedGroupId = myGroupIdField.getText();
myInheritedVersion = myVersionField.getText();
myInheritGroupIdCheckBox.setEnabled(true);
myInheritVersionCheckBox.setEnabled(true);
}
}
public static boolean isGradleModuleExist(WizardContext myContext) {
for (Module module : myContext.getModulesProvider().getModules()) {
if (ExternalSystemApiUtil.isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, module)) return true;
}
return false;
}
@Override
public void updateDataModel() {
myContext.setProjectBuilder(myBuilder);
ProjectData parentProject = myParentProjectForm.getParentProject();
myBuilder.setParentProject(parentProject);
myBuilder.setProjectId(new ProjectId(myGroupIdField.getText(),
myArtifactIdField.getText(),
myVersionField.getText()));
myBuilder.setInheritGroupId(myInheritGroupIdCheckBox.isSelected());
myBuilder.setInheritVersion(myInheritVersionCheckBox.isSelected());
if (StringUtil.isNotEmpty(myBuilder.getProjectId().getArtifactId())) {
myContext.setProjectName(myBuilder.getProjectId().getArtifactId());
}
if (parentProject != null) {
myContext.setProjectFileDirectory(parentProject.getLinkedExternalProjectPath() + '/' + myContext.getProjectName());
}
else {
if (myProjectOrNull != null) {
myContext.setProjectFileDirectory(myProjectOrNull.getBaseDir().getPath() + '/' + myContext.getProjectName());
}
}
}
@Override
public Icon getIcon() {
return WIZARD_ICON;
}
private static void setTestIfEmpty(@NotNull JTextField field, @Nullable String text) {
if (StringUtil.isEmpty(field.getText())) {
field.setText(StringUtil.notNullize(text));
}
}
@Override
public String getHelpId() {
return "Gradle_Archetype_Dialog";
}
@Override
public void disposeUIResources() {
Disposer.dispose(myParentProjectForm);
}
}

View File

@@ -1,158 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* 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.gradle.kdsl.frameworkSupport;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Set;
public class BuildScriptDataBuilder {
@NotNull private final VirtualFile myBuildScriptFile;
private final Set<String> plugins = ContainerUtil.newTreeSet();
private final Set<String> pluginsInGroup = ContainerUtil.newTreeSet();
private final Set<String> repositories = ContainerUtil.newTreeSet();
private final Set<String> dependencies = ContainerUtil.newTreeSet();
private final Set<String> properties = ContainerUtil.newTreeSet();
private final Set<String> buildScriptProperties = ContainerUtil.newTreeSet();
private final Set<String> buildScriptRepositories = ContainerUtil.newTreeSet();
private final Set<String> buildScriptDependencies = ContainerUtil.newTreeSet();
private final Set<String> other = ContainerUtil.newTreeSet();
public BuildScriptDataBuilder(@NotNull VirtualFile buildScriptFile) {
myBuildScriptFile = buildScriptFile;
}
@NotNull
public VirtualFile getBuildScriptFile() {
return myBuildScriptFile;
}
public String buildConfigurationPart() {
List<String> lines = ContainerUtil.newArrayList();
addBuildscriptLines(lines, BuildScriptDataBuilder::padding);
if (!pluginsInGroup.isEmpty()) {
lines.add("plugins {");
lines.addAll(ContainerUtil.map(pluginsInGroup, BuildScriptDataBuilder::padding));
lines.add("}");
lines.add("");
}
return StringUtil.join(lines, "\n");
}
public String buildMainPart() {
List<String> lines = ContainerUtil.newArrayList();
if (!plugins.isEmpty()) {
lines.addAll(plugins);
lines.add("");
}
if (!properties.isEmpty()) {
lines.addAll(properties);
lines.add("");
}
if (!repositories.isEmpty()) {
lines.add("repositories {");
lines.addAll(ContainerUtil.map(repositories, BuildScriptDataBuilder::padding));
lines.add("}");
lines.add("");
}
if (!dependencies.isEmpty()) {
lines.add("dependencies {");
lines.addAll(ContainerUtil.map(dependencies, BuildScriptDataBuilder::padding));
lines.add("}");
lines.add("");
}
if (!other.isEmpty()) {
lines.addAll(other);
}
return StringUtil.join(lines, "\n");
}
private void addBuildscriptLines(@NotNull List<String> lines, @NotNull Function<String, String> padding) {
if (!buildScriptRepositories.isEmpty() || !buildScriptDependencies.isEmpty() || !buildScriptProperties.isEmpty()) {
lines.add("buildscript {");
final List<String> buildScriptLines = ContainerUtil.newSmartList();
if (!buildScriptProperties.isEmpty()) {
buildScriptLines.addAll(buildScriptProperties);
buildScriptLines.add("");
}
if (!buildScriptRepositories.isEmpty()) {
buildScriptLines.add("repositories {");
buildScriptLines.addAll(ContainerUtil.map(buildScriptRepositories, padding));
buildScriptLines.add("}");
}
if (!buildScriptDependencies.isEmpty()) {
buildScriptLines.add("dependencies {");
buildScriptLines.addAll(ContainerUtil.map(buildScriptDependencies, padding));
buildScriptLines.add("}");
}
lines.addAll(ContainerUtil.map(buildScriptLines, padding));
lines.add("}");
lines.add("");
}
}
public BuildScriptDataBuilder addBuildscriptPropertyDefinition(@NotNull String definition) {
buildScriptProperties.add(definition.trim());
return this;
}
public BuildScriptDataBuilder addBuildscriptRepositoriesDefinition(@NotNull String definition) {
buildScriptRepositories.add(definition.trim());
return this;
}
public BuildScriptDataBuilder addBuildscriptDependencyNotation(@NotNull String notation) {
buildScriptDependencies.add(notation.trim());
return this;
}
public BuildScriptDataBuilder addPluginDefinitionInPluginsGroup(@NotNull String definition) {
pluginsInGroup.add(definition.trim());
return this;
}
public BuildScriptDataBuilder addPluginDefinition(@NotNull String definition) {
plugins.add(definition.trim());
return this;
}
public BuildScriptDataBuilder addRepositoriesDefinition(@NotNull String definition) {
repositories.add(definition.trim());
return this;
}
public BuildScriptDataBuilder addDependencyNotation(@NotNull String notation) {
dependencies.add(notation.trim());
return this;
}
public BuildScriptDataBuilder addPropertyDefinition(@NotNull String definition) {
properties.add(definition.trim());
return this;
}
public BuildScriptDataBuilder addOther(@NotNull String definition) {
other.add(definition.trim());
return this;
}
private static String padding(String s) {return StringUtil.isNotEmpty(s) ? " " + s : "";}
}

View File

@@ -1,72 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* 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.gradle.kdsl.frameworkSupport;
import com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.roots.ModifiableModelsProvider;
import com.intellij.openapi.roots.ModifiableRootModel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import static org.jetbrains.kotlin.gradle.kdsl.GradleModuleBuilder.getBuildScriptData;
public abstract class GradleFrameworkSupportProvider extends FrameworkSupportInModuleProvider {
public static final ExtensionPointName<GradleFrameworkSupportProvider> EP_NAME =
ExtensionPointName.create("org.jetbrains.kotlin.gradleFrameworkSupport");
public abstract void addSupport(@NotNull Module module, @NotNull ModifiableRootModel rootModel,
@NotNull ModifiableModelsProvider modifiableModelsProvider,
@NotNull BuildScriptDataBuilder buildScriptData);
public JComponent createComponent() {
return null;
}
@NotNull
@Override
public FrameworkSupportInModuleConfigurable createConfigurable(@NotNull FrameworkSupportModel model) {
return new FrameworkSupportInModuleConfigurable() {
@Nullable
@Override
public JComponent createComponent() {
return GradleFrameworkSupportProvider.this.createComponent();
}
@Override
public void addSupport(@NotNull Module module,
@NotNull ModifiableRootModel rootModel,
@NotNull ModifiableModelsProvider modifiableModelsProvider) {
final BuildScriptDataBuilder buildScriptData = getBuildScriptData(module);
if (buildScriptData != null) {
GradleFrameworkSupportProvider.this.addSupport(module, rootModel, modifiableModelsProvider, buildScriptData);
}
}
};
}
@Override
public boolean isEnabledForModuleType(@NotNull ModuleType moduleType) {
return false;
}
}

View File

@@ -1,67 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* 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.gradle.kdsl.frameworkSupport;
import com.intellij.framework.FrameworkTypeEx;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableModelsProvider;
import com.intellij.openapi.roots.ModifiableRootModel;
import icons.JetgroovyIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class GradleGroovyFrameworkSupportProvider extends GradleFrameworkSupportProvider {
public static final String ID = "groovy";
@NotNull
@Override
public FrameworkTypeEx getFrameworkType() {
return new FrameworkTypeEx(ID) {
@NotNull
@Override
public FrameworkSupportInModuleProvider createProvider() {
return GradleGroovyFrameworkSupportProvider.this;
}
@NotNull
@Override
public String getPresentableName() {
return "Groovy";
}
@NotNull
@Override
public Icon getIcon() {
return JetgroovyIcons.Groovy.Groovy_16x16;
}
};
}
@Override
public void addSupport(@NotNull Module module,
@NotNull ModifiableRootModel rootModel,
@NotNull ModifiableModelsProvider modifiableModelsProvider,
@NotNull BuildScriptDataBuilder buildScriptData) {
buildScriptData
.addPluginDefinition("plugin(\"groovy\")")
.addRepositoriesDefinition("mavenCentral()")
.addDependencyNotation("compile(\"org.codehaus.groovy:groovy-all:2.3.11\")")
.addDependencyNotation("testCompile(\"junit\", \"junit\", \"4.12\")");
}
}

View File

@@ -1,68 +0,0 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* 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.gradle.kdsl.frameworkSupport;
import com.intellij.framework.FrameworkTypeEx;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableModelsProvider;
import com.intellij.openapi.roots.ModifiableRootModel;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class GradleJavaFrameworkSupportProvider extends GradleFrameworkSupportProvider {
public static final String ID = "java";
@NotNull
@Override
public FrameworkTypeEx getFrameworkType() {
return new FrameworkTypeEx(ID) {
@NotNull
@Override
public FrameworkSupportInModuleProvider createProvider() {
return GradleJavaFrameworkSupportProvider.this;
}
@NotNull
@Override
public String getPresentableName() {
return "Java";
}
@NotNull
@Override
public Icon getIcon() {
return AllIcons.Nodes.Module;
}
};
}
@Override
public void addSupport(@NotNull Module module,
@NotNull ModifiableRootModel rootModel,
@NotNull ModifiableModelsProvider modifiableModelsProvider,
@NotNull BuildScriptDataBuilder buildScriptData) {
buildScriptData
.addPluginDefinition("plugin(\"java\")")
// TODO: in gradle > 4.0 it is just 'java { ... }'
.addOther("configure<JavaPluginConvention> {\n sourceCompatibility = JavaVersion.VERSION_1_8\n}")
.addRepositoriesDefinition("mavenCentral()")
.addDependencyNotation("testCompile(\"junit\", \"junit\", \"4.12\")");
}
}

View File

@@ -1,93 +0,0 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* 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.gradle.kdsl.frameworkSupport
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.containers.ContainerUtil
class KotlinBuildScriptDataBuilder(buildScriptFile: VirtualFile) : BuildScriptDataBuilder(buildScriptFile) {
private val plugins: MutableSet<String> = ContainerUtil.newTreeSet<String>()
private val properties: MutableSet<String> = ContainerUtil.newTreeSet<String>()
private val repositories: MutableSet<String> = ContainerUtil.newTreeSet<String>()
private val dependencies: MutableSet<String> = ContainerUtil.newTreeSet<String>()
private val buildScriptProperties: MutableSet<String> = ContainerUtil.newTreeSet<String>()
private val buildScriptRepositories: MutableSet<String> = ContainerUtil.newTreeSet<String>()
private val buildScriptDependencies: MutableSet<String> = ContainerUtil.newTreeSet<String>()
private val other: MutableSet<String> = ContainerUtil.newTreeSet<String>()
override fun addPluginDefinition(definition: String): BuildScriptDataBuilder = apply { plugins.add(definition) }
override fun addRepositoriesDefinition(definition: String): BuildScriptDataBuilder = apply { repositories.add(definition) }
override fun addPropertyDefinition(definition: String): BuildScriptDataBuilder = apply { properties.add(definition) }
override fun addDependencyNotation(notation: String): BuildScriptDataBuilder = apply { dependencies.add(notation) }
override fun addBuildscriptPropertyDefinition(definition: String): BuildScriptDataBuilder = apply { buildScriptProperties.add(definition) }
override fun addBuildscriptRepositoriesDefinition(definition: String): BuildScriptDataBuilder = apply { buildScriptRepositories.add(definition) }
override fun addBuildscriptDependencyNotation(notation: String): BuildScriptDataBuilder = apply { buildScriptDependencies.add(notation) }
override fun addOther(definition: String): BuildScriptDataBuilder = apply { other.add(definition) }
override fun buildMainPart(): String = buildString {
appendlnIfNotNull(buildBuildScriptBlock())
appendlnIfNotNull(buildBlock("apply", plugins))
if (properties.isNotEmpty()) {
properties.forEach { appendln(it) }
appendln()
}
appendlnIfNotNull(buildBlock("repositories", repositories))
appendlnIfNotNull(buildBlock("dependencies", dependencies))
other.forEach { appendln(it) }
}
private fun buildBuildScriptBlock(): String? = buildString {
if (buildScriptProperties.isEmpty() || buildScriptRepositories.isEmpty() || buildScriptDependencies.isEmpty()) {
return null
}
appendln("buildscript {")
buildScriptProperties.forEach { appendln(it.withMargin) }
appendln()
appendlnIfNotNull(buildBlock("repositories", buildScriptRepositories)?.withMargin)
appendlnIfNotNull(buildBlock("dependencies", buildScriptDependencies)?.withMargin)
appendln("}")
}
private fun buildBlock(name: String, lines: Set<String>): String? = buildString {
if (lines.isEmpty()) {
return null
}
appendln("$name {")
lines.forEach { appendln(it.withMargin) }
appendln("}")
}
private val String.withMargin: String
get() = lines().joinToString(separator = "\n") { " " + it }
private fun StringBuilder.appendlnIfNotNull(text: String?) = text?.let { appendln(it) }
}

View File

@@ -14,16 +14,15 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.gradle.kdsl.frameworkSupport
package org.jetbrains.kotlin.idea.configuration
import com.intellij.framework.FrameworkTypeEx
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider
import com.intellij.openapi.externalSystem.model.project.ProjectId
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.ModifiableModelsProvider
import com.intellij.openapi.roots.ModifiableRootModel
import com.intellij.openapi.vfs.VfsUtil
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.configuration.*
import org.jetbrains.kotlin.idea.configuration.KotlinBuildScriptManipulator.Companion.GSK_KOTLIN_VERSION_PROPERTY_NAME
import org.jetbrains.kotlin.idea.configuration.KotlinBuildScriptManipulator.Companion.getCompileDependencySnippet
import org.jetbrains.kotlin.idea.configuration.KotlinBuildScriptManipulator.Companion.getKotlinGradlePluginClassPathSnippet
@@ -31,20 +30,23 @@ import org.jetbrains.kotlin.idea.versions.MAVEN_JS_STDLIB_ID
import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion
import org.jetbrains.kotlin.idea.versions.getDefaultJvmTarget
import org.jetbrains.kotlin.idea.versions.getStdlibArtifactId
import org.jetbrains.plugins.gradle.frameworkSupport.BuildScriptDataBuilder
import org.jetbrains.plugins.gradle.frameworkSupport.KotlinDslGradleFrameworkSupportProvider
import javax.swing.Icon
abstract class GradleKotlinDSLKotlinFrameworkSupportProvider(
abstract class KotlinDslGradleKotlinFrameworkSupportProvider(
val frameworkTypeId: String,
val displayName: String,
val frameworkIcon: Icon
) : GradleFrameworkSupportProvider() {
) : KotlinDslGradleFrameworkSupportProvider() {
override fun getFrameworkType(): FrameworkTypeEx = object : FrameworkTypeEx(frameworkTypeId) {
override fun getIcon(): Icon = frameworkIcon
override fun getPresentableName(): String = displayName
override fun createProvider(): FrameworkSupportInModuleProvider = this@GradleKotlinDSLKotlinFrameworkSupportProvider
override fun createProvider(): FrameworkSupportInModuleProvider = this@KotlinDslGradleKotlinFrameworkSupportProvider
}
override fun addSupport(module: Module,
override fun addSupport(projectId: ProjectId,
module: Module,
rootModel: ModifiableRootModel,
modifiableModelsProvider: ModifiableModelsProvider,
buildScriptData: BuildScriptDataBuilder) {
@@ -67,18 +69,20 @@ abstract class GradleKotlinDSLKotlinFrameworkSupportProvider(
.addBuildscriptRepositoriesDefinition("mavenCentral()")
.addRepositoriesDefinition("mavenCentral()")
// TODO: in gradle > 4.1 this could be single declaration e.g. 'val kotlin_version: String by extra { "1.1.11" }'
.addBuildscriptPropertyDefinition("var $GSK_KOTLIN_VERSION_PROPERTY_NAME: String by extra\n$GSK_KOTLIN_VERSION_PROPERTY_NAME = \"$kotlinVersion\"")
.addBuildscriptPropertyDefinition("var $GSK_KOTLIN_VERSION_PROPERTY_NAME: String by extra\n $GSK_KOTLIN_VERSION_PROPERTY_NAME = \"$kotlinVersion\"")
.addDependencyNotation(getRuntimeLibrary(rootModel))
.addBuildscriptDependencyNotation(getKotlinGradlePluginClassPathSnippet())
}
private fun RepositoryDescription.toKotlinRepositorySnippet() = "maven { setUrl(\"$url\") }"
protected abstract fun getRuntimeLibrary(rootModel: ModifiableRootModel): String
protected abstract fun getPluginDefinition(): String
}
class GradleKotlinDSLKotlinJavaFrameworkSupportProvider :
GradleKotlinDSLKotlinFrameworkSupportProvider("KOTLIN", "Kotlin (Java)", KotlinIcons.SMALL_LOGO) {
class KotlinDslGradleKotlinJavaFrameworkSupportProvider :
KotlinDslGradleKotlinFrameworkSupportProvider("KOTLIN", "Kotlin (Java)", KotlinIcons.SMALL_LOGO) {
override fun getPluginDefinition() = "plugin(\"${KotlinGradleModuleConfigurator.KOTLIN}\")"
@@ -86,28 +90,24 @@ class GradleKotlinDSLKotlinJavaFrameworkSupportProvider :
getCompileDependencySnippet(KOTLIN_GROUP_ID, getStdlibArtifactId(rootModel.sdk, bundledRuntimeVersion()))
override fun addSupport(
projectId: ProjectId,
module: Module,
rootModel: ModifiableRootModel,
modifiableModelsProvider: ModifiableModelsProvider,
buildScriptData: BuildScriptDataBuilder
) {
super.addSupport(module, rootModel, modifiableModelsProvider, buildScriptData)
super.addSupport(projectId, module, rootModel, modifiableModelsProvider, buildScriptData)
val jvmTarget = getDefaultJvmTarget(rootModel.sdk, bundledRuntimeVersion())
if (jvmTarget != null) {
buildScriptData
.addImports("import org.jetbrains.kotlin.gradle.tasks.KotlinCompile")
.addImport("import org.jetbrains.kotlin.gradle.tasks.KotlinCompile")
.addOther("tasks.withType<KotlinCompile> {\n kotlinOptions.jvmTarget = \"1.8\"\n}\n")
}
}
private fun BuildScriptDataBuilder.addImports(vararg import: String): BuildScriptDataBuilder = apply {
val text = VfsUtil.loadText(buildScriptFile)
VfsUtil.saveText(buildScriptFile, import.joinToString(separator = "\n") + "\n\n" + text)
}
}
class GradleKotlinDSLKotlinJSFrameworkSupportProvider :
GradleKotlinDSLKotlinFrameworkSupportProvider("KOTLIN_JS", "Kotlin (JavaScript)", KotlinIcons.JS) {
class KotlinDslGradleKotlinJSFrameworkSupportProvider :
KotlinDslGradleKotlinFrameworkSupportProvider("KOTLIN_JS", "Kotlin (JavaScript)", KotlinIcons.JS) {
override fun getPluginDefinition(): String = "plugin(\"${KotlinJsGradleModuleConfigurator.KOTLIN_JS}\")"

View File

@@ -90,6 +90,6 @@ class KotlinGradleMultiplatformModuleBuilder : GradleModuleBuilder() {
val buildScriptData = BuildScriptDataBuilder(buildGradle)
supportProvider.addSupport(buildScriptData, sdk)
buildScriptData.addDependencyNotation("expectedBy project(\":\")")
VfsUtil.saveText(buildGradle, buildScriptData.build())
VfsUtil.saveText(buildGradle, buildScriptData.buildConfigurationPart() + buildScriptData.buildMainPart())
}
}

View File

@@ -259,7 +259,6 @@ class GradleInspectionTest : GradleImportingTestCase() {
val foundProblems = presentation.problemElements
.values
.flatMap { it.toList() }
.mapNotNull { it as? ProblemDescriptorBase }
.map { it.descriptionTemplate }

View File

@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.maven
import com.intellij.codeInspection.CommonProblemDescriptor
import com.intellij.codeInspection.ProblemDescriptorBase
import com.intellij.codeInspection.QuickFix
import com.intellij.codeInspection.reference.RefEntity
import com.intellij.ide.highlighter.JavaFileType
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.Result
@@ -64,11 +65,11 @@ abstract class AbstractKotlinMavenInspectionTest : MavenImportingTestCase() {
val matcher = "<!--\\s*problem:\\s*on\\s*([^,]+),\\s*title\\s*(.+)\\s*-->".toRegex()
val expected = pomText.lines().mapNotNull { matcher.find(it) }.map { SimplifiedProblemDescription(it.groups[2]!!.value.trim(), it.groups[1]!!.value.trim()) }
val actualProblems =
runInspection(inspectionClass, myProject)
.problemElements
.filter { it.key.name == "pom.xml" }
.values
val problemElements = runInspection(inspectionClass, myProject).problemElements
val actualProblems = problemElements
.keys()
.filter { it.name == "pom.xml" }
.map { problemElements.get(it) }
.flatMap { it.toList() }
.mapNotNull { it as? ProblemDescriptorBase }

View File

@@ -21,6 +21,7 @@ import com.intellij.execution.process.ProcessOutputTypes
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.annotations.NotNull
import org.jetbrains.kotlin.console.actions.logError
import org.jetbrains.kotlin.diagnostics.Severity
import org.w3c.dom.Element
@@ -47,7 +48,7 @@ class ReplOutputHandler(
override fun isSilentlyDestroyOnClose() = true
override fun notifyTextAvailable(text: String, key: Key<*>?) {
override fun notifyTextAvailable(text: String, key: Key<*>) {
// hide warning about adding test folder to classpath
if (text.startsWith("warning: classpath entry points to a non-existent location")) return

View File

@@ -8,11 +8,9 @@ jvmTarget = "1.6"
dependencies {
compile(projectDist(":kotlin-stdlib"))
compile(project(":compiler:cli-common"))
compile(ideaSdkDeps("gradle-tooling-api",
compile(ideaSdkDeps("gradle-api",
"gradle-tooling-extension-api",
"gradle",
"gradle-core",
"gradle-base-services-groovy",
subdir = "plugins/gradle/lib"))
}

View File

@@ -1,118 +1,9 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<externalAnnotator language="kotlin" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintExternalAnnotator"/>
<externalAnnotator language="kotlin" implementationClass="org.jetbrains.android.inspections.lint.AndroidLintExternalAnnotator"/>
</extensions>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintAddJavascriptInterface" displayName="addJavascriptInterface Called" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintAddJavascriptInterfaceInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintAllowAllHostnameVerifier" displayName="Insecure HostnameVerifier" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintAllowAllHostnameVerifierInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintAlwaysShowAction" displayName="Usage of showAsAction=always" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintAlwaysShowActionInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintAppCompatMethod" displayName="Using Wrong AppCompat Method" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintAppCompatMethodInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintAuthLeak" displayName="Code contains url auth" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintAuthLeakInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintBadHostnameVerifier" displayName="Insecure HostnameVerifier" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintBadHostnameVerifierInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintBatteryLife" displayName="Battery Life Issues" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintBatteryLifeInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintCommitPrefEdits" displayName="Missing commit() on SharedPreference editor" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintCommitPrefEditsInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintCommitTransaction" displayName="Missing commit() calls" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintCommitTransactionInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintCustomViewStyleable" displayName="Mismatched Styleable/Custom View Name" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintCustomViewStyleableInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintCutPasteId" displayName="Likely cut &amp; paste mistakes" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintCutPasteIdInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintDefaultLocale" displayName="Implied default locale in case conversion" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintDefaultLocaleInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintDrawAllocation" displayName="Memory allocations within drawing code" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintDrawAllocationInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintEasterEgg" displayName="Code contains easter egg" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="false" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintEasterEggInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintExportedContentProvider" displayName="Content provider does not require permission" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintExportedContentProviderInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintExportedPreferenceActivity" displayName="PreferenceActivity should not be exported" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintExportedPreferenceActivityInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintExportedReceiver" displayName="Receiver does not require permission" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintExportedReceiverInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintExportedService" displayName="Exported service does not require permission" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintExportedServiceInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintFloatMath" displayName="Using FloatMath instead of Math" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintFloatMathInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintGetInstance" displayName="Cipher.getInstance with ECB" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintGetInstanceInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintGifUsage" displayName="Using .gif format for bitmaps is discouraged" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintGifUsageInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintGoogleAppIndexingApiWarning" displayName="Missing support for Google App Indexing Api" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="false" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintGoogleAppIndexingApiWarningInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintGoogleAppIndexingUrlError" displayName="URL not supported by app for Google App Indexing" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintGoogleAppIndexingUrlErrorInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintGoogleAppIndexingWarning" displayName="Missing support for Google App Indexing" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintGoogleAppIndexingWarningInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintGrantAllUris" displayName="Content provider shares everything" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintGrantAllUrisInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintHandlerLeak" displayName="Handler reference leaks" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintHandlerLeakInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconColors" displayName="Icon colors do not follow the recommended visual style" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconColorsInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconDensities" displayName="Icon densities validation" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconDensitiesInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconDipSize" displayName="Icon density-independent size validation" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconDipSizeInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconDuplicates" displayName="Duplicated icons under different names" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconDuplicatesInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconDuplicatesConfig" displayName="Identical bitmaps across various configurations" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconDuplicatesConfigInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconExpectedSize" displayName="Icon has incorrect size" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="false" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconExpectedSizeInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconExtension" displayName="Icon format does not match the file extension" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconExtensionInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconLauncherShape" displayName="The launcher icon shape should use a distinct silhouette" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconLauncherShapeInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconLocation" displayName="Image defined in density-independent drawable folder" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconLocationInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconMissingDensityFolder" displayName="Missing density folder" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconMissingDensityFolderInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconMixedNinePatch" displayName="Clashing PNG and 9-PNG files" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconMixedNinePatchInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconNoDpi" displayName="Icon appears in both -nodpi and dpi folders" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconNoDpiInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintIconXmlAndPng" displayName="Icon is specified both as .xml file and as a bitmap" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintIconXmlAndPngInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintInconsistentLayout" displayName="Inconsistent Layouts" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInconsistentLayoutInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintInflateParams" displayName="Layout Inflation without a Parent" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInflateParamsInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintInlinedApi" displayName="Using inlined constants on older versions" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInlinedApiInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintInvalidUsesTagAttribute" displayName="Invalid name attribute for uses element." groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintInvalidUsesTagAttributeInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintJavascriptInterface" displayName="Missing @JavascriptInterface on methods" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintJavascriptInterfaceInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintLocalSuppress" displayName="@SuppressLint on invalid element" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintLocalSuppressInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintLogConditional" displayName="Unconditional Logging Calls" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="false" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintLogConditionalInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintLogTagMismatch" displayName="Mismatched Log Tags" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintLogTagMismatchInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintLongLogTag" displayName="Too Long Log Tags" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintLongLogTagInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintMergeRootFrame" displayName="FrameLayout can be replaced with &lt;merge> tag" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintMergeRootFrameInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintMissingIntentFilterForMediaSearch" displayName="Missing intent-filter with action android.media.action.MEDIA_PLAY_FROM_SEARCH" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintMissingIntentFilterForMediaSearchInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintMissingMediaBrowserServiceIntentFilter" displayName="Missing intent-filter with action android.media.browse.MediaBrowserService." groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintMissingMediaBrowserServiceIntentFilterInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintMissingOnPlayFromSearch" displayName="Missing onPlayFromSearch." groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintMissingOnPlayFromSearchInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintMissingSuperCall" displayName="Missing Super Call" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintMissingSuperCallInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintNewApi" displayName="Calling new methods on older versions" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintNewApiInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintOverdraw" displayName="Overdraw: Painting regions more than once" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintOverdrawInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintOverride" displayName="Method conflicts with new inherited method" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintOverrideInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintOverrideAbstract" displayName="Not overriding abstract methods on older platforms" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintOverrideAbstractInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintPackageManagerGetSignatures" displayName="Potential Multiple Certificate Exploit" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintPackageManagerGetSignaturesInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintParcelClassLoader" displayName="Default Parcel Class Loader" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintParcelClassLoaderInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintParcelCreator" displayName="Missing Parcelable CREATOR field" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintParcelCreatorInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintPendingBindings" displayName="Missing Pending Bindings" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintPendingBindingsInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintPluralsCandidate" displayName="Potential Plurals" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintPluralsCandidateInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintPrivateResource" displayName="Using private resources" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintPrivateResourceInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintRecycle" displayName="Missing recycle() calls" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintRecycleInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintRecyclerView" displayName="RecyclerView Problems" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintRecyclerViewInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintRegistered" displayName="Class is not registered in the manifest" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintRegisteredInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintRequiredSize" displayName="Missing layout_width or layout_height attributes" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintRequiredSizeInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintRtlCompat" displayName="Right-to-left text compatibility issues" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintRtlCompatInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintRtlEnabled" displayName="Using RTL attributes without enabling RTL support" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintRtlEnabledInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintRtlHardcoded" displayName="Using left/right instead of start/end attributes" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintRtlHardcodedInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintRtlSymmetry" displayName="Padding and margin symmetry" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintRtlSymmetryInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSdCardPath" displayName="Hardcoded reference to /sdcard" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSdCardPathInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSecureRandom" displayName="Using a fixed seed with SecureRandom" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSecureRandomInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintServiceCast" displayName="Wrong system service casts" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintServiceCastInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSetJavaScriptEnabled" displayName="Using setJavaScriptEnabled" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSetJavaScriptEnabledInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSetTextI18n" displayName="TextView Internationalization" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSetTextI18nInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSetWorldReadable" displayName="File.setReadable() used to make file world-readable" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSetWorldReadableInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSetWorldWritable" displayName="File.setWritable() used to make file world-writable" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSetWorldWritableInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintShiftFlags" displayName="Dangerous Flag Constant Declaration" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintShiftFlagsInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintShortAlarm" displayName="Short or Frequent Alarm" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintShortAlarmInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintShowToast" displayName="Toast created but not shown" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintShowToastInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSimpleDateFormat" displayName="Implied locale in date format" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSimpleDateFormatInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSQLiteString" displayName="Using STRING instead of TEXT" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSQLiteStringInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSSLCertificateSocketFactoryCreateSocket" displayName="Insecure call to SSLCertificateSocketFactory.createSocket()" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSSLCertificateSocketFactoryCreateSocketInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSSLCertificateSocketFactoryGetInsecure" displayName="Call to SSLCertificateSocketFactory.getInsecure()" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSSLCertificateSocketFactoryGetInsecureInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintStopShip" displayName="Code contains STOPSHIP marker" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="false" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintStopShipInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintStringFormatCount" displayName="Formatting argument types incomplete or inconsistent" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintStringFormatCountInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintStringFormatInvalid" displayName="Invalid format string" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintStringFormatInvalidInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintStringFormatMatches" displayName="String.format string doesn&apos;t match the XML format string" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintStringFormatMatchesInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSupportAnnotationUsage" displayName="Incorrect support annotation usage" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSupportAnnotationUsageInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSuspiciousImport" displayName="&apos;import android.R&apos; statement" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSuspiciousImportInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintSwitchIntDef" displayName="Missing @IntDef in Switch" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintSwitchIntDefInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintTrustAllX509TrustManager" displayName="Insecure TLS/SSL trust manager" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintTrustAllX509TrustManagerInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintUniqueConstants" displayName="Overlapping Enumeration Constants" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintUniqueConstantsInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintUnlocalizedSms" displayName="SMS phone number missing country code" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintUnlocalizedSmsInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintUnprotectedSMSBroadcastReceiver" displayName="Unprotected SMS BroadcastReceiver" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintUnprotectedSMSBroadcastReceiverInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintUnsafeDynamicallyLoadedCode" displayName="load used to dynamically load code" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintUnsafeDynamicallyLoadedCodeInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintUnsafeNativeCodeLocation" displayName="Native code outside library directory" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintUnsafeNativeCodeLocationInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintUnsafeProtectedBroadcastReceiver" displayName="Unsafe Protected BroadcastReceiver" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintUnsafeProtectedBroadcastReceiverInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintUnusedAttribute" displayName="Attribute unused on older versions" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintUnusedAttributeInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintUseSparseArrays" displayName="HashMap can be replaced with SparseArray" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintUseSparseArraysInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintUseValueOf" displayName="Should use valueOf instead of new" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintUseValueOfInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintValidFragment" displayName="Fragment not instantiatable" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintValidFragmentInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintViewConstructor" displayName="Missing View constructors for XML inflation" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintViewConstructorInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintViewHolder" displayName="View Holder Candidates" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintViewHolderInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintViewTag" displayName="Tagged object leaks" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintViewTagInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintWorldReadableFiles" displayName="openFileOutput() or similar call passing MODE_WORLD_READABLE" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintWorldReadableFilesInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintWorldWriteableFiles" displayName="openFileOutput() or similar call passing MODE_WORLD_WRITEABLE" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="WARNING" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintWorldWriteableFilesInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintWrongCall" displayName="Using wrong draw/layout method" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintWrongCallInspection"/>
<globalInspection language="kotlin" hasStaticDescription="true" shortName="AndroidKLintWrongViewCast" displayName="Mismatched view type" groupKey="android.klint.inspections.group.name" bundle="org.jetbrains.kotlin.idea.KotlinBundle" enabledByDefault="true" level="ERROR" implementationClass="org.jetbrains.android.inspections.klint.AndroidLintInspectionToolProvider$AndroidKLintWrongViewCastInspection"/>
<codeInspection.InspectionExtension implementation="org.jetbrains.android.inspections.klint.AndroidInspectionExtensionsFactory"/>
<extensions defaultExtensionNs="org.jetbrains.uast">
<uastLanguagePlugin implementation="org.jetbrains.uast.kotlin.KotlinUastLanguagePlugin"/>
</extensions>
</idea-plugin>

View File

@@ -1,5 +1,6 @@
<idea-plugin>
<id>org.jetbrains.kotlin</id>
<version>1.2</version>
<extensionPoints>
<extensionPoint name="diagnosticSuppressor"
@@ -46,8 +47,6 @@
interface="org.jetbrains.kotlin.idea.completion.CompletionInformationProvider" />
<extensionPoint name="moduleBuilder"
interface="com.intellij.ide.util.projectWizard.ModuleBuilder"/>
<extensionPoint name="gradleFrameworkSupport"
interface="org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleFrameworkSupportProvider"/>
<extensionPoint name="defaultScriptDependenciesProvider"
interface="org.jetbrains.kotlin.idea.core.script.DefaultScriptDependenciesProvider"
area="IDEA_PROJECT"/>

View File

@@ -2,6 +2,8 @@
<extensions defaultExtensionNs="org.jetbrains.plugins.gradle">
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJavaFrameworkSupportProvider"/>
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinJSFrameworkSupportProvider"/>
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJavaFrameworkSupportProvider"/>
<kotlinDslFrameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.KotlinDslGradleKotlinJSFrameworkSupportProvider"/>
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinMPPCommonFrameworkSupportProvider"/>
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinMPPJavaFrameworkSupportProvider"/>
<frameworkSupport implementation="org.jetbrains.kotlin.idea.configuration.GradleKotlinMPPJSFrameworkSupportProvider"/>
@@ -53,8 +55,6 @@
<projectTaskRunner implementation="org.jetbrains.kotlin.idea.run.MultiplatformGradleProjectTaskRunner" order="first"/>
<orderEnumerationHandlerFactory implementation="org.jetbrains.kotlin.idea.run.MultiplatformGradleOrderEnumeratorHandler$FactoryImpl" order="first"/>
<moduleBuilder builderClass="org.jetbrains.kotlin.gradle.kdsl.GradleModuleBuilder" />
</extensions>
<extensions defaultExtensionNs="org.jetbrains.kotlin">
@@ -70,10 +70,5 @@
<scriptDefinitionContributor implementation="org.jetbrains.kotlin.idea.core.script.GradleScriptDefinitionsContributor"/>
<moduleBuilder implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleMultiplatformModuleBuilder"/>
<gradleFrameworkSupport implementation="org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleJavaFrameworkSupportProvider" />
<gradleFrameworkSupport implementation="org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleKotlinDSLKotlinJavaFrameworkSupportProvider" />
<gradleFrameworkSupport implementation="org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleKotlinDSLKotlinJSFrameworkSupportProvider" />
<gradleFrameworkSupport implementation="org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleGroovyFrameworkSupportProvider" />
</extensions>
</idea-plugin>

View File

@@ -6,7 +6,7 @@
<version>@snapshot@</version>
<vendor url="http://www.jetbrains.com">JetBrains</vendor>
<idea-version since-build="172.1" until-build="172.*"/>
<idea-version since-build="181.1" until-build="181.*"/>
<depends>com.intellij.modules.java</depends>

View File

@@ -98,7 +98,7 @@ class JavaToKotlinAction : AnAction() {
var converterResult: JavaToKotlinConverter.FilesResult? = null
fun convert() {
val converter = JavaToKotlinConverter(project, ConverterSettings.defaultSettings, IdeaJavaToKotlinServices)
converterResult = converter.filesToKotlin(javaFiles, J2kPostProcessor(formatCode = true), ProgressManager.getInstance().progressIndicator)
converterResult = converter.filesToKotlin(javaFiles, J2kPostProcessor(formatCode = true), ProgressManager.getInstance().progressIndicator!!)
}
@@ -117,7 +117,7 @@ class JavaToKotlinAction : AnAction() {
ProgressManager.getInstance().runProcessWithProgressSynchronously(
{
runReadAction {
externalCodeUpdate = converterResult!!.externalCodeProcessing!!.prepareWriteOperation(ProgressManager.getInstance().progressIndicator)
externalCodeUpdate = converterResult!!.externalCodeProcessing!!.prepareWriteOperation(ProgressManager.getInstance().progressIndicator!!)
}
},
title,

View File

@@ -54,7 +54,7 @@ class SearchNotPropertyCandidatesAction : AnAction() {
ProgressManager.getInstance().runProcessWithProgressSynchronously(
{
runReadAction {
ProgressManager.getInstance().progressIndicator.isIndeterminate = true
ProgressManager.getInstance().progressIndicator!!.isIndeterminate = true
processAllDescriptors(packageDesc, project)
}
},

View File

@@ -54,6 +54,7 @@ import org.jetbrains.kotlin.utils.getOrPutNullable
import org.jetbrains.org.objectweb.asm.*
import java.io.File
import java.util.*
import java.util.concurrent.ConcurrentMap
fun isInlineFunctionLineNumber(file: VirtualFile, lineNumber: Int, project: Project): Boolean {
if (ProjectRootsUtil.isProjectSourceFile(project, file)) {
@@ -118,7 +119,7 @@ class WeakBytecodeDebugInfoStorage : ConcurrentWeakFactoryMap<BinaryCacheKey, By
return BytecodeDebugInfo(smapData, lineNumberMapping)
}
override fun createMap(): Map<BinaryCacheKey, BytecodeDebugInfo?> {
override fun createMap(): ConcurrentMap<BinaryCacheKey, BytecodeDebugInfo?> {
return ContainerUtil.createConcurrentWeakKeyWeakValueMap()
}
}

View File

@@ -98,7 +98,7 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() {
val semaphore = Semaphore()
semaphore.down()
val nameRef = AtomicReference<KotlinType>()
val worker = object : KotlinRuntimeTypeEvaluator(null, expression, debuggerContext, ProgressManager.getInstance().progressIndicator) {
val worker = object : KotlinRuntimeTypeEvaluator(null, expression, debuggerContext, ProgressManager.getInstance().progressIndicator!!) {
override fun typeCalculationFinished(type: KotlinType?) {
nameRef.set(type)
semaphore.up()

View File

@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtFile
class KotlinStringTemplateBackspaceHandler : BackspaceHandlerDelegate() {
override fun beforeCharDeleted(c: Char, file: PsiFile?, editor: Editor?) {
override fun beforeCharDeleted(c: Char, file: PsiFile, editor: Editor) {
if (c != '{' || file !is KtFile || !CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET) return
val offset = editor?.caretModel?.offset ?: return
@@ -38,7 +38,7 @@ class KotlinStringTemplateBackspaceHandler : BackspaceHandlerDelegate() {
editor.document.deleteString(offset, offset + 1)
}
override fun charDeleted(c: Char, file: PsiFile?, editor: Editor?): Boolean {
override fun charDeleted(c: Char, file: PsiFile, editor: Editor): Boolean {
return false
}
}

View File

@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.psi.KtContainerNode
class KotlinBracketsSelectioner : ExtendWordSelectionHandlerBase() {
override fun canSelect(e: PsiElement?): Boolean {
override fun canSelect(e: PsiElement): Boolean {
return e is KtContainerNode && e.node.elementType == KtNodeTypes.INDICES
}
}

View File

@@ -26,11 +26,11 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset
import org.jetbrains.kotlin.psi.psiUtil.startOffset
class KotlinInvokedExpressionSelectioner : ExtendWordSelectionHandlerBase() {
override fun canSelect(e: PsiElement?): Boolean {
override fun canSelect(e: PsiElement): Boolean {
return e is KtDotQualifiedExpression
}
override fun select(e: PsiElement?, editorText: CharSequence?, cursorOffset: Int, editor: Editor): List<TextRange>? {
override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange>? {
if (e !is KtDotQualifiedExpression) return null
val endOffset = e.selectorExpression?.children?.firstOrNull { it is KtNameReferenceExpression }?.endOffset ?: return null
return listOf(TextRange(e.startOffset, endOffset))

View File

@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.psi.psiUtil.startOffset
class KotlinSuperTypeSelectioner : ExtendWordSelectionHandlerBase() {
override fun canSelect(e: PsiElement?): Boolean {
override fun canSelect(e: PsiElement): Boolean {
return e is KtSuperTypeList && e.getStrictParentOfType<KtObjectDeclaration>() == null
}

View File

@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset
class KotlinTypeSelectioner : ExtendWordSelectionHandlerBase() {
override fun canSelect(e: PsiElement?): Boolean {
override fun canSelect(e: PsiElement): Boolean {
return e is KtTypeReference
&& e.getStrictParentOfType<KtObjectDeclaration>() == null
&& e.getStrictParentOfType<KtParameter>() == null

View File

@@ -53,7 +53,7 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
val lineNumber = element.getLineNumber()
if (lineNumber !in markedLineNumbers && isRecursiveCall(element)) {
markedLineNumbers.add(lineNumber)
result.add(RecursiveMethodCallMarkerInfo(element))
result.add(RecursiveMethodCallMarkerInfo(getElementForLineMark(element)))
}
}
}
@@ -113,8 +113,8 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
return true
}
private class RecursiveMethodCallMarkerInfo(callElement: KtElement)
: LineMarkerInfo<KtElement>(
private class RecursiveMethodCallMarkerInfo(callElement: PsiElement)
: LineMarkerInfo<PsiElement>(
callElement,
callElement.textRange,
AllIcons.Gutter.RecursiveMethod,
@@ -125,7 +125,7 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
) {
override fun createGutterRenderer(): GutterIconRenderer? {
return object : LineMarkerInfo.LineMarkerGutterIconRenderer<KtElement>(this) {
return object : LineMarkerInfo.LineMarkerGutterIconRenderer<PsiElement>(this) {
override fun getClickAction() = null // to place breakpoint on mouse click
}
}
@@ -133,6 +133,15 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
}
internal fun getElementForLineMark(callElement: PsiElement): PsiElement =
when (callElement) {
is KtSimpleNameExpression -> callElement.getReferencedNameElement()
else ->
// a fallback,
//but who knows what to reference in KtArrayAccessExpression ?
generateSequence(callElement, { it.firstChild }).last()
}
private fun PsiElement.getLineNumber(): Int {
return PsiDocumentManager.getInstance(project).getDocument(containingFile)!!.getLineNumber(textOffset)
}

View File

@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
class KotlinSuspendCallLineMarkerProvider : LineMarkerProvider {
private class SuspendCallMarkerInfo(callElement: KtElement, message: String) : LineMarkerInfo<KtElement>(
private class SuspendCallMarkerInfo(callElement: PsiElement, message: String) : LineMarkerInfo<PsiElement>(
callElement,
callElement.textRange,
KotlinIcons.SUSPEND_CALL,
@@ -46,7 +46,7 @@ class KotlinSuspendCallLineMarkerProvider : LineMarkerProvider {
GutterIconRenderer.Alignment.RIGHT
) {
override fun createGutterRenderer(): GutterIconRenderer? {
return object : LineMarkerInfo.LineMarkerGutterIconRenderer<KtElement>(this) {
return object : LineMarkerInfo.LineMarkerGutterIconRenderer<PsiElement>(this) {
override fun getClickAction(): AnAction? = null
}
}
@@ -70,9 +70,9 @@ class KotlinSuspendCallLineMarkerProvider : LineMarkerProvider {
markedLineNumbers += lineNumber
result += if (element is KtForExpression) {
SuspendCallMarkerInfo(element.loopRange!!, "Suspending iteration")
SuspendCallMarkerInfo(getElementForLineMark(element.loopRange!!), "Suspending iteration")
} else {
SuspendCallMarkerInfo(element, "Suspend function call")
SuspendCallMarkerInfo(getElementForLineMark(element), "Suspend function call")
}
}
}

View File

@@ -25,6 +25,7 @@ import com.intellij.codeInsight.daemon.impl.MarkerType
import com.intellij.codeInsight.daemon.impl.PsiElementListNavigator
import com.intellij.codeInsight.navigation.ListBackgroundUpdaterTask
import com.intellij.icons.AllIcons
import com.intellij.ide.util.PsiClassOrFunctionalExpressionListCellRenderer
import com.intellij.openapi.editor.markup.GutterIconRenderer
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.project.DumbService
@@ -49,11 +50,9 @@ import org.jetbrains.kotlin.idea.facet.implementedDescriptor
import org.jetbrains.kotlin.idea.facet.implementingDescriptors
import org.jetbrains.kotlin.idea.search.declarationsSearch.toPossiblyFakeLightMethods
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
import org.jetbrains.kotlin.idea.util.module
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
import org.jetbrains.kotlin.psi.psiUtil.hasActualModifier
import java.awt.event.MouseEvent
import java.util.*
import javax.swing.Icon
@@ -141,12 +140,20 @@ interface TestableLineMarkerNavigator {
fun getTargetsPopupDescriptor(element: PsiElement?): NavigationPopupDescriptor?
}
private class SubclassRenderer: PsiClassOrFunctionalExpressionListCellRenderer() {
override fun getComparingObject(element: NavigatablePsiElement?): Comparable<Nothing> {
val baseText = super.getComparingObject(element)
val moduleName = element?.module?.name ?: return baseText
return "$baseText [$moduleName]"
}
}
private val SUBCLASSED_CLASS = MarkerType(
"SUBCLASSED_CLASS",
{ getPsiClass(it)?.let { MarkerType.getSubclassedClassTooltip(it) } },
object : LineMarkerNavigator() {
override fun browse(e: MouseEvent?, element: PsiElement?) {
getPsiClass(element)?.let { MarkerType.navigateToSubclassedClass(e, it) }
getPsiClass(element)?.let { MarkerType.navigateToSubclassedClass(e, it, SubclassRenderer()) }
}
})

View File

@@ -136,7 +136,7 @@ private class OverridingMethodsUpdater(
override fun run(indicator: ProgressIndicator) {
super.run(indicator)
val processor = object : CommonProcessors.CollectProcessor<PsiMethod>() {
override fun process(psiMethod: PsiMethod?): Boolean {
override fun process(psiMethod: PsiMethod): Boolean {
if (!updateComponent(psiMethod, myRenderer.comparator)) {
indicator.cancel()
}

View File

@@ -23,20 +23,30 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.util.text.StringUtilRt
import com.intellij.patterns.PatternCondition
import com.intellij.patterns.PatternConditionPlus
import com.intellij.patterns.PsiClassNamePatternCondition
import com.intellij.patterns.ValuePatternCondition
import com.intellij.psi.*
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil
import com.intellij.psi.search.LocalSearchScope
import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiTreeUtil
import org.intellij.plugins.intelliLang.Configuration
import org.intellij.plugins.intelliLang.inject.InjectorUtils
import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport
import org.intellij.plugins.intelliLang.inject.TemporaryPlacesRegistry
import org.intellij.plugins.intelliLang.inject.config.BaseInjection
import org.intellij.plugins.intelliLang.inject.config.InjectionPlace
import org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport
import org.intellij.plugins.intelliLang.util.AnnotationUtilEx
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.patterns.KotlinFunctionPattern
import org.jetbrains.kotlin.idea.references.KtReference
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.idea.runInReadActionWithWriteActionPriority
@@ -45,24 +55,28 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.annotations.argumentValue
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import java.util.*
import kotlin.collections.ArrayList
import org.jetbrains.kotlin.util.aliasImportMap
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
class KotlinLanguageInjector(
val configuration: Configuration,
val project: Project,
val temporaryPlacesRegistry: TemporaryPlacesRegistry
private val configuration: Configuration,
private val project: Project,
private val temporaryPlacesRegistry: TemporaryPlacesRegistry
) : MultiHostInjector {
companion object {
private val STRING_LITERALS_REGEXP = "\"([^\"]*)\"".toRegex()
private val ABSENT_KOTLIN_INJECTION = BaseInjection("ABSENT_KOTLIN_BASE_INJECTION")
}
val kotlinSupport: KotlinLanguageInjectionSupport? by lazy {
var annotationInjectionsEnabled = Registry.`is`("kotlin.annotation.injection.enabled", false)
private val kotlinSupport: KotlinLanguageInjectionSupport? by lazy {
ArrayList(InjectorUtils.getActiveInjectionSupports()).filterIsInstance(KotlinLanguageInjectionSupport::class.java).firstOrNull()
}
private data class KotlinCachedInjection(val modificationCount: Long, val baseInjection: BaseInjection)
private var KtStringTemplateExpression.cachedInjectionWithModification: KotlinCachedInjection? by UserDataProperty(
Key.create<KotlinCachedInjection>("CACHED_INJECTION_WITH_MODIFICATION"))
@@ -72,7 +86,7 @@ class KotlinLanguageInjector(
val support = kotlinSupport ?: return
if (!ProjectRootsUtil.isInProjectOrLibSource(ktHost)) return
if (!ProjectRootsUtil.isInProjectOrLibSource(ktHost.containingFile.originalFile)) return
val needImmediateAnswer = with(ApplicationManager.getApplication()) { isDispatchThread && !isUnitTestMode }
val kotlinCachedInjection = ktHost.cachedInjectionWithModification
@@ -153,9 +167,9 @@ class KotlinLanguageInjector(
private fun findInjectionInfo(place: KtElement, originalHost: Boolean = true): InjectionInfo? {
return injectWithExplicitCodeInstruction(place)
?: injectWithCall(place)
?: injectInAnnotationCall(place)
?: injectWithReceiver(place)
?: injectWithVariableUsage(place, originalHost)
?: injectWithAnnotationEntry(place)
}
private fun injectWithExplicitCodeInstruction(host: KtElement): InjectionInfo? {
@@ -174,9 +188,9 @@ class KotlinLanguageInjector(
val callExpression = qualifiedExpression.selectorExpression as? KtCallExpression ?: return null
val callee = callExpression.calleeExpression ?: return null
if (isAnalyzeOff(qualifiedExpression.project)) return null
if (isAnalyzeOff()) return null
val kotlinInjections = Configuration.getInstance().getInjections(KOTLIN_SUPPORT_ID)
val kotlinInjections = configuration.getInjections(KOTLIN_SUPPORT_ID)
val calleeName = callee.text
val possibleNames = collectPossibleNames(kotlinInjections)
@@ -219,11 +233,10 @@ class KotlinLanguageInjector(
// Given place is not original host of the injection so we stop to prevent stepping through indirect references
if (!originalHost) return null
val ktHost: KtElement = host
val ktProperty = host.parent as? KtProperty ?: return null
if (ktProperty.initializer != host) return null
if (isAnalyzeOff(ktHost.project)) return null
if (isAnalyzeOff()) return null
val searchScope = LocalSearchScope(arrayOf(ktProperty.containingFile), "", true)
return ReferencesSearch.search(ktProperty, searchScope).asSequence().mapNotNull { psiReference ->
@@ -239,7 +252,7 @@ class KotlinLanguageInjector(
val callExpression = PsiTreeUtil.getParentOfType(ktHost, KtCallExpression::class.java) ?: return null
val callee = callExpression.calleeExpression ?: return null
if (isAnalyzeOff(ktHost.project)) return null
if (isAnalyzeOff()) return null
for (reference in callee.references) {
ProgressManager.checkCanceled()
@@ -262,18 +275,38 @@ class KotlinLanguageInjector(
return null
}
private fun injectInAnnotationCall(host: KtElement): InjectionInfo? {
if (!annotationInjectionsEnabled) return null
val argument = host.parent as? KtValueArgument ?: return null
val annotationEntry = argument.parent.parent as? KtAnnotationEntry ?: return null
if (!fastCheckInjectionsExists(annotationEntry)) return null
val calleeReference = annotationEntry.calleeExpression?.constructorReferenceExpression?.mainReference
val callee = calleeReference?.resolve()
when (callee) {
is KtFunction -> return injectionForKotlinCall(argument, callee, calleeReference)
is PsiClass -> {
val psiClass = callee as? PsiClass ?: return null
val argumentName = argument.getArgumentName()?.asName?.identifier ?: "value"
val method = psiClass.findMethodsByName(argumentName, false).singleOrNull() ?: return null
return findInjection(method, configuration.getInjections(JavaLanguageInjectionSupport.JAVA_SUPPORT_ID))
}
else -> return null
}
}
private fun injectionForJavaMethod(argument: KtValueArgument, javaMethod: PsiMethod): InjectionInfo? {
val argumentIndex = (argument.parent as KtValueArgumentList).arguments.indexOf(argument)
val psiParameter = javaMethod.parameterList.parameters.getOrNull(argumentIndex) ?: return null
val injectionInfo = findInjection(psiParameter, Configuration.getInstance().getInjections(JavaLanguageInjectionSupport.JAVA_SUPPORT_ID))
val injectionInfo = findInjection(psiParameter, configuration.getInjections(JavaLanguageInjectionSupport.JAVA_SUPPORT_ID))
if (injectionInfo != null) {
return injectionInfo
}
val annotations = AnnotationUtilEx.getAnnotationFrom(
psiParameter,
Configuration.getProjectInstance(psiParameter.project).advancedConfiguration.languageAnnotationPair,
configuration.advancedConfiguration.languageAnnotationPair,
true)
if (annotations.isNotEmpty()) {
@@ -287,7 +320,7 @@ class KotlinLanguageInjector(
val argumentIndex = (argument.parent as KtValueArgumentList).arguments.indexOf(argument)
val ktParameter = ktFunction.valueParameters.getOrNull(argumentIndex) ?: return null
val patternInjection = findInjection(ktParameter, Configuration.getInstance().getInjections(KOTLIN_SUPPORT_ID))
val patternInjection = findInjection(ktParameter, configuration.getInjections(KOTLIN_SUPPORT_ID))
if (patternInjection != null) {
return patternInjection
}
@@ -305,29 +338,6 @@ class KotlinLanguageInjector(
return InjectionInfo(languageId, null, null)
}
private fun injectWithAnnotationEntry(host: KtElement): InjectionInfo? {
val argument = host.parent as? KtValueArgument ?: return null
val annotationEntry = PsiTreeUtil.getParentOfType(host, KtAnnotationEntry::class.java) ?: return null
if (isAnalyzeOff(host.project)) return null
val calleeReference = annotationEntry.calleeExpression?.constructorReferenceExpression?.mainReference
val callee = calleeReference?.resolve()
return when (callee) {
is KtFunction -> injectionForKotlinCall(argument, callee, calleeReference)
is PsiClass -> {
// Look for java injections for the PsiAnnotationMethod.
(argument.reference ?: argument.getArgumentName()?.referenceExpression?.mainReference)
?.let { it.resolve() as? PsiMethod }
?.let { findInjection(it, Configuration.getInstance().getInjections(JavaLanguageInjectionSupport.JAVA_SUPPORT_ID)) }
?.takeIf { injectionInfo ->
// Temporary forbid injection for SpEL because of inspections that gives warnings when host language is not Java.
injectionInfo.languageId != "SpEL"
}
}
else -> null
}
}
private fun findInjection(element: PsiElement?, injections: List<BaseInjection>): InjectionInfo? {
for (injection in injections) {
if (injection.acceptsPsiElement(element)) {
@@ -338,8 +348,8 @@ class KotlinLanguageInjector(
return null
}
private fun isAnalyzeOff(project: Project): Boolean {
return Configuration.getProjectInstance(project).advancedConfiguration.dfaOption == Configuration.DfaOption.OFF
private fun isAnalyzeOff(): Boolean {
return configuration.advancedConfiguration.dfaOption == Configuration.DfaOption.OFF
}
private class InjectionInfo(val languageId: String?, val prefix: String?, val suffix: String?) {
@@ -368,4 +378,52 @@ class KotlinLanguageInjector(
return InjectionInfo(id, prefix, suffix)
}
}
private val injectableTargetClassShortNames = CachedValuesManager.getManager(project)
.createCachedValue({
CachedValueProvider.Result.create(HashSet<String>().apply {
for (injection in configuration.getInjections(JavaLanguageInjectionSupport.JAVA_SUPPORT_ID)) {
for (injectionPlace in injection.injectionPlaces) {
for (targetClassFQN in retrieveJavaPlaceTargetClassesFQNs(injectionPlace)) {
add(StringUtilRt.getShortName(targetClassFQN))
}
}
}
for (injection in configuration.getInjections(org.jetbrains.kotlin.idea.injection.KOTLIN_SUPPORT_ID)) {
for (injectionPlace in injection.injectionPlaces) {
for (targetClassFQN in retrieveKotlinPlaceTargetClassesFQNs(injectionPlace)) {
add(StringUtilRt.getShortName(targetClassFQN))
}
}
}
}, configuration)
}, false)
private fun fastCheckInjectionsExists(annotationEntry: KtAnnotationEntry): Boolean {
val referencedName = (annotationEntry.typeReference?.typeElement as? KtUserType)?.referencedName ?: return false
val annotationShortName = annotationEntry.containingKtFile.aliasImportMap()[referencedName].singleOrNull() ?: referencedName
return annotationShortName in injectableTargetClassShortNames.value
}
private fun retrieveJavaPlaceTargetClassesFQNs(place: InjectionPlace): Collection<String> {
val classCondition = place.elementPattern.condition.conditions.firstOrNull { it.debugMethodName == "definedInClass" }
as? PatternConditionPlus<*, *> ?: return emptyList()
val psiClassNamePatternCondition = classCondition.valuePattern.condition.conditions.
firstIsInstanceOrNull<PsiClassNamePatternCondition>() ?: return emptyList()
val valuePatternCondition = psiClassNamePatternCondition.namePattern.condition.conditions.firstIsInstanceOrNull<ValuePatternCondition<String>>() ?: return emptyList()
return valuePatternCondition.values
}
private fun retrieveKotlinPlaceTargetClassesFQNs(place: InjectionPlace): Collection<String> {
val classNames = SmartList<String>()
fun collect(condition: PatternCondition<*>) {
when (condition) {
is PatternConditionPlus<*, *> -> condition.valuePattern.condition.conditions.forEach { collect(it) }
is KotlinFunctionPattern.DefinedInClassCondition -> classNames.add(condition.fqName)
}
}
place.elementPattern.condition.conditions.forEach { collect(it) }
return classNames
}
}

View File

@@ -186,7 +186,7 @@ class ConvertFunctionTypeParameterToReceiverIntention : SelfTargetingRangeIntent
runReadAction {
val progressStep = 1.0/callables.size
for ((i, callable) in callables.withIndex()) {
ProgressManager.getInstance().progressIndicator.fraction = (i + 1) * progressStep
ProgressManager.getInstance().progressIndicator!!.fraction = (i + 1) * progressStep
if (callable !is PsiNamedElement) continue

View File

@@ -125,7 +125,7 @@ class ConvertFunctionTypeReceiverToParameterIntention : SelfTargetingRangeIntent
runReadAction {
val progressStep = 1.0/callables.size
for ((i, callable) in callables.withIndex()) {
ProgressManager.getInstance().progressIndicator.fraction = (i + 1) * progressStep
ProgressManager.getInstance().progressIndicator!!.fraction = (i + 1) * progressStep
if (callable !is KtFunction) continue

View File

@@ -97,7 +97,7 @@ class ConvertPropertyToFunctionIntention : SelfTargetingIntention<KtProperty>(Kt
runReadAction {
val progressStep = 1.0/callables.size
for ((i, callable) in callables.withIndex()) {
ProgressManager.getInstance().progressIndicator.fraction = (i + 1)*progressStep
ProgressManager.getInstance().progressIndicator!!.fraction = (i + 1) * progressStep
if (callable !is PsiNamedElement) continue

View File

@@ -74,14 +74,15 @@ open class KotlinFunctionPattern : PsiElementPattern<KtFunction, KotlinFunctionP
}
}
fun definedInClass(fqName: String): KotlinFunctionPattern {
return withPatternCondition("kotlinFunctionPattern-definedInClass") { function, _ ->
if (function.parent is KtFile) return@withPatternCondition false
function.containingClassOrObject?.fqName?.asString() == fqName
class DefinedInClassCondition(val fqName: String) : PatternCondition<KtFunction>("kotlinFunctionPattern-definedInClass") {
override fun accepts(element: KtFunction, context: ProcessingContext?): Boolean {
if (element.parent is KtFile) return false
return element.containingClassOrObject?.fqName?.asString() == fqName
}
}
fun definedInClass(fqName: String): KotlinFunctionPattern = with(DefinedInClassCondition(fqName))
fun definedInPackage(packageFqName: String): KotlinFunctionPattern {
return withPatternCondition("kotlinFunctionPattern-definedInPackage") { function, _ ->
if (function.parent !is KtFile) return@withPatternCondition false

View File

@@ -49,20 +49,9 @@ import org.jetbrains.kotlin.util.findCallableMemberBySignature
import org.jetbrains.kotlin.utils.DFS
import org.jetbrains.kotlin.utils.ifEmpty
import java.util.ArrayList
import kotlin.collections.Collection
import kotlin.collections.HashMap
import kotlin.collections.LinkedHashSet
import kotlin.collections.List
import kotlin.collections.Set
import kotlin.collections.emptyList
import kotlin.collections.emptySet
import kotlin.collections.filter
import kotlin.collections.flatMap
import kotlin.collections.forEach
import kotlin.collections.getOrPut
import kotlin.collections.listOf
import kotlin.collections.mapNotNullTo
import kotlin.collections.plus
class ChangeSuspendInHierarchyFix(
element: KtNamedFunction,
@@ -83,7 +72,7 @@ class ChangeSuspendInHierarchyFix(
private fun findAllFunctionToProcess(project: Project): Set<KtNamedFunction> {
val result = LinkedHashSet<KtNamedFunction>()
val progressIndicator = ProgressManager.getInstance().progressIndicator
val progressIndicator = ProgressManager.getInstance().progressIndicator!!
val function = element ?: return emptySet()
val functionDescriptor = function.unsafeResolveToDescriptor() as FunctionDescriptor

View File

@@ -86,7 +86,7 @@ class CopyKotlinDeclarationDialog(
Pass { setErrorText(it, destinationComboBox) },
packageNameField.childComponent
)
classNameField.text = UsageViewUtil.getShortName(declaration)
classNameField.setText(UsageViewUtil.getShortName(declaration))
classNameField.selectAll()
}

View File

@@ -73,8 +73,8 @@ class KotlinAwareDelegatingMoveDestination(
}
filesToProcess.flatMap {it.declarations}.forEach { it.accept(extraElementCollector) }
val progressIndicator = ProgressManager.getInstance().progressIndicator
progressIndicator?.pushState()
val progressIndicator = ProgressManager.getInstance().progressIndicator!!
progressIndicator.pushState()
val extraUsages = ArrayList<UsageInfo>()
try {
@@ -87,7 +87,7 @@ class KotlinAwareDelegatingMoveDestination(
}
}
finally {
progressIndicator?.popState()
progressIndicator.popState()
}
filesToProcess.forEach {

View File

@@ -163,7 +163,8 @@ class MoveKotlinDeclarationsHandler : MoveHandlerDelegate() {
}
private fun canMove(elements: Array<out PsiElement>, targetContainer: PsiElement?, editorMode: Boolean): Boolean {
if (!super.canMove(elements, targetContainer)) return false
if (targetContainer != null && !isValidTarget(targetContainer, elements)) return false
val container = getUniqueContainer(elements) ?: return false
if (container is KtClassOrObject && targetContainer != null && targetContainer !is KtClassOrObject && elements.size > 1) {

View File

@@ -35,6 +35,8 @@ import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDe
import com.intellij.usageView.UsageInfo
import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.asJava.*
import org.jetbrains.kotlin.asJava.elements.KtLightField
import org.jetbrains.kotlin.asJava.elements.KtLightFieldImpl
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.idea.KotlinBundle
@@ -131,7 +133,15 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
fun findUsagesByJavaProcessor(element: PsiElement, forceReferencedElementUnwrapping: Boolean): NonCodeUsageSearchInfo? {
val javaUsages = ArrayList<UsageInfo>()
val searchInfo = super.findUsages(element, allElementsToDelete, javaUsages)
val elementToPassToJava = when (element) {
is KtLightFieldImpl<*> -> object : KtLightField by element {
// Suppress walking through initializer compiled PSI (it doesn't contain any reference expressions anyway)
override fun getInitializer() = null
}
else -> element
}
val searchInfo = super.findUsages(elementToPassToJava, allElementsToDelete, javaUsages)
javaUsages.filterIsInstance<SafeDeleteOverridingMethodUsageInfo>().mapNotNullTo(deleteSet) { it.element }

View File

@@ -16,18 +16,59 @@
package org.jetbrains.kotlin.idea.slicer
import com.intellij.codeInspection.dataFlow.Nullness
import com.intellij.ide.util.treeView.AbstractTreeStructure
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.psi.PsiElement
import com.intellij.slicer.SliceAnalysisParams
import com.intellij.slicer.SliceLanguageSupportProvider
import com.intellij.slicer.SliceTreeBuilder
import com.intellij.slicer.*
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.guessTypes
import org.jetbrains.kotlin.idea.references.KtReference
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.isPlainWithEscapes
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.isError
import org.jetbrains.kotlin.types.isNullabilityFlexible
class KotlinSliceProvider : SliceLanguageSupportProvider {
companion object {
val LEAF_ELEMENT_EQUALITY = object : SliceLeafEquality() {
override fun substituteElement(element: PsiElement) = (element as? KtReference)?.resolve() ?: element
}
}
class KotlinGroupByNullnessAction(treeBuilder: SliceTreeBuilder) : GroupByNullnessActionBase(treeBuilder) {
override fun isAvailable() = true
}
val leafAnalyzer by lazy { SliceLeafAnalyzer(LEAF_ELEMENT_EQUALITY, this) }
val nullnessAnalyzer: SliceNullnessAnalyzerBase by lazy {
object : SliceNullnessAnalyzerBase(LEAF_ELEMENT_EQUALITY, this) {
override fun checkNullness(element: PsiElement?): Nullness {
val types = when (element) {
is KtCallableDeclaration -> listOfNotNull((element.resolveToDescriptorIfAny() as? CallableDescriptor)?.returnType)
is KtDeclaration -> emptyList()
is KtExpression -> {
val (bindingContext, moduleDescriptor) = element.analyzeAndGetResult()
element.guessTypes(bindingContext, moduleDescriptor).toList()
}
else -> emptyList()
}
return when {
types.isEmpty() -> return Nullness.UNKNOWN
types.all { KotlinBuiltIns.isNullableNothing(it) } -> Nullness.NULLABLE
types.any { it.isError || TypeUtils.isNullableType(it) || it.isNullabilityFlexible() } -> Nullness.UNKNOWN
else -> Nullness.NOT_NULL
}
}
}
}
override fun createRootUsage(element: PsiElement, params: SliceAnalysisParams) = KotlinSliceUsage(element, params)
override fun getExpressionAtCaret(atCaret: PsiElement?, dataFlowToThis: Boolean): KtExpression? {
@@ -56,14 +97,17 @@ class KotlinSliceProvider : SliceLanguageSupportProvider {
override fun getRenderer() = KotlinSliceUsageCellRenderer
override fun startAnalyzeLeafValues(structure: AbstractTreeStructure, finalRunnable: Runnable) {
leafAnalyzer.startAnalyzeValues(structure, finalRunnable)
}
override fun startAnalyzeNullness(structure: AbstractTreeStructure, finalRunnable: Runnable) {
nullnessAnalyzer.startAnalyzeNullness(structure, finalRunnable)
}
override fun registerExtraPanelActions(group: DefaultActionGroup, builder: SliceTreeBuilder) {
if (builder.dataFlowToThis) {
group.add(GroupByLeavesAction(builder))
group.add(KotlinGroupByNullnessAction(builder))
}
}
}

View File

@@ -19,10 +19,13 @@ package org.jetbrains.kotlin.idea.slicer
import com.intellij.psi.PsiElement
import com.intellij.slicer.SliceAnalysisParams
import com.intellij.slicer.SliceUsage
import com.intellij.usageView.UsageInfo
import com.intellij.util.Processor
import org.jetbrains.kotlin.psi.KtExpression
open class KotlinSliceUsage : SliceUsage {
class UsageInfoLambdaWrapper(element: PsiElement) : UsageInfo(element)
val lambdaLevel: Int
val forcedExpressionMode: Boolean
@@ -42,6 +45,18 @@ open class KotlinSliceUsage : SliceUsage {
return KotlinSliceUsage(element, parent, lambdaLevel, forcedExpressionMode)
}
override fun getUsageInfo(): UsageInfo {
val originalInfo = super.getUsageInfo()
if (lambdaLevel > 0 && forcedExpressionMode) {
val element = originalInfo.element ?: return originalInfo
// Do not let IDEA consider usages of the same anonymous function as duplicates when their levels differ
return UsageInfoLambdaWrapper(element)
}
return originalInfo
}
override fun canBeLeaf() = element != null && lambdaLevel == 0
public override fun processUsagesFlownDownTo(element: PsiElement, uniqueProcessor: Processor<SliceUsage>) {
InflowSlicer(element as? KtExpression ?: return, uniqueProcessor, this).processChildren()
}

View File

@@ -1,6 +1,6 @@
operator fun Any.get(a: Int) {
if (a > 0) {
<lineMarker descr="Recursive call">this[a - 1]</lineMarker>
<lineMarker descr="Recursive call">this</lineMarker>[a - 1]
}
}

View File

@@ -1,5 +1,5 @@
// FILE: bar/Foo.before.java
// "/(Static import|Import static) method 'foo.Bar.getValue'/" "true"
// "Import static method..." "true"
// ERROR: Unresolved reference: getValue
// ACTION: Create method 'foobar'
// WITH_RUNTIME
@@ -23,7 +23,7 @@ object Bar {
}
// FILE: bar/Foo.after.java
// "/(Static import|Import static) method 'foo.Bar.getValue'/" "true"
// "Import static method..." "true"
// ERROR: Unresolved reference: getValue
// ACTION: Create method 'foobar'
// WITH_RUNTIME

View File

@@ -1,5 +1,5 @@
// FILE: bar/Foo.before.java
// "/(Static import|Import static) method 'foo.Bar.getValue'/" "true"
// "Import static method..." "true"
// ERROR: Unresolved reference: getValue
// ACTION: Create method 'foobar'
// WITH_RUNTIME
@@ -25,7 +25,7 @@ object Bar {
}
// FILE: bar/Foo.after.java
// "/(Static import|Import static) method 'foo.Bar.getValue'/" "true"
// "Import static method..." "true"
// ERROR: Unresolved reference: getValue
// ACTION: Create method 'foobar'
// WITH_RUNTIME

View File

@@ -1,5 +1,5 @@
// FILE: bar/Foo.before.java
// "/(Static import|Import static) method 'foo.Bar.getValue'/" "true"
// "Import static method..." "true"
// ERROR: Unresolved reference: getValue
// ACTION: Create method 'foobar'
// WITH_RUNTIME
@@ -21,7 +21,7 @@ object Bar {
}
// FILE: bar/Foo.after.java
// "/(Static import|Import static) method 'foo.Bar.getValue'/" "true"
// "Import static method..." "true"
// ERROR: Unresolved reference: getValue
// ACTION: Create method 'foobar'
// WITH_RUNTIME

View File

@@ -1,5 +1,5 @@
// FILE: bar/Foo.before.java
// "/(Static import|Import static) method 'foo.Bar.getValue'/" "true"
// "Import static method..." "true"
// ERROR: Unresolved reference: getValue
// ACTION: Create method 'foobar'
// WITH_RUNTIME
@@ -23,7 +23,7 @@ object Bar {
}
// FILE: bar/Foo.after.java
// "/(Static import|Import static) method 'foo.Bar.getValue'/" "true"
// "Import static method..." "true"
// ERROR: Unresolved reference: getValue
// ACTION: Create method 'foobar'
// WITH_RUNTIME

View File

@@ -1,5 +1,7 @@
// "Create type parameter 'Test' in class 'C'" "false"
// ACTION: Add 'testng' to classpath
// ACTION: Add 'JUnit4' to classpath
// ACTION: Add 'JUnit5.0' to classpath
// ACTION: Create annotation 'Test'
// ACTION: Make internal
// ACTION: Make private

View File

@@ -0,0 +1,12 @@
8 val x = foo(fun(<bold>n: Int</bold>) = n)
8 val <bold>x = foo(fun(n: Int) = n)</bold>
8 val x = <bold>foo(fun(n: Int) = n)</bold>
3 fun <bold>foo(f: (Int) -> Int): Int {</bold>
4 return <bold>f(1)</bold>
4 [LAMBDA] return <bold>f</bold>(1)
3 [LAMBDA] fun foo(<bold>f: (Int) -> Int</bold>): Int {
8 [LAMBDA] val x = foo(<bold>fun(n: Int) = n</bold>)
8 val x = foo(<bold>fun(n: Int) = n</bold>)
8 val x = foo(fun(n: Int) = <bold>n</bold>)
8 val x = foo(fun(<bold>n: Int</bold>) = n)

View File

@@ -0,0 +1,3 @@
[NotNull Values]
8 val <bold>x = foo(fun(n: Int) = n)</bold>
8 val <bold>x = foo(fun(n: Int) = n)</bold>

View File

@@ -0,0 +1,12 @@
8 val x = foo(fun(<bold>n: Int</bold>): Int { return n })
8 val <bold>x = foo(fun(n: Int): Int { return n })</bold>
8 val x = <bold>foo(fun(n: Int): Int { return n })</bold>
3 fun <bold>foo(f: (Int) -> Int): Int {</bold>
4 return <bold>f(1)</bold>
4 [LAMBDA] return <bold>f</bold>(1)
3 [LAMBDA] fun foo(<bold>f: (Int) -> Int</bold>): Int {
8 [LAMBDA] val x = foo(<bold>fun(n: Int): Int { return n }</bold>)
8 val x = foo(<bold>fun(n: Int): Int { return n }</bold>)
8 val x = foo(fun(n: Int): Int { return <bold>n</bold> })
8 val x = foo(fun(<bold>n: Int</bold>): Int { return n })

View File

@@ -0,0 +1,3 @@
[NotNull Values]
8 val <bold>x = foo(fun(n: Int): Int { return n })</bold>
8 val <bold>x = foo(fun(n: Int): Int { return n })</bold>

View File

@@ -0,0 +1,6 @@
3 fun test(<bold>o: Any</bold>) {
4 val <bold>x = o as String</bold>
4 val x = <bold>o as String</bold>
4 val x = <bold>o</bold> as String
3 fun test(<bold>o: Any</bold>) {

View File

@@ -0,0 +1,4 @@
[NotNull Values]
4 val <bold>x = o as String</bold>
4 val <bold>x = o as String</bold>

View File

@@ -0,0 +1,17 @@
7 <bold>--result</bold>
3 fun <bold>assignmentWithSum(n: Int): Int {</bold>
8 return <bold>result</bold>
4 var <bold>result = 0</bold>
7 <bold>--result</bold>
4 var result = <bold>0</bold>
3 fun <bold>assignmentWithSum(n: Int): Int {</bold>
8 return <bold>result</bold>
4 var <bold>result = 0</bold>
4 var result = <bold>0</bold>
5 <bold>result += n</bold>
3 fun <bold>assignmentWithSum(n: Int): Int {</bold>
8 return <bold>result</bold>
4 var <bold>result = 0</bold>
5 <bold>result += n</bold>

View File

@@ -0,0 +1,3 @@
[NotNull Values]
3 fun <bold>assignmentWithSum(n: Int): Int {</bold>
3 fun <bold>assignmentWithSum(n: Int): Int {</bold>

View File

@@ -0,0 +1,14 @@
6 field = if (b) value else <bold>0</bold>
10 val x = <bold>foo</bold>
4 var <bold>foo: Int</bold>
6 field = <bold>if (b) value else 0</bold>
6 field = if (b) value else <bold>0</bold>
11 foo = <bold>1</bold>
10 val x = <bold>foo</bold>
4 var <bold>foo: Int</bold>
6 field = <bold>if (b) value else 0</bold>
6 field = if (b) <bold>value</bold> else 0
5 set(<bold>value</bold>) {
11 foo = <bold>1</bold>

View File

@@ -0,0 +1,3 @@
[NotNull Values]
10 val x = <bold>foo</bold>
10 val x = <bold>foo</bold>

View File

@@ -0,0 +1,7 @@
6 operator fun getValue(thisRef: Any?, property: KProperty<*>) = <bold>1</bold>
12 val <bold>x = foo</bold>
12 val x = <bold>foo</bold>
9 val <bold>foo: Int by D</bold>
6 operator fun <bold>getValue(thisRef: Any?, property: KProperty<*>) = 1</bold>
6 operator fun getValue(thisRef: Any?, property: KProperty<*>) = <bold>1</bold>

View File

@@ -0,0 +1,3 @@
[NotNull Values]
12 val <bold>x = foo</bold>
12 val <bold>x = foo</bold>

View File

@@ -0,0 +1,12 @@
8 override fun foo() = <bold>2</bold>
21 val <bold>y = b.foo()</bold>
21 val y = <bold>b.foo()</bold>
8 override fun <bold>foo() = 2</bold>
8 override fun foo() = <bold>2</bold>
16 override fun foo() = <bold>4</bold>
21 val <bold>y = b.foo()</bold>
21 val y = <bold>b.foo()</bold>
16 override fun <bold>foo() = 4</bold>
16 override fun foo() = <bold>4</bold>

View File

@@ -0,0 +1,3 @@
[NotNull Values]
21 val <bold>y = b.foo()</bold>
21 val <bold>y = b.foo()</bold>

View File

@@ -0,0 +1,12 @@
12 override fun foo() = <bold>3</bold>
22 val <bold>z = c.foo()</bold>
22 val z = <bold>c.foo()</bold>
12 override fun <bold>foo() = 3</bold>
12 override fun foo() = <bold>3</bold>
16 override fun foo() = <bold>4</bold>
22 val <bold>z = c.foo()</bold>
22 val z = <bold>c.foo()</bold>
16 override fun <bold>foo() = 4</bold>
16 override fun foo() = <bold>4</bold>

View File

@@ -0,0 +1,3 @@
[NotNull Values]
22 val <bold>z = c.foo()</bold>
22 val <bold>z = c.foo()</bold>

View File

@@ -0,0 +1,24 @@
4 fun foo() = <bold>1</bold>
20 val <bold>x = a.foo()</bold>
20 val x = <bold>a.foo()</bold>
4 fun <bold>foo() = 1</bold>
4 fun foo() = <bold>1</bold>
8 override fun foo() = <bold>2</bold>
20 val <bold>x = a.foo()</bold>
20 val x = <bold>a.foo()</bold>
8 override fun <bold>foo() = 2</bold>
8 override fun foo() = <bold>2</bold>
12 override fun foo() = <bold>3</bold>
20 val <bold>x = a.foo()</bold>
20 val x = <bold>a.foo()</bold>
12 override fun <bold>foo() = 3</bold>
12 override fun foo() = <bold>3</bold>
16 override fun foo() = <bold>4</bold>
20 val <bold>x = a.foo()</bold>
20 val x = <bold>a.foo()</bold>
16 override fun <bold>foo() = 4</bold>
16 override fun foo() = <bold>4</bold>

View File

@@ -0,0 +1,3 @@
[NotNull Values]
20 val <bold>x = a.foo()</bold>
20 val <bold>x = a.foo()</bold>

View File

@@ -0,0 +1,14 @@
8 val x = foo(1, 2) { { <bold>it</bold> } }
8 val <bold>x = foo(1, 2) { { it } }</bold>
8 val x = <bold>foo(1, 2) { { it } }</bold>
3 fun <bold>foo(a: Int, b: Int, f: (Int) -> (Int) -> Int): Int {</bold>
4 return <bold>f(a)(b)</bold>
4 [LAMBDA] return <bold>f(a)</bold>(b)
4 [LAMBDA] [LAMBDA] return <bold>f</bold>(a)(b)
3 [LAMBDA] [LAMBDA] fun foo(a: Int, b: Int, <bold>f: (Int) -> (Int) -> Int</bold>): Int {
8 [LAMBDA] [LAMBDA] val x = foo(1, 2) <bold>{ { it } }</bold>
8 [LAMBDA] val x = foo(1, 2) <bold>{ { it } }</bold>
8 [LAMBDA] val x = foo(1, 2) { <bold>{ it }</bold> }
8 val x = foo(1, 2) { <bold>{ it }</bold> }
8 val x = foo(1, 2) { { <bold>it</bold> } }

View File

@@ -0,0 +1,3 @@
[NotNull Values]
8 val <bold>x = foo(1, 2) { { it } }</bold>
8 val <bold>x = foo(1, 2) { { it } }</bold>

View File

@@ -0,0 +1,4 @@
8 foo(<bold>1</bold>)
3 fun foo(<bold>n: Int</bold>, s: String = "???") {
8 foo(<bold>1</bold>)

View File

@@ -0,0 +1,3 @@
[NotNull Values]
3 fun foo(<bold>n: Int</bold>, s: String = "???") {
3 fun foo(<bold>n: Int</bold>, s: String = "???") {

View File

@@ -0,0 +1,8 @@
9 foo(1, <bold>"2"</bold>)
3 fun foo(n: Int, <bold>s: String = "???"</bold>) {
9 foo(1, <bold>"2"</bold>)
3 fun foo(n: Int, s: String = <bold>"???"</bold>) {
3 fun foo(n: Int, <bold>s: String = "???"</bold>) {
3 fun foo(n: Int, s: String = <bold>"???"</bold>) {

View File

@@ -0,0 +1,3 @@
[NotNull Values]
3 fun foo(n: Int, <bold>s: String = "???"</bold>) {
3 fun foo(n: Int, <bold>s: String = "???"</bold>) {

View File

@@ -0,0 +1,12 @@
8 fun bar(<bold>n: Int</bold>) = n
9 val <bold>x = foo(::bar)</bold>
9 val x = <bold>foo(::bar)</bold>
3 fun <bold>foo(f: (Int) -> Int): Int {</bold>
4 return <bold>f(1)</bold>
4 [LAMBDA] return <bold>f</bold>(1)
3 [LAMBDA] fun foo(<bold>f: (Int) -> Int</bold>): Int {
9 [LAMBDA] val x = foo(<bold>::bar</bold>)
8 fun <bold>bar(n: Int) = n</bold>
8 fun bar(n: Int) = <bold>n</bold>
8 fun bar(<bold>n: Int</bold>) = n

Some files were not shown because too many files have changed in this diff Show More