use of com.intellij.testFramework.LightVirtualFile in project intellij-plugins by JetBrains.
the class LiveObjectsNode method getNavigatable.
@Override
public Navigatable getNavigatable() {
if (navigatableCache == null) {
final VirtualFile virtualFile = new LightVirtualFile(runConfigurationName, new LiveObjectsFileType(), "") {
@NotNull
@Override
public String getPath() {
return getName();
}
};
virtualFile.putUserData(ProfileData.CONTROLLER, liveModelController);
virtualFile.putUserData(ProfileData.PROFILING_MANAGER, profilingManager);
navigatableCache = new OpenFileDescriptor(module.getProject(), virtualFile);
}
return navigatableCache;
}
use of com.intellij.testFramework.LightVirtualFile in project smali by JesusFreke.
the class LightCodeInsightParsingTestCase method doTest.
protected void doTest(boolean checkResult) {
String name = getTestName(false);
try {
String text = loadFile(name + "." + myFileExt);
PsiFile f = createPsiFile(name, text);
if (f instanceof PsiFileImpl) {
// Also want to test stub serialization/deserialization
StubTree stubTree = ((PsiFileImpl) f).calcStubTree();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SerializationManagerImpl.getInstanceEx().serialize(stubTree.getRoot(), baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
SerializationManagerImpl.getInstanceEx().deserialize(bais);
}
ensureParsed(f);
assertEquals("light virtual file text mismatch", text, ((LightVirtualFile) f.getVirtualFile()).getContent().toString());
assertEquals("virtual file text mismatch", text, LoadTextUtil.loadText(f.getVirtualFile()));
assertEquals("doc text mismatch", text, f.getViewProvider().getDocument().getText());
assertEquals("psi text mismatch", text, f.getText());
if (checkResult) {
checkResult(name, f);
} else {
toParseTreeText(f, skipSpaces(), includeRanges());
}
} catch (IOException e) {
throw new RuntimeException(e);
} catch (SerializerNotFoundException e) {
throw new RuntimeException(e);
}
}
use of com.intellij.testFramework.LightVirtualFile in project smali by JesusFreke.
the class LightCodeInsightParsingTestCase 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 intellij-plugins by JetBrains.
the class LibraryUtil method getTestGlobalLibrary.
@TestOnly
static // we cannot use LocalFileSystem, because our test can run outside the idea
VirtualFile getTestGlobalLibrary(boolean isPlayer) {
String name = (isPlayer ? "player" : "air") + "-catalog.xml";
File file = new File(DebugPathManager.getTestDataPath() + "/lib/playerglobal", name);
assert file.exists();
try {
return new LightVirtualFile(name, XmlFileType.INSTANCE, IOUtil.getCharSequence(file), StandardCharsets.UTF_8, 0);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class PerFileMappingsBase method getMappingInner.
@Nullable
protected T getMappingInner(@Nullable VirtualFile file, @Nullable Map<VirtualFile, T> mappings, @Nullable Key<T> pusherKey) {
if (file instanceof VirtualFileWindow) {
final VirtualFileWindow window = (VirtualFileWindow) file;
file = window.getDelegate();
}
VirtualFile originalFile = file instanceof LightVirtualFile ? ((LightVirtualFile) file).getOriginalFile() : null;
if (Comparing.equal(originalFile, file))
originalFile = null;
if (file != null) {
final T pushedValue = pusherKey == null ? null : file.getUserData(pusherKey);
if (pushedValue != null)
return pushedValue;
}
if (originalFile != null) {
final T pushedValue = pusherKey == null ? null : originalFile.getUserData(pusherKey);
if (pushedValue != null)
return pushedValue;
}
if (mappings == null)
return null;
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (mappings) {
T t = getMappingForHierarchy(file, mappings);
if (t != null)
return t;
t = getMappingForHierarchy(originalFile, mappings);
if (t != null)
return t;
Project project = getProject();
if (project == null || file == null || file.getFileSystem() instanceof NonPhysicalFileSystem || ProjectFileIndex.getInstance(project).isInContent(file)) {
return mappings.get(null);
}
return null;
}
}
Aggregations