Merge branch 'master' of git.labs.intellij.net:jet

This commit is contained in:
Dmitry Jemerov
2012-02-14 11:32:59 +01:00
40 changed files with 355 additions and 8 deletions
@@ -460,9 +460,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
consArgTypes.add(insert++, new JvmMethodParameterSignature(t, "", JvmMethodParameterKind.SHARED_VAR));
}
}
}
constructorMethod = JvmMethodSignature.simple("<init>", Type.VOID_TYPE, consArgTypes);
constructorMethod = JvmMethodSignature.simple("<init>", Type.VOID_TYPE, consArgTypes);
}
int flags = ACC_PUBLIC; // TODO
final MethodVisitor mv = v.newMethod(myClass, flags, constructorMethod.getName(), constructorMethod.getAsmMethod().getDescriptor(), constructorMethod.getGenericsSignature(), null);
@@ -357,7 +357,15 @@ public class OverrideResolver {
abstractNoImpl.add(single);
}
} else {
manyImpl.addAll(overridenDeclarations);
List<CallableMemberDescriptor> nonAbstractManyImpl = Lists.newArrayList();
for (CallableMemberDescriptor overriden : overridenDeclarations) {
if (overriden.getModality() != Modality.ABSTRACT) {
nonAbstractManyImpl.add(overriden);
}
}
if (nonAbstractManyImpl.size() > 1) {
manyImpl.addAll(nonAbstractManyImpl);
}
}
}
}
@@ -0,0 +1,9 @@
open class Ccc() {
fun foo() = 1
}
trait Ttt {
fun foo(): Int
}
class Zzz() : Ccc(), Ttt
@@ -0,0 +1,10 @@
import javax.swing.SwingUtilities
fun main(args : Array<String>) {
SwingUtilities.invokeLater(object : Runnable {
<caret> override fun run() {
throw UnsupportedOperationException()
}
})
}
+5
View File
@@ -0,0 +1,5 @@
import javax.swing.SwingUtilities
fun main(args : Array<String>) {
SwingUtilities.invokeLater(<caret>)
}
@@ -0,0 +1,7 @@
import javax.swing.SwingUtilities
fun main(args : Array<String>) {
SwingUtilities.invokeLater(object : Thread(<caret>) {
})
}
+5
View File
@@ -0,0 +1,5 @@
import javax.swing.SwingUtilities
fun main(args : Array<String>) {
SwingUtilities.invokeLater(<caret>)
}
+3
View File
@@ -0,0 +1,3 @@
fun main(args : Array<String>) {
val someFun = {param -> param}<caret>
}
+3
View File
@@ -0,0 +1,3 @@
fun main(args : Array<String>) {
val someFun = <caret>
}
+3
View File
@@ -0,0 +1,3 @@
fun Int.foo(arg : Int) : Unit {
<caret>
}
+1
View File
@@ -0,0 +1 @@
<caret>
+4
View File
@@ -0,0 +1,4 @@
val Int.v : Int
get() {
<caret>
}
+1
View File
@@ -0,0 +1 @@
<caret>
+7
View File
@@ -0,0 +1,7 @@
var Int.v : Int
get() {
<caret>
}
set(value) {
}
+1
View File
@@ -0,0 +1 @@
<caret>
+3
View File
@@ -0,0 +1,3 @@
fun foo() : Unit {
<caret>
}
+1
View File
@@ -0,0 +1 @@
<caret>
+3
View File
@@ -0,0 +1,3 @@
fun foo(x : Any) : Unit {
<caret>
}
+1
View File
@@ -0,0 +1 @@
<caret>
+3
View File
@@ -0,0 +1,3 @@
fun foo(x : Any, y : Any) : Unit {
<caret>
}
+1
View File
@@ -0,0 +1 @@
<caret>
+3
View File
@@ -0,0 +1,3 @@
trait SomeTrait {
<caret>
}
+1
View File
@@ -0,0 +1 @@
<caret>
+18
View File
@@ -0,0 +1,18 @@
import java.io.InputStream
import java.util.ArrayList
import java.io.FileInputStream
import java.util.HashSet
class MyClass {
public var collection : HashSet<Int>? = null
private var isAlive : Boolean = false
fun main(args : Array<String>, v : Int) {
var str = ""
val myList = ArrayList<String>()
val stream = FileInputStream(".")
for (i in args) {
<caret>
}
}
}
+3
View File
@@ -0,0 +1,3 @@
fun main(args : Array<String>) {
<caret>
}
View File
+3
View File
@@ -0,0 +1,3 @@
fun main(args : Array<String>) {
System.err?.println(<caret>)
}
+3
View File
@@ -0,0 +1,3 @@
fun main(args : Array<String>) {
<caret>
}
+3
View File
@@ -0,0 +1,3 @@
object MySingleton {
<caret>
}
+1
View File
@@ -0,0 +1 @@
<caret>
+3
View File
@@ -0,0 +1,3 @@
fun main(args : Array<String>) {
println(<caret>)
}
+3
View File
@@ -0,0 +1,3 @@
fun main(args : Array<String>) {
<caret>
}
+5
View File
@@ -0,0 +1,5 @@
fun main(args : Array<String>) {
fun secondary(x : Int, y : Int) {
println("x = [${x}], y = [${y}]")<caret>
}
}
+5
View File
@@ -0,0 +1,5 @@
fun main(args : Array<String>) {
fun secondary(x : Int, y : Int) {
<caret>
}
}
+5
View File
@@ -0,0 +1,5 @@
fun main(args : Array<String>) {
val x = 5
val y = "str"
println("y = ${y}")<caret>
}
+5
View File
@@ -0,0 +1,5 @@
fun main(args : Array<String>) {
val x = 5
val y = "str"
<caret>
}
+3
View File
@@ -0,0 +1,3 @@
fun foo(x : Int) {
<caret>
}
+1
View File
@@ -0,0 +1 @@
<caret>
@@ -5,12 +5,16 @@ import com.intellij.codeInsight.lookup.LookupEx;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.codeInsight.template.impl.TemplateState;
import com.intellij.ide.DataManager;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor;
@@ -25,12 +29,213 @@ import java.util.Arrays;
* @since 2/10/12
*/
public class LiveTemplatesTest extends LightCodeInsightFixtureTestCase {
public void testSout() {
paremeterless();
}
public void testSerr() {
paremeterless();
}
public void testMain() {
paremeterless();
}
public void testSoutv() {
start();
assertStringItems("args", "x", "y");
typeAndNextTab("y");
checkAfter();
}
public void testSoutp() {
paremeterless();
}
public void testFun0() {
start();
type("foo");
nextTab(2);
checkAfter();
}
public void testFun1() {
start();
type("foo");
nextTab(4);
checkAfter();
}
public void testFun2() {
start();
type("foo");
nextTab(6);
checkAfter();
}
public void testExfun() {
start();
typeAndNextTab("Int");
typeAndNextTab("foo");
typeAndNextTab("arg : Int");
nextTab();
checkAfter();
}
public void testExval() {
start();
typeAndNextTab("Int");
nextTab();
typeAndNextTab("Int");
checkAfter();
}
public void testExvar() {
start();
typeAndNextTab("Int");
nextTab();
typeAndNextTab("Int");
checkAfter();
}
public void testClosure() {
start();
typeAndNextTab("param");
nextTab();
checkAfter();
}
public void testInterface() {
start();
typeAndNextTab("SomeTrait");
checkAfter();
}
public void testSingleton() {
start();
typeAndNextTab("MySingleton");
checkAfter();
}
public void testVoid() {
start();
typeAndNextTab("foo");
typeAndNextTab("x : Int");
checkAfter();
}
public void testIter() {
myFixture.configureByFile(getTestName(false) + ".kt");
myFixture.type("iter");
start();
assertStringItems("args", "collection", "myList", "str", "stream");
type("args");
nextTab(2);
checkAfter();
}
public void testAnonymous_1() {
start();
typeAndNextTab("Runnable");
checkAfter();
}
public void testAnonymous_2() {
start();
typeAndNextTab("Thread");
checkAfter();
}
private void paremeterless() {
start();
checkAfter();
}
private void start() {
myFixture.configureByFile(getTestName(true) + ".kt");
myFixture.type(getTemplateName());
doAction("ExpandLiveTemplateByTab");
assertStringItems("args", "collection", "myList", "str", "stream");
}
private String getTemplateName() {
String testName = getTestName(true);
if (testName.contains("_")) {
return testName.substring(0, testName.indexOf("_"));
}
return testName;
}
private void checkAfter() {
assertNull(getTemplateState());
myFixture.checkResultByFile(getTestName(true) + ".exp.kt", true);
}
private void typeAndNextTab(String s) {
type(s);
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
nextTab();
}
});
}
}, "nextTab", null);
}
});
}
private void type(String s) {
myFixture.type(s);
}
private void nextTab() {
getTemplateState().nextTab();
}
private void nextTab(int times) {
for (int i = 0; i < times; i++) {
nextTab();
}
}
private TemplateState getTemplateState() {
return TemplateManagerImpl.getTemplateState(myFixture.getEditor());
}
@NotNull
@@ -59,10 +264,8 @@ public class LiveTemplatesTest extends LightCodeInsightFixtureTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
myFixture.setTestDataPath(new File(PluginTestCaseBase.getTestDataPathBase(), "/templates").getPath() +
File.separator);
((TemplateManagerImpl) TemplateManager.getInstance(getProject())).setTemplateTesting(true);
}