Package com.intellij.psi.codeStyle

Examples of com.intellij.psi.codeStyle.CodeStyleManager.reformat()


  public TextRange surroundElements(@NotNull final Project project, @NotNull final Editor editor, final Expression element) throws IncorrectOperationException {
    MathematicaPsiElementFactory factory = new MathematicaPsiElementFactory(project);
    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);

    Expression parExpr = factory.createExpressionFromText(myOpener + element.getText() + myCloser);
    parExpr = (Expression) codeStyleManager.reformat(parExpr);
    final PsiElement replace = element.replace(parExpr);
    return TextRange.from(replace.getTextOffset() + replace.getTextLength(), 0);
  }

  @Override
View Full Code Here


    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]);

    final List<PsiElement> arguments = MathematicaPsiUtilities.getArguments(newElement);
    if (arguments.isEmpty()) {
      return null;
View Full Code Here

        PsiFileFactory fileFactory = PsiFileFactory.getInstance( directory.getProject() );
        PsiFile file = fileFactory.createFileFromText( fileName, text );

        // Reformat the file according to project/default style
        CodeStyleManager codeStyleManager = CodeStyleManager.getInstance( psiManager );
        codeStyleManager.reformat( file );

        // Add newly created file to directory
        return (PsiFile) directory.add( file );
    }
}
View Full Code Here

                                                                   actionClass);

      final JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(project);
      actionMethod = (PsiMethod) javaCodeStyleManager.shortenClassReferences(actionMethod);
      final CodeStyleManager codestylemanager = CodeStyleManager.getInstance(project);
      actionMethod = (PsiMethod) codestylemanager.reformat(actionMethod);

      final PsiMethod element = (PsiMethod) actionClass.add(actionMethod);

      //noinspection ConstantConditions
      OpenSourceUtil.navigate((Navigatable) element.getBody().getNavigationElement());
View Full Code Here

      if (newVariable != null) {
        final GherkinScenarioOutline scenario = PsiTreeUtil.getParentOfType(newVariable, GherkinScenarioOutline.class);

        if (scenario != null) {
          final CodeStyleManager csManager = CodeStyleManager.getInstance(newVariable.getProject());
          csManager.reformat(scenario);
        }
      }
    }
  }
}
View Full Code Here

      buffer.append("=");
      buffer.append(parameterName);
      buffer.append(";\n}");
      PsiCodeBlock body = factory.createCodeBlockFromText(buffer.toString(), null);
      setMethod.getBody().replace(body);
      setMethod = (PsiMethod)codeStyleManager.reformat(setMethod);
      return setMethod;
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
      return null;
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.