mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add entry point for inspections settings import
This commit is contained in:
@@ -18,5 +18,6 @@
|
||||
<orderEntry type="module" module-name="indexing-impl" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
<orderEntry type="module" module-name="uast-common" />
|
||||
<orderEntry type="module" module-name="external-system-api" />
|
||||
</component>
|
||||
</module>
|
||||
+46
@@ -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<String, *> = configuration.find("inspections") as? Map<String,*> ?: 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)
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@
|
||||
<externalSystemConfigurationHandler implementation="com.intellij.openapi.externalSystem.service.project.manage.CodeStyleConfigurationHandler"/>
|
||||
<externalSystemConfigurationHandler implementation="com.intellij.openapi.externalSystem.service.project.manage.RunConfigurationHandler"/>
|
||||
<externalSystemConfigurationHandler implementation="com.intellij.openapi.externalSystem.service.project.manage.FacetHandler"/>
|
||||
<externalSystemConfigurationHandler implementation="com.intellij.profile.codeInspection.InspectionsProfileConfigurationHandler"/>
|
||||
<runConfigurationHandlerExtension implementation="com.intellij.openapi.externalSystem.service.project.manage.ApplicationRunConfigHandler"/>
|
||||
|
||||
<configuration.ModuleStructureExtension implementation="com.intellij.openapi.externalSystem.service.project.manage.ExternalModuleStructureExtension"/>
|
||||
|
||||
+24
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user