use of com.intellij.testFramework.LightVirtualFile in project Main by SpartanRefactoring.
the class LeonidasTipper method getPsiTreeFromString.
/**
* @param name the name of the tipper
* @param content the definition file of the tipper
* @return PsiFile representing the file of the tipper
*/
private PsiJavaFile getPsiTreeFromString(String name, String content) {
Language language = JavaLanguage.INSTANCE;
LightVirtualFile virtualFile = new LightVirtualFile(name, language, content);
SingleRootFileViewProvider.doNotCheckFileSizeLimit(virtualFile);
final FileViewProviderFactory factory = LanguageFileViewProviders.INSTANCE.forLanguage(language);
FileViewProvider viewProvider = factory != null ? factory.createFileViewProvider(virtualFile, language, Utils.getPsiManager(Utils.getProject()), true) : null;
if (viewProvider == null)
viewProvider = new SingleRootFileViewProvider(Utils.getPsiManager(ProjectManager.getInstance().getDefaultProject()), virtualFile, true);
language = viewProvider.getBaseLanguage();
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
if (parserDefinition != null) {
return (PsiJavaFile) viewProvider.getPsi(language);
}
return null;
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class PyExpressionCodeFragmentImpl method clone.
protected PyExpressionCodeFragmentImpl clone() {
final PyExpressionCodeFragmentImpl clone = (PyExpressionCodeFragmentImpl) cloneImpl((FileElement) calcTreeElement().clone());
clone.myPhysical = false;
clone.myOriginalFile = this;
FileManager fileManager = ((PsiManagerEx) getManager()).getFileManager();
SingleRootFileViewProvider cloneViewProvider = (SingleRootFileViewProvider) fileManager.createFileViewProvider(new LightVirtualFile(getName(), getLanguage(), getText()), false);
cloneViewProvider.forceCachedPsi(clone);
clone.myViewProvider = cloneViewProvider;
return clone;
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class PyElementGeneratorImpl method createDummyFile.
public PsiFile createDummyFile(LanguageLevel langLevel, String contents, boolean physical) {
final PsiFileFactory factory = PsiFileFactory.getInstance(myProject);
final String name = getDummyFileName();
final LightVirtualFile virtualFile = new LightVirtualFile(name, PythonFileType.INSTANCE, contents);
virtualFile.putUserData(LanguageLevel.KEY, langLevel);
final PsiFile psiFile = ((PsiFileFactoryImpl) factory).trySetupPsiForFile(virtualFile, PythonLanguage.getInstance(), physical, true);
assert psiFile != null;
return psiFile;
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class MavenDomUtil method getVirtualFile.
@Nullable
private static VirtualFile getVirtualFile(PsiFile psiFile) {
if (psiFile == null)
return null;
psiFile = psiFile.getOriginalFile();
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile instanceof LightVirtualFile) {
virtualFile = ObjectUtils.chooseNotNull(psiFile.getUserData(MavenGroovyPomCompletionContributor.ORIGINAL_POM_FILE), virtualFile);
}
return virtualFile;
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class IpnbPyFragment method clone.
protected IpnbPyFragment clone() {
final IpnbPyFragment clone = (IpnbPyFragment) cloneImpl((FileElement) calcTreeElement().clone());
clone.myPhysical = false;
clone.myOriginalFile = this;
FileManager fileManager = ((PsiManagerEx) getManager()).getFileManager();
SingleRootFileViewProvider cloneViewProvider = (SingleRootFileViewProvider) fileManager.createFileViewProvider(new LightVirtualFile(getName(), getLanguage(), getText()), false);
cloneViewProvider.forceCachedPsi(clone);
clone.myViewProvider = cloneViewProvider;
return clone;
}
Aggregations