- changed status to open
Extract constant failing
Issue #2598
open
Trying to extract a constant for a string, inside a private static method.
The constant is added to the file (without the live editing of the name nor replacing the constant usage), though it gets inserted between the @TestVisible
annotation and the existing static field.
2024-07-11 10:20:14,311 [ 96831] INFO - #com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexIntroduceHandler - Introducing constant for project = Project(name=repo, containerState=COMPONENT_CREATED, componentStore=/Users/xander/Documents/RTBA/repo), file = Apex(SendNewTransactionFilesBatch.cls), dataContext = injected:component=EditorComponent file=file:///Users/xander/Documents/RTBA/repo/force-app/main/default/classes/SendNewTransactionFilesBatch.cls
2024-07-11 10:20:14,311 [ 96831] INFO - #com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexIntroduceHandler - Looking for expressions in text range (1804,1811).
2024-07-11 10:20:14,311 [ 96831] INFO - #com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexIntroduceHandler - Found expression for selected text range: ApexLiteralExpressionImpl(LITERAL_EXPRESSION)
2024-07-11 10:20:14,324 [ 96844] INFO - #c.i.p.c.CustomCodeStyleSettings - Loaded org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
2024-07-11 10:20:14,324 [ 96844] INFO - #c.i.p.c.CustomCodeStyleSettings - Loaded org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
2024-07-11 10:20:14,324 [ 96844] INFO - #c.i.p.c.CustomCodeStyleSettings - Loaded com.intellij.psi.codeStyle.JavaCodeStyleSettings
2024-07-11 10:20:14,325 [ 96845] INFO - #c.i.p.c.CommonCodeStyleSettings - Loaded Kotlin common code style settings
2024-07-11 10:20:14,325 [ 96845] INFO - #c.i.p.c.CommonCodeStyleSettings - Loaded Kotlin common code style settings
2024-07-11 10:20:15,506 [ 98026] INFO - STDOUT - 1000
2024-07-11 10:20:15,514 [ 98034] SEVERE - #c.i.i.p.PluginManager - Cannot invoke "com.illuminatedcloud.intellij.apex.psi.ApexDeclaration.getNameIdentifier()" because "<local22>" is null
java.lang.NullPointerException: Cannot invoke "com.illuminatedcloud.intellij.apex.psi.ApexDeclaration.getNameIdentifier()" because "<local22>" is null
at com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexInplaceIntroducer.lambda$createFieldToStartTemplateOn$0(SourceFile:204)
at com.intellij.openapi.application.impl.RwLockHolder.runWriteAction(RwLockHolder.kt:354)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:888)
at com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexInplaceIntroducer.createFieldToStartTemplateOn(SourceFile:144)
at com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexInplaceIntroducer.createFieldToStartTemplateOn(SourceFile:63)
at com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer.lambda$startInplaceIntroduceTemplate$1(AbstractInplaceIntroducer.java:184)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:216)
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.refactoring.introduce.inplace.AbstractInplaceIntroducer.startInplaceIntroduceTemplate(AbstractInplaceIntroducer.java:174)
at com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexInplaceIntroduceHandler$1.pass(SourceFile:46)
at com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexInplaceIntroduceHandler$1.pass(SourceFile:41)
at com.intellij.openapi.util.Pass.accept(Pass.java:18)
at com.intellij.refactoring.introduce.inplace.OccurrencesChooser.showChooser(OccurrencesChooser.java:83)
at com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexInplaceIntroduceHandler.introduceDeclarationFromExpression(SourceFile:40)
at com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexIntroduceHandler.lambda$introduceDeclarationFromExpression$2(SourceFile:300)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:225)
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.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexIntroduceHandler.introduceDeclarationFromExpression(SourceFile:284)
at com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexIntroduceHandler.introduceFromExpression(SourceFile:93)
at com.illuminatedcloud.intellij.apex.refactoring.introduce.AbstractApexIntroduceHandler.invoke(SourceFile:70)
at com.intellij.refactoring.actions.BaseRefactoringAction.performRefactoringAction(BaseRefactoringAction.java:161)
at com.intellij.refactoring.actions.BaseRefactoringAction.actionPerformed(BaseRefactoringAction.java:110)
at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.kt:304)
at com.intellij.openapi.keymap.impl.ActionProcessor.performAction(ActionProcessor.java:32)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$actionProcessor$1.performAction(IdeKeyEventDispatcher.kt:495)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.doPerformActionInner$lambda$4$lambda$3(IdeKeyEventDispatcher.kt:844)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:95)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.doPerformActionInner$lambda$4(IdeKeyEventDispatcher.kt:844)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.performWithActionCallbacks(ActionManagerImpl.kt:1166)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.kt:321)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.doPerformActionInner(IdeKeyEventDispatcher.kt:842)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.access$doPerformActionInner(IdeKeyEventDispatcher.kt:1)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction$intellij_platform_ide_impl(IdeKeyEventDispatcher.kt:571)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.kt:508)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.kt:447)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.kt:440)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.kt:302)
at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.kt:623)
at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$11(IdeEventQueue.kt:585)
at com.intellij.openapi.application.impl.RwLockHolder.runWithEnabledImplicitRead(RwLockHolder.kt:138)
at com.intellij.openapi.application.impl.RwLockHolder.runWithImplicitRead(RwLockHolder.kt:129)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:585)
at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:77)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:362)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:361)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:843)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:361)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:356)
at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1022)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:114)
at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1022)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:356)
at com.intellij.openapi.application.impl.RwLockHolder.runIntendedWriteActionOnCurrentThread(RwLockHolder.kt:209)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:830)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:398)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
2024-07-11 10:20:15,521 [ 98041] SEVERE - #c.i.i.p.PluginManager - IntelliJ IDEA 2024.1.3 Build #IU-241.17890.1
2024-07-11 10:20:15,521 [ 98041] SEVERE - #c.i.i.p.PluginManager - JDK: 17.0.11; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2024-07-11 10:20:15,521 [ 98041] SEVERE - #c.i.i.p.PluginManager - OS: Mac OS X
2024-07-11 10:20:15,521 [ 98041] SEVERE - #c.i.i.p.PluginManager - Plugin to blame: Illuminated Cloud 2 version: 2.3.2.2
2024-07-11 10:20:15,521 [ 98041] SEVERE - #c.i.i.p.PluginManager - Last Action: IntroduceConstant
Comments (1)
-
repo owner - Log in to comment
Xander, can you provide a concrete example that reproduces this? I just tried a few scenarios and none failed, and I was actually just using constant refactoring pretty heavily in one of my own projects without any issues. I'm assuming there's some specific context that leads to this?