@Override public boolean shouldInspect(@NotNull PsiElement psiRoot) { if (ApplicationManager.getApplication().isUnitTestMode()) return true; final FileHighlightingSetting settingForRoot = getHighlightingSettingForRoot(psiRoot); if (settingForRoot == FileHighlightingSetting.SKIP_HIGHLIGHTING || settingForRoot == FileHighlightingSetting.SKIP_INSPECTION) { return false; } final Project project = psiRoot.getProject(); final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false; return !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile); }
public static boolean shouldInspect(@NotNull PsiElement psiRoot) { if (ApplicationManager.getApplication().isUnitTestMode()) return true; if (!shouldHighlight(psiRoot)) return false; final Project project = psiRoot.getProject(); final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false; if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false; final HighlightingSettingsPerFile component = HighlightingSettingsPerFile.getInstance(project); if (component == null) return true; final FileHighlightingSetting settingForRoot = component.getHighlightingSettingForRoot(psiRoot); return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION; }
@NotNull public static CSharpFragmentFileImpl createExpressionFragment(Project project, String text, @Nullable final PsiElement context) { LightVirtualFile virtualFile = new LightVirtualFile("dummy.cs", CSharpFileType.INSTANCE, text, System.currentTimeMillis()); SingleRootFileViewProvider viewProvider = new SingleRootFileViewProvider(PsiManager.getInstance(project), virtualFile, true) { @NotNull @Override public SingleRootFileViewProvider createCopy(@NotNull final VirtualFile copy) { SingleRootFileViewProvider provider = new SingleRootFileViewProvider(getManager(), copy, false); CSharpFragmentFileImpl psiFile = new CSharpFragmentFileImpl(ourExpressionFileElementType, ourExpressionFileElementType, provider, context); provider.forceCachedPsi(psiFile); psiFile.getNode(); return provider; } }; CSharpFragmentFileImpl file = new CSharpFragmentFileImpl(ourExpressionFileElementType, ourExpressionFileElementType, viewProvider, context); viewProvider.forceCachedPsi(file); file.getNode(); return file; }
public HaxeExpressionCodeFragmentImpl(Project project, @NonNls String name, CharSequence text, boolean isPhysical) { super(new SingleRootFileViewProvider(PsiManager.getInstance(project), new LightVirtualFile(name, FileTypeManager.getInstance().getFileTypeByFileName(name), text), isPhysical) { @Override public boolean supportsIncrementalReparse(@NotNull Language rootLanguage) { return false; } }); myPhysical = isPhysical; ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this); final MyHaxeFileElementType type = new MyHaxeFileElementType(); init(type, type); }
public HaxeExpressionCodeFragmentImpl(Project project, @NonNls String name, CharSequence text, boolean isPhysical) { super(new SingleRootFileViewProvider(PsiManager.getInstance(project), new LightVirtualFile(name, FileTypeManager.getInstance().getFileTypeByFileName(name), text), isPhysical) { @Override public boolean supportsIncrementalReparse(@NotNull Language rootLanguage) { return false; } }); myPhysical = isPhysical; ((SingleRootFileViewProvider) getViewProvider()).forceCachedPsi(this); final MyHaxeFileElementType type = new MyHaxeFileElementType(); init(type, type); }
@Override public boolean shouldInspect(@Nonnull PsiElement psiRoot) { if (ApplicationManager.getApplication().isUnitTestMode()) return true; if (!shouldHighlight(psiRoot)) return false; final Project project = psiRoot.getProject(); final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false; if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false; final FileHighlightingSetting settingForRoot = getHighlightingSettingForRoot(psiRoot); return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION; }
public static boolean shouldInspect(@Nonnull PsiElement psiRoot) { if (ApplicationManager.getApplication().isUnitTestMode()) return true; if (!shouldHighlight(psiRoot)) return false; final Project project = psiRoot.getProject(); final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return false; if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false; if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false; final HighlightingSettingsPerFile component = HighlightingSettingsPerFile.getInstance(project); if (component == null) return true; final FileHighlightingSetting settingForRoot = component.getHighlightingSettingForRoot(psiRoot); return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION; }
protected PsiFile createPsiFileFromSource(final Language language, CharSequence sourceCode, PsiManager manager) { @NonNls final LightVirtualFile virtualFile = new LightVirtualFile("foo", createTemplateFakeFileType(language), sourceCode, LocalTimeCounter.currentTime()); FileViewProvider viewProvider = new SingleRootFileViewProvider(manager, virtualFile, false) { @Override @Nonnull public Language getBaseLanguage() { return language; } }; // Since we're already inside a template language PSI that was built regardless of the file size (for whatever reason), // there should also be no file size checks for template data files. SingleRootFileViewProvider.doNotCheckFileSizeLimit(virtualFile); return viewProvider.getPsi(language); }
public LuaCodeFragment(Project project, IElementType contentElementType, boolean isPhysical, @NonNls String name, CharSequence text, @Nullable PsiElement context) { super(TokenType.CODE_FRAGMENT, contentElementType, PsiManagerEx.getInstanceEx(project).getFileManager().createFileViewProvider( new LightVirtualFile(name, FileTypeManager.getInstance().getFileTypeByFileName(name), text), isPhysical) ); setContext(context); ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this); }
private static boolean isDetectable(@NotNull final VirtualFile file) { if (file.isDirectory() || !file.isValid() || file.is(VFileProperty.SPECIAL) || file.getLength() == 0) { // for empty file there is still hope its type will change return false; } return file.getFileSystem() instanceof FileSystemInterface && !SingleRootFileViewProvider.isTooLargeForContentLoading(file); }
public PyExpressionCodeFragmentImpl(Project project, @NonNls String name, CharSequence text, boolean isPhysical) { super(((PsiManagerEx)PsiManager.getInstance(project)).getFileManager().createFileViewProvider( new LightVirtualFile(name, FileTypeManager.getInstance().getFileTypeByFileName(name), text), isPhysical) ); myPhysical = isPhysical; ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this); }
public PyExpressionCodeFragment(@NotNull final Project project, @NonNls final String name, @NotNull final CharSequence text) { super(((PsiManagerEx)PsiManager.getInstance(project)).getFileManager().createFileViewProvider( new LightVirtualFile(name, PythonFileType.INSTANCE, text), true)); ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this); }
@Override public boolean accept(@NotNull Project project, @NotNull VirtualFile file) { if (file.isDirectory() || !file.isValid()) { return false; } if (SingleRootFileViewProvider.isTooLargeForContentLoading(file)) { return false; } final FileType ft = file.getFileType(); return !ft.isBinary() || BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null; }
protected PsiFile createFromText(final Language language, CharSequence text, PsiManager manager) { @NonNls final LightVirtualFile virtualFile = new LightVirtualFile("foo", createTemplateFakeFileType(language), text, LocalTimeCounter.currentTime()); FileViewProvider viewProvider = new SingleRootFileViewProvider(manager, virtualFile, false) { @Override @NotNull public Language getBaseLanguage() { return language; } }; return viewProvider.getPsi(language); }
@NotNull @Override @RequiredReadAction public PsiFile transform(String fileName, @NotNull MsilFile msilFile) { DotNetNamedElement[] members = msilFile.getMembers(); StringBuilder builder = new StringBuilder(); for(DotNetNamedElement member : members) { JavaClassStubBuilder build = StubBuilder.build((DotNetTypeDeclaration) member); if(build == null) { continue; } build.buildToText(builder, null); builder.append("\n"); } VirtualFile virtualFile = new MsilFileRepresentationVirtualFile(fileName, JavaFileType.INSTANCE, builder); SingleRootFileViewProvider viewProvider = new SingleRootFileViewProvider(PsiManager.getInstance(msilFile.getProject()), virtualFile, true); final PsiJavaFileImpl file = new PsiJavaFileImpl(viewProvider); viewProvider.forceCachedPsi(file); ((PsiManagerEx) PsiManager.getInstance(msilFile.getProject())).getFileManager().setViewProvider(virtualFile, viewProvider); new WriteCommandAction.Simple<Object>(file.getProject(), file) { @Override protected void run() throws Throwable { CodeStyleManager.getInstance(getProject()).reformat(file); } }.execute(); return file; }
@RequiredReadAction private static <T extends PsiElement> T parseFile(CharSequence text, Project project, Class<T> clazz, IElementType elementType) { LightVirtualFile virtualFile = new LightVirtualFile("dummy.cs", CSharpFileType.INSTANCE, text, System.currentTimeMillis()); SingleRootFileViewProvider viewProvider = new SingleRootFileViewProvider(PsiManager.getInstance(project), virtualFile, false); PsiFileBase file = new PsiFileBase(viewProvider, CSharpLanguage.INSTANCE) { { init(elementType, elementType); } }; return PsiTreeUtil.findChildOfType(file, clazz); }
@NotNull public static CSharpFragmentFileImpl createTypeFragment(Project project, String text, @Nullable final PsiElement context) { LightVirtualFile virtualFile = new LightVirtualFile("dummy.cs", CSharpFileType.INSTANCE, text, System.currentTimeMillis()); SingleRootFileViewProvider viewProvider = new SingleRootFileViewProvider(PsiManager.getInstance(project), virtualFile, true); CSharpFragmentFileImpl file = new CSharpFragmentFileImpl(ourTypeFileElementType, ourTypeFileElementType, viewProvider, context); viewProvider.forceCachedPsi(file); file.getNode(); return file; }
@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); }
private static boolean isDetectable(@Nonnull final VirtualFile file) { if (file.isDirectory() || !file.isValid() || file.is(VFileProperty.SPECIAL) || file.getLength() == 0) { // for empty file there is still hope its type will change return false; } return file.getFileSystem() instanceof FileSystemInterface && !SingleRootFileViewProvider.isTooLargeForContentLoading(file); }
public JSExpressionCodeFragmentImpl(Project project, @NonNls String name, CharSequence text, boolean isPhysical) { super(((PsiManagerEx) PsiManager.getInstance(project)).getFileManager().createFileViewProvider(new LightVirtualFile(name, FileTypeManager.getInstance().getFileTypeByFileName(name), text), isPhysical)); myPhysical = isPhysical; ((SingleRootFileViewProvider) getViewProvider()).forceCachedPsi(this); }
@Override public boolean accept(@NotNull Project project, @NotNull VirtualFile file) { return isTextFile(file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file); }
@Override public boolean accept(@NotNull Project project, @NotNull VirtualFile file) { return TextEditorProvider.isTextFile(file) && SingleRootFileViewProvider.isTooLargeForContentLoading(file); }
@Override @NotNull public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final boolean eventSystemEnabled) { return new SingleRootFileViewProvider(myManager, file, eventSystemEnabled); }
@Override protected FileViewProvider create(VirtualFile key) { return new SingleRootFileViewProvider(myManager, key); }
@Override @NotNull public FileViewProvider createFileViewProvider(@NotNull VirtualFile file, boolean eventSystemEnabled) { return new SingleRootFileViewProvider(myManager, file, eventSystemEnabled); }
private boolean isTooLarge(@NotNull VirtualFile file) { if (SingleRootFileViewProvider.isTooLargeForIntelligence(file)) { return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file); } return false; }
private boolean isTooLarge(@NotNull VirtualFile file, long contentSize) { if (SingleRootFileViewProvider.isTooLargeForIntelligence(file, contentSize)) { return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file, contentSize); } return false; }
public TheRCodeFragment(@NotNull final Project project, @NotNull final String name, @NotNull final String text) { super(createLightVirtualFileViewProvider(project, name, text)); ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this); }
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) { if (file.isDirectory() || !file.isValid()) { return false; } return SingleRootFileViewProvider.isTooLargeForContentLoading(file); }
@Override @NotNull public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final boolean physical) { return new SingleRootFileViewProvider(myManager, file, physical); }
@Override protected FileViewProvider create(final VirtualFile key) { return new SingleRootFileViewProvider(myManager, key); }
private static CSharpFileImpl createTypeDeclarationWithScope(Project project, CharSequence text) { LightVirtualFile virtualFile = new LightVirtualFile("dummy.cs", CSharpFileType.INSTANCE, text, System.currentTimeMillis()); SingleRootFileViewProvider viewProvider = new SingleRootFileViewProvider(PsiManager.getInstance(project), virtualFile, false); return new CSharpFileWithScopeImpl(viewProvider); }
private static Document createDocument(final CharSequence text, VirtualFile file) { boolean acceptSlashR = file instanceof LightVirtualFile && StringUtil.indexOf(text, '\r') >= 0; boolean freeThreaded = Boolean.TRUE.equals(file.getUserData(SingleRootFileViewProvider.FREE_THREADED)); return ((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(text, acceptSlashR, freeThreaded); }
@Override public boolean accept(@Nonnull Project project, @Nonnull VirtualFile file) { return isTextFile(file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file); }
@Override public boolean accept(@Nonnull Project project, @Nonnull VirtualFile file) { return TextEditorProvider.isTextFile(file) && SingleRootFileViewProvider.isTooLargeForContentLoading(file); }
@Override @Nonnull public FileViewProvider createFileViewProvider(@Nonnull final VirtualFile file, final boolean physical) { return new SingleRootFileViewProvider(myManager, file, physical); }
private boolean isTooLarge(@Nonnull VirtualFile file) { if (SingleRootFileViewProvider.isTooLargeForIntelligence(file)) { return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file); } return false; }
private boolean isTooLarge(@Nonnull VirtualFile file, long contentSize) { if (SingleRootFileViewProvider.isTooLargeForIntelligence(file, contentSize)) { return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file, contentSize); } return false; }