From 4b5eaccb9486ab6e6bc367f6f6a01c00437fdb8c Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Mon, 14 Jan 2013 18:11:07 +0400 Subject: [PATCH] Load physical files from tests --- .../src/org/jetbrains/jet/lang/psi/JetPsiFactory.java | 6 ++++++ compiler/tests/org/jetbrains/jet/JetTestUtils.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java index 5ff2cfdf1ae..126a7cc9126 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java @@ -100,6 +100,12 @@ public class JetPsiFactory { LocalTimeCounter.currentTime(), false); } + @NotNull + public static JetFile createPhysicalFile(Project project, String fileName, String text) { + return (JetFile) PsiFileFactory.getInstance(project).createFileFromText(fileName, JetFileType.INSTANCE, text, + LocalTimeCounter.currentTime(), true); + } + public static JetProperty createProperty(Project project, String name, String type, boolean isVar, @Nullable String initializer) { String text = (isVar ? "var " : "val ") + name + (type != null ? ":" + type : "") + (initializer == null ? "" : " = " + initializer); return createProperty(project, text); diff --git a/compiler/tests/org/jetbrains/jet/JetTestUtils.java b/compiler/tests/org/jetbrains/jet/JetTestUtils.java index 59f71052a48..002e7483f4d 100644 --- a/compiler/tests/org/jetbrains/jet/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/jet/JetTestUtils.java @@ -547,6 +547,6 @@ public class JetTestUtils { public static JetFile loadJetFile(@NotNull Project project, @NotNull File ioFile) throws IOException { String text = FileUtil.loadFile(ioFile); - return JetPsiFactory.createFile(project, text); + return JetPsiFactory.createPhysicalFile(project, ioFile.getName(), text); } }