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.jet.lang.descriptors.DeclarationDescriptor;
021    import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
022    import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
023    import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
024    import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
025    import org.jetbrains.jet.lang.resolve.name.Name;
026    
027    public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implements JavaCallableMemberDescriptor {
028        private Boolean hasStableParameterNames = null;
029    
030        public JavaMethodDescriptor(
031                @NotNull DeclarationDescriptor containingDeclaration,
032                @NotNull Annotations annotations,
033                @NotNull Name name
034        ) {
035            this(containingDeclaration, annotations, name, Kind.DECLARATION);
036        }
037    
038        private JavaMethodDescriptor(
039                @NotNull DeclarationDescriptor containingDeclaration,
040                @NotNull Annotations annotations,
041                @NotNull Name name,
042                @NotNull Kind kind
043        ) {
044            super(containingDeclaration, annotations, name, kind);
045        }
046    
047        private JavaMethodDescriptor(
048                @NotNull DeclarationDescriptor containingDeclaration,
049                @NotNull SimpleFunctionDescriptor original,
050                @NotNull Annotations annotations,
051                @NotNull Name name,
052                @NotNull Kind kind
053        ) {
054            super(containingDeclaration, original, annotations, name, kind);
055        }
056    
057        @Override
058        public boolean hasStableParameterNames() {
059            assert hasStableParameterNames != null : "hasStableParameterNames was not set: " + this;
060            return hasStableParameterNames;
061        }
062    
063        public void setHasStableParameterNames(boolean hasStableParameterNames) {
064            this.hasStableParameterNames = hasStableParameterNames;
065        }
066    
067        @Override
068        protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
069            JavaMethodDescriptor result = preserveOriginal
070                                          ? new JavaMethodDescriptor(newOwner, getOriginal(), getAnnotations(), getName(), kind)
071                                          : new JavaMethodDescriptor(newOwner, getAnnotations(), getName(), kind);
072            result.setHasStableParameterNames(hasStableParameterNames());
073            return result;
074        }
075    }