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
;
18 import com
.intellij
.lang
.ASTNode
;
19 import com
.intellij
.psi
.*;
20 import com
.intellij
.psi
.impl
.java
.stubs
.PsiImportStatementStub
;
21 import com
.intellij
.util
.ArrayFactory
;
22 import org
.jetbrains
.annotations
.NotNull
;
23 import org
.jetbrains
.annotations
.Nullable
;
25 public class PsiImportStaticStatementImpl
extends PsiImportStatementBaseImpl
implements PsiImportStaticStatement
{
26 public static final PsiImportStaticStatementImpl
[] EMPTY_ARRAY
= new PsiImportStaticStatementImpl
[0];
27 public static final ArrayFactory
<PsiImportStaticStatementImpl
> ARRAY_FACTORY
= new ArrayFactory
<PsiImportStaticStatementImpl
>() {
28 public PsiImportStaticStatementImpl
[] create(final int count
) {
29 return count
== 0 ? EMPTY_ARRAY
: new PsiImportStaticStatementImpl
[count
];
33 public PsiImportStaticStatementImpl(final PsiImportStatementStub stub
) {
37 public PsiImportStaticStatementImpl(final ASTNode node
) {
41 public PsiClass
resolveTargetClass() {
42 final PsiJavaCodeReferenceElement classReference
= getClassReference();
43 if (classReference
== null) return null;
44 final PsiElement result
= classReference
.resolve();
45 if (result
instanceof PsiClass
) {
46 return (PsiClass
) result
;
53 public String
getReferenceName() {
54 if (isOnDemand()) return null;
55 final PsiImportStaticReferenceElement memberReference
= getMemberReference();
56 if (memberReference
!= null) {
57 return memberReference
.getReferenceName();
65 private PsiImportStaticReferenceElement
getMemberReference() {
70 return (PsiImportStaticReferenceElement
) getImportReference();
75 private PsiJavaCodeReferenceElement
getClassReference() {
77 return getImportReference();
80 final PsiImportStaticReferenceElement memberReference
= getMemberReference();
81 if (memberReference
!= null) {
82 return memberReference
.getClassReference();
90 public void accept(@NotNull PsiElementVisitor visitor
){
91 if (visitor
instanceof JavaElementVisitor
) {
92 ((JavaElementVisitor
)visitor
).visitImportStaticStatement(this);
95 visitor
.visitElement(this);
99 public String
toString(){
100 return "PsiImportStaticStatement";