com.intellij.psi.SingleRootFileViewProvider Java Examples

The following examples show how to use com.intellij.psi.SingleRootFileViewProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSharpFragmentFactory.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
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)
	{
		@Nonnull
		@Override
		public SingleRootFileViewProvider createCopy(@Nonnull 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;
}
 
Example #2
Source File: HaxeExpressionCodeFragmentImpl.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: TemplateDataElementType.java    From consulo with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: HighlightingSettingsPerFile.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #5
Source File: HighlightLevelUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: SkylarkExpressionCodeFragment.java    From intellij with Apache License 2.0 5 votes vote down vote up
SkylarkExpressionCodeFragment(Project project, String fileName, String text, boolean isPhysical) {
  super(
      PsiManagerEx.getInstanceEx(project)
          .getFileManager()
          .createFileViewProvider(
              new LightVirtualFile(fileName, BuildFileType.INSTANCE, text), isPhysical));
  this.isPhysical = isPhysical;
  ((SingleRootFileViewProvider) getViewProvider()).forceCachedPsi(this);
}
 
Example #7
Source File: CSharpFragmentFactory.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
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;
}
 
Example #8
Source File: EmptyFileManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public FileViewProvider createFileViewProvider(@Nonnull final VirtualFile file, final boolean physical) {
  return new SingleRootFileViewProvider(myManager, file, physical);
}
 
Example #9
Source File: CppCodeFragment.java    From CppTools with Apache License 2.0 4 votes vote down vote up
public CppCodeFragment(@NotNull FileViewProvider fileViewProvider) {
  super(fileViewProvider);
  ((SingleRootFileViewProvider)fileViewProvider).forceCachedPsi(this);
}
 
Example #10
Source File: FileBasedIndexImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean isTooLarge(@Nonnull VirtualFile file, long contentSize) {
  if (SingleRootFileViewProvider.isTooLargeForIntelligence(file, contentSize)) {
    return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file, contentSize);
  }
  return false;
}
 
Example #11
Source File: FileBasedIndexImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean isTooLarge(@Nonnull VirtualFile file) {
  if (SingleRootFileViewProvider.isTooLargeForIntelligence(file)) {
    return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file);
  }
  return false;
}
 
Example #12
Source File: MockFileManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public FileViewProvider createFileViewProvider(@Nonnull final VirtualFile file, final boolean physical) {
  return new SingleRootFileViewProvider(myManager, file, physical);
}
 
Example #13
Source File: MockFileManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public MockFileManager(final PsiManagerEx manager) {
  myManager = manager;
  myViewProviders = FactoryMap.create(key -> new SingleRootFileViewProvider(manager, key));
}
 
Example #14
Source File: CsvFileEditorProvider.java    From intellij-csv-validator with Apache License 2.0 4 votes vote down vote up
@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
    return CsvHelper.isCsvFile(project, file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
 
Example #15
Source File: DesktopTextEditorProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean accept(@Nonnull Project project, @Nonnull VirtualFile file) {
  return isTextFile(file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
 
Example #16
Source File: LargeFileEditorProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean accept(@Nonnull Project project, @Nonnull VirtualFile file) {
  return TextEditorProvider.isTextFile(file) && SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
 
Example #17
Source File: TextEditorProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean accept(@Nonnull Project project, @Nonnull VirtualFile file) {
  return isTextFile(file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
 
Example #18
Source File: CsvTableEditorProvider.java    From intellij-csv-validator with Apache License 2.0 4 votes vote down vote up
@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
    return CsvEditorSettings.getInstance().getEditorPrio() != CsvEditorSettings.EditorPrio.TEXT_ONLY &&
            CsvHelper.isCsvFile(project, file) &&
            !SingleRootFileViewProvider.isTooLargeForIntelligence(file);
}