Added tests for 'open' modifier checks

This commit is contained in:
svtk
2011-09-29 14:20:57 +04:00
parent ea9e1bee85
commit 7ec15fd00a
24 changed files with 78 additions and 20 deletions
@@ -4,6 +4,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNameIdentifierOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetModifierListOwner;
import org.jetbrains.jet.lang.psi.JetPropertyAccessor;
import org.jetbrains.jet.lexer.JetKeywordToken;
/**
@@ -19,12 +20,19 @@ public abstract class ModifierFix extends JetIntentionAction<JetModifierListOwne
@NotNull
protected String getElementName() {
String name = null;
if (element instanceof PsiNameIdentifierOwner) {
PsiElement nameIdentifier = ((PsiNameIdentifierOwner) element).getNameIdentifier();
if (nameIdentifier != null) {
return "'" + nameIdentifier.getText() + "'";
name = nameIdentifier.getText();
}
}
return "'" + element.getText() + "'";
else if (element instanceof JetPropertyAccessor) {
name = ((JetPropertyAccessor) element).getNamePlaceholder().getText();
}
if (name == null) {
name = element.getText();
}
return "'" + name + "'";
}
}
@@ -0,0 +1,17 @@
namespace illegal_modifiers
abstract class A() {
<!INCOMPATIBLE_MODIFIERS!>abstract<!> <!INCOMPATIBLE_MODIFIERS!>final<!> fun f()
abstract <!REDUNDANT_MODIFIER!>open<!> fun g()
<!INCOMPATIBLE_MODIFIERS!>final<!> <!INCOMPATIBLE_MODIFIERS!>open<!> fun h() {}
}
<!TRAIT_CAN_NOT_BE_FINAL!>final<!> trait T {}
class FinalClass() {
<!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> fun foo() {}
val i: Int = 1
<!NON_FINAL_ACCESSOR_OF_FINAL_PROPERTY!>open<!> get(): Int = $i
var j: Int = 1
<!NON_FINAL_ACCESSOR_OF_FINAL_PROPERTY!>open<!> set(v: Int) {}
}
@@ -1,7 +0,0 @@
namespace a
abstract class A() {
<!INCOMPATIBLE_MODIFIERS!>abstract<!> <!INCOMPATIBLE_MODIFIERS!>final<!> fun f()
abstract <!REDUNDANT_MODIFIER!>open<!> fun g()
<!INCOMPATIBLE_MODIFIERS!>final<!> <!INCOMPATIBLE_MODIFIERS!>open<!> fun h() {}
}
@@ -1,2 +1,2 @@
// "Make 'abstract get' not abstract" "true"
// "Make 'get' not abstract" "true"
val i : Int = 0; <caret>get
@@ -1,2 +1,2 @@
// "Make 'abstract get' not abstract" "true"
// "Make 'get' not abstract" "true"
val i : Int = 0; <caret>abstract get
@@ -0,0 +1,2 @@
// "Remove 'final' modifier" "true"
<caret>trait A {}
@@ -0,0 +1,5 @@
// "Make 'i' open" "true"
open class A() {
open val i: Int = 1
<caret>open get(): Int = $i
}
@@ -0,0 +1,5 @@
// "Make 'get' not open" "true"
open class A() {
val i: Int = 1
<caret>get(): Int = $i
}
@@ -0,0 +1,4 @@
// "Make 'A' open" "true"
open class A() {
<caret>open fun foo() {}
}
@@ -0,0 +1,4 @@
// "Make 'foo' not open" "true"
class A() {
<caret>fun foo() {}
}
@@ -0,0 +1,2 @@
// "Remove 'final' modifier" "true"
<caret>final trait A {}
@@ -0,0 +1,5 @@
// "Make 'i' open" "true"
open class A() {
val i: Int = 1
<caret>open get(): Int = $i
}
@@ -0,0 +1,5 @@
// "Make 'get' not open" "true"
open class A() {
val i: Int = 1
<caret>open get(): Int = $i
}
@@ -0,0 +1,4 @@
// "Make 'A' open" "true"
class A() {
<caret>open fun foo() {}
}
@@ -0,0 +1,4 @@
// "Make 'foo' not open" "true"
class A() {
<caret>open fun foo() {}
}
@@ -136,7 +136,7 @@ public class TypeInfoTest extends CodegenTestCase {
}
public void testInner() throws Exception {
blackBoxFile("typeinfo/inner.jet");
blackBoxFile("typeInfo/inner.jet");
System.out.println(generateToText());
}
}
@@ -6,7 +6,7 @@ import org.jetbrains.jet.JetTestCaseBase;
/**
* @author svtk
*/
public class AbstractModifierTest extends LightQuickFixTestCase {
public class AbstractModifierFixTest extends LightQuickFixTestCase {
public void test() throws Exception {
doAllTests();
@@ -6,7 +6,7 @@ import org.jetbrains.jet.JetTestCaseBase;
/**
* @author svtk
*/
public class AddPrimaryConstructorTest extends LightQuickFixTestCase {
public class AddPrimaryConstructorFixTest extends LightQuickFixTestCase {
public void test() throws Exception {
doAllTests();
@@ -6,7 +6,7 @@ import org.jetbrains.jet.JetTestCaseBase;
/**
* @author svtk
*/
public class ChangeVariableMutabilityTest extends LightQuickFixTestCase {
public class ChangeVariableMutabilityFixTest extends LightQuickFixTestCase {
public void test() throws Exception {
doAllTests();
@@ -7,7 +7,7 @@ import org.jetbrains.jet.JetTestCaseBase;
/**
* @author svtk
*/
public class ClassImportTests extends LightQuickFixTestCase {
public class ClassImportFixTest extends LightQuickFixTestCase {
public void test() throws Exception {
doAllTests();
@@ -6,7 +6,7 @@ import org.jetbrains.jet.JetTestCaseBase;
/**
* @author svtk
*/
public class ExpressionsTest extends LightQuickFixTestCase {
public class ExpressionsFixTest extends LightQuickFixTestCase {
public void test() throws Exception {
doAllTests();
@@ -6,7 +6,7 @@ import org.jetbrains.jet.JetTestCaseBase;
/**
* @author svtk
*/
public class ModifiersTest extends LightQuickFixTestCase {
public class ModifiersFixTest extends LightQuickFixTestCase {
public void test() throws Exception {
doAllTests();
@@ -6,7 +6,7 @@ import org.jetbrains.jet.JetTestCaseBase;
/**
* @author svtk
*/
public class OverrideModifierTest extends LightQuickFixTestCase {
public class OverrideModifierFixTest extends LightQuickFixTestCase {
public void test() throws Exception {
doAllTests();
@@ -6,7 +6,7 @@ import org.jetbrains.jet.JetTestCaseBase;
/**
* @author svtk
*/
public class TypeAdditionTests extends LightQuickFixTestCase {
public class TypeAdditionFixTests extends LightQuickFixTestCase {
public void test() throws Exception {
doAllTests();