[performancePlugin] Remove doc provider since all HTML files were removed

GitOrigin-RevId: 803eca74aa22e0b1786f4fb9a596f4e12191115f
This commit is contained in:
Maxim.Kolmakov
2024-05-22 17:15:52 +02:00
committed by intellij-monorepo-bot
parent 6b8e91b816
commit fc972f13df
2 changed files with 0 additions and 92 deletions

View File

@@ -63,8 +63,6 @@
<annotator language="IntegrationPerformanceTest" implementationClass="com.jetbrains.performancePlugin.lang.inspections.IJPerfStartStopProfileInspection"/>
<documentationProvider implementation="com.jetbrains.performancePlugin.lang.doc.IJPerfDocumentationProvider"/>
<initProjectActivity implementation="com.jetbrains.performancePlugin.PerformancePluginInitProjectActivity"/>
<postStartupActivity implementation="com.jetbrains.performancePlugin.PerformanceTestTotalTimeTimer" />
<applicationInitializedListener implementation="com.jetbrains.performancePlugin.ProjectLoaded"/>

View File

@@ -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>") + "<title>".length(), title.indexOf("</title>"));
}
}
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;
}
}