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 FileTemplateConfigurable method createHighlighter.
private EditorHighlighter createHighlighter() {
if (myTemplate != null && myVelocityFileType != FileTypes.UNKNOWN) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft"));
}
FileType fileType = null;
if (myTemplate != null) {
fileType = FileTypeManager.getInstance().getFileTypeByExtension(myTemplate.getExtension());
}
if (fileType == null) {
fileType = FileTypes.PLAIN_TEXT;
}
SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null);
if (originalHighlighter == null) {
originalHighlighter = new PlainSyntaxHighlighter();
}
final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
LayeredLexerEditorHighlighter highlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), scheme);
highlighter.registerLayer(FileTemplateTokenType.TEXT, new LayerDescriptor(originalHighlighter, ""));
return highlighter;
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class InjectedLanguageUtil method findInjectionHost.
@Nullable
public static PsiLanguageInjectionHost findInjectionHost(@Nullable PsiElement psi) {
if (psi == null)
return null;
// * formatting
PsiFile containingFile = psi.getContainingFile().getOriginalFile();
// * quick-edit-handler
PsiElement fileContext = containingFile.getContext();
if (fileContext instanceof PsiLanguageInjectionHost)
return (PsiLanguageInjectionHost) fileContext;
// * injection-registrar
Place shreds = getShreds(containingFile.getViewProvider());
if (shreds == null) {
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(containingFile);
if (virtualFile instanceof LightVirtualFile) {
// * dynamic files-from-text
virtualFile = ((LightVirtualFile) virtualFile).getOriginalFile();
}
if (virtualFile instanceof VirtualFileWindow) {
shreds = getShreds(((VirtualFileWindow) virtualFile).getDocumentWindow());
}
}
return shreds != null ? shreds.getHostPointer().getElement() : null;
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class PsiCodeFragmentImpl method clone.
@Override
protected PsiCodeFragmentImpl clone() {
final PsiCodeFragmentImpl clone = (PsiCodeFragmentImpl) cloneImpl((FileElement) calcTreeElement().clone());
clone.myPhysical = false;
clone.myOriginalFile = this;
clone.myPseudoImports = new LinkedHashMap<>(myPseudoImports);
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