You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.intellij.test.examples;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@Mapper
public interface SimpleMapper {
- @Mapping(source = "name", target = "testName<caret>")+ @Mapping(source = "name", target = "newName<caret>")
Target map(Source source);
class Source {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
class Target {
private String testName;
public String getTestName() {
return testName;
}
- public Target(String testName) {- this.testName = testName;+ public Target(String newName) {+ this.testName = newName;
}
}
}
Actual result
java.lang.Throwable: file: PsiJavaFile:RenameConstructorTargetParameter.java container: RangeMarker(729,809) 6 markers: [[testName]336, 344], [[testName]750, 758], [[testName]790, 798]
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:182)
at com.intellij.codeInsight.template.TemplateBuilderImpl.initTemplate(TemplateBuilderImpl.java:212)
at com.intellij.codeInsight.template.TemplateBuilderImpl.buildTemplate(TemplateBuilderImpl.java:202)
at com.intellij.codeInsight.template.TemplateBuilderImpl.buildInlineTemplate(TemplateBuilderImpl.java:179)
at com.intellij.refactoring.rename.inplace.InplaceRefactoring.startTemplate(InplaceRefactoring.java:412)
at com.intellij.refactoring.rename.inplace.InplaceRefactoring.lambda$buildTemplateAndStart$0(InplaceRefactoring.java:360)
at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$1(WriteCommandAction.java:143)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:936)
at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$2(WriteCommandAction.java:141)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:216)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:182)
at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.doRunWriteCommandAction(WriteCommandAction.java:150)
at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.run(WriteCommandAction.java:117)
at com.intellij.refactoring.rename.inplace.InplaceRefactoring.buildTemplateAndStart(InplaceRefactoring.java:360)
at com.intellij.refactoring.rename.inplace.VariableInplaceRenamer.buildTemplateAndStart(VariableInplaceRenamer.java:116)
at com.intellij.refactoring.rename.inplace.InplaceRefactoring.performInplaceRefactoring(InplaceRefactoring.java:211)
at com.intellij.refactoring.rename.inplace.VariableInplaceRenamer.performInplaceRename(VariableInplaceRenamer.java:91)
at com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler.doRename(VariableInplaceRenameHandler.java:119)
Actually, I don't think VariableInplaceRenameHandler should be called. We have MapstructSourceTargetParameterRenameHandler, but it just handles PsiMethod so it was passed.
But changing it to accept PsiParameter also does not fix the problem:
VariableInplaceRenameHandler is not disabled so there are two choices for the rename.
Renaming by selecting custom handler only changes the name of the constructor parameter, not the target string literal.
Thanks for reporting this @KENNYSOFT. I'll need to investigate how to hide the VariableInplaceRenameHandler, I remember needing to do something similar for the method one
This is actually the same as #46, which I just remember that I was trying to fix at some point, but without much success. I'll close this so that we can use #46 for fixing this.
testData/rename/RenamingConstructorTargetParameter.java & RenamingConstructorTargetParameterAfter.java
Expected behavior
Actual result
Actually, I don't think
VariableInplaceRenameHandler
should be called. We haveMapstructSourceTargetParameterRenameHandler
, but it just handlesPsiMethod
so it was passed.But changing it to accept
PsiParameter
also does not fix the problem:VariableInplaceRenameHandler
is not disabled so there are two choices for the rename.target
string literal.testData/usages/RenameConstructorTargetReference.java & RenameConstructorTargetReferenceAfter.java
Expected behavior
Actual result
Renaming only changes the name of the constructor parameter, not the
target
string literal.The text was updated successfully, but these errors were encountered: