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 index b288338a3a9..f9155cbfb57 100644 --- 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 @@ -38,16 +38,16 @@ public abstract class JavaAnnotationArgumentImpl extends JavaElementImpl impleme @NotNull /* package */ static JavaAnnotationArgument create(@NotNull PsiAnnotationMemberValue argument, @Nullable Name name) { if (argument instanceof PsiLiteralExpression) { - return new JavaLiteralAnnotationArgument((PsiLiteralExpression) argument, name); + return new JavaLiteralAnnotationArgumentImpl((PsiLiteralExpression) argument, name); } else if (argument instanceof PsiReferenceExpression) { - return new JavaReferenceAnnotationArgument((PsiReferenceExpression) argument, name); + return new JavaReferenceAnnotationArgumentImpl((PsiReferenceExpression) argument, name); } else if (argument instanceof PsiArrayInitializerMemberValue) { - return new JavaArrayAnnotationArgument((PsiArrayInitializerMemberValue) argument, name); + return new JavaArrayAnnotationArgumentImpl((PsiArrayInitializerMemberValue) argument, name); } else if (argument instanceof PsiAnnotation) { - return new JavaAnnotationAsAnnotationArgument((PsiAnnotation) argument, name); + return new JavaAnnotationAsAnnotationArgumentImpl((PsiAnnotation) argument, name); } else { throw new UnsupportedOperationException("Unsupported annotation argument type: " + argument); 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 1b11e7375d2..520e1ebbb7e 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 @@ -18,22 +18,12 @@ package org.jetbrains.jet.lang.resolve.java.structure; import com.intellij.psi.PsiAnnotation; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.resolve.name.Name; - -public class JavaAnnotationAsAnnotationArgument extends JavaAnnotationArgumentImpl { - protected JavaAnnotationAsAnnotationArgument(@NotNull PsiAnnotation psiAnnotation, @Nullable Name name) { - super(psiAnnotation, name); - } +public interface JavaAnnotationAsAnnotationArgument extends JavaAnnotationArgument { @NotNull @Override - public PsiAnnotation getPsi() { - return (PsiAnnotation) super.getPsi(); - } + PsiAnnotation getPsi(); @NotNull - public JavaAnnotation getAnnotation() { - return new JavaAnnotationImpl(getPsi()); - } + JavaAnnotation getAnnotation(); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationAsAnnotationArgumentImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationAsAnnotationArgumentImpl.java new file mode 100644 index 00000000000..90bee806b89 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaAnnotationAsAnnotationArgumentImpl.java @@ -0,0 +1,40 @@ +/* + * 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.PsiAnnotation; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.resolve.name.Name; + +public class JavaAnnotationAsAnnotationArgumentImpl extends JavaAnnotationArgumentImpl implements JavaAnnotationAsAnnotationArgument { + protected JavaAnnotationAsAnnotationArgumentImpl(@NotNull PsiAnnotation psiAnnotation, @Nullable Name name) { + super(psiAnnotation, name); + } + + @NotNull + @Override + public PsiAnnotation getPsi() { + return (PsiAnnotation) super.getPsi(); + } + + @Override + @NotNull + public JavaAnnotation getAnnotation() { + return new JavaAnnotationImpl(getPsi()); + } +} 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 0654c2c8fb8..c4f9eac18bb 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 @@ -18,26 +18,14 @@ package org.jetbrains.jet.lang.resolve.java.structure; import com.intellij.psi.PsiArrayInitializerMemberValue; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.resolve.name.Name; import java.util.Collection; -import static org.jetbrains.jet.lang.resolve.java.structure.JavaElementCollectionFromPsiArrayUtil.namelessAnnotationArguments; - -public class JavaArrayAnnotationArgument extends JavaAnnotationArgumentImpl { - protected JavaArrayAnnotationArgument(@NotNull PsiArrayInitializerMemberValue psiArrayInitializerMemberValue, @Nullable Name name) { - super(psiArrayInitializerMemberValue, name); - } - +public interface JavaArrayAnnotationArgument extends JavaAnnotationArgument { @NotNull @Override - public PsiArrayInitializerMemberValue getPsi() { - return (PsiArrayInitializerMemberValue) super.getPsi(); - } + PsiArrayInitializerMemberValue getPsi(); @NotNull - public Collection getElements() { - return namelessAnnotationArguments(getPsi().getInitializers()); - } + Collection getElements(); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaArrayAnnotationArgumentImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaArrayAnnotationArgumentImpl.java new file mode 100644 index 00000000000..780aa43c141 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaArrayAnnotationArgumentImpl.java @@ -0,0 +1,44 @@ +/* + * 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.PsiArrayInitializerMemberValue; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.resolve.name.Name; + +import java.util.Collection; + +import static org.jetbrains.jet.lang.resolve.java.structure.JavaElementCollectionFromPsiArrayUtil.namelessAnnotationArguments; + +public class JavaArrayAnnotationArgumentImpl extends JavaAnnotationArgumentImpl implements JavaArrayAnnotationArgument { + protected JavaArrayAnnotationArgumentImpl(@NotNull PsiArrayInitializerMemberValue psiArrayInitializerMemberValue, @Nullable Name name) { + super(psiArrayInitializerMemberValue, name); + } + + @NotNull + @Override + public PsiArrayInitializerMemberValue getPsi() { + return (PsiArrayInitializerMemberValue) super.getPsi(); + } + + @Override + @NotNull + public Collection getElements() { + return namelessAnnotationArguments(getPsi().getInitializers()); + } +} 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 04e60f6f980..c07b0cf6a86 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 @@ -19,21 +19,12 @@ package org.jetbrains.jet.lang.resolve.java.structure; import com.intellij.psi.PsiLiteralExpression; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.resolve.name.Name; - -public class JavaLiteralAnnotationArgument extends JavaAnnotationArgumentImpl { - protected JavaLiteralAnnotationArgument(@NotNull PsiLiteralExpression psiLiteralExpression, @Nullable Name name) { - super(psiLiteralExpression, name); - } +public interface JavaLiteralAnnotationArgument extends JavaAnnotationArgument { @NotNull @Override - public PsiLiteralExpression getPsi() { - return (PsiLiteralExpression) super.getPsi(); - } + PsiLiteralExpression getPsi(); @Nullable - public Object getValue() { - return getPsi().getValue(); - } + Object getValue(); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaLiteralAnnotationArgumentImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaLiteralAnnotationArgumentImpl.java new file mode 100644 index 00000000000..48d983ccb80 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaLiteralAnnotationArgumentImpl.java @@ -0,0 +1,40 @@ +/* + * 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.PsiLiteralExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.resolve.name.Name; + +public class JavaLiteralAnnotationArgumentImpl extends JavaAnnotationArgumentImpl implements JavaLiteralAnnotationArgument { + protected JavaLiteralAnnotationArgumentImpl(@NotNull PsiLiteralExpression psiLiteralExpression, @Nullable Name name) { + super(psiLiteralExpression, name); + } + + @NotNull + @Override + public PsiLiteralExpression getPsi() { + return (PsiLiteralExpression) super.getPsi(); + } + + @Override + @Nullable + public Object getValue() { + return getPsi().getValue(); + } +} 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 aefe7212cae..5513a02afe6 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 @@ -16,33 +16,15 @@ package org.jetbrains.jet.lang.resolve.java.structure; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiEnumConstant; -import com.intellij.psi.PsiField; import com.intellij.psi.PsiReferenceExpression; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.resolve.name.Name; - -public class JavaReferenceAnnotationArgument extends JavaAnnotationArgumentImpl { - protected JavaReferenceAnnotationArgument(@NotNull PsiReferenceExpression psiReferenceExpression, @Nullable Name name) { - super(psiReferenceExpression, name); - } +public interface JavaReferenceAnnotationArgument extends JavaAnnotationArgument { @NotNull @Override - public PsiReferenceExpression getPsi() { - return (PsiReferenceExpression) super.getPsi(); - } + PsiReferenceExpression getPsi(); @Nullable - public JavaElement resolve() { - PsiReferenceExpression expression = getPsi(); - PsiElement element = expression.resolve(); - if (element instanceof PsiEnumConstant) { - return new JavaFieldImpl((PsiField) element); - } - // TODO: other types of references - return null; - } + JavaElement resolve(); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaReferenceAnnotationArgumentImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaReferenceAnnotationArgumentImpl.java new file mode 100644 index 00000000000..a7410b30acb --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/JavaReferenceAnnotationArgumentImpl.java @@ -0,0 +1,49 @@ +/* + * 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.PsiElement; +import com.intellij.psi.PsiEnumConstant; +import com.intellij.psi.PsiField; +import com.intellij.psi.PsiReferenceExpression; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.resolve.name.Name; + +public class JavaReferenceAnnotationArgumentImpl extends JavaAnnotationArgumentImpl implements JavaReferenceAnnotationArgument { + protected JavaReferenceAnnotationArgumentImpl(@NotNull PsiReferenceExpression psiReferenceExpression, @Nullable Name name) { + super(psiReferenceExpression, name); + } + + @NotNull + @Override + public PsiReferenceExpression getPsi() { + return (PsiReferenceExpression) super.getPsi(); + } + + @Override + @Nullable + public JavaElement resolve() { + PsiReferenceExpression expression = getPsi(); + PsiElement element = expression.resolve(); + if (element instanceof PsiEnumConstant) { + return new JavaFieldImpl((PsiField) element); + } + // TODO: other types of references + return null; + } +}