2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.psi
.impl
.compiled
;
18 import com
.intellij
.openapi
.diagnostic
.Logger
;
19 import com
.intellij
.psi
.*;
20 import com
.intellij
.psi
.impl
.java
.stubs
.PsiFieldStub
;
21 import com
.intellij
.psi
.impl
.source
.SourceTreeToPsiMap
;
22 import com
.intellij
.psi
.impl
.source
.tree
.TreeElement
;
23 import org
.jetbrains
.annotations
.NotNull
;
28 public class ClsEnumConstantImpl
extends ClsFieldImpl
implements PsiEnumConstant
{
29 private static final Logger LOG
= Logger
.getInstance("#com.intellij.psi.impl.compiled.ClsEnumConstantImpl");
31 public ClsEnumConstantImpl(final PsiFieldStub stub
) {
35 public void appendMirrorText(final int indentLevel
, final StringBuffer buffer
) {
36 ClsDocCommentImpl docComment
= (ClsDocCommentImpl
)getDocComment();
37 if (docComment
!= null) {
38 docComment
.appendMirrorText(indentLevel
, buffer
);
39 goNextLine(indentLevel
, buffer
);
42 ((ClsElementImpl
)getModifierList()).appendMirrorText(indentLevel
, buffer
);
44 ((ClsElementImpl
)getNameIdentifier()).appendMirrorText(indentLevel
, buffer
);
47 public void setMirror(@NotNull TreeElement element
) {
48 setMirrorCheckingType(element
, null);
50 PsiField mirror
= (PsiField
)SourceTreeToPsiMap
.treeElementToPsi(element
);
51 if (getDocComment() != null) {
52 ((ClsElementImpl
)getDocComment()).setMirror((TreeElement
)SourceTreeToPsiMap
.psiElementToTree(mirror
.getDocComment()));
54 ((ClsElementImpl
)getModifierList()).setMirror((TreeElement
)SourceTreeToPsiMap
.psiElementToTree(mirror
.getModifierList()));
55 ((ClsElementImpl
)getNameIdentifier()).setMirror((TreeElement
)SourceTreeToPsiMap
.psiElementToTree(mirror
.getNameIdentifier()));
58 public PsiExpressionList
getArgumentList() {
62 public PsiMethod
resolveMethod() {
67 public JavaResolveResult
resolveMethodGenerics() {
68 return JavaResolveResult
.EMPTY
;
71 public PsiEnumConstantInitializer
getInitializingClass() {
75 public PsiMethod
resolveConstructor() {
81 public PsiType
getType() {
82 return JavaPsiFacade
.getInstance(getProject()).getElementFactory().createType(getContainingClass());
85 public PsiTypeElement
getTypeElement() {
89 public PsiExpression
getInitializer() {
93 public boolean hasInitializer() {
97 public boolean hasModifierProperty(@NotNull String name
) {
98 return PsiModifier
.PUBLIC
.equals(name
) || PsiModifier
.STATIC
.equals(name
) || PsiModifier
.FINAL
.equals(name
);