Fix line separators insertion
This commit is contained in:
@@ -53,11 +53,12 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String lineSeparator = System.getProperty("line.separator");
|
final PsiElement newLineWhitespace = JetPsiFactory.createWhiteSpace(body.getProject(), "\n");
|
||||||
|
|
||||||
for (DescriptorClassMember selectedElement : selectedElements) {
|
for (DescriptorClassMember selectedElement : selectedElements) {
|
||||||
|
|
||||||
body.addBefore(JetPsiFactory.createWhiteSpace(body.getProject(), lineSeparator + lineSeparator), body.getRBrace());
|
// TODO: Insert spaces should be done by formatter
|
||||||
|
body.addBefore(newLineWhitespace, body.getRBrace());
|
||||||
|
|
||||||
final DeclarationDescriptor descriptor = selectedElement.getDescriptor();
|
final DeclarationDescriptor descriptor = selectedElement.getDescriptor();
|
||||||
if (descriptor instanceof NamedFunctionDescriptor) {
|
if (descriptor instanceof NamedFunctionDescriptor) {
|
||||||
|
|||||||
@@ -47,7 +47,10 @@ public class ImportClassHelper {
|
|||||||
|
|
||||||
JetImportDirective newDirective = JetPsiFactory.createImportDirective(file.getProject(), importString);
|
JetImportDirective newDirective = JetPsiFactory.createImportDirective(file.getProject(), importString);
|
||||||
|
|
||||||
String lineSeparator = System.getProperty("line.separator");
|
// TODO: Should be processed with formatter
|
||||||
|
final PsiElement newLineWhitespace = JetPsiFactory.createWhiteSpace(file.getProject(), "\n");
|
||||||
|
final PsiElement doubleLineWhitespace = JetPsiFactory.createWhiteSpace(file.getProject(), "\n\n");
|
||||||
|
|
||||||
if (!importDirectives.isEmpty()) {
|
if (!importDirectives.isEmpty()) {
|
||||||
|
|
||||||
// Check if import is already present
|
// Check if import is already present
|
||||||
@@ -59,14 +62,14 @@ public class ImportClassHelper {
|
|||||||
|
|
||||||
JetImportDirective lastDirective = importDirectives.get(importDirectives.size() - 1);
|
JetImportDirective lastDirective = importDirectives.get(importDirectives.size() - 1);
|
||||||
lastDirective.getParent().addAfter(newDirective, lastDirective);
|
lastDirective.getParent().addAfter(newDirective, lastDirective);
|
||||||
lastDirective.getParent().addAfter(JetPsiFactory.createWhiteSpace(file.getProject(), lineSeparator), lastDirective);
|
lastDirective.getParent().addAfter(newLineWhitespace, lastDirective);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
List<JetDeclaration> declarations = file.getDeclarations();
|
List<JetDeclaration> declarations = file.getDeclarations();
|
||||||
assert !declarations.isEmpty();
|
assert !declarations.isEmpty();
|
||||||
JetDeclaration firstDeclaration = declarations.iterator().next();
|
JetDeclaration firstDeclaration = declarations.iterator().next();
|
||||||
firstDeclaration.getParent().addBefore(newDirective, firstDeclaration);
|
firstDeclaration.getParent().addBefore(newDirective, firstDeclaration);
|
||||||
firstDeclaration.getParent().addBefore(JetPsiFactory.createWhiteSpace(file.getProject(), lineSeparator + lineSeparator), firstDeclaration);
|
firstDeclaration.getParent().addBefore(doubleLineWhitespace, firstDeclaration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,8 @@ class SomeOther<S> : Some<S> {
|
|||||||
override fun someFoo() {
|
override fun someFoo() {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun someGenericFoo(): S {
|
override fun someGenericFoo(): S {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun someOtherFoo(): Int = 0
|
override fun someOtherFoo(): Int = 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user