001 /*
002 * Copyright 2010-2013 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.jet.lang.resolve.java.descriptor;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.annotations.Nullable;
021 import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
022 import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
023 import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
024 import org.jetbrains.jet.lang.descriptors.SourceElement;
025 import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
026 import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
027 import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
028 import org.jetbrains.jet.lang.resolve.name.Name;
029
030 public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implements JavaCallableMemberDescriptor {
031 private Boolean hasStableParameterNames = null;
032 private Boolean hasSynthesizedParameterNames = null;
033
034 protected JavaMethodDescriptor(
035 @NotNull DeclarationDescriptor containingDeclaration,
036 @Nullable SimpleFunctionDescriptor original,
037 @NotNull Annotations annotations,
038 @NotNull Name name,
039 @NotNull Kind kind,
040 @NotNull SourceElement source
041 ) {
042 super(containingDeclaration, original, annotations, name, kind, source);
043 }
044
045 @NotNull
046 public static JavaMethodDescriptor createJavaMethod(
047 @NotNull DeclarationDescriptor containingDeclaration,
048 @NotNull Annotations annotations,
049 @NotNull Name name,
050 @NotNull SourceElement source
051 ) {
052 return new JavaMethodDescriptor(containingDeclaration, null, annotations, name, Kind.DECLARATION, source);
053 }
054
055 @Override
056 public boolean hasStableParameterNames() {
057 assert hasStableParameterNames != null : "hasStableParameterNames was not set: " + this;
058 return hasStableParameterNames;
059 }
060
061 public void setHasStableParameterNames(boolean hasStableParameterNames) {
062 this.hasStableParameterNames = hasStableParameterNames;
063 }
064
065 @Override
066 public boolean hasSynthesizedParameterNames() {
067 assert hasSynthesizedParameterNames != null : "hasSynthesizedParameterNames was not set: " + this;
068 return hasSynthesizedParameterNames;
069 }
070
071 public void setHasSynthesizedParameterNames(boolean hasSynthesizedParameterNames) {
072 this.hasSynthesizedParameterNames = hasSynthesizedParameterNames;
073 }
074
075 @NotNull
076 @Override
077 protected FunctionDescriptorImpl createSubstitutedCopy(
078 @NotNull DeclarationDescriptor newOwner,
079 @Nullable FunctionDescriptor original,
080 @NotNull Kind kind
081 ) {
082 JavaMethodDescriptor result = new JavaMethodDescriptor(
083 newOwner,
084 (SimpleFunctionDescriptor) original,
085 getAnnotations(),
086 getName(),
087 kind,
088 SourceElement.NO_SOURCE
089 );
090 result.setHasStableParameterNames(hasStableParameterNames());
091 result.setHasSynthesizedParameterNames(hasSynthesizedParameterNames());
092 return result;
093 }
094 }