Examples of PsiElementFactory


Examples of com.intellij.psi.PsiElementFactory

                return rootTag;
        }

        final Project project = file.getProject();
        final PsiManager psiMgr = PsiManager.getInstance(project);
        final PsiElementFactory eltFactory = psiMgr.getElementFactory();

        final String tagExpr = "<" + parseRootTagName() + "/>";
        rootTag = eltFactory.createTagFromText(tagExpr);
        return (XmlTag) xmlDocument.add(rootTag);
    }
View Full Code Here

Examples of com.intellij.psi.PsiElementFactory

      }

      final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
      final PsiMethodCallExpression equalsCall = (PsiMethodCallExpression) factory.createExpressionFromText("a.equals(b)", null);
*/
      final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
      //final PsiAnnotation annotation = factory.createAnnotationFromText("@SomeAnnotation(someVariable = true)", descriptor.getPsiElement());
      //final PsiAnnotation annotation = factory.createAnnotationFromText("@" + _annotation + "({" + _bugType + "})", descriptor.getPsiElement().getContext());
      final PsiAnnotation annotation = factory.createAnnotationFromText('@' + _annotation + "({\"" + _bugType + "\"})\r\n", descriptor.getPsiElement());
      //factory.createImportStatement()
      descriptor.getPsiElement().addBefore(annotation, descriptor.getStartElement());

      /*equalsCall.getMethodExpression().getQualifierExpression().replace(lExpr);
      equalsCall.getArgumentList().getExpressions()[0].replace(rExpr);
 
View Full Code Here

Examples of com.intellij.psi.PsiElementFactory

  public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      public void run() {
        //final PsiElementFactory elfactory = parent.getManager().getElementFactory();
        final PsiElementFactory elfactory = JavaPsiFacade.getInstance(_parent.getProject()).getElementFactory();
        elfactory.createAnnotationFromText("@SomeAnnotation(someVariable = true)", descriptor.getPsiElement());

        try {
          final StringBuilder builder = new StringBuilder(_parent.getTextRange().getLength());
          //noinspection ForLoopWithMissingComponent
          for (PsiElement next = _firstChild; ; next = next.getNextSibling()) {
View Full Code Here

Examples of com.intellij.psi.PsiElementFactory

  }

  public <Psi extends PsiElement> void process(@NotNull PsiClass psiClass, @NotNull PsiMethod[] classMethods, @NotNull PsiAnnotation psiAnnotation, @NotNull List<Psi> target) {
    Project project = psiClass.getProject();
    PsiManager manager = psiClass.getContainingFile().getManager();
    PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();

    final String visibility = LombokProcessorUtil.getAccessVisibity(psiAnnotation);
    if (null != visibility) {
      PsiMethod constructorMethod = createConstructorMethod(visibility, Collections.<PsiField>emptyList(), psiClass, elementFactory);
      target.add((Psi) prepareMethod(manager, constructorMethod, psiClass, psiAnnotation));
View Full Code Here

Examples of com.intellij.psi.PsiElementFactory

  }

  @Override
  @NotNull
  public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
    final PsiAnnotation psiAnnotation = elementFactory.createAnnotationFromText('@' + qualifiedName, null);
    myAnnotations.put(qualifiedName, psiAnnotation);
    return psiAnnotation;
  }
View Full Code Here

Examples of com.intellij.psi.PsiElementFactory

  protected <Psi extends PsiElement> void processIntern(@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<Psi> target) {
    Project project = psiClass.getProject();
    PsiManager manager = psiClass.getContainingFile().getManager();

    final PsiElementFactory psiElementFactory = JavaPsiFacade.getElementFactory(project);
    PsiType psiLoggerType = psiElementFactory.createTypeFromText(loggerType, psiClass);
    LombokLightFieldBuilder loggerField = LombokPsiElementFactory.getInstance().createLightField(manager, loggerName, psiLoggerType)
        .withContainingClass(psiClass)
        .withModifier(PsiModifier.FINAL).withModifier(PsiModifier.STATIC).withModifier(PsiModifier.PRIVATE)
        .withNavigationElement(psiAnnotation);

    final String classQualifiedName = psiClass.getQualifiedName();
    final String className = null != classQualifiedName ? classQualifiedName : psiClass.getName();
    PsiExpression initializer = psiElementFactory.createExpressionFromText(String.format(loggerInitializer, className), psiClass);
    loggerField.setInitializer(initializer);

    target.add((Psi) loggerField);
  }
View Full Code Here

Examples of com.intellij.psi.PsiElementFactory

        builder.deleteCharAt(builder.length() - 1);
      }
      builder.append(')');
      builder.append('{').append("  ").append('}');

      PsiElementFactory elementFactory = JavaPsiFacade.getInstance(getManager().getProject()).getElementFactory();
      return elementFactory.createMethodFromText(builder.toString(), getContainingClass());
    } finally {
      StringBuilderSpinAllocator.dispose(builder);
    }
  }
View Full Code Here

Examples of com.intellij.psi.PsiElementFactory

*/
public class PsiMethodUtil {
  @NotNull
  public static PsiMethod createMethod(@NotNull PsiClass psiClass, @NotNull String methodText, @NotNull PsiElement navigationTarget) {
    PsiManager manager = psiClass.getContainingFile().getManager();
    PsiElementFactory elementFactory = JavaPsiFacade.getInstance(psiClass.getProject()).getElementFactory();

    PsiMethod method = elementFactory.createMethodFromText(methodText, psiClass);

    LombokLightMethod lightMethod = LombokPsiElementFactory.getInstance().createLightMethod(manager, method, psiClass);
    lightMethod.withNavigationElement(navigationTarget);
    return lightMethod;
  }
View Full Code Here

Examples of com.intellij.psi.PsiElementFactory

  }

  @Override
  @NotNull
  public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
    final PsiAnnotation psiAnnotation = elementFactory.createAnnotationFromText('@' + qualifiedName, null);
    myAnnotations.put(qualifiedName, psiAnnotation);
    return psiAnnotation;
  }
View Full Code Here

Examples of com.intellij.psi.PsiElementFactory

  }

  @Override
  @NotNull
  public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
    final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
    final PsiAnnotation psiAnnotation = elementFactory.createAnnotationFromText('@' + qualifiedName, null);
    myAnnotations.put(qualifiedName, psiAnnotation);
    return psiAnnotation;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.