Load physical files from tests

This commit is contained in:
Andrey Breslav
2013-01-14 18:11:07 +04:00
parent 7668141f85
commit 4b5eaccb94
2 changed files with 7 additions and 1 deletions
@@ -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);
@@ -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);
}
}