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
.openapi
.diagnostic
.Logger
;
19 import com
.intellij
.openapi
.project
.Project
;
20 import com
.intellij
.psi
.PsiJavaCodeReferenceCodeFragment
;
21 import com
.intellij
.psi
.PsiJavaCodeReferenceElement
;
22 import com
.intellij
.psi
.impl
.source
.tree
.CompositeElement
;
23 import com
.intellij
.psi
.impl
.source
.tree
.ElementType
;
24 import org
.jetbrains
.annotations
.NonNls
;
29 public class PsiJavaCodeReferenceCodeFragmentImpl
extends PsiCodeFragmentImpl
implements PsiJavaCodeReferenceCodeFragment
{
30 private static final Logger LOG
= Logger
.getInstance("#com.intellij.psi.impl.source.PsiJavaCodeReferenceCodeFragmentImpl");
31 private final boolean myIsClassesAccepted
;
33 public PsiJavaCodeReferenceCodeFragmentImpl(final Project project
,
34 final boolean isPhysical
,
35 final @NonNls String name
,
36 final CharSequence text
,
37 boolean isClassesAccepted
) {
38 super(project
, Constants
.REFERENCE_TEXT
, isPhysical
, name
, text
);
39 myIsClassesAccepted
= isClassesAccepted
;
42 public PsiJavaCodeReferenceElement
getReferenceElement() {
43 final CompositeElement treeElement
= calcTreeElement();
44 LOG
.assertTrue (treeElement
.getFirstChildNode().getElementType() == ElementType
.JAVA_CODE_REFERENCE
);
45 return (PsiJavaCodeReferenceElement
)SourceTreeToPsiMap
.treeElementToPsi(treeElement
.getFirstChildNode());
48 public boolean isClassesAccepted() {
49 return myIsClassesAccepted
;