Java 类com.intellij.psi.SingleRootFileViewProvider 实例源码

项目:intellij-ce-playground    文件:HighlightingSettingsPerFile.java   
@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);
}
项目:tools-idea    文件:HighlightLevelUtil.java   
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;
}
项目:consulo-csharp    文件:CSharpFragmentFactory.java   
@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;
}
项目:intellij-haxe    文件:HaxeExpressionCodeFragmentImpl.java   
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);
}
项目:consulo-haxe    文件:HaxeExpressionCodeFragmentImpl.java   
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);
}
项目:consulo    文件:HighlightingSettingsPerFile.java   
@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;
}
项目:consulo    文件:HighlightLevelUtil.java   
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;
}
项目:consulo    文件:TemplateDataElementType.java   
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);
}
项目:lua-for-idea    文件:LuaCodeFragment.java   
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);
}
项目:intellij-ce-playground    文件:FileTypeManagerImpl.java   
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);
}
项目:intellij-ce-playground    文件:PyExpressionCodeFragmentImpl.java   
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);
}
项目:intellij-ce-playground    文件:PyExpressionCodeFragment.java   
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);
}
项目:tools-idea    文件:TextEditorProvider.java   
@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;
}
项目:tools-idea    文件:TemplateDataElementType.java   
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);
}
项目:consulo-ikvm    文件:JavaRepresentationProvider.java   
@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;
}
项目:consulo-csharp    文件:CSharpFileFactory.java   
@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);
}
项目:consulo-csharp    文件:CSharpFragmentFactory.java   
@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;
}
项目:consulo-dotnet    文件:DotNetEditorsProvider.java   
@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);
}
项目:consulo    文件:FileTypeManagerImpl.java   
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);
}
项目:consulo-javascript    文件:JSExpressionCodeFragmentImpl.java   
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);
}
项目:intellij-ce-playground    文件:TextEditorProvider.java   
@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
  return isTextFile(file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
项目:intellij-ce-playground    文件:LargeFileEditorProvider.java   
@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
  return TextEditorProvider.isTextFile(file) && SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
项目:intellij-ce-playground    文件:EmptyFileManager.java   
@Override
@NotNull
public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final boolean eventSystemEnabled) {
  return new SingleRootFileViewProvider(myManager, file, eventSystemEnabled);
}
项目:intellij-ce-playground    文件:MockFileManager.java   
@Override
protected FileViewProvider create(VirtualFile key) {
  return new SingleRootFileViewProvider(myManager, key);
}
项目:intellij-ce-playground    文件:MockFileManager.java   
@Override
@NotNull
public FileViewProvider createFileViewProvider(@NotNull VirtualFile file, boolean eventSystemEnabled) {
  return new SingleRootFileViewProvider(myManager, file, eventSystemEnabled);
}
项目:intellij-ce-playground    文件:FileBasedIndexImpl.java   
private boolean isTooLarge(@NotNull VirtualFile file) {
  if (SingleRootFileViewProvider.isTooLargeForIntelligence(file)) {
    return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file);
  }
  return false;
}
项目:intellij-ce-playground    文件:FileBasedIndexImpl.java   
private boolean isTooLarge(@NotNull VirtualFile file, long contentSize) {
  if (SingleRootFileViewProvider.isTooLargeForIntelligence(file, contentSize)) {
    return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file, contentSize);
  }
  return false;
}
项目:TheRPlugin    文件:TheRCodeFragment.java   
public TheRCodeFragment(@NotNull final Project project, @NotNull final String name, @NotNull final String text) {
  super(createLightVirtualFileViewProvider(project, name, text));

  ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this);
}
项目:tools-idea    文件:LargeFileEditorProvider.java   
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
  if (file.isDirectory() || !file.isValid()) {
    return false;
  }
  return SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
项目:tools-idea    文件:EmptyFileManager.java   
@Override
@NotNull
public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final boolean physical) {
  return new SingleRootFileViewProvider(myManager, file, physical);
}
项目:tools-idea    文件:MockFileManager.java   
@Override
protected FileViewProvider create(final VirtualFile key) {
  return new SingleRootFileViewProvider(myManager, key);
}
项目:tools-idea    文件:MockFileManager.java   
@Override
@NotNull
public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final boolean physical) {
  return new SingleRootFileViewProvider(myManager, file, physical);
}
项目:consulo-csharp    文件:CSharpFileFactory.java   
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);
}
项目:consulo    文件:FileDocumentManagerImpl.java   
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);
}
项目:consulo    文件:TextEditorProvider.java   
@Override
public boolean accept(@Nonnull Project project, @Nonnull VirtualFile file) {
  return isTextFile(file) && !SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
项目:consulo    文件:LargeFileEditorProvider.java   
@Override
public boolean accept(@Nonnull Project project, @Nonnull VirtualFile file) {
  return TextEditorProvider.isTextFile(file) && SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
项目:consulo    文件:MockFileManager.java   
@Override
protected FileViewProvider create(final VirtualFile key) {
  return new SingleRootFileViewProvider(myManager, key);
}
项目:consulo    文件:MockFileManager.java   
@Override
@Nonnull
public FileViewProvider createFileViewProvider(@Nonnull final VirtualFile file, final boolean physical) {
  return new SingleRootFileViewProvider(myManager, file, physical);
}
项目:consulo    文件:FileBasedIndexImpl.java   
private boolean isTooLarge(@Nonnull VirtualFile file) {
  if (SingleRootFileViewProvider.isTooLargeForIntelligence(file)) {
    return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file);
  }
  return false;
}
项目:consulo    文件:FileBasedIndexImpl.java   
private boolean isTooLarge(@Nonnull VirtualFile file, long contentSize) {
  if (SingleRootFileViewProvider.isTooLargeForIntelligence(file, contentSize)) {
    return !myNoLimitCheckTypes.contains(file.getFileType()) || SingleRootFileViewProvider.isTooLargeForContentLoading(file, contentSize);
  }
  return false;
}