Examples of PsiFileFactory


Examples of com.intellij.psi.PsiFileFactory

  }

  @Override
  public PsiElement setName(@NonNls @NotNull String name) {
    ASTNode identifierNode = getNode().findChildByType(MathematicaElementTypes.IDENTIFIER);
    final PsiFileFactory fileFactory = PsiFileFactory.getInstance(getProject());
    final MathematicaPsiFileImpl file = (MathematicaPsiFileImpl) fileFactory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, name);
    ASTNode newElm = file.getFirstChild().getNode().findChildByType(MathematicaElementTypes.IDENTIFIER);
    if (identifierNode != null && newElm != null) {
      getNode().replaceChild(identifierNode, newElm);
    }
    return this;
View Full Code Here

Examples of com.intellij.psi.PsiFileFactory

  @Override
  public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException {
    assert (elements.length == 1 && elements[0] != null) || PsiTreeUtil.findCommonParent(elements) == elements[0].getParent();
    final PsiElement e = elements[0];

    final PsiFileFactory factory = PsiFileFactory.getInstance(project);
    final StringBuilder stringBuilder = new StringBuilder("f[");
    stringBuilder.append(e.getText());
    stringBuilder.append("]");

    final PsiFile file = factory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, stringBuilder);
    final FunctionCall[] func = PsiTreeUtil.getChildrenOfType(file, FunctionCall.class);
    assert func != null && func[0] != null;
    PsiElement newElement = e.replace(func[0]);
    final PsiElement head = newElement.getFirstChild();
    return head == null ? null : head.getTextRange();
View Full Code Here

Examples of com.intellij.psi.PsiFileFactory

  public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException {
    assert (elements.length == 1 && elements[0] != null) || PsiTreeUtil.findCommonParent(elements) == elements[0].getParent();
    final PsiElement e = elements[0];
    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);

    final PsiFileFactory factory = PsiFileFactory.getInstance(project);
    final StringBuilder stringBuilder = new StringBuilder(myHead + "[{},\n");
    stringBuilder.append(e.getText());
    stringBuilder.append("\n]");

    final PsiFile file = factory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, stringBuilder);
    final FunctionCall[] func = PsiTreeUtil.getChildrenOfType(file, FunctionCall.class);
    assert func != null && func[0] != null;
    func[0] = (FunctionCall) codeStyleManager.reformat(func[0]);
    PsiElement newElement = e.replace(func[0]);
View Full Code Here

Examples of com.intellij.psi.PsiFileFactory

  @Override
  public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException {
    assert (elements.length == 1 && elements[0] != null) || PsiTreeUtil.findCommonParent(elements) == elements[0].getParent();
    final PsiElement e = elements[0];

    final PsiFileFactory factory = PsiFileFactory.getInstance(project);
    final StringBuilder stringBuilder = new StringBuilder("(");
    stringBuilder.append(e.getText());
    stringBuilder.append(")&");

    final PsiFile file = factory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, stringBuilder);
    final Function[] func = PsiTreeUtil.getChildrenOfType(file, Function.class);
    assert func != null && func[0] != null;
    e.replace(func[0]);
    return null;
  }
View Full Code Here

Examples of com.intellij.psi.PsiFileFactory

    return (Symbol) file.getFirstChild();
  }

  private static MathematicaPsiFileImpl createFile(Project project, String symbolName) {
    String fileName = "dummy.m";
    final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(project);
    return (MathematicaPsiFileImpl) psiFileFactory.createFileFromText(fileName, MathematicaFileType.INSTANCE, symbolName);
  }
View Full Code Here

Examples of com.intellij.psi.PsiFileFactory

  }

  @Override
  public PsiElement setName(@NonNls @NotNull String name) {
    ASTNode identifierNode = getNode().findChildByType(MathematicaElementTypes.IDENTIFIER);
    final PsiFileFactory fileFactory = PsiFileFactory.getInstance(getProject());
    final MathematicaPsiFileImpl file = (MathematicaPsiFileImpl) fileFactory.createFileFromText("dummy.m", MathematicaFileType.INSTANCE, name);
    ASTNode newElm = file.getFirstChild().getNode().findChildByType(MathematicaElementTypes.IDENTIFIER);
    if (identifierNode != null && newElm != null) {
      getNode().replaceChild(identifierNode, newElm);
    }
    return this;
View Full Code Here

Examples of com.intellij.psi.PsiFileFactory

        return executeStatement;
    }

    public ExecutablePsiElement getExecutablePsiElement() {
        if (originalPsiElement == null) {
            PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(executionProcessor.getProject());
            PsiFile previewFile = psiFileFactory.createFileFromText("preview", connectionHandler.getLanguageDialect(SQLLanguage.INSTANCE), originalStatement);

            PsiElement firstChild = previewFile.getFirstChild();
            if (firstChild instanceof ExecutableBundlePsiElement) {
                ExecutableBundlePsiElement rootPsiElement = (ExecutableBundlePsiElement) firstChild;
                originalPsiElement = rootPsiElement.getExecutablePsiElements().get(0);
View Full Code Here

Examples of com.intellij.psi.PsiFileFactory

        }
        return originalPsiElement;
    }

    public PsiFile getPreviewFile() {
        PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(executionProcessor.getProject());
        return psiFileFactory.createFileFromText("preview", connectionHandler.getLanguageDialect(SQLLanguage.INSTANCE), executeStatement);
    }
View Full Code Here

Examples of com.intellij.psi.PsiFileFactory

    final PsiFile dummyFile = createDummyFile(myProject, "package " + path + ";");
    return PsiTreeUtil.getChildOfType(dummyFile, HaxePackageStatement.class);
  }

  public static PsiFile createDummyFile(Project myProject, String text) {
    final PsiFileFactory factory = PsiFileFactory.getInstance(myProject);
    final String name = "dummy." + HaxeFileType.HAXE_FILE_TYPE.getDefaultExtension();
    final LightVirtualFile virtualFile = new LightVirtualFile(name, HaxeFileType.HAXE_FILE_TYPE, text);
    final PsiFile psiFile = ((PsiFileFactoryImpl)factory).trySetupPsiForFile(virtualFile, HaxeLanguage.INSTANCE, false, true);
    assert psiFile != null;
    return psiFile;
View Full Code Here

Examples of com.intellij.psi.PsiFileFactory

    public PsiReference findReferenceAt(int offset) {return null;}

    public PsiFile getContainingFile() throws PsiInvalidElementAccessException {
        if (DUMMY_FILE == null) {
            PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(getProject());

            DUMMY_FILE = psiFileFactory.createFileFromText(
                    "object", SQLLanguage.INSTANCE, "");

        }
        return DUMMY_FILE;
    }
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.