@Nullable protected PsiFile createFile(@NotNull Project project, @NotNull VirtualFile file, @NotNull FileType fileType) { if (fileType.isBinary() || file.is(VFileProperty.SPECIAL)) { return new PsiBinaryFileImpl((PsiManagerImpl)getManager(), this); } if (!isTooLargeForIntelligence(file)) { final PsiFile psiFile = createFile(getBaseLanguage()); if (psiFile != null) return psiFile; } if (isTooLargeForContentLoading(file)) { return new PsiLargeFileImpl((PsiManagerImpl)getManager(), this); } return new PsiPlainTextFileImpl(this); }
@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; }
@Override @NotNull public PsiFile createFileFromText(@NotNull String name, @NotNull FileType fileType, @NotNull CharSequence text, long modificationStamp, final boolean physical, 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, physical, markAsCopy); if (file != null) return file; } final SingleRootFileViewProvider singleRootFileViewProvider = new SingleRootFileViewProvider(myManager, virtualFile, physical); final PsiPlainTextFileImpl plainTextFile = new PsiPlainTextFileImpl(singleRootFileViewProvider); if(markAsCopy) CodeEditUtil.setNodeGenerated(plainTextFile.getNode(), true); return plainTextFile; }
@Nullable protected PsiFile createFile(@Nonnull Project project, @Nonnull VirtualFile file, @Nonnull FileType fileType) { if (fileType.isBinary() || file.is(VFileProperty.SPECIAL)) { return SingleRootFileViewProvider.isTooLargeForContentLoading(file) ? new PsiLargeBinaryFileImpl((PsiManagerImpl)getManager(), this) : new PsiBinaryFileImpl((PsiManagerImpl)getManager(), this); } if (!SingleRootFileViewProvider.isTooLargeForIntelligence(file)) { final PsiFile psiFile = createFile(getBaseLanguage()); if (psiFile != null) return psiFile; } if (SingleRootFileViewProvider.isTooLargeForContentLoading(file)) { return new PsiLargeTextFileImpl(this); } return new PsiPlainTextFileImpl(this); }
@Override @Nonnull public PsiFile createFileFromText(@Nonnull String name, @Nonnull FileType fileType, @Nonnull CharSequence text, long modificationStamp, final boolean physical, 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, LanguageVersionUtil.findDefaultVersion(language), physical, markAsCopy); if (file != null) return file; } final SingleRootFileViewProvider singleRootFileViewProvider = new SingleRootFileViewProvider(myManager, virtualFile, physical); final PsiPlainTextFileImpl plainTextFile = new PsiPlainTextFileImpl(singleRootFileViewProvider); if (markAsCopy) CodeEditUtil.setNodeGenerated(plainTextFile.getNode(), true); return plainTextFile; }
@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; }
@Override @RequiredReadAction protected PsiFile createExpressionCodeFragment(@NotNull Project project, @NotNull String text, @Nullable PsiElement context, boolean isPhysical) { if(context == null) { XDebugSession session = mySession; XSourcePosition currentPosition = session == null ? null : session.getCurrentPosition(); if(currentPosition != null) { VirtualFile file = currentPosition.getFile(); PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if(psiFile != null) { context = psiFile.findElementAt(currentPosition.getOffset()); } } } DotNetDebuggerProvider debuggerProvider = context == null ? null : DotNetDebuggerProviders.findByPsiFile(context.getContainingFile()); if(debuggerProvider == null) { LightVirtualFile virtualFile = new LightVirtualFile("test.txt", PlainTextFileType.INSTANCE, text); return new PsiPlainTextFileImpl(new SingleRootFileViewProvider(PsiManager.getInstance(project), virtualFile, true)); } return debuggerProvider.createExpressionCodeFragment(project, context, text, isPhysical); }
@Nonnull public PsiFile createFileFromText(@Nonnull String name, @Nonnull FileType fileType, final Language language, @Nonnull Language targetLanguage, @Nonnull 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; }
@Override public PsiFile createFile(FileViewProvider viewProvider) { return new PsiPlainTextFileImpl(viewProvider); }