Skip to content

Commit

Permalink
Merge pull request #518 from alex999990009/alex99999/warnings
Browse files Browse the repository at this point in the history
Fix new and some old warnings
  • Loading branch information
sxhya authored Jun 18, 2024
2 parents 8825bd4 + 0874e61 commit 58a4c17
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.intellij.psi.PsiManager
import com.intellij.psi.PsiRecursiveElementVisitor
import com.intellij.psi.util.elementType
import com.intellij.testFramework.LightVirtualFile
import org.apache.commons.lang.StringEscapeUtils
import org.arend.highlight.ArendHighlightingColors
import org.arend.highlight.ArendHighlightingPass
import org.arend.highlight.ArendSyntaxHighlighter
Expand Down Expand Up @@ -279,7 +278,7 @@ private fun generateHtmlForArend(
counter = result.second

append("<a${" id=\"$id\""}${href?.let { " href=\"$it\" style=\"text-decoration:none;\"" } ?: ""}${
cssClass?.let { " class=\"$it\"" } ?: ""}>${StringEscapeUtils.escapeHtml(element.text)}</a>")
cssClass?.let { " class=\"$it\"" } ?: ""}>${element.text.htmlEscape()}</a>")
}
})
append("<script src=\"$extraHtmlDir/$AREND_JS\"></script>")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.arend.documentation

import com.intellij.openapi.application.ApplicationStarter
import com.intellij.openapi.editor.colors.EditorColorsManager

class GenerateArendLibHtmlStarter : ApplicationStarter {
@Suppress("OVERRIDE_DEPRECATION")
override val commandName: String
get() = "generateArendLibHtml"

Expand Down
22 changes: 12 additions & 10 deletions src/main/kotlin/org/arend/graph/GraphSimulator.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.arend.graph

import com.intellij.notification.NotificationListener
import com.intellij.ide.BrowserUtil
import com.intellij.notification.NotificationAction
import com.intellij.notification.Notifications
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.openapi.ui.MessageType
import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.notificationGroup
import com.intellij.ui.util.minimumHeight
import com.intellij.ui.util.minimumWidth
import com.intellij.ui.components.JBPanel
import guru.nidi.graphviz.engine.Format
import guru.nidi.graphviz.engine.Graphviz
import guru.nidi.graphviz.model.Factory.graph
Expand Down Expand Up @@ -88,17 +88,17 @@ class GraphSimulator(
}

override fun createCenterPanel(): JComponent {
val panel = JPanel()
val panel = JBPanel<JBPanel<*>>()
panel.add(imageLabel)
panel.background = Color.WHITE
panel.addComponentListener(object : ComponentAdapter() {
override fun componentResized(e: ComponentEvent) {
val component = panel.components.getOrNull(0) ?: return
panel.minimumWidth = baseImageIcon.iconWidth + size.width - e.component.width
panel.minimumHeight = baseImageIcon.iconHeight + size.height - e.component.height
panel.withMinimumWidth(baseImageIcon.iconWidth + size.width - e.component.width)
panel.withMinimumHeight(baseImageIcon.iconHeight + size.height - e.component.height)

val imageIcon = getImageIcon(baseImageIcon, graphviz, e.component.width - component.bounds.x * 2, e.component.height - component.bounds.y * 2)
imageLabel = JLabel(imageIcon)
val newImageIcon = getImageIcon(baseImageIcon, graphviz, e.component.width - component.bounds.x * 2, e.component.height - component.bounds.y * 2)
imageLabel = JLabel(newImageIcon)

panel.removeAll()
panel.add(imageLabel)
Expand Down Expand Up @@ -137,8 +137,10 @@ class GraphSimulator(
dialogWrapper.pack()
dialogWrapper.show()
} catch (e: Exception) {
val notification = notificationGroup.createNotification("It is not possible to visualize the diagram on your device. Install <a href=https://graphviz.org/download/>Graphviz</a> please", MessageType.WARNING)
notification.setListener(NotificationListener.UrlOpeningListener(true))
val notification = notificationGroup.createNotification("It is not possible to visualize the diagram on your device. Install Graphviz please", MessageType.WARNING)
.addAction(NotificationAction.createSimple("Open Graphviz") {
BrowserUtil.open("https://graphviz.org/download/")
})
Notifications.Bus.notify(notification, project)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FileOutsideSourcesProvider : EditorNotificationProvider {
return null
}

return Function<FileEditor, JComponent> { fileEditor: FileEditor? ->
return Function<FileEditor, EditorNotificationPanel?> { fileEditor: FileEditor? ->
fileEditor?.let { createPanel(fileEditor) }
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/org/arend/search/proof/ProofSearchUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.intellij.codeInsight.lookup.impl.actions.ChooseItemAction
import com.intellij.icons.AllIcons
import com.intellij.ide.actions.BigPopupUI
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.actionSystem.toolbarLayout.ToolbarLayoutStrategy
import com.intellij.openapi.application.invokeAndWaitIfNeeded
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.application.runInEdt
Expand Down Expand Up @@ -172,7 +173,7 @@ class ProofSearchUI(private val project: Project, private val caret: Caret?) : B
actionGroup.addAction(ShowInFindWindowAction(this, project))
actionGroup.addAction(ShowHelpAction(this))
val toolbar = ActionManager.getInstance().createActionToolbar("proof.search.top.toolbar", actionGroup, true)
toolbar.layoutPolicy = ActionToolbar.NOWRAP_LAYOUT_POLICY
toolbar.layoutStrategy = ToolbarLayoutStrategy.NOWRAP_STRATEGY
toolbar.targetComponent = this
val toolbarComponent = toolbar.component
toolbarComponent.isOpaque = false
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/arend/yaml/YamlNotificationProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class YamlNotificationProvider : EditorNotificationProvider {
if (!yamlFileService.containsChangedFile(virtualFile)) {
return null
}
return Function<FileEditor, JComponent> { fileEditor: FileEditor? ->
return Function<FileEditor, EditorNotificationPanel?> { fileEditor: FileEditor? ->
fileEditor?.let { createPanel(yamlFileService, virtualFile, it) }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
<liveTemplateContext contextId="AREND_STATEMENT" baseContextId="AREND" implementation="org.arend.liveTemplates.ArendTemplateContextType$Statement"/>
<liveTemplateContext contextId="AREND_EXPRESSION" baseContextId="AREND" implementation="org.arend.liveTemplates.ArendTemplateContextType$Expression"/>

<!--TODO-->
<!-- Starters -->
<appStarter id="generateArendLibHtml" implementation="org.arend.documentation.GenerateArendLibHtmlStarter"/>

</extensions>
Expand Down

0 comments on commit 58a4c17

Please sign in to comment.