Extract interface out of JavaValueParameter

This commit is contained in:
Alexander Udalov
2013-08-19 18:40:20 +04:00
parent 8c1349b90e
commit 7f77290505
3 changed files with 73 additions and 34 deletions
@@ -74,7 +74,7 @@ public class JavaElementCollectionFromPsiArrayUtil {
if (parameters.length == 0) return Collections.emptyList();
List<JavaValueParameter> result = new ArrayList<JavaValueParameter>(parameters.length);
for (PsiParameter psiParameter : parameters) {
result.add(new JavaValueParameter(psiParameter));
result.add(new JavaValueParameterImpl(psiParameter));
}
return result;
}
@@ -19,46 +19,18 @@ package org.jetbrains.jet.lang.resolve.java.structure;
import com.intellij.psi.PsiParameter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import java.util.Collection;
public class JavaValueParameter extends JavaElementImpl implements JavaAnnotationOwner {
public JavaValueParameter(@NotNull PsiParameter psiParameter) {
super(psiParameter);
}
public interface JavaValueParameter extends JavaAnnotationOwner {
@NotNull
@Override
public PsiParameter getPsi() {
return (PsiParameter) super.getPsi();
}
@NotNull
@Override
public Collection<JavaAnnotation> getAnnotations() {
return JavaElementUtil.getAnnotations(this);
}
PsiParameter getPsi();
@Nullable
@Override
public JavaAnnotation findAnnotation(@NotNull FqName fqName) {
return JavaElementUtil.findAnnotation(this, fqName);
}
@Nullable
public Name getName() {
String name = getPsi().getName();
return name == null ? null : Name.identifier(name);
}
Name getName();
@NotNull
public JavaType getType() {
return JavaTypeImpl.create(getPsi().getType());
}
JavaType getType();
public boolean isVararg() {
return getPsi().isVarArgs();
}
boolean isVararg();
}
@@ -0,0 +1,67 @@
/*
* 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.PsiParameter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import java.util.Collection;
public class JavaValueParameterImpl extends JavaElementImpl implements JavaValueParameter {
public JavaValueParameterImpl(@NotNull PsiParameter psiParameter) {
super(psiParameter);
}
@NotNull
@Override
public PsiParameter getPsi() {
return (PsiParameter) super.getPsi();
}
@NotNull
@Override
public Collection<JavaAnnotation> getAnnotations() {
return JavaElementUtil.getAnnotations(this);
}
@Nullable
@Override
public JavaAnnotation findAnnotation(@NotNull FqName fqName) {
return JavaElementUtil.findAnnotation(this, fqName);
}
@Override
@Nullable
public Name getName() {
String name = getPsi().getName();
return name == null ? null : Name.identifier(name);
}
@Override
@NotNull
public JavaType getType() {
return JavaTypeImpl.create(getPsi().getType());
}
@Override
public boolean isVararg() {
return getPsi().isVarArgs();
}
}