/** * Checks if it is possible to rename the element to the specified name, * and throws an exception if the rename is not possible. Does not actually modify anything. * * @param name the new name to check the renaming possibility for. * @throws IncorrectOperationException if the rename is not supported or not possible for some reason. */ @Override public void checkSetName(String name) throws IncorrectOperationException { throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE); }
@Override protected void run() throws Throwable { try { PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile.getParent()); assert psiDirectory != null; PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(psiDirectory); String packageName = aPackage == null ? null : aPackage.getQualifiedName(); String text = generateLexerText(bnfFile, packageName); VfsUtil.saveText(virtualFile, text); Notifications.Bus.notify(new Notification(BnfConstants.GENERATION_GROUP, virtualFile.getName() + " generated", "to " + virtualFile.getParent().getPath(), NotificationType.INFORMATION), project); associateFileTypeAndNavigate(project, virtualFile); } catch (final IncorrectOperationException e) { ApplicationManager.getApplication().invokeLater( () -> Messages.showErrorDialog(project, "Unable to create file " + flexFileName + "\n" + e.getLocalizedMessage(), "Create JFlex Lexer")); } } }.execute();
@Override protected void run(Result result) throws Throwable { IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace(); PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory(); PsiJavaCodeReferenceElement ref = baseClass == null ? null : elementFactory.createReferenceElementByFQClassName( baseClass, GlobalSearchScope.allScope(project)); try { PsiClass resultClass = JavaDirectoryService.getInstance().createClass(targetDirectory, className); resultRef.set(resultClass); if (ref != null) { PsiElement baseClass = ref.resolve(); boolean isInterface = baseClass instanceof PsiClass && ((PsiClass) baseClass).isInterface(); PsiReferenceList targetReferenceList = isInterface ? resultClass.getImplementsList() : resultClass.getExtendsList(); assert targetReferenceList != null; targetReferenceList.add(ref); } if (consumer != null) { consumer.consume(resultClass); } } catch (final IncorrectOperationException e) { ApplicationManager.getApplication().invokeLater( () -> Messages.showErrorDialog(project, "Unable to create class " + className + "\n" + e.getLocalizedMessage(), title)); } } }.execute();
@NotNull @Override public Shortcut[] getShortcut() { throw new IncorrectOperationException("see getActionIdForShortcut()"); }
/** * Renames the element. * * @param name the new element name. * @return the element corresponding to this element after the rename (either <code>this</code> * or a different element if the rename caused the element to be replaced). * @throws IncorrectOperationException if the modification is not supported or not possible for some reason. */ @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { throw new IncorrectOperationException("Cannot modify module name in Beam files"); }
/** * Renames the element. * * @param name the new element name. * @return the element corresponding to this element after the rename (either <code>this</code> * or a different element if the rename caused the element to be replaced). * @throws IncorrectOperationException if the modification is not supported or not possible for some reason. */ @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE); }
/** * Renames the element. * * @param name the new element name. * @return the element corresponding to this element after the rename (either <code>this</code> * or a different element if the rename caused the element to be replaced). * @throws IncorrectOperationException if the modification is not supported or not possible for some reason. */ @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { throw new IncorrectOperationException("Cannot modify module name in Beam files"); }
throw new IncorrectOperationException("Cannot invoke fix with ambiguous imports on editor ()" + editor + ". Packages: " + packages);
@Override public boolean isXSub() { throw new IncorrectOperationException(); } }
@Override protected void modifyRoots(VirtualFile file, ContentEntry entry) { throw new IncorrectOperationException(); }
@Override public boolean isStatic() { throw new IncorrectOperationException(); }
@Override public boolean isMethod() { throw new IncorrectOperationException(); }
@Nullable @Override public PerlNamespaceElement getNamespaceElement() { throw new IncorrectOperationException("should not"); }
@Override public final PerlSubDefinitionElement createPsi(@NotNull PerlSubDefinitionStub stub) { throw new IncorrectOperationException("Light elements should be created by wrappers, not element types"); }
@NotNull @Override public Shortcut[] getShortcut() { throw new IncorrectOperationException("see getActionIdForShortcut()"); }
@Override public BashKeyword handleContentChange(@NotNull BashKeyword element, String newContent) throws IncorrectOperationException { throw new IncorrectOperationException(); }
@Override public final PerlNamespaceDefinitionElement createPsi(@NotNull PerlNamespaceDefinitionStub stub) { throw new IncorrectOperationException("Light elements should be created by wrappers, not element types"); }
@Nullable @Override public <E extends PsiElement> E getParentStubOfType(@NotNull Class<E> parentClass) { throw new IncorrectOperationException("NYI"); }
@NotNull @Override public List<Sdk> getSdksOfType(@NotNull SdkTypeId type) { throw new IncorrectOperationException(); }
@Nullable @Override public <E extends PsiElement> E getParentStubOfType(@NotNull Class<E> parentClass) { throw new IncorrectOperationException("NYI"); }