Create import list psi element even if no directives are present
Fix a problem where deleting last import directive via "optimize imports" could lead to incorrect psi structure resulting in CCE, see EA-64291 New imports are inserted at the head (after package directive if present) of the file (before any comments) if no imports were present Add test for inserting import to file where a first statement is a comment Drop code dealing with non-existing import list in ImportInsertHelperImpl AbstractQuickFixTest: check for unexpected actions before changes to the file are made as it relies on the first line having specific format
This commit is contained in:
+3
-1
@@ -4,6 +4,8 @@ JetFile: PackageBlockFirst.kt
|
||||
PsiWhiteSpace(' ')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('foobar')
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
FUN
|
||||
PsiErrorElement:Expecting a top level declaration
|
||||
@@ -35,4 +37,4 @@ JetFile: PackageBlockFirst.kt
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiElement(RBRACE)('}')
|
||||
|
||||
@@ -6,6 +6,8 @@ JetFile: PackageLeadingDotDoubleID.kt
|
||||
PsiElement(DOT)('.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
@@ -15,4 +17,4 @@ JetFile: PackageLeadingDotDoubleID.kt
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('b')
|
||||
PsiErrorElement:Expecting a top level declaration
|
||||
<empty list>
|
||||
<empty list>
|
||||
|
||||
@@ -16,4 +16,6 @@ JetFile: PackageLongNameBetweenDots.kt
|
||||
PsiElement(IDENTIFIER)('c')
|
||||
PsiElement(DOT)('.')
|
||||
PsiErrorElement:Package name must be a '.'-separated identifier list placed on a single line
|
||||
<empty list>
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
@@ -4,6 +4,8 @@ JetFile: PackageLongNameDoubleID.kt
|
||||
PsiWhiteSpace(' ')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
@@ -13,4 +15,4 @@ JetFile: PackageLongNameDoubleID.kt
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('b')
|
||||
PsiErrorElement:Expecting a top level declaration
|
||||
<empty list>
|
||||
<empty list>
|
||||
|
||||
@@ -13,4 +13,6 @@ JetFile: PackageLongNameLeadingDot.kt
|
||||
PsiElement(IDENTIFIER)('b')
|
||||
PsiElement(DOT)('.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('c')
|
||||
PsiElement(IDENTIFIER)('c')
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
@@ -16,4 +16,6 @@ JetFile: PackageLongNameLeadingDoubleDot.kt
|
||||
PsiElement(IDENTIFIER)('b')
|
||||
PsiElement(DOT)('.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('c')
|
||||
PsiElement(IDENTIFIER)('c')
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
+3
-1
@@ -16,4 +16,6 @@ JetFile: PackageModifiers.kt
|
||||
PsiElement(package)('package')
|
||||
PsiWhiteSpace(' ')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('name')
|
||||
PsiElement(IDENTIFIER)('name')
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
+3
-1
@@ -8,4 +8,6 @@ JetFile: PackageNameDoubleDot.kt
|
||||
PsiErrorElement:Package name must be a '.'-separated identifier list
|
||||
PsiElement(DOT)('.')
|
||||
PsiErrorElement:Package name must be a '.'-separated identifier list placed on a single line
|
||||
<empty list>
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
+3
-1
@@ -5,4 +5,6 @@ JetFile: PackageNameJustDot.kt
|
||||
PsiErrorElement:Package name must be a '.'-separated identifier list
|
||||
PsiElement(DOT)('.')
|
||||
PsiErrorElement:Package name must be a '.'-separated identifier list placed on a single line
|
||||
<empty list>
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
@@ -5,4 +5,6 @@ JetFile: PackageSimpleNameLeadingDot.kt
|
||||
PsiErrorElement:Package name must be a '.'-separated identifier list
|
||||
PsiElement(DOT)('.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
@@ -8,4 +8,6 @@ JetFile: PackageSimpleNameLeadingDoubleDot.kt
|
||||
PsiErrorElement:Package name must be a '.'-separated identifier list
|
||||
PsiElement(DOT)('.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
Reference in New Issue
Block a user