Search in sources :

Example 1 with INativeFileType

use of com.intellij.openapi.fileTypes.INativeFileType in project intellij-community by JetBrains.

the class AutoScrollToSourceHandler method scrollToSource.

protected void scrollToSource(final Component tree) {
    DataContext dataContext = DataManager.getInstance().getDataContext(tree);
    getReady(dataContext).doWhenDone(() -> {
        DataContext context = DataManager.getInstance().getDataContext(tree);
        final VirtualFile vFile = CommonDataKeys.VIRTUAL_FILE.getData(context);
        if (vFile != null) {
            // asking to register some file type for this file. This behaviour is undesirable when autoscrolling.
            if (vFile.getFileType() == FileTypes.UNKNOWN || vFile.getFileType() instanceof INativeFileType)
                return;
            //IDEA-84881 Don't autoscroll to very large files
            if (vFile.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize())
                return;
        }
        Navigatable[] navigatables = CommonDataKeys.NAVIGATABLE_ARRAY.getData(context);
        if (navigatables != null) {
            if (navigatables.length > 1) {
                return;
            }
            for (Navigatable navigatable : navigatables) {
                // we are not going to open modal dialog during autoscrolling
                if (!navigatable.canNavigateToSource())
                    return;
            }
        }
        OpenSourceUtil.navigate(false, true, navigatables);
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) INativeFileType(com.intellij.openapi.fileTypes.INativeFileType) Navigatable(com.intellij.pom.Navigatable)

Aggregations

INativeFileType (com.intellij.openapi.fileTypes.INativeFileType)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Navigatable (com.intellij.pom.Navigatable)1