Make intentions inner classes
This commit is contained in:
@@ -292,47 +292,47 @@
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldIfToAssignmentIntention</className>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldBranchedExpressionIntention$FoldIfToAssignmentIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldIfToReturnAsymmetricallyIntention</className>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldBranchedExpressionIntention$FoldIfToReturnAsymmetricallyIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldIfToReturnIntention</className>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldBranchedExpressionIntention$FoldIfToReturnIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldWhenToAssignmentIntention</className>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldBranchedExpressionIntention$FoldWhenToAssignmentIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldWhenToReturnIntention</className>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.FoldBranchedExpressionIntention$FoldWhenToReturnIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldAssignmentToIfIntention</className>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldBranchedExpressionIntention$UnfoldAssignmentToIfIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldAssignmentToWhenIntention</className>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldBranchedExpressionIntention$UnfoldAssignmentToWhenIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldReturnToIfIntention</className>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldBranchedExpressionIntention$UnfoldReturnToIfIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldReturnToWhenIntention</className>
|
||||
<className>org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions.UnfoldBranchedExpressionIntention$UnfoldReturnToWhenIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
|
||||
-8
@@ -46,14 +46,6 @@ public abstract class AbstractCodeTransformationIntention<T extends Transformer>
|
||||
return JetPsiUtil.getParentByTypeAndPredicate(element, JetElement.class, filter, false);
|
||||
}
|
||||
|
||||
protected final T getTransformer() {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
protected final Predicate<PsiElement> getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface Transformer {
|
||||
public @NotNull String getKey();
|
||||
@NotNull
|
||||
public String getKey();
|
||||
public void transform(@NotNull PsiElement element);
|
||||
}
|
||||
|
||||
+30
@@ -37,4 +37,34 @@ public abstract class FoldBranchedExpressionIntention extends AbstractCodeTransf
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static class FoldIfToAssignmentIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldIfToAssignmentIntention() {
|
||||
super(FoldableKind.IF_TO_ASSIGNMENT);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FoldIfToReturnAsymmetricallyIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldIfToReturnAsymmetricallyIntention() {
|
||||
super(FoldableKind.IF_TO_RETURN_ASYMMETRICALLY);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FoldIfToReturnIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldIfToReturnIntention() {
|
||||
super(FoldableKind.IF_TO_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FoldWhenToAssignmentIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldWhenToAssignmentIntention() {
|
||||
super(FoldableKind.WHEN_TO_ASSIGNMENT);
|
||||
}
|
||||
}
|
||||
|
||||
public static class FoldWhenToReturnIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldWhenToReturnIntention() {
|
||||
super(FoldableKind.WHEN_TO_RETURN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
|
||||
|
||||
import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
|
||||
|
||||
public class FoldIfToAssignmentIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldIfToAssignmentIntention() {
|
||||
super(FoldableKind.IF_TO_ASSIGNMENT);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
|
||||
|
||||
import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
|
||||
|
||||
public class FoldIfToReturnAsymmetricallyIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldIfToReturnAsymmetricallyIntention() {
|
||||
super(FoldableKind.IF_TO_RETURN_ASYMMETRICALLY);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
|
||||
|
||||
import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
|
||||
|
||||
public class FoldIfToReturnIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldIfToReturnIntention() {
|
||||
super(FoldableKind.IF_TO_RETURN);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
|
||||
|
||||
import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
|
||||
|
||||
public class FoldWhenToAssignmentIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldWhenToAssignmentIntention() {
|
||||
super(FoldableKind.WHEN_TO_ASSIGNMENT);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
|
||||
|
||||
import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.FoldableKind;
|
||||
|
||||
public class FoldWhenToReturnIntention extends FoldBranchedExpressionIntention {
|
||||
public FoldWhenToReturnIntention() {
|
||||
super(FoldableKind.WHEN_TO_RETURN);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
|
||||
|
||||
import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldableKind;
|
||||
|
||||
public class UnfoldAssignmentToIfIntention extends UnfoldBranchedExpressionIntention {
|
||||
public UnfoldAssignmentToIfIntention() {
|
||||
super(UnfoldableKind.ASSIGNMENT_TO_IF);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
|
||||
|
||||
import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldableKind;
|
||||
|
||||
public class UnfoldAssignmentToWhenIntention extends UnfoldBranchedExpressionIntention {
|
||||
public UnfoldAssignmentToWhenIntention() {
|
||||
super(UnfoldableKind.ASSIGNMENT_TO_WHEN);
|
||||
}
|
||||
}
|
||||
+24
@@ -35,4 +35,28 @@ public abstract class UnfoldBranchedExpressionIntention extends AbstractCodeTran
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static class UnfoldAssignmentToIfIntention extends UnfoldBranchedExpressionIntention {
|
||||
public UnfoldAssignmentToIfIntention() {
|
||||
super(UnfoldableKind.ASSIGNMENT_TO_IF);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnfoldAssignmentToWhenIntention extends UnfoldBranchedExpressionIntention {
|
||||
public UnfoldAssignmentToWhenIntention() {
|
||||
super(UnfoldableKind.ASSIGNMENT_TO_WHEN);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnfoldReturnToIfIntention extends UnfoldBranchedExpressionIntention {
|
||||
public UnfoldReturnToIfIntention() {
|
||||
super(UnfoldableKind.RETURN_TO_IF);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnfoldReturnToWhenIntention extends UnfoldBranchedExpressionIntention {
|
||||
public UnfoldReturnToWhenIntention() {
|
||||
super(UnfoldableKind.RETURN_TO_WHEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
|
||||
|
||||
import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldableKind;
|
||||
|
||||
public class UnfoldReturnToIfIntention extends UnfoldBranchedExpressionIntention {
|
||||
public UnfoldReturnToIfIntention() {
|
||||
super(UnfoldableKind.RETURN_TO_IF);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.codeInsight.codeTransformations.branchedTransformations.intentions;
|
||||
|
||||
import org.jetbrains.jet.plugin.codeInsight.codeTransformations.branchedTransformations.UnfoldableKind;
|
||||
|
||||
public class UnfoldReturnToWhenIntention extends UnfoldBranchedExpressionIntention {
|
||||
public UnfoldReturnToWhenIntention() {
|
||||
super(UnfoldableKind.RETURN_TO_WHEN);
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -27,39 +27,39 @@ import java.io.File;
|
||||
|
||||
public abstract class AbstractCodeTransformationTest extends LightCodeInsightTestCase {
|
||||
public void doTestFoldIfToAssignment(@NotNull String path) throws Exception {
|
||||
doTest(path, new FoldIfToAssignmentIntention());
|
||||
doTest(path, new FoldBranchedExpressionIntention.FoldIfToAssignmentIntention());
|
||||
}
|
||||
|
||||
public void doTestFoldIfToReturn(@NotNull String path) throws Exception {
|
||||
doTest(path, new FoldIfToReturnIntention());
|
||||
doTest(path, new FoldBranchedExpressionIntention.FoldIfToReturnIntention());
|
||||
}
|
||||
|
||||
public void doTestFoldIfToReturnAsymmetrically(@NotNull String path) throws Exception {
|
||||
doTest(path, new FoldIfToReturnAsymmetricallyIntention());
|
||||
doTest(path, new FoldBranchedExpressionIntention.FoldIfToReturnAsymmetricallyIntention());
|
||||
}
|
||||
|
||||
public void doTestFoldWhenToAssignment(@NotNull String path) throws Exception {
|
||||
doTest(path, new FoldWhenToAssignmentIntention());
|
||||
doTest(path, new FoldBranchedExpressionIntention.FoldWhenToAssignmentIntention());
|
||||
}
|
||||
|
||||
public void doTestFoldWhenToReturn(@NotNull String path) throws Exception {
|
||||
doTest(path, new FoldWhenToReturnIntention());
|
||||
doTest(path, new FoldBranchedExpressionIntention.FoldWhenToReturnIntention());
|
||||
}
|
||||
|
||||
public void doTestUnfoldAssignmentToIf(@NotNull String path) throws Exception {
|
||||
doTest(path, new UnfoldAssignmentToIfIntention());
|
||||
doTest(path, new UnfoldBranchedExpressionIntention.UnfoldAssignmentToIfIntention());
|
||||
}
|
||||
|
||||
public void doTestUnfoldAssignmentToWhen(@NotNull String path) throws Exception {
|
||||
doTest(path, new UnfoldAssignmentToWhenIntention());
|
||||
doTest(path, new UnfoldBranchedExpressionIntention.UnfoldAssignmentToWhenIntention());
|
||||
}
|
||||
|
||||
public void doTestUnfoldReturnToIf(@NotNull String path) throws Exception {
|
||||
doTest(path, new UnfoldReturnToIfIntention());
|
||||
doTest(path, new UnfoldBranchedExpressionIntention.UnfoldReturnToIfIntention());
|
||||
}
|
||||
|
||||
public void doTestUnfoldReturnToWhen(@NotNull String path) throws Exception {
|
||||
doTest(path, new UnfoldReturnToWhenIntention());
|
||||
doTest(path, new UnfoldBranchedExpressionIntention.UnfoldReturnToWhenIntention());
|
||||
}
|
||||
|
||||
public void doTestRemoveUnnecessaryParentheses(@NotNull String path) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user