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


Java JavaPsiFacade.getElementFactory方法代码示例

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


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

示例1: addAnnotationToPackageInfo

import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
private void addAnnotationToPackageInfo(Project project, PsiJavaFile packageInfoFile) {
    if (!FileModificationService.getInstance().preparePsiElementForWrite(packageInfoFile)) {
        return;
    }

    PsiPackageStatement packageStatement = packageInfoFile.getPackageStatement();
    if (packageStatement == null) {
        return;
    }

    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
    PsiAnnotation annotation = factory.createAnnotationFromText("@" + annotationForTypeQualifierFqn,
            packageInfoFile.getContext());
    PsiElement addedAnnotation = packageInfoFile.addBefore(annotation, packageStatement);
    JavaCodeStyleManager.getInstance(project).shortenClassReferences(addedAnnotation);

    removeRedundantAnnotationsInPackage(project, packageInfoFile.getContainingDirectory().getFiles(), annotation);
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:19,代码来源:AddPackageInfoWithNullabilityDefaultsFix.java

示例2: findAnnotations

import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
static List<String> findAnnotations(PsiModifierListOwner element, boolean nullable) {
    if (overridesSuper(element)) {
        return Collections.emptyList();
    }

    List<String> annotations = new ArrayList<>();
    Project project = element.getProject();
    PsiModifierList modifierList = element.getModifierList();
    List<String> nullabilityAnnotations = nullable
            ? NullableNotNullManager.getInstance(project).getNullables()
            : NullableNotNullManager.getInstance(project).getNotNulls();
    for (String notNullAnnotationFqn : nullabilityAnnotations) {
        PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
        PsiAnnotation annotation = factory.createAnnotationFromText("@" + notNullAnnotationFqn, null);
        PsiAnnotation.TargetType[] targetTypes = getTargetsForLocation(modifierList);
        if (isNullabilityAnnotationForTypeQualifierDefault(annotation, nullable, targetTypes)) {
            annotations.add(annotation.getQualifiedName());
        }
    }
    return annotations;
}
 
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:22,代码来源:NullabilityAnnotationsWithTypeQualifierDefault.java

示例3: actionPerformed

import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {

    // 获取编辑器中的文件
    Project project = e.getData(PlatformDataKeys.PROJECT);
    Editor editor = e.getData(PlatformDataKeys.EDITOR);
    PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);

    // 获取当前类
    PsiClass targetClass = getTargetClass(editor, file);
    // 获取元素操作的工厂类
    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);

    // 生成代码
    new LayoutCreator(project, targetClass, factory, file).execute();
}
 
开发者ID:alidili,项目名称:AndroidStudioPlugin,代码行数:17,代码来源:CreateDialogAction.java

示例4: doFix

import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
@Override
protected void doFix(Project project, ProblemDescriptor descriptor)
  throws IncorrectOperationException {
  final PsiElement element = descriptor.getPsiElement();
  final String text = element.getText();
  final int max = text.length() - 1;
  if (max < 1) {
    return;
  }
  int index = 0;
  while (index < max && (text.charAt(index) == '0' || text.charAt(index) == '_')) {
    index++;
  }
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  final PsiElementFactory factory = psiFacade.getElementFactory();
  final String textWithoutLeadingZeros = text.substring(index);
  final PsiExpression decimalNumber =
    factory.createExpressionFromText(textWithoutLeadingZeros,
                                     element);
  element.replace(decimalNumber);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:RemoveLeadingZeroFix.java

示例5: DataWriter

import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
public DataWriter(PsiFile file, Project project, PsiClass cls) {
    super(project, file);
    factory = JavaPsiFacade.getElementFactory(project);
    this.file = file;
    this.project = project;
    this.cls = cls;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:DataWriter.java

示例6: CodeWriter

import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
CodeWriter(String typeName, boolean onlyBinder, PsiFile psiFile, PsiClass clazz) {
    super(clazz.getProject(), "");
    this.typeName = typeName;
    this.onlyBinder = onlyBinder;
    this.clazz = clazz;
    this.project = clazz.getProject();
    this.factory = JavaPsiFacade.getElementFactory(project);
}
 
开发者ID:drakeet,项目名称:MultiTypeTemplates,代码行数:9,代码来源:CreateInnerItemCodesAction.java

示例7: getFactory

import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
protected static PsiElementFactory getFactory(Project project) {
  return JavaPsiFacade.getElementFactory(project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:JavaPsiViewerExtension.java

示例8: getFactory

import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
@Override
public JVMElementFactory getFactory(Project project) {
  return JavaPsiFacade.getElementFactory(project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:JavaFactoryProvider.java


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