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.asJava.light;
018    
019    import com.intellij.lang.java.JavaLanguage;
020    import com.intellij.openapi.util.TextRange;
021    import com.intellij.psi.*;
022    import com.intellij.psi.impl.light.LightElement;
023    import com.intellij.psi.javadoc.PsiDocComment;
024    import com.intellij.psi.search.SearchScope;
025    import com.intellij.util.IncorrectOperationException;
026    import org.jetbrains.annotations.NonNls;
027    import org.jetbrains.annotations.NotNull;
028    import org.jetbrains.annotations.Nullable;
029    
030    // Copy of com.intellij.psi.impl.light.LightField
031    @SuppressWarnings("UnnecessaryFinalOnLocalVariableOrParameter")
032    public class LightField extends LightElement implements PsiField {
033        private final PsiField myField;
034        private final PsiClass myContainingClass;
035    
036        public LightField(@NotNull final PsiManager manager, @NotNull final PsiField field, @NotNull final PsiClass containingClass) {
037            super(manager, JavaLanguage.INSTANCE);
038            myField = field;
039            myContainingClass = containingClass;
040        }
041    
042        @Override
043        public void setInitializer(@Nullable final PsiExpression initializer) throws IncorrectOperationException {
044            throw new IncorrectOperationException("Not supported");
045        }
046    
047        @NotNull
048        @Override
049        public SearchScope getUseScope() {
050            return myField.getUseScope();
051        }
052    
053        @Override
054        public String getName() {
055            return myField.getName();
056        }
057    
058        @NotNull
059        @Override
060        public PsiIdentifier getNameIdentifier() {
061            return myField.getNameIdentifier();
062        }
063    
064        @Override
065        public PsiDocComment getDocComment() {
066            return myField.getDocComment();
067        }
068    
069        @Override
070        public boolean isDeprecated() {
071            return myField.isDeprecated();
072        }
073    
074        @Override
075        public PsiClass getContainingClass() {
076            return myContainingClass;
077        }
078    
079        @NotNull
080        @Override
081        public PsiType getType() {
082            return myField.getType();
083        }
084    
085        @Override
086        public PsiTypeElement getTypeElement() {
087            return myField.getTypeElement();
088        }
089    
090        @Override
091        public PsiExpression getInitializer() {
092            return myField.getInitializer();
093        }
094    
095        @Override
096        public boolean hasInitializer() {
097            return myField.hasInitializer();
098        }
099    
100        @Override
101        public void normalizeDeclaration() throws IncorrectOperationException {
102            throw new IncorrectOperationException("Not supported");
103        }
104    
105        @Override
106        public Object computeConstantValue() {
107            return myField.computeConstantValue();
108        }
109    
110        @Override
111        public PsiElement setName(@NonNls @NotNull final String name) throws IncorrectOperationException {
112            throw new IncorrectOperationException("Not supported");
113        }
114    
115        @Override
116        public PsiModifierList getModifierList() {
117            return myField.getModifierList();
118        }
119    
120        @Override
121        public boolean hasModifierProperty(@NonNls @NotNull final String name) {
122            return myField.hasModifierProperty(name);
123        }
124    
125        @Override
126        public String getText() {
127            return myField.getText();
128        }
129    
130        @Override
131        public PsiElement copy() {
132            return new LightField(myManager, (PsiField)myField.copy(), myContainingClass);
133        }
134    
135        @Override
136        public TextRange getTextRange() {
137            return new TextRange(-1, -1);
138        }
139    
140        @Override
141        public boolean isValid() {
142            return myContainingClass.isValid();
143        }
144    
145        @Override
146        public String toString() {
147            return "PsiField:" + getName();
148        }
149    }