use of com.intellij.psi.impl.source.PsiPlainTextFileImpl in project intellij-community by JetBrains.
the class PsiFileFactoryImpl method createFileFromText.
@Override
@NotNull
public PsiFile createFileFromText(@NotNull String name, @NotNull FileType fileType, @NotNull CharSequence text, long modificationStamp, final boolean eventSystemEnabled, boolean markAsCopy) {
final LightVirtualFile virtualFile = new LightVirtualFile(name, fileType, text, modificationStamp);
if (fileType instanceof LanguageFileType) {
final Language language = LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType) fileType).getLanguage(), virtualFile, myManager.getProject());
final PsiFile file = trySetupPsiForFile(virtualFile, language, eventSystemEnabled, markAsCopy);
if (file != null)
return file;
}
final SingleRootFileViewProvider singleRootFileViewProvider = new SingleRootFileViewProvider(myManager, virtualFile, eventSystemEnabled);
final PsiPlainTextFileImpl plainTextFile = new PsiPlainTextFileImpl(singleRootFileViewProvider);
if (markAsCopy)
CodeEditUtil.setNodeGenerated(plainTextFile.getNode(), true);
return plainTextFile;
}
use of com.intellij.psi.impl.source.PsiPlainTextFileImpl in project intellij-community by JetBrains.
the class PsiFileFactoryImpl method createFileFromText.
@NotNull
public PsiFile createFileFromText(@NotNull String name, @NotNull FileType fileType, final Language language, @NotNull Language targetLanguage, @NotNull CharSequence text, long modificationStamp, final boolean physical, boolean markAsCopy) {
final LightVirtualFile virtualFile = new LightVirtualFile(name, fileType, text, modificationStamp);
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
final FileViewProviderFactory factory = LanguageFileViewProviders.INSTANCE.forLanguage(language);
FileViewProvider viewProvider = factory != null ? factory.createFileViewProvider(virtualFile, language, myManager, physical) : null;
if (viewProvider == null)
viewProvider = new SingleRootFileViewProvider(myManager, virtualFile, physical);
if (parserDefinition != null) {
final PsiFile psiFile = viewProvider.getPsi(targetLanguage);
if (psiFile != null) {
if (markAsCopy) {
markGenerated(psiFile);
}
return psiFile;
}
}
final SingleRootFileViewProvider singleRootFileViewProvider = new SingleRootFileViewProvider(myManager, virtualFile, physical);
final PsiPlainTextFileImpl plainTextFile = new PsiPlainTextFileImpl(singleRootFileViewProvider);
if (markAsCopy)
CodeEditUtil.setNodeGenerated(plainTextFile.getNode(), true);
return plainTextFile;
}
Aggregations