Skip to content

Commit

Permalink
✨ feat: Optimize quick document display content
Browse files Browse the repository at this point in the history
  • Loading branch information
imyuyu committed May 12, 2024
1 parent c7c1858 commit 6bf3f70
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

## [Unreleased]

### Added
- Optimize quick document display content
- 优化快速文档展示效果,直接显示sql内容

## [0.4.0] - 2024-04-26

### Added
- added support for [SqlToy-Plus](https://gitee.com/gzghde/sqltoy-plus);
- sqltoy sql xml inspection
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.github.imyuyu
pluginName = SQLToy Integration
pluginRepositoryUrl = https://github.com/imyuyu/sqltoy-idea-plugin
# SemVer format -> https://semver.org
pluginVersion = 0.4.0
pluginVersion = 0.4.1

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 222
Expand Down
27 changes: 24 additions & 3 deletions src/main/kotlin/com/github/imyuyu/sqltoy/provider/SqlIdQuickDoc.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package com.github.imyuyu.sqltoy.provider

import com.github.imyuyu.sqltoy.dom.model.Sql
import com.github.imyuyu.sqltoy.util.XmlUtil
import com.intellij.codeInsight.documentation.DocumentationManagerProtocol
import com.intellij.codeInsight.documentation.DocumentationManagerUtil

Check warning on line 6 in src/main/kotlin/com/github/imyuyu/sqltoy/provider/SqlIdQuickDoc.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.intellij.lang.documentation.AbstractDocumentationProvider
import com.intellij.lang.documentation.DocumentationMarkup
import com.intellij.lang.documentation.DocumentationMarkup.DEFINITION_ELEMENT

Check warning on line 9 in src/main/kotlin/com/github/imyuyu/sqltoy/provider/SqlIdQuickDoc.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive
import com.intellij.openapi.util.text.HtmlBuilder
import com.intellij.openapi.util.text.HtmlChunk
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.psi.util.PsiUtil
import com.intellij.psi.xml.XmlAttributeValue
import com.intellij.psi.xml.XmlTag
import com.intellij.util.xml.DomManager


class SqlIdQuickDoc : AbstractDocumentationProvider() {
Expand All @@ -29,12 +37,25 @@ class SqlIdQuickDoc : AbstractDocumentationProvider() {

val id = element.text.replace("\"", "");

Check warning on line 38 in src/main/kotlin/com/github/imyuyu/sqltoy/provider/SqlIdQuickDoc.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Redundant semicolon

Redundant semicolon

// todo 下一步使用HtmlBuilder
//var stringBuilder = StringBuilder()
//DocumentationManagerUtil.createHyperlink(stringBuilder, element, element.toString(), "$id",true);

return "<div class='definition'>" +
val sql = DomManager.getDomManager(element.project)
.getDomElement(PsiTreeUtil.getParentOfType(element, XmlTag::class.java)) as Sql

return HtmlBuilder().append(
HtmlChunk.div().setClass(DocumentationMarkup.CLASS_DEFINITION).children(HtmlChunk.tag("pre")

Check warning on line 47 in src/main/kotlin/com/github/imyuyu/sqltoy/provider/SqlIdQuickDoc.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'CLASS_DEFINITION' is marked unstable with @ApiStatus.Internal
.addText("SQL ID ")
.child(HtmlChunk.link(DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL+PsiUtil.getName(element), id))
.addText(" is defined in ")
.child(HtmlChunk.link("psi_element://"+ (PsiUtil.getVirtualFile(element)?.path ?: ""), element.containingFile.name)))
)
.append(HtmlChunk.div().setClass(DocumentationMarkup.CLASS_CONTENT).addText(sql.getSqlValue().getValue()!!)).toString();

Check warning on line 53 in src/main/kotlin/com/github/imyuyu/sqltoy/provider/SqlIdQuickDoc.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Redundant semicolon

Redundant semicolon

Check warning on line 53 in src/main/kotlin/com/github/imyuyu/sqltoy/provider/SqlIdQuickDoc.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'CLASS_CONTENT' is marked unstable with @ApiStatus.Internal

/*return "<div class='definition'>" +
"<pre>XML File : <a href=''>" + element.containingFile.name + "</a></pre>" +
"</div>" +
"<div class='content'>SQLToy SqlId : " + id + "</div>"
"<div class='content'>SQLToy SqlId : " + id + "</div>"*/

//return "SQLToy SqlId : "+element.text
}
Expand Down

0 comments on commit 6bf3f70

Please sign in to comment.