Fix import resolution for some cases of malformed imports ("import some.")

Fix parsing import directives in case of non-identifier after "import"
Add diagnostics test for malformed imports
This commit is contained in:
Pavel V. Talanov
2015-06-16 20:46:25 +03:00
parent 37bcd455b5
commit 997a6f1381
9 changed files with 112 additions and 9 deletions
@@ -6132,6 +6132,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("MalformedImports.kt")
public void testMalformedImports() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/imports/MalformedImports.kt");
doTest(fileName);
}
@TestMetadata("PackageLocalClassNotImported.kt")
public void testPackageLocalClassNotImported() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/imports/PackageLocalClassNotImported.kt");
@@ -54,9 +54,9 @@ public class JetPsiUtilTest extends JetLiteFixture {
public void testConvertToImportPath() {
Assert.assertEquals(null, getImportPathFromParsed("import "));
Assert.assertEquals(null, getImportPathFromParsed("import some."));
Assert.assertEquals(new ImportPath(new FqName("some"), false), getImportPathFromParsed("import some."));
Assert.assertEquals(null, getImportPathFromParsed("import *"));
Assert.assertEquals(null, getImportPathFromParsed("import some.test.* as SomeTest"));
Assert.assertEquals(new ImportPath(new FqName("some.test"), true), getImportPathFromParsed("import some.test.* as SomeTest"));
Assert.assertEquals(new ImportPath(new FqName("some"), false), getImportPathFromParsed("import some?.Test"));
Assert.assertEquals(new ImportPath(new FqName("some"), false), getImportPathFromParsed("import some"));