Drop undocumented absolute name specification feature with 'package.'
This commit is contained in:
@@ -106,7 +106,6 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
|
||||
|
||||
IDENTIFIER, // SimpleName
|
||||
|
||||
PACKAGE_KEYWORD, // for absolute qualified names
|
||||
AT // Just for better recovery and maybe for annotations
|
||||
);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.KtNodeType;
|
||||
import org.jetbrains.kotlin.lexer.KtKeywordToken;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
|
||||
@@ -1939,7 +1938,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
|
||||
/*
|
||||
* userType
|
||||
* : ("package" ".")? simpleUserType{"."}
|
||||
* : simpleUserType{"."}
|
||||
* ;
|
||||
*
|
||||
* recovers on platform types:
|
||||
@@ -1951,7 +1950,9 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
||||
PsiBuilder.Marker userType = mark();
|
||||
|
||||
if (at(PACKAGE_KEYWORD)) {
|
||||
PsiBuilder.Marker keyword = mark();
|
||||
advance(); // PACKAGE_KEYWORD
|
||||
keyword.error("Expecting an element");
|
||||
expect(DOT, "Expecting '.'", TokenSet.create(IDENTIFIER, LBRACE, RBRACE));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,15 +43,8 @@ public class KtImportDirective extends KtElementImplStub<KotlinImportDirectiveSt
|
||||
return visitor.visitImportDirective(this, data);
|
||||
}
|
||||
|
||||
public boolean isAbsoluteInRootPackage() {
|
||||
KotlinImportDirectiveStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.isAbsoluteInRootPackage();
|
||||
}
|
||||
return findChildByType(KtTokens.PACKAGE_KEYWORD) != null;
|
||||
}
|
||||
|
||||
@Nullable @IfNotParsed
|
||||
@Nullable
|
||||
@IfNotParsed
|
||||
public KtExpression getImportedReference() {
|
||||
KtExpression[] references = getStubOrPsiChildren(KtStubElementTypes.INSIDE_DIRECTIVE_EXPRESSIONS, KtExpression.ARRAY_FACTORY);
|
||||
if (references.length > 0) {
|
||||
|
||||
@@ -37,14 +37,6 @@ public class KtUserType extends KtElementImplStub<KotlinUserTypeStub> implements
|
||||
super(stub, KtStubElementTypes.USER_TYPE);
|
||||
}
|
||||
|
||||
public boolean isAbsoluteInRootPackage() {
|
||||
KotlinUserTypeStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.isAbsoluteInRootPackage();
|
||||
}
|
||||
return findChildByType(KtTokens.PACKAGE_KEYWORD) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitUserType(this, data);
|
||||
@@ -83,15 +75,6 @@ public class KtUserType extends KtElementImplStub<KotlinUserTypeStub> implements
|
||||
return getStubOrPsiChild(KtStubElementTypes.USER_TYPE);
|
||||
}
|
||||
|
||||
public boolean hasTypesWithTypeArgsInside() {
|
||||
for (KtUserType type : getStubOrPsiChildrenAsList(KtStubElementTypes.USER_TYPE)) {
|
||||
if (!type.getTypeArguments().isEmpty() || type.hasTypesWithTypeArgsInside()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void deleteQualifier() {
|
||||
KtUserType qualifier = getQualifier();
|
||||
assert qualifier != null;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class KtImportDirectiveElementType extends KtStubElementType<KotlinImport
|
||||
FqName importedFqName = psi.getImportedFqName();
|
||||
StringRef fqName = StringRef.fromString(importedFqName == null ? null : importedFqName.asString());
|
||||
StringRef aliasName = StringRef.fromString(psi.getAliasName());
|
||||
return new KotlinImportDirectiveStubImpl(parentStub, psi.isAbsoluteInRootPackage(), psi.isAllUnder(),
|
||||
return new KotlinImportDirectiveStubImpl(parentStub, false /* TODO: drop */, psi.isAllUnder(),
|
||||
fqName, aliasName, psi.isValidImport());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class KtUserTypeElementType extends KtStubElementType<KotlinUserTypeStub,
|
||||
|
||||
@Override
|
||||
public KotlinUserTypeStub createStub(@NotNull KtUserType psi, StubElement parentStub) {
|
||||
return new KotlinUserTypeStubImpl(parentStub, psi.isAbsoluteInRootPackage());
|
||||
return new KotlinUserTypeStubImpl(parentStub, false /* TODO: drop */);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,7 +70,7 @@ class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageValidator
|
||||
isDebuggerContext: Boolean
|
||||
): TypeQualifierResolutionResult {
|
||||
val ownerDescriptor = if (!isDebuggerContext) scope.ownerDescriptor else null
|
||||
if (userType.qualifier == null && !userType.startWithPackage) {
|
||||
if (userType.qualifier == null) {
|
||||
val descriptor = userType.referenceExpression?.let {
|
||||
val classifier = scope.findClassifier(it.getReferencedNameAsName(), KotlinLookupLocation(it))
|
||||
storeResult(trace, it, classifier, ownerDescriptor, position = QualifierPosition.TYPE, isQualifier = false)
|
||||
@@ -80,32 +80,29 @@ class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageValidator
|
||||
return TypeQualifierResolutionResult(userType.asQualifierPartList().first, descriptor)
|
||||
}
|
||||
|
||||
val module = scope.ownerDescriptor.module
|
||||
val (qualifierPartList, hasError) = userType.asQualifierPartList()
|
||||
if (hasError) {
|
||||
val descriptor = resolveToPackageOrClass(
|
||||
qualifierPartList, module, trace, ownerDescriptor, scope, position = QualifierPosition.TYPE
|
||||
qualifierPartList, scope.ownerDescriptor.module, trace, ownerDescriptor, scope, position = QualifierPosition.TYPE
|
||||
) as? ClassifierDescriptor
|
||||
return TypeQualifierResolutionResult(qualifierPartList, descriptor)
|
||||
}
|
||||
|
||||
return resolveQualifierPartListForType(
|
||||
qualifierPartList, ownerDescriptor, module, scope.check { !userType.startWithPackage }, trace, isQualifier = false
|
||||
)
|
||||
return resolveQualifierPartListForType(qualifierPartList, ownerDescriptor, scope, trace, isQualifier = false)
|
||||
}
|
||||
|
||||
private fun resolveQualifierPartListForType(
|
||||
qualifierPartList: List<QualifierPart>,
|
||||
ownerDescriptor: DeclarationDescriptor?,
|
||||
module: ModuleDescriptor,
|
||||
scope: LexicalScope?,
|
||||
scope: LexicalScope,
|
||||
trace: BindingTrace,
|
||||
isQualifier: Boolean
|
||||
): TypeQualifierResolutionResult {
|
||||
assert(qualifierPartList.isNotEmpty()) { "Qualifier list should not be empty" }
|
||||
|
||||
val qualifier = resolveToPackageOrClass(
|
||||
qualifierPartList.subList(0, qualifierPartList.size - 1), module, trace, ownerDescriptor, scope,
|
||||
qualifierPartList.subList(0, qualifierPartList.size - 1),
|
||||
scope.ownerDescriptor.module, trace, ownerDescriptor, scope,
|
||||
position = QualifierPosition.TYPE
|
||||
) ?: return TypeQualifierResolutionResult(qualifierPartList, null)
|
||||
|
||||
@@ -140,21 +137,9 @@ class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageValidator
|
||||
return TypeQualifierResolutionResult(qualifierPartList, descriptor)
|
||||
}
|
||||
|
||||
return resolveQualifierPartListForType(
|
||||
qualifierPartList, ownerDescriptor, scope.ownerDescriptor.module, scope, trace, isQualifier = true
|
||||
)
|
||||
return resolveQualifierPartListForType(qualifierPartList, ownerDescriptor, scope, trace, isQualifier = true)
|
||||
}
|
||||
|
||||
private val KtUserType.startWithPackage: Boolean
|
||||
get() {
|
||||
var firstPart = this
|
||||
while (firstPart.qualifier != null) {
|
||||
firstPart = firstPart.qualifier!!
|
||||
}
|
||||
return firstPart.isAbsoluteInRootPackage
|
||||
}
|
||||
|
||||
|
||||
private fun KtUserType.asQualifierPartList(): Pair<List<QualifierPart>, Boolean> {
|
||||
var hasError = false
|
||||
val result = SmartList<QualifierPart>()
|
||||
|
||||
+1
-4
@@ -28,9 +28,6 @@ fun Any?.vars(<!UNUSED_PARAMETER!>a<!>: Any?) : Int {
|
||||
if (example.ns.y is Int) {
|
||||
<!UNUSED_VALUE!>b =<!> <!DEBUG_INFO_SMARTCAST!>example.ns.y<!>
|
||||
}
|
||||
// if (package.bottles.ns.y is Int) {
|
||||
// b = ns.y
|
||||
// }
|
||||
if (Obj.y is Int) {
|
||||
<!UNUSED_VALUE!>b =<!> <!DEBUG_INFO_SMARTCAST!>Obj.y<!>
|
||||
}
|
||||
@@ -86,4 +83,4 @@ open class C {
|
||||
<!UNUSED_VALUE!>t =<!> <!DEBUG_INFO_SMARTCAST!>this@C<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-1
@@ -359,7 +359,8 @@ JetFile: When.kt
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
USER_TYPE
|
||||
PsiElement(package)('package')
|
||||
PsiErrorElement:Expecting an element
|
||||
PsiElement(package)('package')
|
||||
PsiElement(DOT)('.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
|
||||
@@ -74,7 +74,8 @@ JetFile: functionTypes.kt
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
PsiElement(package)('package')
|
||||
PsiErrorElement:Expecting an element
|
||||
PsiElement(package)('package')
|
||||
PsiElement(DOT)('.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
|
||||
@@ -22,7 +22,8 @@ JetFile: IncompleteTypeRefWithPackageKeyword.kt
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
PsiElement(package)('package')
|
||||
PsiErrorElement:Expecting an element
|
||||
PsiElement(package)('package')
|
||||
PsiErrorElement:Expecting '.'
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
|
||||
@@ -122,7 +122,6 @@ atomicExpression
|
||||
: loop
|
||||
: SimpleName
|
||||
: FieldName
|
||||
: "package" // for the root package
|
||||
;
|
||||
|
||||
labelReference
|
||||
|
||||
@@ -36,7 +36,7 @@ selfType
|
||||
*/
|
||||
|
||||
userType
|
||||
: ("package" ".")? simpleUserType{"."}
|
||||
: simpleUserType{"."}
|
||||
;
|
||||
|
||||
simpleUserType
|
||||
|
||||
@@ -2,6 +2,4 @@ fun foo() {
|
||||
val test : <caret>
|
||||
}
|
||||
|
||||
/*TODO: Is 'package' type qualifier syntax correct?*/
|
||||
// EXIST: package
|
||||
// NOTHING_ELSE
|
||||
|
||||
Reference in New Issue
Block a user