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
017package org.jetbrains.jet.lang.descriptors.impl;
018
019import org.jetbrains.annotations.NotNull;
020import org.jetbrains.annotations.Nullable;
021import org.jetbrains.jet.lang.descriptors.*;
022import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
023import org.jetbrains.jet.lang.resolve.name.Name;
024import org.jetbrains.jet.lang.types.JetType;
025import org.jetbrains.jet.lang.types.TypeSubstitutor;
026
027import java.util.List;
028
029public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl implements SimpleFunctionDescriptor {
030
031    private boolean isInline = false;
032
033    public SimpleFunctionDescriptorImpl(
034            @NotNull DeclarationDescriptor containingDeclaration,
035            @NotNull List<AnnotationDescriptor> annotations,
036            @NotNull Name name,
037            @NotNull Kind kind) {
038        super(containingDeclaration, annotations, name, kind);
039    }
040
041    private SimpleFunctionDescriptorImpl(
042            @NotNull DeclarationDescriptor containingDeclaration,
043            @NotNull SimpleFunctionDescriptor original,
044            @NotNull List<AnnotationDescriptor> annotations,
045            @NotNull Name name,
046            @NotNull Kind kind) {
047        super(containingDeclaration, original, annotations, name, kind);
048    }
049
050    public SimpleFunctionDescriptorImpl initialize(
051            @Nullable JetType receiverParameterType,
052            @Nullable ReceiverParameterDescriptor expectedThisObject,
053            @NotNull List<? extends TypeParameterDescriptor> typeParameters,
054            @NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
055            @Nullable JetType unsubstitutedReturnType,
056            @Nullable Modality modality,
057            @NotNull Visibility visibility,
058            boolean isInline) {
059        super.initialize(receiverParameterType, expectedThisObject, typeParameters, unsubstitutedValueParameters, unsubstitutedReturnType, modality, visibility);
060        this.isInline = isInline;
061        return this;
062    }
063
064    @NotNull
065    @Override
066    public SimpleFunctionDescriptor getOriginal() {
067        return (SimpleFunctionDescriptor) super.getOriginal();
068    }
069
070    @Override
071    protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
072        if (preserveOriginal) {
073            return new SimpleFunctionDescriptorImpl(
074                    newOwner,
075                    getOriginal(),
076                    // TODO : safeSubstitute
077                    getAnnotations(),
078                    getName(),
079                    kind);
080        }
081        else {
082            return new SimpleFunctionDescriptorImpl(
083                    newOwner,
084                    // TODO : safeSubstitute
085                    getAnnotations(),
086                    getName(),
087                    kind);
088        }
089    }
090
091    @NotNull
092    @Override
093    public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
094        SimpleFunctionDescriptorImpl copy = (SimpleFunctionDescriptorImpl)doSubstitute(TypeSubstitutor.EMPTY, newOwner, modality, visibility, false, copyOverrides, kind);
095        copy.isInline = isInline;
096        return copy;
097    }
098
099    @Override
100    public boolean isInline() {
101        return isInline;
102    }
103}