- Tests for KT-1051, KT-1151 and KT-1100
- Icon for java fake class
This commit is contained in:
@@ -8,6 +8,7 @@ import com.intellij.openapi.project.Project;
|
|||||||
import com.intellij.openapi.util.Comparing;
|
import com.intellij.openapi.util.Comparing;
|
||||||
import com.intellij.openapi.util.Key;
|
import com.intellij.openapi.util.Key;
|
||||||
import com.intellij.psi.*;
|
import com.intellij.psi.*;
|
||||||
|
import com.intellij.psi.impl.PsiClassImplUtil;
|
||||||
import com.intellij.psi.impl.PsiManagerImpl;
|
import com.intellij.psi.impl.PsiManagerImpl;
|
||||||
import com.intellij.psi.impl.compiled.ClsFileImpl;
|
import com.intellij.psi.impl.compiled.ClsFileImpl;
|
||||||
import com.intellij.psi.impl.java.stubs.PsiClassStub;
|
import com.intellij.psi.impl.java.stubs.PsiClassStub;
|
||||||
@@ -32,6 +33,7 @@ import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
|
|||||||
import org.jetbrains.jet.lang.resolve.java.JetJavaMirrorMarker;
|
import org.jetbrains.jet.lang.resolve.java.JetJavaMirrorMarker;
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -162,7 +164,6 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
List<JetFile> files = Collections.singletonList(file);
|
List<JetFile> files = Collections.singletonList(file);
|
||||||
final BindingContext context = AnalyzerFacade.shallowAnalyzeFiles(files);
|
final BindingContext context = AnalyzerFacade.shallowAnalyzeFiles(files);
|
||||||
state.compileCorrectFiles(context, files);
|
state.compileCorrectFiles(context, files);
|
||||||
@@ -175,4 +176,9 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa
|
|||||||
public boolean isEquivalentTo(PsiElement another) {
|
public boolean isEquivalentTo(PsiElement another) {
|
||||||
return another instanceof PsiClass && Comparing.equal(((PsiClass) another).getQualifiedName(), getQualifiedName());
|
return another instanceof PsiClass && Comparing.equal(((PsiClass) another).getQualifiedName(), getQualifiedName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getElementIcon(final int flags) {
|
||||||
|
return PsiClassImplUtil.getClassIcon(flags, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,16 +50,6 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
|||||||
public String[] getAllClassNames() {
|
public String[] getAllClassNames() {
|
||||||
final Collection<String> classNames = JetShortClassNameIndex.getInstance().getAllKeys(project);
|
final Collection<String> classNames = JetShortClassNameIndex.getInstance().getAllKeys(project);
|
||||||
return classNames.toArray(new String[classNames.size()]);
|
return classNames.toArray(new String[classNames.size()]);
|
||||||
|
|
||||||
// final Collection<String> fqNames = getALlJetClassFQNames();
|
|
||||||
//
|
|
||||||
// return Collections2.transform(fqNames, new Function<String, String>() {
|
|
||||||
// @Override
|
|
||||||
// public String apply(@Nullable String fqName) {
|
|
||||||
// assert fqName != null;
|
|
||||||
// return fqnToShortName(fqName);
|
|
||||||
// }
|
|
||||||
// }).toArray(new String[fqNames.size()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,7 +140,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Collection<String> getAllTopLevelFunctionNames() {
|
public Collection<String> getAllTopLevelFunctionNames() {
|
||||||
final ArrayList<String> functionNames = new ArrayList<String>();
|
final HashSet<String> functionNames = new HashSet<String>();
|
||||||
functionNames.addAll(JetShortFunctionNameIndex.getInstance().getAllKeys(project));
|
functionNames.addAll(JetShortFunctionNameIndex.getInstance().getAllKeys(project));
|
||||||
functionNames.addAll(JetFromJavaDescriptorHelper.getPossiblePackageDeclarationsNames(project, GlobalSearchScope.allScope(project)));
|
functionNames.addAll(JetFromJavaDescriptorHelper.getPossiblePackageDeclarationsNames(project, GlobalSearchScope.allScope(project)));
|
||||||
return functionNames;
|
return functionNames;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package first
|
||||||
|
|
||||||
|
class FirstClass() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun firstFun() {
|
||||||
|
val a = FirstClass()
|
||||||
|
a.<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: secondExtension
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package second
|
||||||
|
|
||||||
|
import first.FirstClass
|
||||||
|
|
||||||
|
fun FirstClass.secondExtension() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package first
|
||||||
|
|
||||||
|
fun firstFun() {
|
||||||
|
sec<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: secondFun
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package second
|
||||||
|
|
||||||
|
fun secondFun() {
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
|
package testing
|
||||||
|
|
||||||
fun other() {
|
fun other() {
|
||||||
HashSe<caret>
|
SortedS<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// INSERT: HashSet
|
// INSERT: SortedSet
|
||||||
@@ -1,3 +1,9 @@
|
|||||||
|
package testing
|
||||||
|
|
||||||
|
import java.util.SortedSet
|
||||||
|
|
||||||
fun other() {
|
fun other() {
|
||||||
HashSe<caret>
|
SortedSet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// INSERT: SortedSet
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
public class Testing {
|
||||||
|
public static void test() {
|
||||||
|
jett<caret>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: jettesting
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package jettesting
|
||||||
|
|
||||||
|
class ClassFromJet {
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package testing
|
||||||
|
|
||||||
|
private fun times<T>(times : Int, body : () -> T) {
|
||||||
|
for (var i in 1..times) {
|
||||||
|
body()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
times(3) {
|
||||||
|
<caret>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package testing
|
||||||
|
|
||||||
|
private fun times<T>(times : Int, body : () -> T) {
|
||||||
|
for (var i in 1..times) {
|
||||||
|
body()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
times(3) {<caret>
|
||||||
|
}
|
||||||
@@ -15,6 +15,11 @@ public class JetInJavaCompletionTest extends JetCompletionMultiTestBase {
|
|||||||
doFileTest();
|
doFileTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: fix and uncomment
|
||||||
|
public void skiptestTopLevelPackages() throws Exception {
|
||||||
|
doFileTest();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTestDataPath() {
|
protected String getTestDataPath() {
|
||||||
return PluginTestCaseBase.getTestDataPathBase() + "/completion/injava/";
|
return PluginTestCaseBase.getTestDataPathBase() + "/completion/injava/";
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nikolay Krasko
|
||||||
|
*/
|
||||||
|
public class JetMultifileBasicCompletionTest extends JetCompletionMultiTestBase {
|
||||||
|
|
||||||
|
// TODO: fix and uncomment
|
||||||
|
public void skiptestTopLevelFunction() throws Exception {
|
||||||
|
doFileTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testExtensionFunction() throws Exception {
|
||||||
|
// TODO: fix and uncomment
|
||||||
|
// doFileTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTestDataPath() {
|
||||||
|
return PluginTestCaseBase.getTestDataPathBase() + "/completion/basic/multifile";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String[] getFileNameList() {
|
||||||
|
String fileName = getTestName(false);
|
||||||
|
return new String[]{fileName + "-1.kt", fileName + "-2.kt"};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package org.jetbrains.jet.completion.handlers;
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.completion.LightCompletionTestCase;
|
||||||
|
import com.intellij.openapi.projectRoots.Sdk;
|
||||||
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nikolay Krasko
|
||||||
|
*/
|
||||||
|
public class CompletionHandlerTest extends LightCompletionTestCase {
|
||||||
|
|
||||||
|
public void testNoParamsFunction() {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParamsFunction() {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testInsertJavaClassImport() {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPropertiesSetter() {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSingleBrackets() {
|
||||||
|
configureByFile("SingleBrackets.kt");
|
||||||
|
type('(');
|
||||||
|
checkResultByFile("SingleBrackets.kt.after");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doTest() {
|
||||||
|
String fileName = getTestName(false);
|
||||||
|
try {
|
||||||
|
configureByFileNoComplete(fileName + ".kt");
|
||||||
|
complete(2);
|
||||||
|
checkResultByFile(fileName + ".kt.after");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTestDataPath() {
|
||||||
|
return new File(PluginTestCaseBase.getTestDataPathBase(), "/completion/handlers/").getPath() + File.separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Sdk getProjectJDK() {
|
||||||
|
return PluginTestCaseBase.jdkFromIdeaHome();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package org.jetbrains.jet.completion.handlers;
|
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.LightCompletionTestCase;
|
|
||||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nikolay Krasko
|
|
||||||
*/
|
|
||||||
public class FunctionsHandlerTest extends LightCompletionTestCase {
|
|
||||||
|
|
||||||
public void testNoParamsFunction() {
|
|
||||||
configureByFile("NoParamsFunction.kt");
|
|
||||||
checkResultByFile("NoParamsFunction.kt.after");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFunctionWithParams() {
|
|
||||||
configureByFile("ParamsFunction.kt");
|
|
||||||
checkResultByFile("ParamsFunction.kt.after");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSingleBrackets() {
|
|
||||||
configureByFile("SingleBrackets.kt");
|
|
||||||
type('(');
|
|
||||||
checkResultByFile("SingleBrackets.kt.after");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getTestDataPath() {
|
|
||||||
return new File(PluginTestCaseBase.getTestDataPathBase(), "/completion/handlers/").getPath() + File.separator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,6 +25,11 @@ public class JetTypingIndentationTest extends LightCodeInsightTestCase {
|
|||||||
doFileNewlineTest();
|
doFileNewlineTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: fix and uncomment
|
||||||
|
public void testFunctionBlock() {
|
||||||
|
// doFileNewlineTest();
|
||||||
|
}
|
||||||
|
|
||||||
public void doFileNewlineTest() {
|
public void doFileNewlineTest() {
|
||||||
configureByFile(getTestName(false) + ".kt");
|
configureByFile(getTestName(false) + ".kt");
|
||||||
type('\n');
|
type('\n');
|
||||||
@@ -33,6 +38,7 @@ public class JetTypingIndentationTest extends LightCodeInsightTestCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTestDataPath() {
|
protected String getTestDataPath() {
|
||||||
|
|
||||||
final String testRelativeDir = "formatter/IndentationOnNewline";
|
final String testRelativeDir = "formatter/IndentationOnNewline";
|
||||||
return new File(PluginTestCaseBase.getTestDataPathBase(), testRelativeDir).getPath() +
|
return new File(PluginTestCaseBase.getTestDataPathBase(), testRelativeDir).getPath() +
|
||||||
File.separator;
|
File.separator;
|
||||||
|
|||||||
Reference in New Issue
Block a user