update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / psi / impl / source / tree / java / PsiClassObjectAccessExpressionImpl.java
bloba1a22cdf3bee9b74a9a2fab0758f2ce42103c62d
1 /*
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.source.tree.java;
18 import com.intellij.lang.ASTNode;
19 import com.intellij.openapi.diagnostic.Logger;
20 import com.intellij.psi.*;
21 import com.intellij.psi.impl.PsiImplUtil;
22 import com.intellij.psi.impl.source.Constants;
23 import com.intellij.psi.impl.source.tree.ChildRole;
24 import com.intellij.psi.tree.IElementType;
25 import com.intellij.psi.tree.ChildRoleBase;
26 import com.intellij.ui.RowIcon;
27 import com.intellij.util.Icons;
28 import org.jetbrains.annotations.NotNull;
30 import javax.swing.*;
32 public class PsiClassObjectAccessExpressionImpl extends ExpressionPsiElement implements PsiClassObjectAccessExpression, Constants {
33 private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.PsiClassObjectAccessExpressionImpl");
35 public PsiClassObjectAccessExpressionImpl() {
36 super(CLASS_OBJECT_ACCESS_EXPRESSION);
39 public PsiType getType() {
40 return PsiImplUtil.getType(this);
43 @NotNull
44 public PsiTypeElement getOperand() {
45 return (PsiTypeElement)findChildByRoleAsPsiElement(ChildRole.TYPE);
48 public ASTNode findChildByRole(int role) {
49 LOG.assertTrue(ChildRole.isUnique(role));
50 switch(role){
51 default:
52 return null;
54 case ChildRole.TYPE:
55 return findChildByType(TYPE);
57 case ChildRole.DOT:
58 return findChildByType(DOT);
60 case ChildRole.CLASS_KEYWORD:
61 return findChildByType(CLASS_KEYWORD);
65 public int getChildRole(ASTNode child) {
66 LOG.assertTrue(child.getTreeParent() == this);
67 IElementType i = child.getElementType();
68 if (i == TYPE) {
69 return ChildRole.TYPE;
71 else if (i == DOT) {
72 return ChildRole.DOT;
74 else if (i == CLASS_KEYWORD) {
75 return ChildRole.CLASS_KEYWORD;
77 else {
78 return ChildRoleBase.NONE;
82 public void accept(@NotNull PsiElementVisitor visitor) {
83 if (visitor instanceof JavaElementVisitor) {
84 ((JavaElementVisitor)visitor).visitClassObjectAccessExpression(this);
86 else {
87 visitor.visitElement(this);
91 public String toString() {
92 return "PsiClassObjectAccessExpression:" + getText();
95 public Icon getElementIcon(final int flags) {
96 final RowIcon rowIcon = createLayeredIcon(Icons.FIELD_ICON, 0);
97 rowIcon.setIcon(Icons.PUBLIC_ICON, 1);
98 return rowIcon;