diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationArgument.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationArgument.java index b678aca8eeb..41d42af95d2 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationArgument.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationArgument.java @@ -16,46 +16,16 @@ package org.jetbrains.jet.lang.resolve.java.structure; -import com.intellij.psi.*; +import com.intellij.psi.PsiAnnotationMemberValue; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.resolve.name.Name; -public abstract class JavaAnnotationArgument extends JavaElementImpl { - private final Name name; - - protected JavaAnnotationArgument(@NotNull PsiAnnotationMemberValue psiAnnotationMemberValue, @Nullable Name name) { - super(psiAnnotationMemberValue); - this.name = name; - } - +public interface JavaAnnotationArgument extends JavaElement { @NotNull @Override - public PsiAnnotationMemberValue getPsi() { - return (PsiAnnotationMemberValue) super.getPsi(); - } - - @NotNull - public static JavaAnnotationArgument create(@NotNull PsiAnnotationMemberValue argument, @Nullable Name name) { - if (argument instanceof PsiLiteralExpression) { - return new JavaLiteralAnnotationArgument((PsiLiteralExpression) argument, name); - } - else if (argument instanceof PsiReferenceExpression) { - return new JavaReferenceAnnotationArgument((PsiReferenceExpression) argument, name); - } - else if (argument instanceof PsiArrayInitializerMemberValue) { - return new JavaArrayAnnotationArgument((PsiArrayInitializerMemberValue) argument, name); - } - else if (argument instanceof PsiAnnotation) { - return new JavaAnnotationAsAnnotationArgument((PsiAnnotation) argument, name); - } - else { - throw new UnsupportedOperationException("Unsupported annotation argument type: " + argument); - } - } + PsiAnnotationMemberValue getPsi(); @Nullable - public Name getName() { - return name; - } + Name getName(); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationArgumentImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationArgumentImpl.java new file mode 100644 index 00000000000..b288338a3a9 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationArgumentImpl.java @@ -0,0 +1,62 @@ +/* + * 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.resolve.java.structure; + +import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.resolve.name.Name; + +public abstract class JavaAnnotationArgumentImpl extends JavaElementImpl implements JavaAnnotationArgument { + private final Name name; + + protected JavaAnnotationArgumentImpl(@NotNull PsiAnnotationMemberValue psiAnnotationMemberValue, @Nullable Name name) { + super(psiAnnotationMemberValue); + this.name = name; + } + + @NotNull + @Override + public PsiAnnotationMemberValue getPsi() { + return (PsiAnnotationMemberValue) super.getPsi(); + } + + @NotNull + /* package */ static JavaAnnotationArgument create(@NotNull PsiAnnotationMemberValue argument, @Nullable Name name) { + if (argument instanceof PsiLiteralExpression) { + return new JavaLiteralAnnotationArgument((PsiLiteralExpression) argument, name); + } + else if (argument instanceof PsiReferenceExpression) { + return new JavaReferenceAnnotationArgument((PsiReferenceExpression) argument, name); + } + else if (argument instanceof PsiArrayInitializerMemberValue) { + return new JavaArrayAnnotationArgument((PsiArrayInitializerMemberValue) argument, name); + } + else if (argument instanceof PsiAnnotation) { + return new JavaAnnotationAsAnnotationArgument((PsiAnnotation) argument, name); + } + else { + throw new UnsupportedOperationException("Unsupported annotation argument type: " + argument); + } + } + + @Override + @Nullable + public Name getName() { + return name; + } +} diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationAsAnnotationArgument.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationAsAnnotationArgument.java index afa367ebeaf..1b11e7375d2 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationAsAnnotationArgument.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationAsAnnotationArgument.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.resolve.name.Name; -public class JavaAnnotationAsAnnotationArgument extends JavaAnnotationArgument { +public class JavaAnnotationAsAnnotationArgument extends JavaAnnotationArgumentImpl { protected JavaAnnotationAsAnnotationArgument(@NotNull PsiAnnotation psiAnnotation, @Nullable Name name) { super(psiAnnotation, name); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationImpl.java index 0d341525943..b8f9eb433c6 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationImpl.java @@ -42,7 +42,7 @@ public class JavaAnnotationImpl extends JavaElementImpl implements JavaAnnotatio @Nullable public JavaAnnotationArgument findArgument(@NotNull Name name) { PsiAnnotationMemberValue attribute = getPsi().findAttributeValue(name.asString()); - return attribute == null ? null : JavaAnnotationArgument.create(attribute, name); + return attribute == null ? null : JavaAnnotationArgumentImpl.create(attribute, name); } @Override diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaArrayAnnotationArgument.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaArrayAnnotationArgument.java index 995e97cd994..0654c2c8fb8 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaArrayAnnotationArgument.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaArrayAnnotationArgument.java @@ -25,7 +25,7 @@ import java.util.Collection; import static org.jetbrains.jet.lang.resolve.java.structure.JavaElementCollectionFromPsiArrayUtil.namelessAnnotationArguments; -public class JavaArrayAnnotationArgument extends JavaAnnotationArgument { +public class JavaArrayAnnotationArgument extends JavaAnnotationArgumentImpl { protected JavaArrayAnnotationArgument(@NotNull PsiArrayInitializerMemberValue psiArrayInitializerMemberValue, @Nullable Name name) { super(psiArrayInitializerMemberValue, name); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaElementCollectionFromPsiArrayUtil.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaElementCollectionFromPsiArrayUtil.java index 2812c05f1ca..7a5b4791f88 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaElementCollectionFromPsiArrayUtil.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaElementCollectionFromPsiArrayUtil.java @@ -124,7 +124,7 @@ public class JavaElementCollectionFromPsiArrayUtil { if (memberValues.length == 0) return Collections.emptyList(); List result = new ArrayList(memberValues.length); for (PsiAnnotationMemberValue psiAnnotationMemberValue : memberValues) { - result.add(JavaAnnotationArgument.create(psiAnnotationMemberValue, null)); + result.add(JavaAnnotationArgumentImpl.create(psiAnnotationMemberValue, null)); } return result; } @@ -137,7 +137,7 @@ public class JavaElementCollectionFromPsiArrayUtil { String name = pair.getName(); PsiAnnotationMemberValue value = pair.getValue(); assert value != null : "Annotation argument value cannot be null: " + name; - result.add(JavaAnnotationArgument.create(value, name == null ? null : Name.identifier(name))); + result.add(JavaAnnotationArgumentImpl.create(value, name == null ? null : Name.identifier(name))); } return result; } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaLiteralAnnotationArgument.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaLiteralAnnotationArgument.java index fdb452d305b..04e60f6f980 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaLiteralAnnotationArgument.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaLiteralAnnotationArgument.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.resolve.name.Name; -public class JavaLiteralAnnotationArgument extends JavaAnnotationArgument { +public class JavaLiteralAnnotationArgument extends JavaAnnotationArgumentImpl { protected JavaLiteralAnnotationArgument(@NotNull PsiLiteralExpression psiLiteralExpression, @Nullable Name name) { super(psiLiteralExpression, name); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaReferenceAnnotationArgument.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaReferenceAnnotationArgument.java index 233887df104..aefe7212cae 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaReferenceAnnotationArgument.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaReferenceAnnotationArgument.java @@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.resolve.name.Name; -public class JavaReferenceAnnotationArgument extends JavaAnnotationArgument { +public class JavaReferenceAnnotationArgument extends JavaAnnotationArgumentImpl { protected JavaReferenceAnnotationArgument(@NotNull PsiReferenceExpression psiReferenceExpression, @Nullable Name name) { super(psiReferenceExpression, name); }