update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / psi / impl / source / PsiExpressionCodeFragmentImpl.java
blobe1d366d9fa2def9d2d4f9bec03d9f1df83a58532
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;
18 import com.intellij.lang.ASTNode;
19 import com.intellij.openapi.project.Project;
20 import com.intellij.psi.PsiExpression;
21 import com.intellij.psi.PsiExpressionCodeFragment;
22 import com.intellij.psi.PsiType;
23 import com.intellij.psi.impl.source.tree.JavaElementType;
24 import org.jetbrains.annotations.NonNls;
26 public class PsiExpressionCodeFragmentImpl extends PsiCodeFragmentImpl implements PsiExpressionCodeFragment {
27 private PsiType myExpectedType;
29 public PsiExpressionCodeFragmentImpl(Project project,
30 boolean isPhysical,
31 @NonNls String name,
32 CharSequence text,
33 final PsiType expectedType) {
34 super(project, JavaElementType.EXPRESSION_TEXT, isPhysical, name, text);
35 myExpectedType = expectedType;
38 public PsiExpression getExpression() {
39 ASTNode exprChild = calcTreeElement().findChildByType(Constants.EXPRESSION_BIT_SET);
40 if (exprChild == null) return null;
41 return (PsiExpression)SourceTreeToPsiMap.treeElementToPsi(exprChild);
44 public PsiType getExpectedType() {
45 return myExpectedType;
48 public void setExpectedType(PsiType type) {
49 myExpectedType = type;