From fc972f13df8a9d7a28dcc20a3b55ae61a4c5e413 Mon Sep 17 00:00:00 2001 From: "Maxim.Kolmakov" Date: Wed, 22 May 2024 17:15:52 +0200 Subject: [PATCH] [performancePlugin] Remove doc provider since all HTML files were removed GitOrigin-RevId: 803eca74aa22e0b1786f4fb9a596f4e12191115f --- .../core/resources/META-INF/plugin.xml | 2 - .../lang/doc/IJPerfDocumentationProvider.java | 90 ------------------- 2 files changed, 92 deletions(-) delete mode 100644 plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/lang/doc/IJPerfDocumentationProvider.java diff --git a/plugins/performanceTesting/core/resources/META-INF/plugin.xml b/plugins/performanceTesting/core/resources/META-INF/plugin.xml index 97bf58f4e22f..ee0c5b9105f0 100644 --- a/plugins/performanceTesting/core/resources/META-INF/plugin.xml +++ b/plugins/performanceTesting/core/resources/META-INF/plugin.xml @@ -63,8 +63,6 @@ - - diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/lang/doc/IJPerfDocumentationProvider.java b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/lang/doc/IJPerfDocumentationProvider.java deleted file mode 100644 index dce73dca84ed..000000000000 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/lang/doc/IJPerfDocumentationProvider.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.jetbrains.performancePlugin.lang.doc; - -import com.intellij.lang.documentation.AbstractDocumentationProvider; -import com.intellij.lang.documentation.DocumentationMarkup; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.NlsSafe; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.PsiElement; -import com.intellij.util.ResourceUtil; -import com.jetbrains.performancePlugin.CommandProvider; -import com.jetbrains.performancePlugin.lang.psi.IJPerfCommandName; -import com.jetbrains.performancePlugin.lang.psi.IJPerfPsiImplUtil; -import org.jetbrains.annotations.Nls; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; -import java.io.InputStream; - -import static com.intellij.openapi.util.Predicates.nonNull; - -public class IJPerfDocumentationProvider extends AbstractDocumentationProvider { - - @Nullable - @Override - public @Nls String generateHoverDoc(@NotNull PsiElement element, @Nullable PsiElement originalElement) { - @NlsSafe - String title = null; - if (!(element instanceof IJPerfCommandName)) { - return null; - } - try { - String commandDescriptionFileName = getCommandDescriptionFileName(IJPerfPsiImplUtil.getName((IJPerfCommandName)element)); - InputStream inputStream = getDocumentationStream(commandDescriptionFileName); - if (inputStream != null) { - title = ResourceUtil.loadText(inputStream); - title = title.substring(title.indexOf("") + "<title>".length(), title.indexOf("")); - } - } - catch (IOException ex) { - Logger.getInstance(getClass()).error(ex.getMessage()); - } - if (title != null) { - title = DocumentationMarkup.DEFINITION_START + StringUtil.escapeXmlEntities(title) + DocumentationMarkup.DEFINITION_END; - } - return title; - } - - private static InputStream getDocumentationStream(@NotNull String commandDescriptionFileName) { - return CommandProvider.EP_NAME.getExtensionList().stream() - .map(commandProvider -> ResourceUtil.getResourceAsStream( - commandProvider.getClass().getClassLoader(), "commandDescriptions", commandDescriptionFileName)) - .filter(nonNull()) - .findFirst() - .orElse(null); - } - - @Nullable - private static String getCommandDescriptionFileName(@Nullable String commandName) { - return commandName != null ? commandName.replaceAll("%", "") + "Command.html" : null; - } - - @Nullable - @Override - public @Nls String generateDoc(PsiElement element, @Nullable PsiElement originalElement) { - @NlsSafe - String description; - if (!(element instanceof IJPerfCommandName)) { - return null; - } - try { - @NonNls - String commandName = IJPerfPsiImplUtil.getName((IJPerfCommandName)element); - String commandDescriptionFileName = getCommandDescriptionFileName(commandName); - InputStream inputStream = getDocumentationStream(commandDescriptionFileName); - if (inputStream != null) { - description = ResourceUtil.loadText(inputStream); - return DocumentationMarkup.DEFINITION_START + StringUtil.escapeXmlEntities(commandName) + - DocumentationMarkup.DEFINITION_END + - DocumentationMarkup.CONTENT_START + description + - DocumentationMarkup.CONTENT_END; - } - } - catch (IOException ex) { - Logger.getInstance(getClass()).error(ex.getMessage()); - } - return null; - } -}