From bc2c1f05b7fd8ab61b57d9e575a67c9708e8b1e3 Mon Sep 17 00:00:00 2001 From: "Alexander.Kass" Date: Tue, 20 Oct 2020 17:10:45 +0300 Subject: [PATCH] do not enable reader mode for database source files GitOrigin-RevId: 96c79e28d00112ff413835e481e9bde4c32e5f43 --- .../codeInsight/actions/ReaderModeMatcher.kt | 18 ++++++++++++++++++ .../codeInsight/actions/ReaderModeSettings.kt | 14 +++++++++++--- .../src/META-INF/LangExtensionPoints.xml | 1 + 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 platform/editor-ui-api/src/com/intellij/codeInsight/actions/ReaderModeMatcher.kt diff --git a/platform/editor-ui-api/src/com/intellij/codeInsight/actions/ReaderModeMatcher.kt b/platform/editor-ui-api/src/com/intellij/codeInsight/actions/ReaderModeMatcher.kt new file mode 100644 index 000000000000..9cfff8651e39 --- /dev/null +++ b/platform/editor-ui-api/src/com/intellij/codeInsight/actions/ReaderModeMatcher.kt @@ -0,0 +1,18 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.codeInsight.actions + +import com.intellij.codeInsight.actions.ReaderModeProvider.ReaderMode +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile + +/** + * Use it to override file <--> reader mode matching + */ +interface ReaderModeMatcher { + /** + * It's triggered on Reader Mode to check if file matches mode specified. + * + * @return null if unable to decide + */ + fun matches(project: Project, file: VirtualFile, mode: ReaderMode): Boolean? +} \ No newline at end of file diff --git a/platform/platform-api/src/com/intellij/codeInsight/actions/ReaderModeSettings.kt b/platform/platform-api/src/com/intellij/codeInsight/actions/ReaderModeSettings.kt index e9d23e1c1b2b..5c665ba4a67e 100644 --- a/platform/platform-api/src/com/intellij/codeInsight/actions/ReaderModeSettings.kt +++ b/platform/platform-api/src/com/intellij/codeInsight/actions/ReaderModeSettings.kt @@ -14,6 +14,7 @@ import com.intellij.psi.PsiManager class ReaderModeSettings : PersistentStateComponentWithModificationTracker { companion object { private var EP_READER_MODE_PROVIDER = ExtensionPointName("com.intellij.readerModeProvider") + private var EP_READER_MODE_MATCHER = ExtensionPointName("com.intellij.readerModeMatcher") @JvmStatic fun instance(project: Project): ReaderModeSettings { @@ -32,12 +33,19 @@ class ReaderModeSettings : PersistentStateComponentWithModificationTracker inLibraries || !isWritable ReaderMode.LIBRARIES -> inLibraries ReaderMode.READ_ONLY -> !isWritable diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index accca6a61508..39a9526800fc 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -581,6 +581,7 @@ +