Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow quick label change #1733

Merged
merged 9 commits into from
Jan 12, 2021

Conversation

fberlakovich
Copy link
Contributor

Fix #1725

Summary of additions and changes

  • Immediately start a rename refactoring after introducing a label for a command/environment for which no reasonable label name can be inferred

How to test this pull request

  • See the included test cases
  • Invoke the "Add label" quickfix on the environment/command in the following latex document
\begin{document}
    \begin{lstlisting}
    \end{lstlisting}

    \lstinputlisting[lang=test]{test.txt}
\end{document}

@fberlakovich fberlakovich marked this pull request as ready for review January 10, 2021 15:53
Copy link
Member

@HannahSchellekens HannahSchellekens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this :) Looks good! Just one thing:

I get the following crash when I execute the intention in an lstlisting environment.

Write access is allowed inside write-action only java.lang.Throwable:` Assertion failed: Write access is allowed inside write-action only (see com.intellij.openapi.application.Application.runWriteAction()) at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:195) at com.intellij.openapi.application.impl.ApplicationImpl.assertWriteAccessAllowed(ApplicationImpl.java:1311) at com.intellij.openapi.vfs.newvfs.impl.CachedFileType.clearCache(CachedFileType.java:38) at com.intellij.openapi.vfs.newvfs.impl.CachedFileType$PsiListener.modificationCountChanged(CachedFileType.java:49) at jdk.internal.reflect.GeneratedMethodAccessor43.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:652) at com.intellij.util.messages.impl.MessageBusImpl.deliverMessage(MessageBusImpl.java:426) at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:401) at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:383) at com.intellij.util.messages.impl.MessageBusImpl.access$100(MessageBusImpl.java:33) at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:189) at com.sun.proxy.$Proxy38.modificationCountChanged(Unknown Source) at com.intellij.psi.impl.PsiModificationTrackerImpl.fireEvent(PsiModificationTrackerImpl.java:81) at com.intellij.psi.impl.PsiModificationTrackerImpl.incCountersInner(PsiModificationTrackerImpl.java:86) at com.intellij.psi.impl.PsiModificationTrackerImpl.treeChanged(PsiModificationTrackerImpl.java:96) at com.intellij.psi.impl.PsiManagerImpl.fireEvent(PsiManagerImpl.java:338) at com.intellij.psi.impl.PsiManagerImpl.childrenChanged(PsiManagerImpl.java:298) at com.intellij.pom.core.impl.PomModelImpl.sendAfterChildrenChangedEvent(PomModelImpl.java:370) at com.intellij.pom.core.impl.PomModelImpl.commitTransaction(PomModelImpl.java:199) at com.intellij.pom.core.impl.PomModelImpl.lambda$runTransaction$1(PomModelImpl.java:152) at com.intellij.psi.impl.DebugUtil.performPsiModification(DebugUtil.java:567) at com.intellij.pom.core.impl.PomModelImpl.lambda$runTransaction$2(PomModelImpl.java:104) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65) at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:218) at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:93) at com.intellij.psi.impl.source.tree.ChangeUtil.prepareAndRunChangeAction(ChangeUtil.java:142) at com.intellij.psi.impl.source.tree.CompositeElement.addChild(CompositeElement.java:579) at com.intellij.psi.impl.source.tree.CompositeElement.addChildren(CompositeElement.java:673) at com.intellij.psi.impl.source.codeStyle.CodeEditUtil.addChildren(CodeEditUtil.java:53) at com.intellij.extapi.psi.ASTDelegatePsiElement.addInternal(ASTDelegatePsiElement.java:306) at com.intellij.extapi.psi.ASTDelegatePsiElement.addInnerBefore(ASTDelegatePsiElement.java:279) at com.intellij.extapi.psi.ASTDelegatePsiElement.addBefore(ASTDelegatePsiElement.java:273) at nl.hannahsten.texifyidea.psi.LatexPsiHelper.setOptionalParameter(LatexPsiHelper.kt:139) at nl.hannahsten.texifyidea.intentions.LatexAddLabelIntention.createLabelAndStartRename(LatexAddLabelIntention.kt:99) at nl.hannahsten.texifyidea.intentions.LatexAddLabelToEnvironmentIntention.invoke(LatexAddLabelToEnvironmentIntention.kt:48) at com.intellij.codeInsight.intention.impl.config.IntentionActionWrapper.invoke(IntentionActionWrapper.java:66) at com.intellij.codeInsight.intention.impl.IntentionActionWithTextCaching$MyIntentionAction.invoke(IntentionActionWithTextCaching.java:208) at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.invokeIntention(ShowIntentionActionsHandler.java:252) at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.lambda$chooseActionAndInvoke$3(ShowIntentionActionsHandler.java:225) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:220) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:177) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:167) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:153) at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.chooseActionAndInvoke(ShowIntentionActionsHandler.java:224) at com.intellij.codeInsight.intention.impl.IntentionListStep.lambda$applyAction$3(IntentionListStep.java:128) at com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:88) at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2194) at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.java:188) at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.java:140) at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:173) at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.doWhenFocusSettlesDown(IdeFocusManagerImpl.java:36) at com.intellij.codeInsight.intention.impl.IntentionListStep.lambda$applyAction$4(IntentionListStep.java:127) at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:216) at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:24) at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:199) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:822) at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:324) at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:85) at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:134) at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47) at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:190) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:976) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:843) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:454) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:773) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:453) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:822) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:501) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Document: \begin{document} \begin{lstlisting} I \end{lstlisting} \end{document}

@HannahSchellekens HannahSchellekens added the enhancement New feature or (non bug related) change to the program. label Jan 11, 2021
@HannahSchellekens HannahSchellekens added this to the b0.7.3 milestone Jan 11, 2021
Copy link
Collaborator

@PHPirates PHPirates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@PHPirates PHPirates merged commit 17cb4ec into Hannah-Sten:master Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or (non bug related) change to the program.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to quickly change the inserted label of lstlisting and lstinputlisting
3 participants