JavaDescriptorResolver: Add resolve for annotation parameters (array, annotation, enum)
Temporary change testData for LoadJavaTest because enums in parameters of annotations in kotlin files is now unsupported
This commit is contained in:
+6
@@ -45,4 +45,10 @@ public interface AnnotationArgumentVisitor<R, D> {
|
||||
R visitStringValue(StringValue value, D data);
|
||||
|
||||
R visitNullValue(NullValue value, D data);
|
||||
|
||||
R visitEnumValue(EnumValue value, D data);
|
||||
|
||||
R visitArrayValue(ArrayValue value, D data);
|
||||
|
||||
R visitAnnotationValue(AnnotationValue value, D data);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.constants;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
/**
|
||||
* @author Natalia Ukhorskaya
|
||||
*/
|
||||
public class AnnotationValue implements CompileTimeConstant<AnnotationDescriptor> {
|
||||
|
||||
private final AnnotationDescriptor value;
|
||||
|
||||
public AnnotationValue(@NotNull AnnotationDescriptor value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public AnnotationDescriptor getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
|
||||
return value.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(AnnotationArgumentVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitAnnotationValue(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.constants;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Natalia.Ukhorskaya
|
||||
*/
|
||||
public class ArrayValue implements CompileTimeConstant<List<CompileTimeConstant<?>>> {
|
||||
|
||||
private final List<CompileTimeConstant<?>> value;
|
||||
private final JetType type;
|
||||
|
||||
public ArrayValue(@NotNull List<CompileTimeConstant<?>> value, @NotNull JetType type) {
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<CompileTimeConstant<?>> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(AnnotationArgumentVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitArrayValue(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ArrayValue that = (ArrayValue) o;
|
||||
|
||||
if (value == null) {
|
||||
return that.value == null;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (Object thisObject : value) {
|
||||
if (!thisObject.equals(that.value.get(i))) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 0;
|
||||
if (value == null) return hashCode;
|
||||
for (Object o : value) {
|
||||
hashCode += o.hashCode();
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.constants;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
/**
|
||||
* @author Natalia.Ukhorskaya
|
||||
*/
|
||||
public class EnumValue implements CompileTimeConstant<PropertyDescriptor> {
|
||||
|
||||
private final PropertyDescriptor value;
|
||||
|
||||
public EnumValue(@NotNull PropertyDescriptor value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PropertyDescriptor getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType(@NotNull JetStandardLibrary standardLibrary) {
|
||||
return value.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(AnnotationArgumentVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitEnumValue(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.getType() + "." + value.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
EnumValue enumValue = (EnumValue) o;
|
||||
|
||||
return value.equals(enumValue.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return value.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user