mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 21:44:49 +07:00
Java: Quick fix for merging duplicate statements in module-info (IDEA-169211)
This commit is contained in:
+4
@@ -0,0 +1,4 @@
|
||||
module M {
|
||||
exports my.api to M4;
|
||||
exports <caret>my.api to M6;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module M {
|
||||
exports my.api to M4, M6;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
module M {
|
||||
exports my.api;
|
||||
exports <caret>my.api to M2, M4;
|
||||
exports my.api to M6;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
module M {
|
||||
exports my.api;
|
||||
exports my.api to M6, M2, M4;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
module M {
|
||||
opens my.api to M4;
|
||||
opens <caret>my.api to M6;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module M {
|
||||
opens my.api to M4, M6;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
module M {
|
||||
opens my.api;
|
||||
opens <caret>my.api to M2, M4;
|
||||
opens my.api to M6;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
module M {
|
||||
opens my.api;
|
||||
opens my.api to M6, M2, M4;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
module M {
|
||||
provides my.api.MyService with my.impl.MyServiceImpl;
|
||||
provides my.api.MyService with my.impl.<caret>MyServiceImpl1;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module M {
|
||||
provides my.api.MyService with my.impl.MyServiceImpl,my.impl.MyServiceImpl1;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import my.impl.MyServiceImpl;
|
||||
import my.impl.MyServiceImpl1;
|
||||
import my.impl.MyServiceImpl2;
|
||||
|
||||
module M {
|
||||
provides my.api.MyService with MyServiceImpl, MyServiceImpl2;
|
||||
provides my.api.MyService with <caret>MyServiceImpl1;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import my.impl.MyServiceImpl;
|
||||
import my.impl.MyServiceImpl1;
|
||||
import my.impl.MyServiceImpl2;
|
||||
|
||||
module M {
|
||||
provides my.api.MyService with MyServiceImpl,MyServiceImpl2,MyServiceImpl1;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import my.impl.MyServiceImpl;
|
||||
import my.impl.MyServiceImpl1;
|
||||
import my.impl.MyServiceImpl2;
|
||||
|
||||
module M {
|
||||
provides my.api.MyService with MyServiceImpl;
|
||||
provides my.api.MyService with <caret>MyServiceImpl1, MyServiceImpl2;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import my.impl.MyServiceImpl;
|
||||
import my.impl.MyServiceImpl1;
|
||||
import my.impl.MyServiceImpl2;
|
||||
|
||||
module M {
|
||||
provides my.api.MyService with MyServiceImpl,MyServiceImpl1,MyServiceImpl2;
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.codeInsight.daemon.quickFix
|
||||
|
||||
import com.intellij.JavaTestUtil.getRelativeJavaTestDataPath
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.testFramework.fixtures.LightJava9ModulesCodeInsightFixtureTestCase
|
||||
import com.intellij.testFramework.fixtures.MultiModuleJava9ProjectDescriptor.ModuleDescriptor.*
|
||||
|
||||
/**
|
||||
* @author Pavel.Dolgov
|
||||
*/
|
||||
class MergeModuleStatementsFixTest : LightJava9ModulesCodeInsightFixtureTestCase() {
|
||||
|
||||
override fun getBasePath() = getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/quickFix/mergeModuleStatementsFix"
|
||||
|
||||
fun testExports1() = doTest("exports", "my.api")
|
||||
fun testExports2() = doTest("exports", "my.api")
|
||||
|
||||
fun testProvides1() = doTest("provides", "my.api.MyService")
|
||||
fun testProvides2() = doTest("provides", "my.api.MyService")
|
||||
fun testProvides3() = doTest("provides", "my.api.MyService")
|
||||
|
||||
fun testOpens1() = doTest("opens", "my.api")
|
||||
fun testOpens2() = doTest("opens", "my.api")
|
||||
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
addFile("module-info.java", "module M2 { }", M2)
|
||||
addFile("module-info.java", "module M4 { }", M4)
|
||||
addFile("module-info.java", "module M6 { }", M6)
|
||||
|
||||
addFile("my/api/MyService.java", "package my.api; public class MyService {}")
|
||||
addFile("my/impl/MyServiceImpl.java", "package my.impl; public class MyServiceImpl extends my.api.MyService {}")
|
||||
addFile("my/impl/MyServiceImpl1.java", "package my.impl; public class MyServiceImpl1 extends my.api.MyService {}")
|
||||
addFile("my/impl/MyServiceImpl2.java", "package my.impl; public class MyServiceImpl2 extends my.api.MyService {}")
|
||||
}
|
||||
|
||||
private fun doTest(type: String, name: String) {
|
||||
val testName = getTestName(false)
|
||||
val virtualFile = myFixture.copyFileToProject("${testName}.java", "module-info.java")
|
||||
myFixture.configureFromExistingVirtualFile(virtualFile)
|
||||
|
||||
val action = findActionWithText(QuickFixBundle.message("java.9.merge.module.statements.fix.name", type, name))
|
||||
myFixture.launchAction(action)
|
||||
myFixture.checkResultByFile("${testName}_after.java")
|
||||
}
|
||||
|
||||
private fun findActionWithText(actionText: String): IntentionAction {
|
||||
myFixture.doHighlighting()
|
||||
|
||||
val actions = LightQuickFixTestCase.getAvailableActions(editor, file)
|
||||
val action = LightQuickFixTestCase.findActionWithText(actions, actionText)
|
||||
assertNotNull("No action [$actionText] in ${actions.map { it.text }}", action)
|
||||
return action
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user