Rewrite JavaAnnotationArgument interfaces and implementations to Kotlin

This commit is contained in:
Alexander Udalov
2014-08-27 13:30:53 +04:00
parent ec02382976
commit 4c51368244
17 changed files with 133 additions and 434 deletions
@@ -41,8 +41,8 @@ import org.jetbrains.jet.lang.types.TypeUtils
import org.jetbrains.jet.lang.resolve.resolveTopLevelClass
private object DEPRECATED_IN_JAVA : JavaLiteralAnnotationArgument {
override fun getName(): Name? = null
override fun getValue(): Any? = "Deprecated in Java"
override val name: Name? = null
override val value: Any? = "Deprecated in Java"
}
class LazyJavaAnnotationDescriptor(
@@ -66,7 +66,7 @@ class LazyJavaAnnotationDescriptor(
if (arguments.isEmpty() && _fqName()?.asString() == "java.lang.Deprecated") {
arguments = listOf(DEPRECATED_IN_JAVA)
}
arguments.valuesToMap { a -> a.getName() }
arguments.valuesToMap { it.name }
}
private val _valueArguments = c.storageManager.createMemoizedFunctionWithNullableValues<ValueParameterDescriptor, CompileTimeConstant<out Any?>> {
@@ -99,9 +99,9 @@ class LazyJavaAnnotationDescriptor(
private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): CompileTimeConstant<*>? {
return when (argument) {
is JavaLiteralAnnotationArgument -> createCompileTimeConstant(argument.getValue(), true, false, false, null)
is JavaLiteralAnnotationArgument -> createCompileTimeConstant(argument.value, true, false, false, null)
is JavaEnumValueAnnotationArgument -> resolveFromEnumValue(argument.resolve())
is JavaArrayAnnotationArgument -> resolveFromArray(argument.getName() ?: DEFAULT_ANNOTATION_MEMBER_NAME, argument.getElements())
is JavaArrayAnnotationArgument -> resolveFromArray(argument.name ?: DEFAULT_ANNOTATION_MEMBER_NAME, argument.getElements())
is JavaAnnotationAsAnnotationArgument -> resolveFromAnnotation(argument.getAnnotation())
is JavaClassObjectAnnotationArgument -> resolveFromJavaClassObjectType(argument.getReferencedType())
else -> 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.resolve.java.structure;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.name.Name;
public interface JavaAnnotationArgument extends JavaElement {
@Nullable
Name getName();
}
@@ -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.resolve.java.structure;
import org.jetbrains.annotations.NotNull;
public interface JavaAnnotationAsAnnotationArgument extends JavaAnnotationArgument {
@NotNull
JavaAnnotation getAnnotation();
}
@@ -1,26 +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.resolve.java.structure;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface JavaArrayAnnotationArgument extends JavaAnnotationArgument {
@NotNull
List<JavaAnnotationArgument> getElements();
}
@@ -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.resolve.java.structure;
import org.jetbrains.annotations.NotNull;
public interface JavaClassObjectAnnotationArgument extends JavaAnnotationArgument {
@NotNull
JavaType getReferencedType();
}
@@ -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.resolve.java.structure;
import org.jetbrains.annotations.Nullable;
public interface JavaEnumValueAnnotationArgument extends JavaAnnotationArgument {
@Nullable
JavaField resolve();
}
@@ -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.resolve.java.structure;
import org.jetbrains.annotations.Nullable;
public interface JavaLiteralAnnotationArgument extends JavaAnnotationArgument {
@Nullable
Object getValue();
}
@@ -0,0 +1,43 @@
/*
* 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.resolve.java.structure
import org.jetbrains.jet.lang.resolve.name.Name
public trait JavaAnnotationArgument : JavaElement {
public val name: Name?
}
public trait JavaLiteralAnnotationArgument : JavaAnnotationArgument {
public val value: Any?
}
public trait JavaArrayAnnotationArgument : JavaAnnotationArgument {
public fun getElements(): List<JavaAnnotationArgument>
}
public trait JavaEnumValueAnnotationArgument : JavaAnnotationArgument {
public fun resolve(): JavaField?
}
public trait JavaClassObjectAnnotationArgument : JavaAnnotationArgument {
public fun getReferencedType(): JavaType
}
public trait JavaAnnotationAsAnnotationArgument : JavaAnnotationArgument {
public fun getAnnotation(): JavaAnnotation
}