001    /*
002     * Copyright 2010-2015 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.kotlin.resolve.lazy.data;
018    
019    import com.intellij.psi.PsiElement;
020    import org.jetbrains.annotations.NotNull;
021    import org.jetbrains.annotations.Nullable;
022    import org.jetbrains.kotlin.descriptors.ClassKind;
023    import org.jetbrains.kotlin.name.FqName;
024    import org.jetbrains.kotlin.psi.*;
025    import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor;
026    
027    import java.util.Collections;
028    import java.util.List;
029    
030    public class SyntheticClassObjectInfo implements JetClassLikeInfo {
031        private final JetClassLikeInfo classInfo;
032        private final LazyClassDescriptor classDescriptor;
033    
034        public SyntheticClassObjectInfo(@NotNull JetClassLikeInfo classInfo, @NotNull LazyClassDescriptor classDescriptor) {
035            this.classInfo = classInfo;
036            this.classDescriptor = classDescriptor;
037        }
038    
039        @NotNull
040        public LazyClassDescriptor getClassDescriptor() {
041            return classDescriptor;
042        }
043    
044    
045        @NotNull
046        @Override
047        public FqName getContainingPackageFqName() {
048            return classInfo.getContainingPackageFqName();
049        }
050    
051        @Nullable
052        @Override
053        public JetModifierList getModifierList() {
054            return null;
055        }
056    
057        @Nullable
058        @Override
059        public JetClassObject getClassObject() {
060            return null;
061        }
062    
063        @NotNull
064        @Override
065        public List<JetClassObject> getClassObjects() {
066            return Collections.emptyList();
067        }
068    
069        @NotNull
070        @Override
071        public PsiElement getScopeAnchor() {
072            return classInfo.getScopeAnchor();
073        }
074    
075        @Nullable
076        @Override
077        public JetClassOrObject getCorrespondingClassOrObject() {
078            return null;
079        }
080    
081        @Nullable
082        @Override
083        public JetTypeParameterList getTypeParameterList() {
084            return null;
085        }
086    
087        @NotNull
088        @Override
089        public List<? extends JetParameter> getPrimaryConstructorParameters() {
090            return Collections.emptyList();
091        }
092    
093        @NotNull
094        @Override
095        public ClassKind getClassKind() {
096            return ClassKind.CLASS_OBJECT;
097        }
098    
099        @NotNull
100        @Override
101        public List<JetAnnotationEntry> getDanglingAnnotations() {
102            return Collections.emptyList();
103        }
104    
105        @NotNull
106        @Override
107        public List<JetDeclaration> getDeclarations() {
108            // There can be no declarations in a synthetic class object, all its members are fake overrides
109            return Collections.emptyList();
110        }
111    
112        @Override
113        public String toString() {
114            return "class object of " + classInfo;
115        }
116    }