当前位置: 首页>>代码示例>>Java>>正文


Java PsiElementFactory.createTypeFromText方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiElementFactory.createTypeFromText方法的典型用法代码示例。如果您正苦于以下问题:Java PsiElementFactory.createTypeFromText方法的具体用法?Java PsiElementFactory.createTypeFromText怎么用?Java PsiElementFactory.createTypeFromText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiElementFactory的用法示例。


在下文中一共展示了PsiElementFactory.createTypeFromText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getParameterTypes

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
@Override
public PsiType[] getParameterTypes() {
  ArrayList<PsiType> types = new ArrayList<PsiType>();
  PsiManagerEx manager = getManager();
  GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
  PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
  for (GrDocMethodParameter parameter : getParameters()) {
    GrDocReferenceElement typeElement = parameter.getTypeElement();
    try {
      PsiType type = factory.createTypeFromText(typeElement.getText(), this);
      type = TypesUtil.boxPrimitiveType(type, manager, scope);
      types.add(type);
    } catch (IncorrectOperationException e) {
      LOG.info(e);
      types.add(null);
    }
  }
  return types.toArray(PsiType.createArray(types.size()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GrDocMethodParamsImpl.java

示例2: getParameterTypes

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
public PsiType[] getParameterTypes() {
  ArrayList<PsiType> types = new ArrayList<PsiType>();
  PsiManagerEx manager = getManager();
  GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
  PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
  for (GrDocMethodParameter parameter : getParameters()) {
    GrDocReferenceElement typeElement = parameter.getTypeElement();
    try {
      PsiType type = factory.createTypeFromText(typeElement.getText(), this);
      type = TypesUtil.boxPrimitiveType(type, manager, scope);
      types.add(type);
    } catch (IncorrectOperationException e) {
      LOG.info(e);
      types.add(null);
    }
  }
  return types.toArray(new PsiType[types.size()]);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:GrDocMethodParamsImpl.java

示例3: createLoggerField

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
private LombokLightFieldBuilder createLoggerField(@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) {
  final Project project = psiClass.getProject();
  final PsiManager manager = psiClass.getContainingFile().getManager();

  final PsiElementFactory psiElementFactory = JavaPsiFacade.getElementFactory(project);
  final PsiType psiLoggerType = psiElementFactory.createTypeFromText(loggerType, psiClass);

  LombokLightFieldBuilder loggerField = new LombokLightFieldBuilder(manager, getLoggerName(psiClass), psiLoggerType)
    .withContainingClass(psiClass)
    .withModifier(PsiModifier.FINAL)
    .withModifier(PsiModifier.PRIVATE)
    .withNavigationElement(psiAnnotation);
  if (isLoggerStatic(psiClass)) {
    loggerField.withModifier(PsiModifier.STATIC);
  }

  final String loggerInitializerParameter = createLoggerInitializeParameter(psiClass, psiAnnotation);
  final PsiExpression initializer = psiElementFactory.createExpressionFromText(String.format(loggerInitializer, loggerInitializerParameter), psiClass);
  loggerField.setInitializer(initializer);
  return loggerField;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:22,代码来源:AbstractLogProcessor.java

示例4: updateBoundFieldType

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
private static void updateBoundFieldType(final GuiEditor editor, final RadComponent oldComponent, final ComponentItem targetItem) {
  PsiField oldBoundField = BindingProperty.findBoundField(editor.getRootContainer(), oldComponent.getBinding());
  if (oldBoundField != null) {
    final PsiElementFactory factory = JavaPsiFacade.getInstance(editor.getProject()).getElementFactory();
    try {
      PsiType componentType = factory.createTypeFromText(targetItem.getClassName().replace('$', '.'), null);
      new ChangeFieldTypeFix(editor, oldBoundField, componentType).run();
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:MorphAction.java

示例5: generateCreator

import com.intellij.psi.PsiElementFactory; //导入方法依赖的package包/类
private PsiElement generateCreator(PsiClass psiClass, PsiAnnotation psiAnnotation) {
  PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiClass.getProject());
  PsiType creatorType = elementFactory.createTypeFromText("android.os.Parcelable.Creator<" + psiClass.getName() + ">", psiClass);
  return new LombokLightFieldBuilder(psiClass.getManager(), "CREATOR", creatorType)
      .withModifier(PsiModifier.PUBLIC)
      .withModifier(PsiModifier.STATIC)
      .withModifier(PsiModifier.FINAL)
      .withContainingClass(psiClass)
      .withNavigationElement(psiAnnotation);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:11,代码来源:ParcelableFieldsProcessor.java


注:本文中的com.intellij.psi.PsiElementFactory.createTypeFromText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。