Fixed formatting problem + other way of creating returns

This commit is contained in:
Valentin Kipyatkov
2015-05-10 11:07:29 +03:00
parent 386be4bd10
commit ed595aab27
2 changed files with 4 additions and 5 deletions
@@ -63,7 +63,8 @@ public class JetPsiFactory(private val project: Project) {
}
public fun createExpression(text: String): JetExpression {
return createProperty("val x = $text").getInitializer() ?: error("Failed to create expression from text: '$text'")
//TODO: '\n' below if important - some strange code indenting problems appear without it
return createProperty("val x =\n$text").getInitializer() ?: error("Failed to create expression from text: '$text'")
}
public fun createClassLiteral(className: String): JetClassLiteralExpression =
@@ -345,8 +346,8 @@ public class JetPsiFactory(private val project: Project) {
return createExpression("return $text") as JetReturnExpression
}
public fun createReturn(expression: JetExpression?): JetReturnExpression {
return createReturn(JetPsiUtil.getText(expression))
public fun createReturn(expression: JetExpression): JetReturnExpression {
return createExpressionByPattern("return $0", expression) as JetReturnExpression
}
public fun createIf(condition: JetExpression, thenExpr: JetExpression, elseExpr: JetExpression?): JetIfExpression {
@@ -20,7 +20,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
@@ -74,7 +73,6 @@ public class DeclarationUtils {
Project project = newInitializer.getProject();
PsiFile file = parent.getContainingFile();
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(PsiDocumentManager.getInstance(project).getDocument(file));
CodeStyleManager.getInstance(project).adjustLineIndent(file, newInitializer.getTextRange());
//noinspection ConstantConditions
JetType inferredType = getPropertyTypeIfNeeded(property);