diff --git a/compiler/frontend/src/org/jetbrains/kotlin/KtNodeTypes.java b/compiler/frontend/src/org/jetbrains/kotlin/KtNodeTypes.java index 8a62711034a..f33eadff4a4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/KtNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/KtNodeTypes.java @@ -31,8 +31,8 @@ public interface KtNodeTypes { IElementType DESTRUCTURING_DECLARATION = new KtNodeType("DESTRUCTURING_DECLARATION", KtDestructuringDeclaration.class); IElementType DESTRUCTURING_DECLARATION_ENTRY = new KtNodeType("DESTRUCTURING_DECLARATION_ENTRY", KtDestructuringDeclarationEntry.class); - //KtNodeType TYPEDEF = new KtNodeType("TYPEDEF", KtTypedef.class); IElementType OBJECT_DECLARATION = KtStubElementTypes.OBJECT_DECLARATION; + IElementType TYPEALIAS = KtStubElementTypes.TYPEALIAS; IElementType ENUM_ENTRY = KtStubElementTypes.ENUM_ENTRY; IElementType CLASS_INITIALIZER = KtStubElementTypes.CLASS_INITIALIZER; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java index fffc0e738f5..e161814eeaa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java @@ -1256,11 +1256,9 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing { else if (keywordToken == VAL_KEYWORD || keywordToken == VAR_KEYWORD) { declType = myKotlinParsing.parseProperty(true); } - /* else if (keywordToken == TYPE_ALIAS_KEYWORD) { declType = myKotlinParsing.parseTypeAlias(); } - */ else if (keywordToken == OBJECT_KEYWORD) { // Object expression may appear at the statement position: should parse it // as expression instead of object declaration diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java index f669ceb0bb5..37e735e71f8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java @@ -23,6 +23,7 @@ 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; @@ -422,11 +423,9 @@ public class KotlinParsing extends AbstractKotlinParsing { else if (keywordToken == VAL_KEYWORD || keywordToken == VAR_KEYWORD) { declType = parseProperty(); } - /* else if (keywordToken == TYPE_ALIAS_KEYWORD) { declType = parseTypeAlias(); } - */ else if (keywordToken == OBJECT_KEYWORD) { parseObject(NameParsingMode.REQUIRED, true); declType = OBJECT_DECLARATION; @@ -1085,11 +1084,9 @@ public class KotlinParsing extends AbstractKotlinParsing { else if (keywordToken == VAL_KEYWORD || keywordToken == VAR_KEYWORD) { declType = parseProperty(); } - /* else if (keywordToken == TYPE_ALIAS_KEYWORD) { declType = parseTypeAlias(); } - */ else if (keywordToken == OBJECT_KEYWORD) { parseObject(isDefault ? NameParsingMode.ALLOWED : NameParsingMode.REQUIRED, true); declType = OBJECT_DECLARATION; @@ -1189,17 +1186,17 @@ public class KotlinParsing extends AbstractKotlinParsing { /* * typeAlias - * : modifiers "typealias" SimpleName (typeParameters typeConstraints)? "=" type + * : modifiers "typealias" SimpleName typeParameters? "=" type * ; */ - /* - KtNodeType parseTypeAlias() { + IElementType parseTypeAlias() { assert _at(TYPE_ALIAS_KEYWORD); advance(); // TYPE_ALIAS_KEYWORD expect(IDENTIFIER, "Type name expected", TokenSet.orSet(TokenSet.create(LT, EQ, SEMICOLON), TOP_LEVEL_DECLARATION_FIRST)); + // TODO drop type constraints parsing if (parseTypeParameterList(TYPE_PARAMETER_GT_RECOVERY_SET)) { parseTypeConstraints(); } @@ -1210,9 +1207,8 @@ public class KotlinParsing extends AbstractKotlinParsing { consumeIf(SEMICOLON); - return TYPEDEF; + return TYPEALIAS; } - */ /* * variableDeclarationEntry diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtTypeAlias.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtTypeAlias.kt new file mode 100644 index 00000000000..6013e813dc5 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtTypeAlias.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.psi + +import com.intellij.lang.ASTNode +import org.jetbrains.kotlin.KtNodeTypes +import org.jetbrains.kotlin.psi.stubs.KotlinTypeAliasStub +import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes + +class KtTypeAlias : KtTypeParameterListOwnerStub, KtNamedDeclaration { + constructor(node: ASTNode) : super(node) + constructor(stub: KotlinTypeAliasStub) : super(stub, KtStubElementTypes.TYPEALIAS) + + override fun accept(visitor: KtVisitor, data: D): R = + visitor.visitTypeAlias(this, data) + + fun isTopLevel(): Boolean = + stub?.isTopLevel() ?: parent is KtFile + + @IfNotParsed + fun getTypeReference(): KtTypeReference? = + findChildByType(KtNodeTypes.TYPE_REFERENCE) +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtVisitor.java index 8b0647dae80..9c3217da9b5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtVisitor.java @@ -65,6 +65,10 @@ public class KtVisitor extends PsiElementVisitor { return visitNamedDeclaration(multiDeclarationEntry, data); } + public R visitTypeAlias(@NotNull KtTypeAlias typeAlias, D data) { + return visitNamedDeclaration(typeAlias, data); + } + public R visitKtFile(@NotNull KtFile file, D data) { visitFile(file); return null; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtVisitorVoid.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtVisitorVoid.java index cfea6bc6b33..3883d8c12bf 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtVisitorVoid.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtVisitorVoid.java @@ -53,6 +53,10 @@ public class KtVisitorVoid extends KtVisitor { super.visitProperty(property, null); } + public void visitTypeAlias(@NotNull KtTypeAlias typeAlias) { + super.visitTypeAlias(typeAlias, null); + } + public void visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration destructuringDeclaration) { super.visitDestructuringDeclaration(destructuringDeclaration, null); } @@ -478,6 +482,12 @@ public class KtVisitorVoid extends KtVisitor { return null; } + @Override + public final Void visitTypeAlias(@NotNull KtTypeAlias typeAlias, Void data) { + visitTypeAlias(typeAlias); + return null; + } + @Override public final Void visitDestructuringDeclaration(@NotNull KtDestructuringDeclaration multiDeclaration, Void data) { visitDestructuringDeclaration(multiDeclaration); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/StubInterfaces.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/StubInterfaces.kt index 17d4a45f58a..a7a152e91e1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/StubInterfaces.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/StubInterfaces.kt @@ -36,6 +36,10 @@ interface KotlinStubWithFqName : NamedStub { fun getFqName(): FqName? } +interface KotlinTypeAliasStub : KotlinStubWithFqName { + fun isTopLevel(): Boolean +} + interface KotlinClassOrObjectStub : KotlinStubWithFqName { fun isLocal(): Boolean fun getSuperNames(): List diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementTypes.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementTypes.java index fd9596204f0..07519a414ba 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementTypes.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementTypes.java @@ -28,6 +28,7 @@ public interface KtStubElementTypes { KtFunctionElementType FUNCTION = new KtFunctionElementType("FUN"); KtPropertyElementType PROPERTY = new KtPropertyElementType("PROPERTY"); KtPropertyAccessorElementType PROPERTY_ACCESSOR = new KtPropertyAccessorElementType("PROPERTY_ACCESSOR"); + KtTypeAliasElementType TYPEALIAS = new KtTypeAliasElementType("TYPEALIAS"); KtClassElementType ENUM_ENTRY = new KtClassElementType("ENUM_ENTRY"); KtObjectElementType OBJECT_DECLARATION = new KtObjectElementType("OBJECT_DECLARATION"); @@ -119,7 +120,7 @@ public interface KtStubElementTypes { KtScriptElementType SCRIPT = new KtScriptElementType("SCRIPT"); TokenSet DECLARATION_TYPES = - TokenSet.create(CLASS, OBJECT_DECLARATION, FUNCTION, PROPERTY, CLASS_INITIALIZER, SECONDARY_CONSTRUCTOR, ENUM_ENTRY); + TokenSet.create(CLASS, OBJECT_DECLARATION, FUNCTION, PROPERTY, TYPEALIAS, CLASS_INITIALIZER, SECONDARY_CONSTRUCTOR, ENUM_ENTRY); TokenSet SUPER_TYPE_LIST_ENTRIES = TokenSet.create(DELEGATED_SUPER_TYPE_ENTRY, SUPER_TYPE_CALL_ENTRY, SUPER_TYPE_ENTRY); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtTypeAliasElementType.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtTypeAliasElementType.kt new file mode 100644 index 00000000000..53a167a0ae4 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtTypeAliasElementType.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.psi.stubs.elements + +import com.intellij.psi.stubs.StubElement +import com.intellij.psi.stubs.StubInputStream +import com.intellij.psi.stubs.StubOutputStream +import com.intellij.util.io.StringRef +import org.jetbrains.kotlin.psi.KtTypeAlias +import org.jetbrains.kotlin.psi.stubs.KotlinTypeAliasStub +import org.jetbrains.kotlin.psi.stubs.impl.KotlinTypeAliasStubImpl +import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils + +class KtTypeAliasElementType(debugName: String) : + KtStubElementType(debugName, KtTypeAlias::class.java, KotlinTypeAliasStub::class.java) { + + override fun createStub(psi: KtTypeAlias, parentStub: StubElement<*>?): KotlinTypeAliasStub { + val name = StringRef.fromString(psi.name) + val fqName = StringRef.fromString(ResolveSessionUtils.safeFqNameForLazyResolve(psi)?.asString()) + val isTopLevel = psi.isTopLevel() + return KotlinTypeAliasStubImpl(KtStubElementTypes.TYPEALIAS, parentStub, name, fqName, isTopLevel) + } + + override fun serialize(stub: KotlinTypeAliasStub, dataStream: StubOutputStream) { + dataStream.writeName(stub.getName()) + dataStream.writeName(stub.getFqName()?.asString()) + dataStream.writeBoolean(stub.isTopLevel()) + } + + override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>?): KotlinTypeAliasStub { + val name = dataStream.readName() + val fqName = dataStream.readName() + val isTopLevel = dataStream.readBoolean() + return KotlinTypeAliasStubImpl(KtStubElementTypes.TYPEALIAS, parentStub, name, fqName, isTopLevel) + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinTypeAliasStubImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinTypeAliasStubImpl.kt new file mode 100644 index 00000000000..c0a245a7c0d --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinTypeAliasStubImpl.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.psi.stubs.impl + +import com.intellij.psi.PsiElement +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.KtTypeAlias +import org.jetbrains.kotlin.psi.stubs.KotlinTypeAliasStub +import org.jetbrains.kotlin.psi.stubs.elements.KtTypeAliasElementType + +class KotlinTypeAliasStubImpl( + type: KtTypeAliasElementType, + parent: StubElement?, + private val name: StringRef?, + private val qualifiedName: StringRef?, + private val isTopLevel: Boolean +) : KotlinStubBaseImpl(parent, type), KotlinTypeAliasStub { + + override fun getName(): String? = + StringRef.toString(name) + + override fun getFqName(): FqName? = + StringRef.toString(qualifiedName)?.let { FqName(it) } + + override fun isTopLevel(): Boolean = isTopLevel +} diff --git a/compiler/testData/psi/EOLsOnRollback.kt b/compiler/testData/psi/EOLsOnRollback.kt index e698c02e3db..d92e3e2f773 100644 --- a/compiler/testData/psi/EOLsOnRollback.kt +++ b/compiler/testData/psi/EOLsOnRollback.kt @@ -3,6 +3,7 @@ fun foo() { fun foo() class foo + typealias x = t var r @a var foo = 4 diff --git a/compiler/testData/psi/EOLsOnRollback.txt b/compiler/testData/psi/EOLsOnRollback.txt index 1bb1f574241..0bce5021b5d 100644 --- a/compiler/testData/psi/EOLsOnRollback.txt +++ b/compiler/testData/psi/EOLsOnRollback.txt @@ -32,6 +32,18 @@ JetFile: EOLsOnRollback.kt PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiWhiteSpace('\n\n ') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('t') + PsiWhiteSpace('\n ') PROPERTY PsiElement(var)('var') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/FunctionTypes.kt b/compiler/testData/psi/FunctionTypes.kt index fafeed7a642..faa96b53279 100644 --- a/compiler/testData/psi/FunctionTypes.kt +++ b/compiler/testData/psi/FunctionTypes.kt @@ -1,24 +1,22 @@ -val v: (@[a] a) -> b -val v: (a) -> b -val v: () -> @[x] b -val v: () -> Unit +typealias f = (@[a] a) -> b +typealias f = (a) -> b +typealias f = () -> @[x] b +typealias f = () -> Unit -val v: (a : @[a] a) -> b -val v: (a : a) -> b -val v: () -> b -val v: () -> Unit +typealias f = (a : @[a] a) -> b +typealias f = (a : a) -> b +typealias f = () -> b +typealias f = () -> Unit -val v: (a : @[a] a, foo, x : bar) -> b -val v: (foo, a : a) -> b -val v: (foo, a : (a) -> b) -> b -val v: (foo, a : (a) -> b) -> () -> Unit +typealias f = (a : @[a] a, foo, x : bar) -> b +typealias f = (foo, a : a) -> b +typealias f = (foo, a : (a) -> b) -> b +typealias f = (foo, a : (a) -> b) -> () -> Unit -//type f = (ref foo, ref a : (ref a) -> b) -> () -> Unit +typealias f = T.() -> Unit +typealias f = T.T.() -> Unit +typealias f = T.T.() -> Unit -val v: T.() -> Unit -val v: T.T.() -> Unit -val v: T.T.() -> Unit - -val v: @[a] T.() -> Unit -val v: @[a] T.T.() -> Unit -val v: @[a] T.T.() -> Unit +typealias f = @[a] T.() -> Unit +typealias f = @[a] T.T.() -> Unit +typealias f = @[a] T.T.() -> Unit diff --git a/compiler/testData/psi/FunctionTypes.txt b/compiler/testData/psi/FunctionTypes.txt index f69ec5e1980..108bd01bd2d 100644 --- a/compiler/testData/psi/FunctionTypes.txt +++ b/compiler/testData/psi/FunctionTypes.txt @@ -3,12 +3,13 @@ JetFile: FunctionTypes.kt IMPORT_LIST - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -39,12 +40,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -63,12 +65,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -93,12 +96,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -112,12 +116,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Unit') PsiWhiteSpace('\n\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -151,12 +156,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -179,12 +185,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -198,12 +205,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -217,12 +225,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Unit') PsiWhiteSpace('\n\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -274,12 +283,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -309,12 +319,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -357,12 +368,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST @@ -413,14 +425,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Unit') PsiWhiteSpace('\n\n') - PsiComment(EOL_COMMENT)('//type f = (ref foo, ref a : (ref a) -> b) -> () -> Unit') - PsiWhiteSpace('\n\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE FUNCTION_TYPE_RECEIVER @@ -440,12 +451,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Unit') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE FUNCTION_TYPE_RECEIVER @@ -469,12 +481,13 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Unit') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE FUNCTION_TYPE_RECEIVER @@ -521,11 +534,12 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Unit') PsiWhiteSpace('\n\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE @@ -557,11 +571,12 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Unit') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE @@ -597,11 +612,12 @@ JetFile: FunctionTypes.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Unit') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE diff --git a/compiler/testData/psi/FunctionTypes_ERR.kt b/compiler/testData/psi/FunctionTypes_ERR.kt index 995dcb19f56..14ef9e8387b 100644 --- a/compiler/testData/psi/FunctionTypes_ERR.kt +++ b/compiler/testData/psi/FunctionTypes_ERR.kt @@ -1 +1 @@ -val v: (a, ) -> b +typealias f = (a, ) -> b diff --git a/compiler/testData/psi/FunctionTypes_ERR.txt b/compiler/testData/psi/FunctionTypes_ERR.txt index 7223d25047c..1d3bbdd61f1 100644 --- a/compiler/testData/psi/FunctionTypes_ERR.txt +++ b/compiler/testData/psi/FunctionTypes_ERR.txt @@ -3,12 +3,13 @@ JetFile: FunctionTypes_ERR.kt IMPORT_LIST - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE VALUE_PARAMETER_LIST diff --git a/compiler/testData/psi/LocalDeclarations.kt b/compiler/testData/psi/LocalDeclarations.kt index b799840c6fb..105d9178389 100644 --- a/compiler/testData/psi/LocalDeclarations.kt +++ b/compiler/testData/psi/LocalDeclarations.kt @@ -6,4 +6,5 @@ fun foo() { out val foo = 5 @a var foo = 4 + typealias f = T.() -> Unit } diff --git a/compiler/testData/psi/LocalDeclarations.txt b/compiler/testData/psi/LocalDeclarations.txt index f46dc25a372..3382467bc34 100644 --- a/compiler/testData/psi/LocalDeclarations.txt +++ b/compiler/testData/psi/LocalDeclarations.txt @@ -91,5 +91,31 @@ JetFile: LocalDeclarations.kt PsiWhiteSpace(' ') INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('4') + PsiWhiteSpace('\n ') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + FUNCTION_TYPE_RECEIVER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Unit') PsiWhiteSpace('\n') PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/SimpleClassMembers.kt b/compiler/testData/psi/SimpleClassMembers.kt index 4703a23d667..9b84ce9e4d0 100644 --- a/compiler/testData/psi/SimpleClassMembers.kt +++ b/compiler/testData/psi/SimpleClassMembers.kt @@ -12,6 +12,8 @@ class foo { val x var f + + typealias foo = bar } class Bar { @@ -42,6 +44,8 @@ class foo { val x var f + + typealias foo = bar } fun foo() @@ -50,6 +54,8 @@ class foo { var f + typealias foo = bar + companion object { } diff --git a/compiler/testData/psi/SimpleClassMembers.txt b/compiler/testData/psi/SimpleClassMembers.txt index d7800bfd9bf..fac6684590d 100644 --- a/compiler/testData/psi/SimpleClassMembers.txt +++ b/compiler/testData/psi/SimpleClassMembers.txt @@ -55,6 +55,18 @@ JetFile: SimpleClassMembers.kt PsiElement(var)('var') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('f') + PsiWhiteSpace('\n\n ') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiWhiteSpace('\n ') PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') @@ -222,6 +234,18 @@ JetFile: SimpleClassMembers.kt PsiElement(var)('var') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('f') + PsiWhiteSpace('\n\n ') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiWhiteSpace('\n ') PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') @@ -243,6 +267,18 @@ JetFile: SimpleClassMembers.kt PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('f') PsiWhiteSpace('\n\n ') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n\n ') OBJECT_DECLARATION MODIFIER_LIST PsiElement(companion)('companion') diff --git a/compiler/testData/psi/SimpleClassMembers_ERR.kt b/compiler/testData/psi/SimpleClassMembers_ERR.kt index 4cc20f1f359..9119c75c8cb 100644 --- a/compiler/testData/psi/SimpleClassMembers_ERR.kt +++ b/compiler/testData/psi/SimpleClassMembers_ERR.kt @@ -11,4 +11,6 @@ class foo { val x var f + + typealias foo = ; } \ No newline at end of file diff --git a/compiler/testData/psi/SimpleClassMembers_ERR.txt b/compiler/testData/psi/SimpleClassMembers_ERR.txt index 5822a8a4093..ec91a48a2fa 100644 --- a/compiler/testData/psi/SimpleClassMembers_ERR.txt +++ b/compiler/testData/psi/SimpleClassMembers_ERR.txt @@ -53,5 +53,17 @@ JetFile: SimpleClassMembers_ERR.kt PsiElement(var)('var') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('f') + PsiWhiteSpace('\n\n ') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(SEMICOLON)(';') PsiWhiteSpace('\n') PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/TypeAlias.kt b/compiler/testData/psi/TypeAlias.kt new file mode 100644 index 00000000000..c622e0b0bb9 --- /dev/null +++ b/compiler/testData/psi/TypeAlias.kt @@ -0,0 +1,14 @@ +package foo.bar.goo + +typealias foo = bar +typealias foo = bar +typealias foo = bar +typealias foo = bar +typealias foo = bar + +typealias foo = bar ; +typealias foo = bar ; + +typealias foo = bar ; +typealias foo = bar ; +typealias foo = bar ; diff --git a/compiler/testData/psi/TypeAlias.txt b/compiler/testData/psi/TypeAlias.txt new file mode 100644 index 00000000000..0ce8a088b5d --- /dev/null +++ b/compiler/testData/psi/TypeAlias.txt @@ -0,0 +1,230 @@ +JetFile: TypeAlias.kt + PACKAGE_DIRECTIVE + PsiElement(package)('package') + PsiWhiteSpace(' ') + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('goo') + IMPORT_LIST + + PsiWhiteSpace('\n\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') \ No newline at end of file diff --git a/compiler/testData/psi/TypeAlias_ERR.kt b/compiler/testData/psi/TypeAlias_ERR.kt new file mode 100644 index 00000000000..1681d75bf3e --- /dev/null +++ b/compiler/testData/psi/TypeAlias_ERR.kt @@ -0,0 +1,17 @@ +typealias +typealias foo +typealias foo = +typealias ; +typealias foo ; +typealias foo = ; +typealias = foo +typealias = +typealias = foo ; +typealias = ; + +typealias foo<> = bar +typealias foo = bar +typealias foo = bar + +class +typealias foo = bar \ No newline at end of file diff --git a/compiler/testData/psi/TypeAlias_ERR.txt b/compiler/testData/psi/TypeAlias_ERR.txt new file mode 100644 index 00000000000..3b1cff3e13a --- /dev/null +++ b/compiler/testData/psi/TypeAlias_ERR.txt @@ -0,0 +1,196 @@ +JetFile: TypeAlias_ERR.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + TYPEALIAS + PsiElement(typealias)('typealias') + PsiErrorElement:Type name expected + + PsiWhiteSpace('\n') + TYPE_REFERENCE + PsiErrorElement:Type expected + + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiErrorElement:Expecting '=' + + PsiWhiteSpace('\n') + TYPE_REFERENCE + PsiErrorElement:Type expected + + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace('\n') + TYPE_REFERENCE + PsiErrorElement:Type expected + + TYPEALIAS + PsiElement(typealias)('typealias') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiErrorElement:Expecting '=' + + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace('\n') + TYPE_REFERENCE + PsiErrorElement:Type expected + + TYPEALIAS + PsiElement(typealias)('typealias') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + PsiErrorElement:Type parameter declaration expected + + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiErrorElement:Type parameter declaration expected + + PsiWhiteSpace(' ') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('A') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('B') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiErrorElement:Name expected + + PsiWhiteSpace('\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') \ No newline at end of file diff --git a/compiler/testData/psi/functionReceivers/FunctionTypesWithFunctionReceivers.kt b/compiler/testData/psi/functionReceivers/FunctionTypesWithFunctionReceivers.kt index 942b30fc900..ebcdce20335 100644 --- a/compiler/testData/psi/functionReceivers/FunctionTypesWithFunctionReceivers.kt +++ b/compiler/testData/psi/functionReceivers/FunctionTypesWithFunctionReceivers.kt @@ -1,10 +1,10 @@ -val v: (((S).() -> S).() -> S) -val v: ((T.() -> S).() -> S) -val v: ((T.T.() -> S).() -> S) -val v: ((T.T.() -> S).() -> S) -val v: (((S).() -> S).() -> S) +typealias f = (((S).() -> S).() -> S) +typealias f = ((T.() -> S).() -> S) +typealias f = ((T.T.() -> S).() -> S) +typealias f = ((T.T.() -> S).() -> S) +typealias f = (((S).() -> S).() -> S) -val v: @[a] (@[a] ((S).() -> S).() -> S) -val v: @[a] (@[a] (T.() -> S).() -> S) -val v: @[a] (@[a] (T.() -> S).() -> S) -val v: @[a] (@[a] ((S).() -> S).() -> S) \ No newline at end of file +typealias f = @[a] (@[a] ((S).() -> S).() -> S) +typealias f = @[a] (@[a] (T.() -> S).() -> S) +typealias f = @[a] (@[a] (T.() -> S).() -> S) +typealias f = @[a] (@[a] ((S).() -> S).() -> S) \ No newline at end of file diff --git a/compiler/testData/psi/functionReceivers/FunctionTypesWithFunctionReceivers.txt b/compiler/testData/psi/functionReceivers/FunctionTypesWithFunctionReceivers.txt index b59e8df7f4e..316bd93fd1d 100644 --- a/compiler/testData/psi/functionReceivers/FunctionTypesWithFunctionReceivers.txt +++ b/compiler/testData/psi/functionReceivers/FunctionTypesWithFunctionReceivers.txt @@ -3,11 +3,12 @@ JetFile: FunctionTypesWithFunctionReceivers.kt IMPORT_LIST - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE PsiElement(LPAR)('(') @@ -48,11 +49,12 @@ JetFile: FunctionTypesWithFunctionReceivers.kt PsiElement(IDENTIFIER)('S') PsiElement(RPAR)(')') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE PsiElement(LPAR)('(') @@ -91,11 +93,12 @@ JetFile: FunctionTypesWithFunctionReceivers.kt PsiElement(IDENTIFIER)('S') PsiElement(RPAR)(')') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE PsiElement(LPAR)('(') @@ -138,11 +141,12 @@ JetFile: FunctionTypesWithFunctionReceivers.kt PsiElement(IDENTIFIER)('S') PsiElement(RPAR)(')') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE PsiElement(LPAR)('(') @@ -208,11 +212,12 @@ JetFile: FunctionTypesWithFunctionReceivers.kt PsiElement(IDENTIFIER)('S') PsiElement(RPAR)(')') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE PsiElement(LPAR)('(') @@ -253,12 +258,13 @@ JetFile: FunctionTypesWithFunctionReceivers.kt PsiElement(IDENTIFIER)('S') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') TYPE_REFERENCE ANNOTATION PsiElement(AT)('@') @@ -320,11 +326,12 @@ JetFile: FunctionTypesWithFunctionReceivers.kt PsiElement(IDENTIFIER)('S') PsiElement(RPAR)(')') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE ANNOTATION @@ -385,11 +392,12 @@ JetFile: FunctionTypesWithFunctionReceivers.kt PsiElement(IDENTIFIER)('S') PsiElement(RPAR)(')') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE ANNOTATION @@ -465,11 +473,12 @@ JetFile: FunctionTypesWithFunctionReceivers.kt PsiElement(IDENTIFIER)('S') PsiElement(RPAR)(')') PsiWhiteSpace('\n') - PROPERTY - PsiElement(val)('val') + TYPEALIAS + PsiElement(typealias)('typealias') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('v') - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE ANNOTATION diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java index c62874bfdf9..a117011bafb 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java @@ -733,6 +733,18 @@ public class ParsingTestGenerated extends AbstractParsingTest { doParsingTest(fileName); } + @TestMetadata("TypeAlias.kt") + public void testTypeAlias() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/psi/TypeAlias.kt"); + doParsingTest(fileName); + } + + @TestMetadata("TypeAlias_ERR.kt") + public void testTypeAlias_ERR() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/psi/TypeAlias_ERR.kt"); + doParsingTest(fileName); + } + @TestMetadata("TypeConstraints.kt") public void testTypeConstraints() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/psi/TypeConstraints.kt"); diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt index 022b1e80f25..bce362b1922 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt @@ -85,6 +85,9 @@ class StubBasedPackageMemberDeclarationProvider( return PackageIndexUtil.findFilesWithExactPackage(fqName, searchScope, project) } + override fun getTypeAliasDeclarations(name: Name): Collection = + emptyList() // TODO stub index for type aliases + private fun childName(name: Name): String { return fqName.child(ResolveSessionUtils.safeNameForLazyResolve(name)).asString() }