diff --git a/platform/analysis-impl/analysis-impl.iml b/platform/analysis-impl/analysis-impl.iml index eafc1b2b89cd..ec8ddd53502c 100644 --- a/platform/analysis-impl/analysis-impl.iml +++ b/platform/analysis-impl/analysis-impl.iml @@ -18,5 +18,6 @@ + \ No newline at end of file diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionsProfileConfigurationHandler.kt b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionsProfileConfigurationHandler.kt new file mode 100644 index 000000000000..e49a8f10ec5d --- /dev/null +++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionsProfileConfigurationHandler.kt @@ -0,0 +1,46 @@ +/* + * 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 com.intellij.profile.codeInspection + +import com.intellij.codeInspection.ex.InspectionProfileImpl +import com.intellij.codeInspection.ex.InspectionToolRegistrar +import com.intellij.openapi.externalSystem.model.project.ConfigurationData +import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider +import com.intellij.openapi.externalSystem.service.project.manage.ConfigurationHandler +import com.intellij.openapi.project.Project + +/** + * Created by Nikita.Skvortsov + * date: 19.09.2017. + */ +class InspectionsProfileConfigurationHandler: ConfigurationHandler { + override fun apply(project: Project, modelsProvider: IdeModifiableModelsProvider, configuration: ConfigurationData) { + val inspectionsSettings: Map = configuration.find("inspections") as? Map ?: return + + val gradleProfileName = "Gradle Imported" + val profileManager = ProjectInspectionProfileManager.getInstance(project) + val importedProfile = InspectionProfileImpl(gradleProfileName, InspectionToolRegistrar.getInstance(), profileManager) + + importedProfile.copyFrom(profileManager.getProfile(com.intellij.codeInspection.ex.DEFAULT_PROFILE_NAME)) + importedProfile.initInspectionTools(project) + val modifiableModel = importedProfile.modifiableModel + modifiableModel.name = gradleProfileName + + modifiableModel.commit() + profileManager.addProfile(importedProfile) + profileManager.setRootProfile(gradleProfileName) + } +} \ No newline at end of file diff --git a/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml b/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml index 20fa7c37f4ab..ed769ca79bee 100644 --- a/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml +++ b/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml @@ -39,6 +39,7 @@ + diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleSettingsImportingTest.java b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleSettingsImportingTest.java index d9bde324b662..eed808da7741 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleSettingsImportingTest.java +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleSettingsImportingTest.java @@ -15,6 +15,7 @@ */ package org.jetbrains.plugins.gradle.importing; +import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.compiler.CompilerConfiguration; import com.intellij.compiler.CompilerConfigurationImpl; import com.intellij.compiler.CompilerWorkspaceConfiguration; @@ -25,6 +26,7 @@ import com.intellij.openapi.externalSystem.service.project.manage.FacetHandlerEx import com.intellij.openapi.externalSystem.service.project.manage.RunConfigHandlerExtension; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; +import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.psi.codeStyle.CodeStyleScheme; import com.intellij.psi.codeStyle.CodeStyleSchemes; import com.intellij.psi.codeStyle.CodeStyleSettings; @@ -48,6 +50,28 @@ public class GradleSettingsImportingTest extends GradleImportingTestCase { } + @Test + public void testInspectionSettingsImport() throws Exception { + importProject( + "buildscript {\n" + + " dependencies {\n" + + " classpath files('" + getGradlePluginPath() + "')\n" + + " }\n" + + "}\n" + + "apply plugin: 'org.jetbrains.gradle.plugin.idea-ext'\n" + + "idea {\n" + + " project.settings {\n" + + " inspections {\n" + + " }\n" + + " }\n" + + "}" + ); + + final InspectionProfileImpl profile = InspectionProfileManager.getInstance(myProject).getCurrentProfile(); + assertEquals("Gradle Imported", profile.getName()); + } + + @Test public void testCodeStyleSettingsImport() throws Exception { importProject( diff --git a/plugins/gradle/tooling-extension-impl/testData/testCompilerConfigurationSettingsImport/gradle-idea-ext.jar b/plugins/gradle/tooling-extension-impl/testData/testCompilerConfigurationSettingsImport/gradle-idea-ext.jar index 395fec877a98..21a3d99d83fb 100755 Binary files a/plugins/gradle/tooling-extension-impl/testData/testCompilerConfigurationSettingsImport/gradle-idea-ext.jar and b/plugins/gradle/tooling-extension-impl/testData/testCompilerConfigurationSettingsImport/gradle-idea-ext.jar differ