Java 类com.intellij.psi.impl.PsiJavaParserFacadeImpl 实例源码

项目:consulo-java    文件:ClsTypeElementImpl.java   
private ClsElementImpl calculateChild()
{
    if(PsiJavaParserFacadeImpl.getPrimitiveType(myTypeText) != null)
    {
        return null;
    }
    if(isArray())
    {
        return myVariance == VARIANCE_NONE ? new ClsTypeElementImpl(this, myTypeText.substring(0, myTypeText.length() - 2),
                myVariance) : new ClsTypeElementImpl(this, myTypeText, VARIANCE_NONE);
    }
    if(isVarArgs())
    {
        return new ClsTypeElementImpl(this, myTypeText.substring(0, myTypeText.length() - 3), myVariance);
    }
    return myVariance == VARIANCE_INVARIANT ? null : new ClsJavaCodeReferenceElementImpl(this, myTypeText);
}
项目:consulo-java    文件:UnBoxingEvaluator.java   
@Nullable
public static PrimitiveValue getInnerPrimitiveValue(ObjectReference value)
{
    ReferenceType type = value.referenceType();
    Field valueField = type.fieldByName("value");
    if(valueField != null)
    {
        Value primitiveValue = value.getValue(valueField);
        if(primitiveValue instanceof PrimitiveValue)
        {
            LOG.assertTrue(type.name().equals(PsiJavaParserFacadeImpl.getPrimitiveType(primitiveValue.type().name()).getBoxedTypeName()));
            return (PrimitiveValue) primitiveValue;
        }
    }
    return null;
}
项目:intellij-ce-playground    文件:ClsTypeElementImpl.java   
private ClsElementImpl calculateChild() {
  if (PsiJavaParserFacadeImpl.getPrimitiveType(myTypeText) != null) {
    return null;
  }
  if (isArray()) {
    return myVariance == VARIANCE_NONE
           ? new ClsTypeElementImpl(this, myTypeText.substring(0, myTypeText.length() - 2), myVariance)
           : new ClsTypeElementImpl(this, myTypeText, VARIANCE_NONE);
  }
  if (isVarArgs()) {
    return new ClsTypeElementImpl(this, myTypeText.substring(0, myTypeText.length() - 3), myVariance);
  }
  return myVariance == VARIANCE_INVARIANT ? null : new ClsJavaCodeReferenceElementImpl(this, myTypeText);
}
项目:tools-idea    文件:ClsParsingUtil.java   
public static PsiExpression createExpressionFromText(final String exprText, final PsiManager manager, final ClsElementImpl parent) {
  final PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(manager.getProject()).getParserFacade();
  final PsiJavaFile dummyJavaFile = ((PsiJavaParserFacadeImpl)parserFacade).getDummyJavaFile(); // to resolve classes from java.lang
  final PsiExpression expr;
  try {
    expr = parserFacade.createExpressionFromText(exprText, dummyJavaFile);
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
    return null;
  }

  return psiToClsExpression(expr, parent);
}
项目:tools-idea    文件:ClsParsingUtil.java   
@NotNull
public static PsiAnnotationMemberValue createMemberValueFromText(final String text, final PsiManager manager, final ClsElementImpl parent) {
  final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
  final PsiJavaFile context = ((PsiJavaParserFacadeImpl)factory).getDummyJavaFile(); // to resolve classes from java.lang
  final LanguageLevel level = PsiUtil.getLanguageLevel(parent);
  final DummyHolder holder = DummyHolderFactory.createHolder(manager, new JavaDummyElement(text, ANNOTATION_VALUE, level), context);
  final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
  if (!(element instanceof PsiAnnotationMemberValue)) {
    LOG.error("Could not parse initializer:'" + text + "'");
    return null;
  }

  return getMemberValue(element, parent);
}
项目:consulo-java    文件:DebuggerUtilsImpl.java   
@NotNull
public static Pair<PsiElement, PsiType> getPsiClassAndType(@Nullable String className, Project project)
{
    PsiElement contextClass = null;
    PsiType contextType = null;
    if(!StringUtil.isEmpty(className))
    {
        PsiPrimitiveType primitiveType = PsiJavaParserFacadeImpl.getPrimitiveType(className);
        if(primitiveType != null)
        {
            contextClass = JavaPsiFacade.getInstance(project).findClass(primitiveType.getBoxedTypeName(), GlobalSearchScope.allScope(project));
            contextType = primitiveType;
        }
        else
        {
            contextClass = findClass(className, project, GlobalSearchScope.allScope(project));
            if(contextClass != null)
            {
                contextClass = contextClass.getNavigationElement();
            }
            if(contextClass instanceof PsiCompiledElement)
            {
                contextClass = ((PsiCompiledElement) contextClass).getMirror();
            }
            contextType = getType(className, project);
        }
        if(contextClass != null)
        {
            contextClass.putUserData(PSI_TYPE_KEY, contextType);
        }
    }
    return Pair.create(contextClass, contextType);
}