to line end comment: trim lines

This commit is contained in:
Anna.Kozlova
2018-07-09 15:03:36 +02:00
parent 83cd49a8f2
commit bf298ef66f
4 changed files with 27 additions and 1 deletions
@@ -53,7 +53,7 @@ public class ChangeToEndOfLineCommentIntention extends Intention {
}
}
final PsiComment newComment =
factory.createCommentFromText("//" + lines[0], parent);
factory.createCommentFromText("//" + lines[0].trim(), parent);
final PsiElement replacedComment = comment.replace(newComment);
codeStyleManager.reformat(replacedComment);
}
@@ -0,0 +1,3 @@
class MyTest {
/* simple end comment<caret> */
}
@@ -0,0 +1,3 @@
class MyTest {
//simple end comment<caret>
}
@@ -0,0 +1,20 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.siyeh.ipp.comment;
import com.siyeh.IntentionPowerPackBundle;
import com.siyeh.ipp.IPPTestCase;
public class ChangeToEndOfLineCommentIntentionTest extends IPPTestCase {
public void testTrimLines() { doTest(); }
@Override
protected String getIntentionName() {
return IntentionPowerPackBundle.message("change.to.end.of.line.comment.intention.name");
}
@Override
protected String getRelativePath() {
return "comment/to_end_of_line";
}
}