use of com.intellij.testFramework.LightVirtualFile in project kotlin by JetBrains.
the class KotlinTestUtils method createFile.
@NotNull
public static KtFile 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, KotlinLanguage.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
return (KtFile) factory.trySetupPsiForFile(virtualFile, KotlinLanguage.INSTANCE, true, false);
}
use of com.intellij.testFramework.LightVirtualFile in project kotlin by JetBrains.
the class KtParsingTestCase method createFile.
protected PsiFile createFile(@NonNls String name, String text) {
LightVirtualFile virtualFile = new LightVirtualFile(name, myLanguage, text);
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
return createFile(virtualFile);
}
use of com.intellij.testFramework.LightVirtualFile in project kotlin by JetBrains.
the class TestCheckerUtil method createCheckAndReturnPsiFile.
@NotNull
public static KtFile createCheckAndReturnPsiFile(@NotNull String fileName, @NotNull String text, @NotNull Project project) {
KtFile myFile = KotlinTestUtils.createFile(fileName, text, project);
ensureParsed(myFile);
TestCase.assertEquals("light virtual file text mismatch", text, ((LightVirtualFile) myFile.getVirtualFile()).getContent().toString());
TestCase.assertEquals("virtual file text mismatch", text, LoadTextUtil.loadText(myFile.getVirtualFile()));
//noinspection ConstantConditions
TestCase.assertEquals("doc text mismatch", text, myFile.getViewProvider().getDocument().getText());
TestCase.assertEquals("psi text mismatch", text, myFile.getText());
return myFile;
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class PythonConsoleParsingTest method createFile.
@Override
protected PsiFile createFile(String name, String text) {
LightVirtualFile originalFile = new LightVirtualFile(name, myLanguage, text);
LightVirtualFile virtualFile = new LightVirtualFile(name, myLanguage, text);
virtualFile.setOriginalFile(originalFile);
originalFile.setCharset(CharsetToolkit.UTF8_CHARSET);
originalFile.putUserData(LanguageLevel.KEY, myLanguageLevel);
PyConsoleUtil.markIPython(originalFile);
return createFile(virtualFile);
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class CellOperationTest method testAddCell.
public void testAddCell() throws IOException {
final String fileName = "testData/emptyFile.ipynb";
final String fileText = IpnbTestCase.getFileText(fileName);
final IpnbFile ipnbFile = IpnbParser.parseIpnbFile(fileText, new LightVirtualFile());
ipnbFile.addCell(IpnbCodeCell.createEmptyCodeCell(), ipnbFile.getCells().size());
final IpnbCodeCell cell = (IpnbCodeCell) ipnbFile.getCells().get(ipnbFile.getCells().size() - 1);
assertTrue(cell.getCellOutputs().isEmpty());
assertNull(cell.getPromptNumber());
assertTrue(cell.getMetadata().isEmpty());
}
Aggregations