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
81cad6fd
Commit
81cad6fd
authored
7 years ago
by
Anna.Kozlova
Browse files
Options
Download
Email Patches
Plain Diff
preserve comments: temp skip comments in imports
parent
aa517015
Branches unavailable
Tags unavailable
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
java/java-tests/testSrc/com/intellij/java/propertyBased/JavaIntentionPolicy.java
+8
-0
.../com/intellij/java/propertyBased/JavaIntentionPolicy.java
platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/IntentionPolicy.java
+5
-0
...intellij/testFramework/propertyBased/IntentionPolicy.java
platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeIntention.java
+3
-2
...intellij/testFramework/propertyBased/InvokeIntention.java
with
16 additions
and
2 deletions
+16
-2
java/java-tests/testSrc/com/intellij/java/propertyBased/JavaIntentionPolicy.java
+
8
-
0
View file @
81cad6fd
...
...
@@ -18,7 +18,10 @@ package com.intellij.java.propertyBased;
import
com.intellij.codeInsight.intention.IntentionAction
;
import
com.intellij.openapi.editor.Editor
;
import
com.intellij.psi.JavaPsiFacade
;
import
com.intellij.psi.PsiComment
;
import
com.intellij.psi.PsiFile
;
import
com.intellij.psi.PsiImportList
;
import
com.intellij.psi.util.PsiTreeUtil
;
import
com.intellij.testFramework.propertyBased.IntentionPolicy
;
import
org.jetbrains.annotations.NotNull
;
...
...
@@ -91,6 +94,11 @@ class JavaCommentingStrategy extends JavaIntentionPolicy {
return
!
commentChangingActions
;
}
@Override
public
boolean
trackComment
(
PsiComment
comment
)
{
return
PsiTreeUtil
.
getParentOfType
(
comment
,
PsiImportList
.
class
)
==
null
;
}
@Override
public
boolean
mayBreakCode
(
@NotNull
IntentionAction
action
,
@NotNull
Editor
editor
,
@NotNull
PsiFile
file
)
{
return
true
;
...
...
This diff is collapsed.
Click to expand it.
platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/IntentionPolicy.java
+
5
-
0
View file @
81cad6fd
...
...
@@ -17,6 +17,7 @@ package com.intellij.testFramework.propertyBased;
import
com.intellij.codeInsight.intention.IntentionAction
;
import
com.intellij.openapi.editor.Editor
;
import
com.intellij.psi.PsiComment
;
import
com.intellij.psi.PsiFile
;
import
org.jetbrains.annotations.NotNull
;
...
...
@@ -57,4 +58,8 @@ public class IntentionPolicy {
public
boolean
checkComments
(
IntentionAction
intention
)
{
return
false
;
}
public
boolean
trackComment
(
PsiComment
comment
)
{
return
true
;
}
}
This diff is collapsed.
Click to expand it.
platform/testFramework/testSrc/com/intellij/testFramework/propertyBased/InvokeIntention.java
+
3
-
2
View file @
81cad6fd
...
...
@@ -34,9 +34,9 @@ import com.intellij.psi.util.PsiUtilBase;
import
com.intellij.testFramework.PsiTestUtil
;
import
com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
;
import
com.intellij.util.containers.ContainerUtil
;
import
org.jetbrains.jetCheck.Generator
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jetCheck.Generator
;
import
java.util.Collection
;
import
java.util.Collections
;
...
...
@@ -144,7 +144,8 @@ public class InvokeIntention extends ActionOnRange {
protected
List
<
String
>
extractCommentsReformattedToSingleWhitespace
(
PsiFile
file
)
{
return
PsiTreeUtil
.
findChildrenOfType
(
file
,
PsiComment
.
class
)
.
stream
().
map
(
comment
->
comment
.
getText
().
replaceAll
(
"[\\s*]+"
,
" "
)).
collect
(
Collectors
.
toList
());
.
stream
()
.
filter
(
comment
->
myPolicy
.
trackComment
(
comment
)).
map
(
comment
->
comment
.
getText
().
replaceAll
(
"[\\s*]+"
,
" "
)).
collect
(
Collectors
.
toList
());
}
private
static
void
checkNoNewErrors
(
Project
project
,
Editor
editor
,
String
intentionString
)
{
...
...
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