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.psi.stubs.impl;
018    
019    import com.intellij.psi.stubs.StubElement;
020    import com.intellij.util.io.StringRef;
021    import org.jetbrains.annotations.NotNull;
022    import org.jetbrains.annotations.Nullable;
023    import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
024    import org.jetbrains.jet.lang.psi.stubs.PsiJetObjectStub;
025    import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
026    import org.jetbrains.jet.lang.resolve.name.FqName;
027    
028    import java.util.ArrayList;
029    import java.util.List;
030    
031    public class PsiJetObjectStubImpl extends JetStubBaseImpl<JetObjectDeclaration> implements PsiJetObjectStub {
032        private final StringRef name;
033        private final FqName fqName;
034        private final StringRef[] superNames;
035        private final boolean isTopLevel;
036        private final boolean isClassObject;
037        private final boolean isLocal;
038        private final boolean isObjectLiteral;
039    
040        public PsiJetObjectStubImpl(
041                @NotNull StubElement parent,
042                @Nullable StringRef name,
043                @Nullable FqName fqName,
044                @NotNull StringRef[] superNames,
045                boolean isTopLevel,
046                boolean isClassObject,
047                boolean isLocal,
048                boolean isObjectLiteral
049        ) {
050            super(parent, JetStubElementTypes.OBJECT_DECLARATION);
051            this.name = name;
052            this.fqName = fqName;
053            this.superNames = superNames;
054            this.isTopLevel = isTopLevel;
055            this.isClassObject = isClassObject;
056            this.isLocal = isLocal;
057            this.isObjectLiteral = isObjectLiteral;
058        }
059    
060        @Override
061        public String getName() {
062            return StringRef.toString(name);
063        }
064    
065        @Nullable
066        @Override
067        public FqName getFqName() {
068            return fqName;
069        }
070    
071        @NotNull
072        @Override
073        public List<String> getSuperNames() {
074            List<String> result = new ArrayList<String>();
075            for (StringRef ref : superNames) {
076                result.add(ref.toString());
077            }
078            return result;
079        }
080    
081        @Override
082        public boolean isTopLevel() {
083            return isTopLevel;
084        }
085    
086        @Override
087        public boolean isClassObject() {
088            return isClassObject;
089        }
090    
091        @Override
092        public boolean isObjectLiteral() {
093            return isObjectLiteral;
094        }
095    
096        @Override
097        public boolean isLocal() {
098            return isLocal;
099        }
100    }