diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java index 52299e77a26..2036dbf152d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java @@ -107,7 +107,7 @@ public class JetParameter extends JetNamedDeclarationStub i public boolean hasValOrVarNode() { KotlinParameterStub stub = getStub(); if (stub != null) { - return stub.hasValOrValNode(); + return stub.hasValOrVarNode(); } return getValOrVarNode() != null; } @@ -115,7 +115,7 @@ public class JetParameter extends JetNamedDeclarationStub i @Nullable public ASTNode getValOrVarNode() { KotlinParameterStub stub = getStub(); - if (stub != null && !stub.hasValOrValNode()) { + if (stub != null && !stub.hasValOrVarNode()) { return null; } ASTNode val = getNode().findChildByType(JetTokens.VAL_KEYWORD); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinAnnotationEntryStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinAnnotationEntryStub.java deleted file mode 100644 index c16b8da91a0..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinAnnotationEntryStub.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.JetAnnotationEntry; - -public interface KotlinAnnotationEntryStub extends StubElement { - @NotNull - String getShortName(); - - boolean hasValueArguments(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinClassOrObjectStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinClassOrObjectStub.java deleted file mode 100644 index d6362be8079..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinClassOrObjectStub.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.JetClassOrObject; - -import java.util.List; - -public interface KotlinClassOrObjectStub extends KotlinStubWithFqName { - boolean isLocal(); - - @NotNull - List getSuperNames(); - - boolean isTopLevel(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinClassStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinClassStub.java deleted file mode 100644 index e0bd3a18711..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinClassStub.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import org.jetbrains.jet.lang.psi.JetClass; - -public interface KotlinClassStub extends KotlinClassOrObjectStub { - boolean isTrait(); - - boolean isEnumEntry(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinFileStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinFileStub.java deleted file mode 100644 index c37f5a290f2..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinFileStub.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import com.intellij.psi.stubs.PsiFileStub; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.JetFile; -import org.jetbrains.jet.lang.resolve.name.FqName; - -public interface KotlinFileStub extends PsiFileStub { - @NotNull - FqName getPackageFqName(); - boolean isScript(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinFunctionStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinFunctionStub.java deleted file mode 100644 index 1bbe37b68ee..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinFunctionStub.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import org.jetbrains.jet.lang.psi.JetNamedFunction; - -public interface KotlinFunctionStub extends KotlinStubWithFqName { - boolean isTopLevel(); - - boolean isExtension(); - - boolean hasBlockBody(); - - boolean hasBody(); - - boolean hasTypeParameterListBeforeFunctionName(); - - boolean isProbablyNothingType(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinModifierListStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinModifierListStub.java deleted file mode 100644 index 832b258a8d9..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinModifierListStub.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2014 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.jet.lang.psi.stubs; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.JetModifierList; -import org.jetbrains.jet.lexer.JetModifierKeywordToken; - -public interface KotlinModifierListStub extends StubElement { - boolean hasModifier(@NotNull JetModifierKeywordToken modifierToken); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinNameReferenceExpressionStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinNameReferenceExpressionStub.java deleted file mode 100644 index 568fcd183cf..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinNameReferenceExpressionStub.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2014 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.jet.lang.psi.stubs; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.JetNameReferenceExpression; -import org.jetbrains.jet.lang.resolve.name.Name; - -public interface KotlinNameReferenceExpressionStub extends StubElement { - @NotNull - String getReferencedName(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinObjectStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinObjectStub.java deleted file mode 100644 index b39604c6366..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinObjectStub.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import org.jetbrains.jet.lang.psi.JetObjectDeclaration; - -public interface KotlinObjectStub extends KotlinClassOrObjectStub { - boolean isClassObject(); - boolean isObjectLiteral(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinParameterStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinParameterStub.java deleted file mode 100644 index 8ffc05947bc..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinParameterStub.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import org.jetbrains.jet.lang.psi.JetParameter; - -public interface KotlinParameterStub extends KotlinStubWithFqName { - boolean isMutable(); - boolean hasValOrValNode(); - boolean hasDefaultValue(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinPlaceHolderStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinPlaceHolderStub.java deleted file mode 100644 index a08b9fa7602..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinPlaceHolderStub.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2014 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.jet.lang.psi.stubs; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.jet.lang.psi.JetElement; - -public interface KotlinPlaceHolderStub extends StubElement { -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinPropertyAccessorStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinPropertyAccessorStub.java deleted file mode 100644 index 3a08c9eb86b..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinPropertyAccessorStub.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2014 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.jet.lang.psi.stubs; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.jet.lang.psi.JetPropertyAccessor; - -public interface KotlinPropertyAccessorStub extends StubElement { - boolean isGetter(); - boolean hasBody(); - boolean hasBlockBody(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinPropertyStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinPropertyStub.java deleted file mode 100644 index 8dc4b9c9952..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinPropertyStub.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import org.jetbrains.jet.lang.psi.JetProperty; - -public interface KotlinPropertyStub extends KotlinStubWithFqName { - boolean isVar(); - boolean isTopLevel(); - boolean hasDelegate(); - boolean hasDelegateExpression(); - boolean hasInitializer(); - boolean hasReceiverTypeRef(); - boolean hasReturnTypeRef(); - - boolean isProbablyNothingType(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinStubWithFqName.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinStubWithFqName.java deleted file mode 100644 index 64ba94209ce..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinStubWithFqName.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import com.intellij.psi.PsiNamedElement; -import com.intellij.psi.stubs.NamedStub; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.resolve.name.FqName; - -public interface KotlinStubWithFqName extends NamedStub { - @Nullable - FqName getFqName(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinTypeConstraintStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinTypeConstraintStub.java deleted file mode 100644 index 4ac6f9122c9..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinTypeConstraintStub.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2014 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.jet.lang.psi.stubs; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.jet.lang.psi.JetTypeConstraint; - -public interface KotlinTypeConstraintStub extends StubElement { - boolean isClassObjectConstraint(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinTypeParameterStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinTypeParameterStub.java deleted file mode 100644 index 635f49ebef7..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinTypeParameterStub.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs; - -import org.jetbrains.jet.lang.psi.JetTypeParameter; - -public interface KotlinTypeParameterStub extends KotlinStubWithFqName { - boolean isInVariance(); - boolean isOutVariance(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinTypeProjectionStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinTypeProjectionStub.java deleted file mode 100644 index fde00c72199..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinTypeProjectionStub.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2014 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.jet.lang.psi.stubs; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.jet.lang.psi.JetProjectionKind; -import org.jetbrains.jet.lang.psi.JetTypeProjection; - -public interface KotlinTypeProjectionStub extends StubElement { - JetProjectionKind getProjectionKind(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinUserTypeStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinUserTypeStub.java deleted file mode 100644 index 93ed0a225b5..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinUserTypeStub.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2014 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.jet.lang.psi.stubs; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.JetUserType; -import org.jetbrains.jet.lang.resolve.name.Name; - -public interface KotlinUserTypeStub extends StubElement { - boolean isAbsoluteInRootPackage(); -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/StubInterfaces.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/StubInterfaces.kt new file mode 100644 index 00000000000..0bcc88230eb --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/StubInterfaces.kt @@ -0,0 +1,121 @@ +/* + * Copyright 2010-2014 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.jet.lang.psi.stubs + +import com.intellij.psi.PsiNamedElement +import com.intellij.psi.stubs.NamedStub +import org.jetbrains.jet.lang.resolve.name.FqName +import com.intellij.psi.stubs.StubElement +import com.intellij.psi.stubs.PsiFileStub +import org.jetbrains.jet.lexer.JetModifierKeywordToken +import org.jetbrains.jet.lang.psi.* + +public trait KotlinFileStub : PsiFileStub { + public fun getPackageFqName(): FqName + public fun isScript(): Boolean +} + +public trait KotlinPlaceHolderStub : StubElement + +public trait KotlinStubWithFqName : NamedStub { + public fun getFqName(): FqName? +} + +public trait KotlinClassOrObjectStub : KotlinStubWithFqName { + public fun isLocal(): Boolean + public fun getSuperNames(): List + public fun isTopLevel(): Boolean +} + +public trait KotlinClassStub : KotlinClassOrObjectStub { + public fun isTrait(): Boolean + public fun isEnumEntry(): Boolean +} + +public trait KotlinObjectStub : KotlinClassOrObjectStub { + public fun isClassObject(): Boolean + public fun isObjectLiteral(): Boolean +} + +public trait KotlinAnnotationEntryStub : StubElement { + public fun getShortName(): String + public fun hasValueArguments(): Boolean +} + +public trait KotlinFunctionStub : KotlinStubWithFqName { + public fun isTopLevel(): Boolean + public fun isExtension(): Boolean + public fun hasBlockBody(): Boolean + public fun hasBody(): Boolean + public fun hasTypeParameterListBeforeFunctionName(): Boolean + public fun isProbablyNothingType(): Boolean +} + +public trait KotlinImportDirectiveStub : StubElement { + public fun isAbsoluteInRootPackage(): Boolean + public fun isAllUnder(): Boolean + public fun getAliasName(): String? + public fun isValid(): Boolean +} + +public trait KotlinModifierListStub : StubElement { + public fun hasModifier(modifierToken: JetModifierKeywordToken): Boolean +} + +public trait KotlinNameReferenceExpressionStub : StubElement { + public fun getReferencedName(): String +} + +public trait KotlinParameterStub : KotlinStubWithFqName { + public fun isMutable(): Boolean + public fun hasValOrVarNode(): Boolean + public fun hasDefaultValue(): Boolean +} + +public trait KotlinPropertyAccessorStub : StubElement { + public fun isGetter(): Boolean + public fun hasBody(): Boolean + public fun hasBlockBody(): Boolean +} + +public trait KotlinPropertyStub : KotlinStubWithFqName { + public fun isVar(): Boolean + public fun isTopLevel(): Boolean + public fun hasDelegate(): Boolean + public fun hasDelegateExpression(): Boolean + public fun hasInitializer(): Boolean + public fun hasReceiverTypeRef(): Boolean + public fun hasReturnTypeRef(): Boolean + public fun isProbablyNothingType(): Boolean +} + +public trait KotlinTypeConstraintStub : StubElement { + public fun isClassObjectConstraint(): Boolean +} + +public trait KotlinTypeParameterStub : KotlinStubWithFqName { + public fun isInVariance(): Boolean + public fun isOutVariance(): Boolean +} + +public trait KotlinTypeProjectionStub : StubElement { + public fun getProjectionKind(): JetProjectionKind +} + +public trait KotlinUserTypeStub : StubElement { + public fun isAbsoluteInRootPackage(): Boolean +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetModifierListElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetModifierListElementType.java index 27744f75657..94063eabe88 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetModifierListElementType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetModifierListElementType.java @@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.psi.stubs.impl.KotlinModifierListStubImpl; import java.io.IOException; -import static org.jetbrains.jet.lang.psi.stubs.impl.KotlinModifierListStubImpl.computeMaskFromPsi; +import static org.jetbrains.jet.lang.psi.stubs.impl.ModifierMaskUtils.computeMaskFromModifierList; public class JetModifierListElementType extends JetStubElementType { public JetModifierListElementType(@NotNull @NonNls String debugName, @NotNull Class psiClass) { @@ -36,7 +36,7 @@ public class JetModifierListElementType extends JetSt @Override public KotlinModifierListStub createStub(@NotNull T psi, StubElement parentStub) { - return new KotlinModifierListStubImpl(parentStub, computeMaskFromPsi(psi), this); + return new KotlinModifierListStubImpl(parentStub, computeMaskFromModifierList(psi), this); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetParameterElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetParameterElementType.java index 2a974213f34..39614c6c8a9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetParameterElementType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetParameterElementType.java @@ -46,7 +46,7 @@ public class JetParameterElementType extends JetStubElementType implements KotlinAnnotationEntryStub { - private final StringRef shortName; - private final boolean hasValueArguments; - - public KotlinAnnotationEntryStubImpl(StubElement parent, @NotNull StringRef shortName, boolean hasValueArguments) { - super(parent, JetStubElementTypes.ANNOTATION_ENTRY); - this.shortName = shortName; - this.hasValueArguments = hasValueArguments; - } - - @NotNull - @Override - public String getShortName() { - return shortName.getString(); - } - - @Override - public boolean hasValueArguments() { - return hasValueArguments; - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinAnnotationEntryStubImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinAnnotationEntryStubImpl.kt new file mode 100644 index 00000000000..ec89ddc8e06 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinAnnotationEntryStubImpl.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2014 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.jet.lang.psi.stubs.impl + +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import org.jetbrains.jet.lang.psi.JetAnnotationEntry +import org.jetbrains.jet.lang.psi.stubs.KotlinAnnotationEntryStub +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes +import com.intellij.psi.PsiElement + +public class KotlinAnnotationEntryStubImpl( + parent: StubElement?, + private val shortName: StringRef, + private val hasValueArguments: Boolean +) : KotlinStubBaseImpl(parent, JetStubElementTypes.ANNOTATION_ENTRY), KotlinAnnotationEntryStub { + + override fun getShortName() = shortName.getString() + + override fun hasValueArguments() = hasValueArguments +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinClassStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinClassStubImpl.java deleted file mode 100644 index e03c0344ecd..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinClassStubImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs.impl; - -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.psi.JetClass; -import org.jetbrains.jet.lang.psi.stubs.KotlinClassStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetClassElementType; -import org.jetbrains.jet.lang.resolve.name.FqName; - -import java.util.ArrayList; -import java.util.List; - -public class KotlinClassStubImpl extends KotlinStubBaseImpl implements KotlinClassStub { - private final StringRef qualifiedName; - private final StringRef name; - private final StringRef[] superNames; - private final boolean isTrait; - private final boolean isEnumEntry; - private final boolean isLocal; - private final boolean isTopLevel; - - public KotlinClassStubImpl( - JetClassElementType type, - StubElement parent, - StringRef qualifiedName, - StringRef name, - StringRef[] superNames, - boolean isTrait, - boolean isEnumEntry, - boolean isLocal, - boolean isTopLevel - ) { - super(parent, type); - this.qualifiedName = qualifiedName; - this.name = name; - this.superNames = superNames; - this.isTrait = isTrait; - this.isEnumEntry = isEnumEntry; - this.isLocal = isLocal; - this.isTopLevel = isTopLevel; - } - - @Override - public FqName getFqName() { - String stringRef = StringRef.toString(qualifiedName); - if (stringRef == null) { - return null; - } - return new FqName(stringRef); - } - - @Override - public boolean isTrait() { - return isTrait; - } - - @Override - public boolean isEnumEntry() { - return isEnumEntry; - } - - @Override - public boolean isLocal() { - return isLocal; - } - - @Override - public String getName() { - return StringRef.toString(name); - } - - @NotNull - @Override - public List getSuperNames() { - List result = new ArrayList(); - for (StringRef ref : superNames) { - result.add(ref.toString()); - } - return result; - } - - @Override - public boolean isTopLevel() { - return isTopLevel; - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinClassStubImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinClassStubImpl.kt new file mode 100644 index 00000000000..bc6c05b11a6 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinClassStubImpl.kt @@ -0,0 +1,63 @@ +/* + * Copyright 2010-2014 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.jet.lang.psi.stubs.impl + +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import org.jetbrains.jet.lang.psi.JetClass +import org.jetbrains.jet.lang.psi.stubs.KotlinClassStub +import org.jetbrains.jet.lang.psi.stubs.elements.JetClassElementType +import org.jetbrains.jet.lang.resolve.name.FqName + +import java.util.ArrayList +import com.intellij.psi.PsiElement + +public class KotlinClassStubImpl( + type: JetClassElementType, + parent: StubElement?, + private val qualifiedName: StringRef?, + private val name: StringRef?, + private val superNames: Array, + private val isTrait: Boolean, + private val isEnumEntry: Boolean, + private val isLocal: Boolean, + private val isTopLevel: Boolean +) : KotlinStubBaseImpl(parent, type), KotlinClassStub { + + override fun getFqName(): FqName? { + val stringRef = StringRef.toString(qualifiedName) + if (stringRef == null) { + return null + } + return FqName(stringRef) + } + + override fun isTrait() = isTrait + override fun isEnumEntry() = isEnumEntry + override fun isLocal() = isLocal + override fun getName() = StringRef.toString(name) + + override fun getSuperNames(): List { + val result = ArrayList() + for (ref in superNames) { + result.add(ref.toString()) + } + return result + } + + override fun isTopLevel() = isTopLevel +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinFunctionStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinFunctionStubImpl.java deleted file mode 100644 index 4897ddbd247..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinFunctionStubImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs.impl; - -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.psi.JetNamedFunction; -import org.jetbrains.jet.lang.psi.stubs.KotlinFunctionStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; -import org.jetbrains.jet.lang.resolve.name.FqName; - -public class KotlinFunctionStubImpl extends KotlinStubBaseImpl implements KotlinFunctionStub { - - private final StringRef nameRef; - private final boolean isTopLevel; - private final boolean isExtension; - private final FqName fqName; - private final boolean hasBlockBody; - private final boolean hasBody; - private final boolean hasTypeParameterListBeforeFunctionName; - private final boolean probablyNothingType; - - public KotlinFunctionStubImpl( - @NotNull StubElement parent, - @Nullable StringRef nameRef, - boolean isTopLevel, - @Nullable FqName fqName, - boolean isExtension, - boolean hasBlockBody, - boolean hasBody, - boolean hasTypeParameterListBeforeFunctionName, - boolean probablyNothingType - ) { - super(parent, JetStubElementTypes.FUNCTION); - - if (isTopLevel && fqName == null) { - throw new IllegalArgumentException("fqName shouldn't be null for top level functions"); - } - - this.nameRef = nameRef; - this.fqName = fqName; - this.isTopLevel = isTopLevel; - this.isExtension = isExtension; - this.hasBlockBody = hasBlockBody; - this.hasBody = hasBody; - this.hasTypeParameterListBeforeFunctionName = hasTypeParameterListBeforeFunctionName; - this.probablyNothingType = probablyNothingType; - } - - @Override - public String getName() { - return StringRef.toString(nameRef); - } - - @Override - public boolean isTopLevel() { - return isTopLevel; - } - - @Override - public boolean isExtension() { - return isExtension; - } - - @Override - public boolean hasBlockBody() { - return hasBlockBody; - } - - @Override - public boolean hasBody() { - return hasBody; - } - - @Override - public boolean hasTypeParameterListBeforeFunctionName() { - return hasTypeParameterListBeforeFunctionName; - } - - @Nullable - @Override - public FqName getFqName() { - return fqName; - } - - @Override - public boolean isProbablyNothingType() { - return probablyNothingType; - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinFunctionStubImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinFunctionStubImpl.kt new file mode 100644 index 00000000000..02a724cffb3 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinFunctionStubImpl.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2014 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.jet.lang.psi.stubs.impl + +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import org.jetbrains.jet.lang.psi.JetNamedFunction +import org.jetbrains.jet.lang.psi.stubs.KotlinFunctionStub +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes +import org.jetbrains.jet.lang.resolve.name.FqName +import com.intellij.psi.PsiElement + +public class KotlinFunctionStubImpl( + parent: StubElement?, + private val nameRef: StringRef?, + private val isTopLevel: Boolean, + private val fqName: FqName?, + private val isExtension: Boolean, + private val hasBlockBody: Boolean, + private val hasBody: Boolean, + private val hasTypeParameterListBeforeFunctionName: Boolean, + private val isProbablyNothingType: Boolean +) : KotlinStubBaseImpl(parent, JetStubElementTypes.FUNCTION), KotlinFunctionStub { + { + if (isTopLevel && fqName == null) { + throw IllegalArgumentException("fqName shouldn't be null for top level functions") + } + } + override fun getFqName() = fqName + + override fun getName() = StringRef.toString(nameRef) + override fun isTopLevel() = isTopLevel + override fun isExtension() = isExtension + override fun hasBlockBody() = hasBlockBody + override fun hasBody() = hasBody + override fun hasTypeParameterListBeforeFunctionName() = hasTypeParameterListBeforeFunctionName + override fun isProbablyNothingType() = isProbablyNothingType +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinModifierListStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinModifierListStubImpl.java index 02ca3ad9ea3..218a4cfab54 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinModifierListStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinModifierListStubImpl.java @@ -17,33 +17,14 @@ package org.jetbrains.jet.lang.psi.stubs.impl; import com.intellij.psi.stubs.StubElement; -import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.psi.JetModifierList; import org.jetbrains.jet.lang.psi.stubs.KotlinModifierListStub; import org.jetbrains.jet.lang.psi.stubs.elements.JetModifierListElementType; import org.jetbrains.jet.lexer.JetModifierKeywordToken; -import static org.jetbrains.jet.lexer.JetTokens.MODIFIER_KEYWORDS_ARRAY; - public class KotlinModifierListStubImpl extends KotlinStubBaseImpl implements KotlinModifierListStub { - static { - assert MODIFIER_KEYWORDS_ARRAY.length <= 32 : "Current implementation depends on the ability to represent modifier list as bit mask"; - } - - public static int computeMaskFromPsi(@NotNull JetModifierList modifierList) { - int mask = 0; - JetModifierKeywordToken[] orderedKeywords = MODIFIER_KEYWORDS_ARRAY; - for (int i = 0; i < orderedKeywords.length; i++) { - JetModifierKeywordToken modifierKeywordToken = orderedKeywords[i]; - if (modifierList.hasModifier(modifierKeywordToken)) { - mask |= 1 << i; - } - } - return mask; - } - private final int mask; public KotlinModifierListStubImpl(StubElement parent, int mask, @NotNull JetModifierListElementType elementType) { @@ -51,33 +32,18 @@ public class KotlinModifierListStubImpl extends KotlinStubBaseImpl= 0 : "All JetModifierKeywordTokens should present in MODIFIER_KEYWORDS_ARRAY"; - return (mask & (1 << index)) != 0; - } - public int getMask() { return mask; } + @Override + public boolean hasModifier(@NotNull JetModifierKeywordToken modifierToken) { + return ModifierMaskUtils.maskHasModifier(mask, modifierToken); + } + + @NotNull @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(super.toString()); - sb.append("["); - boolean first = true; - for (JetModifierKeywordToken modifierKeyword : MODIFIER_KEYWORDS_ARRAY) { - if (hasModifier(modifierKeyword)) { - if (!first) { - sb.append(" "); - } - sb.append(modifierKeyword.getValue()); - first = false; - } - } - sb.append("]"); - return sb.toString(); + return super.toString() + ModifierMaskUtils.maskToString(mask); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinObjectStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinObjectStubImpl.java deleted file mode 100644 index 0e2d515fd8a..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinObjectStubImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs.impl; - -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.psi.JetObjectDeclaration; -import org.jetbrains.jet.lang.psi.stubs.KotlinObjectStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; -import org.jetbrains.jet.lang.resolve.name.FqName; - -import java.util.ArrayList; -import java.util.List; - -public class KotlinObjectStubImpl extends KotlinStubBaseImpl implements KotlinObjectStub { - private final StringRef name; - private final FqName fqName; - private final StringRef[] superNames; - private final boolean isTopLevel; - private final boolean isClassObject; - private final boolean isLocal; - private final boolean isObjectLiteral; - - public KotlinObjectStubImpl( - @NotNull StubElement parent, - @Nullable StringRef name, - @Nullable FqName fqName, - @NotNull StringRef[] superNames, - boolean isTopLevel, - boolean isClassObject, - boolean isLocal, - boolean isObjectLiteral - ) { - super(parent, JetStubElementTypes.OBJECT_DECLARATION); - this.name = name; - this.fqName = fqName; - this.superNames = superNames; - this.isTopLevel = isTopLevel; - this.isClassObject = isClassObject; - this.isLocal = isLocal; - this.isObjectLiteral = isObjectLiteral; - } - - @Override - public String getName() { - return StringRef.toString(name); - } - - @Nullable - @Override - public FqName getFqName() { - return fqName; - } - - @NotNull - @Override - public List getSuperNames() { - List result = new ArrayList(); - for (StringRef ref : superNames) { - result.add(ref.toString()); - } - return result; - } - - @Override - public boolean isTopLevel() { - return isTopLevel; - } - - @Override - public boolean isClassObject() { - return isClassObject; - } - - @Override - public boolean isObjectLiteral() { - return isObjectLiteral; - } - - @Override - public boolean isLocal() { - return isLocal; - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinObjectStubImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinObjectStubImpl.kt new file mode 100644 index 00000000000..a0d5abde1b3 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinObjectStubImpl.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2014 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.jet.lang.psi.stubs.impl + +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import org.jetbrains.jet.lang.psi.JetObjectDeclaration +import org.jetbrains.jet.lang.psi.stubs.KotlinObjectStub +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes +import org.jetbrains.jet.lang.resolve.name.FqName + +import com.intellij.psi.PsiElement + +public class KotlinObjectStubImpl( + parent: StubElement?, + private val name: StringRef?, + private val fqName: FqName?, + private val superNames: Array, + private val isTopLevel: Boolean, + private val isClassObject: Boolean, + private val isLocal: Boolean, + private val isObjectLiteral: Boolean +) : KotlinStubBaseImpl(parent, JetStubElementTypes.OBJECT_DECLARATION), KotlinObjectStub { + override fun getFqName() = fqName + override fun getName() = StringRef.toString(name) + override fun getSuperNames() = superNames map { it.toString() } + override fun isTopLevel() = isTopLevel + override fun isClassObject() = isClassObject + override fun isObjectLiteral() = isObjectLiteral + override fun isLocal() = isLocal +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinParameterStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinParameterStubImpl.java deleted file mode 100644 index 58d4a490f35..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinParameterStubImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs.impl; - -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.psi.JetParameter; -import org.jetbrains.jet.lang.psi.stubs.KotlinParameterStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; -import org.jetbrains.jet.lang.resolve.name.FqName; - -public class KotlinParameterStubImpl extends KotlinStubBaseImpl implements KotlinParameterStub { - private final StringRef name; - private final boolean isMutable; - private final StringRef fqName; - private final boolean hasValOrValNode; - private final boolean hasDefaultValue; - - public KotlinParameterStubImpl( - StubElement parent, - StringRef fqName, StringRef name, - boolean isMutable, - boolean hasValOrValNode, - boolean hasDefaultValue - ) { - super(parent, JetStubElementTypes.VALUE_PARAMETER); - this.name = name; - this.isMutable = isMutable; - this.fqName = fqName; - this.hasValOrValNode = hasValOrValNode; - this.hasDefaultValue = hasDefaultValue; - } - - @Override - public String getName() { - return StringRef.toString(name); - } - - @Override - public boolean isMutable() { - return isMutable; - } - - @Override - public boolean hasValOrValNode() { - return hasValOrValNode; - } - - @Override - public boolean hasDefaultValue() { - return hasDefaultValue; - } - - @Nullable - @Override - public FqName getFqName() { - return fqName != null ? new FqName(fqName.getString()) : null; - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinParameterStubImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinParameterStubImpl.kt new file mode 100644 index 00000000000..59c54345b11 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinParameterStubImpl.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2014 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.jet.lang.psi.stubs.impl + +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import org.jetbrains.jet.lang.psi.JetParameter +import org.jetbrains.jet.lang.psi.stubs.KotlinParameterStub +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes +import org.jetbrains.jet.lang.resolve.name.FqName +import com.intellij.psi.PsiElement + +public class KotlinParameterStubImpl( + parent: StubElement?, + private val fqName: StringRef?, + private val name: StringRef?, + private val isMutable: Boolean, + private val hasValOrVarNode: Boolean, + private val hasDefaultValue: Boolean +) : KotlinStubBaseImpl(parent, JetStubElementTypes.VALUE_PARAMETER), KotlinParameterStub { + override fun getName(): String? { + return StringRef.toString(name) + } + + override fun getFqName(): FqName? { + return if (fqName != null) FqName(fqName.getString()) else null + } + + override fun isMutable() = isMutable + override fun hasValOrVarNode() = hasValOrVarNode + override fun hasDefaultValue() = hasDefaultValue +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinPropertyStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinPropertyStubImpl.java deleted file mode 100644 index f56fe0cfc26..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinPropertyStubImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs.impl; - -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.psi.JetProperty; -import org.jetbrains.jet.lang.psi.stubs.KotlinPropertyStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; -import org.jetbrains.jet.lang.resolve.name.FqName; - -public class KotlinPropertyStubImpl extends KotlinStubBaseImpl implements KotlinPropertyStub { - private final StringRef name; - private final boolean isVar; - private final boolean isTopLevel; - private final boolean hasDelegate; - private final boolean hasDelegateExpression; - private final boolean hasInitializer; - private final boolean hasReceiverTypeRef; - private final boolean hasReturnTypeRef; - private final boolean probablyNothingType; - private final FqName fqName; - - public KotlinPropertyStubImpl( - StubElement parent, - StringRef name, - boolean isVar, - boolean isTopLevel, - boolean hasDelegate, - boolean hasDelegateExpression, - boolean hasInitializer, - boolean hasReceiverTypeRef, - boolean hasReturnTypeRef, - boolean probablyNothingType, - @Nullable FqName fqName - ) { - super(parent, JetStubElementTypes.PROPERTY); - - if (isTopLevel && fqName == null) { - throw new IllegalArgumentException("fqName shouldn't be null for top level properties"); - } - if (hasDelegateExpression && !hasDelegate) { - throw new IllegalArgumentException("Can't have delegate expression without delegate"); - } - - this.name = name; - this.isVar = isVar; - this.isTopLevel = isTopLevel; - this.hasDelegate = hasDelegate; - this.hasDelegateExpression = hasDelegateExpression; - this.hasInitializer = hasInitializer; - this.hasReceiverTypeRef = hasReceiverTypeRef; - this.hasReturnTypeRef = hasReturnTypeRef; - this.probablyNothingType = probablyNothingType; - this.fqName = fqName; - } - - @Override - public boolean isVar() { - return isVar; - } - - @Override - public boolean isTopLevel() { - return isTopLevel; - } - - @Override - public boolean hasDelegate() { - return hasDelegate; - } - - @Override - public boolean hasDelegateExpression() { - return hasDelegateExpression; - } - - @Override - public boolean hasInitializer() { - return hasInitializer; - } - - @Override - public boolean hasReceiverTypeRef() { - return hasReceiverTypeRef; - } - - @Override - public boolean hasReturnTypeRef() { - return hasReturnTypeRef; - } - - @Override - public boolean isProbablyNothingType() { - return probablyNothingType; - } - - @Nullable - @Override - public FqName getFqName() { - return fqName; - } - - @Override - public String getName() { - return StringRef.toString(name); - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinPropertyStubImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinPropertyStubImpl.kt new file mode 100644 index 00000000000..84f2f542dce --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinPropertyStubImpl.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2014 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.jet.lang.psi.stubs.impl + +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import org.jetbrains.jet.lang.psi.JetProperty +import org.jetbrains.jet.lang.psi.stubs.KotlinPropertyStub +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes +import org.jetbrains.jet.lang.resolve.name.FqName +import com.intellij.psi.PsiElement + +public class KotlinPropertyStubImpl( + parent: StubElement?, + private val name: StringRef?, + private val isVar: Boolean, + private val isTopLevel: Boolean, + private val hasDelegate: Boolean, + private val hasDelegateExpression: Boolean, + private val hasInitializer: Boolean, + private val hasReceiverTypeRef: Boolean, + private val hasReturnTypeRef: Boolean, + private val isProbablyNothingType: Boolean, + private val fqName: FqName? +) : KotlinStubBaseImpl(parent, JetStubElementTypes.PROPERTY), KotlinPropertyStub { + + { + if (isTopLevel && fqName == null) { + throw IllegalArgumentException("fqName shouldn't be null for top level properties") + } + if (hasDelegateExpression && !hasDelegate) { + throw IllegalArgumentException("Can't have delegate expression without delegate") + } + } + + override fun getFqName() = fqName + override fun isVar() = isVar + override fun isTopLevel() = isTopLevel + override fun hasDelegate() = hasDelegate + override fun hasDelegateExpression() = hasDelegateExpression + override fun hasInitializer() = hasInitializer + override fun hasReceiverTypeRef() = hasReceiverTypeRef + override fun hasReturnTypeRef() = hasReturnTypeRef + override fun getName() = StringRef.toString(name) + override fun isProbablyNothingType() = isProbablyNothingType +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinStubBaseImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinStubBaseImpl.kt index a9adba6c725..a8e01f770b0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinStubBaseImpl.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinStubBaseImpl.kt @@ -30,7 +30,7 @@ import java.util.ArrayList public open class KotlinStubBaseImpl>(parent: StubElement<*>?, elementType: IStubElementType<*, *>) : StubBase(parent, elementType) { override fun toString(): String { - val stubInterface = this.javaClass.getInterfaces().first() + val stubInterface = this.javaClass.getInterfaces().filter { it.getName().endsWith("Stub") }.single() val propertiesValues = renderPropertyValues(stubInterface) if (propertiesValues.isEmpty()) { return "" diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeConstraintImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeConstraintStubImpl.kt similarity index 53% rename from compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeConstraintImpl.java rename to compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeConstraintStubImpl.kt index 5ee8eef113c..79229b15ca5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeConstraintImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeConstraintStubImpl.kt @@ -14,23 +14,18 @@ * limitations under the License. */ -package org.jetbrains.jet.lang.psi.stubs.impl; +package org.jetbrains.jet.lang.psi.stubs.impl -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.jet.lang.psi.JetTypeConstraint; -import org.jetbrains.jet.lang.psi.stubs.KotlinTypeConstraintStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; +import com.intellij.psi.stubs.StubElement +import org.jetbrains.jet.lang.psi.JetTypeConstraint +import org.jetbrains.jet.lang.psi.stubs.KotlinTypeConstraintStub +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes +import com.intellij.psi.PsiElement -public class KotlinTypeConstraintImpl extends KotlinStubBaseImpl implements KotlinTypeConstraintStub { - private final boolean isClassObjectConstraint; +public class KotlinTypeConstraintStubImpl( + parent: StubElement?, + private val isClassObjectConstraint: Boolean +) : KotlinStubBaseImpl(parent, JetStubElementTypes.TYPE_CONSTRAINT), KotlinTypeConstraintStub { - public KotlinTypeConstraintImpl(StubElement parent, boolean isClassObjectConstraint) { - super(parent, JetStubElementTypes.TYPE_CONSTRAINT); - this.isClassObjectConstraint = isClassObjectConstraint; - } - - @Override - public boolean isClassObjectConstraint() { - return isClassObjectConstraint; - } + override fun isClassObjectConstraint() = isClassObjectConstraint } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeParameterStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeParameterStubImpl.java deleted file mode 100644 index 8d7994a1cc0..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeParameterStubImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2010-2013 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.jet.lang.psi.stubs.impl; - -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.psi.JetTypeParameter; -import org.jetbrains.jet.lang.psi.stubs.KotlinTypeParameterStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; -import org.jetbrains.jet.lang.resolve.name.FqName; - -public class KotlinTypeParameterStubImpl extends KotlinStubBaseImpl implements KotlinTypeParameterStub { - private final StringRef name; - private final boolean isInVariance; - private final boolean isOutVariance; - - public KotlinTypeParameterStubImpl(StubElement parent, StringRef name, boolean isInVariance, boolean isOutVariance) { - super(parent, JetStubElementTypes.TYPE_PARAMETER); - - this.name = name; - this.isInVariance = isInVariance; - this.isOutVariance = isOutVariance; - } - - @Override - public boolean isInVariance() { - return isInVariance; - } - - @Override - public boolean isOutVariance() { - return isOutVariance; - } - - @Override - public String getName() { - return StringRef.toString(name); - } - - @Nullable - @Override - public FqName getFqName() { - // type parameters doesn't have FqNames - return null; - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeParameterStubImpl.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeParameterStubImpl.kt new file mode 100644 index 00000000000..ae3fbe8167d --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinTypeParameterStubImpl.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2014 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.jet.lang.psi.stubs.impl + +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import org.jetbrains.jet.lang.psi.JetTypeParameter +import org.jetbrains.jet.lang.psi.stubs.KotlinTypeParameterStub +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes +import com.intellij.psi.PsiElement + +public class KotlinTypeParameterStubImpl( + parent: StubElement?, + private val name: StringRef?, + private val isInVariance: Boolean, + private val isOutVariance: Boolean +) : KotlinStubBaseImpl(parent, JetStubElementTypes.TYPE_PARAMETER), KotlinTypeParameterStub { + override fun isInVariance() = isInVariance + override fun isOutVariance() = isOutVariance + override fun getName() = StringRef.toString(name) + // type parameters don't have FqNames + override fun getFqName() = null +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinUserTypeStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinUserTypeStubImpl.java deleted file mode 100644 index 70e847345eb..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinUserTypeStubImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2014 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.jet.lang.psi.stubs.impl; - -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.jet.lang.psi.JetUserType; -import org.jetbrains.jet.lang.psi.stubs.KotlinUserTypeStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; - -public class KotlinUserTypeStubImpl extends KotlinStubBaseImpl implements KotlinUserTypeStub { - private final boolean isAbsoluteInRootPackage; - - public KotlinUserTypeStubImpl(StubElement parent, boolean isAbsoluteInRootPackage) { - super(parent, JetStubElementTypes.USER_TYPE); - this.isAbsoluteInRootPackage = isAbsoluteInRootPackage; - } - - @Override - public boolean isAbsoluteInRootPackage() { - return isAbsoluteInRootPackage; - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinImportDirectiveStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinUserTypeStubImpl.kt similarity index 50% rename from compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinImportDirectiveStub.java rename to compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinUserTypeStubImpl.kt index 373aee68a82..cb852eccbe2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/KotlinImportDirectiveStub.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/KotlinUserTypeStubImpl.kt @@ -14,17 +14,17 @@ * limitations under the License. */ -package org.jetbrains.jet.lang.psi.stubs; +package org.jetbrains.jet.lang.psi.stubs.impl -import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.psi.JetImportDirective; -import org.jetbrains.jet.lang.resolve.name.Name; +import com.intellij.psi.stubs.StubElement +import org.jetbrains.jet.lang.psi.JetUserType +import org.jetbrains.jet.lang.psi.stubs.KotlinUserTypeStub +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes +import com.intellij.psi.PsiElement -public interface KotlinImportDirectiveStub extends StubElement { - boolean isAbsoluteInRootPackage(); - boolean isAllUnder(); - @Nullable - String getAliasName(); - boolean isValid(); +public class KotlinUserTypeStubImpl( + parent: StubElement?, + private val isAbsoluteInRootPackage: Boolean +) : KotlinStubBaseImpl(parent, JetStubElementTypes.USER_TYPE), KotlinUserTypeStub { + override fun isAbsoluteInRootPackage() = isAbsoluteInRootPackage } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/ModifierMaskUtils.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/ModifierMaskUtils.kt new file mode 100644 index 00000000000..562c7117336 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/ModifierMaskUtils.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2010-2014 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.jet.lang.psi.stubs.impl + +import org.jetbrains.jet.lang.psi.JetModifierList + +import org.jetbrains.jet.lexer.JetTokens.MODIFIER_KEYWORDS_ARRAY +import org.jetbrains.jet.lexer.JetModifierKeywordToken +import kotlin.platform.platformStatic + +public object ModifierMaskUtils { + { + assert(MODIFIER_KEYWORDS_ARRAY.size <= 32, "Current implementation depends on the ability to represent modifier list as bit mask") + } + + platformStatic public fun computeMaskFromModifierList(modifierList: JetModifierList): Int = computeMask { modifierList.hasModifier(it) } + + platformStatic public fun computeMask(hasModifier: (JetModifierKeywordToken) -> Boolean): Int { + var mask = 0 + for ((index, modifierKeywordToken) in MODIFIER_KEYWORDS_ARRAY.withIndices()) { + if (hasModifier(modifierKeywordToken)) { + mask = mask or (1 shl index) + } + } + return mask + } + + platformStatic public fun maskHasModifier(mask: Int, modifierToken: JetModifierKeywordToken): Boolean { + val index = MODIFIER_KEYWORDS_ARRAY.indexOf(modifierToken) + assert(index >= 0, "All JetModifierKeywordTokens should be present in MODIFIER_KEYWORDS_ARRAY") + return (mask and (1 shl index)) != 0 + } + + platformStatic public fun maskToString(mask: Int): String { + val sb = StringBuilder() + sb.append("[") + var first = true + for (modifierKeyword in MODIFIER_KEYWORDS_ARRAY) { + if (maskHasModifier(mask, modifierKeyword)) { + if (!first) { + sb.append(" ") + } + sb.append(modifierKeyword.getValue()) + first = false + } + } + sb.append("]") + return sb.toString() + } + +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/Utils.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/Utils.kt index 421878afaad..da7228d02a8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/Utils.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/Utils.kt @@ -20,6 +20,6 @@ import com.intellij.util.io.StringRef object Utils { fun wrapStrings(names : List) : Array { - return Array(names.size()) { i -> StringRef.fromString(names.get(i))!! } + return Array(names.size()) { i -> StringRef.fromString(names.get(i))!! } } } diff --git a/idea/testData/stubs/FunctionParameters.expected b/idea/testData/stubs/FunctionParameters.expected index 689e67f2666..98273fdbdee 100644 --- a/idea/testData/stubs/FunctionParameters.expected +++ b/idea/testData/stubs/FunctionParameters.expected @@ -2,11 +2,11 @@ PsiJetFileStubImpl[package=] PACKAGE_DIRECTIVE: FUN:[fqName=some, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isProbablyNothingType=false, isTopLevel=true, name=some] VALUE_PARAMETER_LIST: - VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrValNode=false, isMutable=false, name=t] + VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVarNode=false, isMutable=false, name=t] TYPE_REFERENCE: USER_TYPE:[isAbsoluteInRootPackage=false] REFERENCE_EXPRESSION:[referencedName=Int] - VALUE_PARAMETER:[fqName=null, hasDefaultValue=true, hasValOrValNode=false, isMutable=false, name=other] + VALUE_PARAMETER:[fqName=null, hasDefaultValue=true, hasValOrVarNode=false, isMutable=false, name=other] TYPE_REFERENCE: USER_TYPE:[isAbsoluteInRootPackage=false] REFERENCE_EXPRESSION:[referencedName=String] diff --git a/idea/testData/stubs/ParametersWithFqName.expected b/idea/testData/stubs/ParametersWithFqName.expected index fb807833dc4..ef42a7b8e0f 100644 --- a/idea/testData/stubs/ParametersWithFqName.expected +++ b/idea/testData/stubs/ParametersWithFqName.expected @@ -3,15 +3,15 @@ PsiJetFileStubImpl[package=test] REFERENCE_EXPRESSION:[referencedName=test] CLASS:[fqName=test.A, isEnumEntry=false, isLocal=false, isTopLevel=true, isTrait=false, name=A, superNames=[]] VALUE_PARAMETER_LIST: - VALUE_PARAMETER:[fqName=test.A.b, hasDefaultValue=false, hasValOrValNode=true, isMutable=false, name=b] + VALUE_PARAMETER:[fqName=test.A.b, hasDefaultValue=false, hasValOrVarNode=true, isMutable=false, name=b] TYPE_REFERENCE: USER_TYPE:[isAbsoluteInRootPackage=false] REFERENCE_EXPRESSION:[referencedName=Int] - VALUE_PARAMETER:[fqName=test.A.c, hasDefaultValue=false, hasValOrValNode=true, isMutable=true, name=c] + VALUE_PARAMETER:[fqName=test.A.c, hasDefaultValue=false, hasValOrVarNode=true, isMutable=true, name=c] TYPE_REFERENCE: USER_TYPE:[isAbsoluteInRootPackage=false] REFERENCE_EXPRESSION:[referencedName=String] - VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrValNode=false, isMutable=false, name=justParam] + VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVarNode=false, isMutable=false, name=justParam] TYPE_REFERENCE: USER_TYPE:[isAbsoluteInRootPackage=false] REFERENCE_EXPRESSION:[referencedName=Int]