Return short name in test LightVirtualFile.getName()

This commit is contained in:
Michael Bogdanov
2015-02-16 18:30:23 +03:00
parent 50c9c93f37
commit 7f788f86fe
2 changed files with 19 additions and 7 deletions
@@ -363,8 +363,18 @@ public class JetTestUtils {
}
@NotNull
public static JetFile createFile(@NotNull @NonNls String name, @NotNull String text, @NotNull Project project) {
LightVirtualFile virtualFile = new LightVirtualFile(name, JetLanguage.INSTANCE, text);
public static JetFile createFile(@NotNull @NonNls final String name, @NotNull String text, @NotNull Project project) {
String shortName = name.substring(name.lastIndexOf('/') + 1);
shortName = shortName.substring(shortName.lastIndexOf('\\') + 1);
LightVirtualFile virtualFile = new LightVirtualFile(shortName, JetLanguage.INSTANCE, text) {
@NotNull
@Override
public String getPath() {
//TODO: patch LightVirtualFile
return "/" + name;
}
};
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
PsiFileFactoryImpl factory = (PsiFileFactoryImpl) PsiFileFactory.getInstance(project);
//noinspection ConstantConditions