本文整理汇总了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()));
}
示例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()]);
}
示例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;
}
示例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);
}
}
}
示例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);
}