@Override public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @Nullable("is null when called from inspection") Editor editor, @NotNull PsiElement element, @NotNull PsiElement end) throws IncorrectOperationException { PsiElement parent = element.getParent(); if (!(parent instanceof JSNewExpression)) return; final JSExpressionCodeFragment useStrict = JSElementFactory.createExpressionCodeFragment(project, getNewExp(), parent); PsiElement child = useStrict.getFirstChild(); parent.replace(child); }
public static Document createDocument(final String text, final Project project, @Nullable VirtualFile contextVirtualFile, int contextOffset) { PsiElement context = null; if(contextVirtualFile != null) { context = getContextElement(contextVirtualFile, contextOffset, project); } JSFile file = JSElementFactory.createExpressionCodeFragment(project, text, context, true); return PsiDocumentManager.getInstance(project).getDocument(file); }
@Override protected PsiFile createExpressionCodeFragment(@NotNull Project project, @NotNull String text, @Nullable PsiElement element, boolean isPhysical) { return JSElementFactory.createExpressionCodeFragment(project, text, element, isPhysical); }