Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
498e5b72
Commit
498e5b72
authored
6 years ago
by
Anna Kozlova
Browse files
Options
Download
Email Patches
Plain Diff
keep comments on introduce variable (IDEA-136027)
parent
8c43bb8b
Branches unavailable
Tags unavailable
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
+4
-1
.../refactoring/introduceVariable/IntroduceVariableBase.java
java/java-tests/testData/refactoring/introduceVariable/KeepComments.after.java
+14
-0
...ata/refactoring/introduceVariable/KeepComments.after.java
java/java-tests/testData/refactoring/introduceVariable/KeepComments.java
+16
-0
.../testData/refactoring/introduceVariable/KeepComments.java
java/java-tests/testSrc/com/intellij/java/refactoring/IntroduceVariableTest.java
+4
-0
.../com/intellij/java/refactoring/IntroduceVariableTest.java
with
38 additions
and
1 deletion
+38
-1
java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
+
4
-
1
View file @
498e5b72
...
...
@@ -58,6 +58,7 @@ import com.intellij.util.IncorrectOperationException;
import
com.intellij.util.Processor
;
import
com.intellij.util.containers.ContainerUtil
;
import
com.intellij.util.containers.MultiMap
;
import
com.siyeh.ig.psiutils.CommentTracker
;
import
org.jetbrains.annotations.NonNls
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
...
...
@@ -924,7 +925,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
if
(
lastChild
instanceof
PsiComment
)
{
// keep trailing comment
declaration
.
addBefore
(
lastChild
,
null
);
}
statement
.
delete
();
CommentTracker
commentTracker
=
new
CommentTracker
();
commentTracker
.
markUnchanged
(
initializer
);
commentTracker
.
deleteAndRestoreComments
(
statement
);
if
(
editor
!=
null
)
{
LogicalPosition
pos
=
new
LogicalPosition
(
line
,
col
);
editor
.
getCaretModel
().
moveToLogicalPosition
(
pos
);
...
...
This diff is collapsed.
Click to expand it.
java/java-tests/testData/refactoring/introduceVariable/KeepComments.after.java
0 → 100644
+
14
-
0
View file @
498e5b72
import
java.util.Arrays
;
import
java.util.List
;
class
Main
{
private
static
void
foo
(
String
...
src
){
String
m
=
Arrays
.
asList
(
src
)
//c-2
.
toArray
()
//c-1
.
toString
();
//c1
//c2
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
java/java-tests/testData/refactoring/introduceVariable/KeepComments.java
0 → 100644
+
16
-
0
View file @
498e5b72
import
java.util.Arrays
;
import
java.util.List
;
class
Main
{
private
static
void
foo
(
String
...
src
){
<
selection
>
Arrays
.
asList
(
src
)
//c-2
.
toArray
()
//c-1
.
toString
()</
selection
>
//c1
//c2
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
java/java-tests/testSrc/com/intellij/java/refactoring/IntroduceVariableTest.java
+
4
-
0
View file @
498e5b72
...
...
@@ -539,6 +539,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest
(
new
MockIntroduceVariableHandler
(
"m"
,
false
,
false
,
false
,
"A<? extends A<? extends java.lang.Object>>"
));
}
public
void
testKeepComments
()
{
doTest
(
new
MockIntroduceVariableHandler
(
"m"
,
false
,
false
,
false
,
CommonClassNames
.
JAVA_LANG_STRING
));
}
public
void
testDenotableType2
()
{
doTest
(
new
MockIntroduceVariableHandler
(
"m"
,
false
,
false
,
false
,
"I<? extends I<?>>"
));
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help