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
.PsiImplUtil
;
21 import com
.intellij
.psi
.impl
.source
.SourceTreeToPsiMap
;
22 import com
.intellij
.psi
.impl
.source
.tree
.TreeElement
;
23 import com
.intellij
.ui
.RowIcon
;
24 import com
.intellij
.util
.Icons
;
25 import org
.jetbrains
.annotations
.NonNls
;
26 import org
.jetbrains
.annotations
.NotNull
;
33 public class ClsClassObjectAccessExpressionImpl
extends ClsElementImpl
implements PsiClassObjectAccessExpression
{
34 private static final Logger LOG
= Logger
.getInstance("com.intellij.psi.impl.compiled.ClsClassObjectAccessExpressionImpl");
35 private final ClsTypeElementImpl myTypeElement
;
36 private final ClsElementImpl myParent
;
37 @NonNls private static final String CLASS_ENDING
= ".class";
39 public ClsClassObjectAccessExpressionImpl(String canonicalClassText
, ClsElementImpl parent
) {
41 myTypeElement
= new ClsTypeElementImpl(this, canonicalClassText
, ClsTypeElementImpl
.VARIANCE_NONE
);
44 public void appendMirrorText(final int indentLevel
, final StringBuffer buffer
) {
45 myTypeElement
.appendMirrorText(0, buffer
);
46 buffer
.append(CLASS_ENDING
);
49 public void setMirror(@NotNull TreeElement element
) {
50 setMirrorCheckingType(element
, null);
52 PsiClassObjectAccessExpression mirror
= (PsiClassObjectAccessExpression
)SourceTreeToPsiMap
.treeElementToPsi(element
);
53 ((ClsElementImpl
)getOperand()).setMirror((TreeElement
)SourceTreeToPsiMap
.psiElementToTree(mirror
.getOperand()));
57 public PsiElement
[] getChildren() {
58 return new PsiElement
[]{myTypeElement
};
61 public PsiElement
getParent() {
65 public void accept(@NotNull PsiElementVisitor visitor
) {
66 if (visitor
instanceof JavaElementVisitor
) {
67 ((JavaElementVisitor
)visitor
).visitClassObjectAccessExpression(this);
70 visitor
.visitElement(this);
75 public PsiTypeElement
getOperand() {
79 public PsiType
getType() {
80 return PsiImplUtil
.getType(this);
83 public String
getText() {
84 StringBuffer buffer
= new StringBuffer();
85 appendMirrorText(0, buffer
);
86 return buffer
.toString();
89 public Icon
getElementIcon(final int flags
) {
90 final RowIcon rowIcon
= createLayeredIcon(Icons
.FIELD_ICON
, 0);
91 rowIcon
.setIcon(Icons
.PUBLIC_ICON
, 1);