Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor fixes #143

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ tasks {
prepareSandbox { enabled = true }
patchPluginXml {
sinceBuild.set("231")
untilBuild.set("")
}
buildSearchableOptions {
enabled = prop("enableBuildSearchableOptions").toBoolean()
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
org.gradle.jvmargs=-Xmx4096m
pluginGroup=org.ton
pluginVersion=2.0.3
pluginVersion=2.0.4
publishChannel=release
publishToken=token
enableBuildSearchableOptions=false
# Existent IDE versions can be found in the following repos:
# https://www.jetbrains.com/intellij-repository/releases/
# https://www.jetbrains.com/intellij-repository/snapshots/
ideaVersion=233-EAP-SNAPSHOT
ideaVersion=231-EAP-SNAPSHOT
# https://plugins.jetbrains.com/plugin/227-psiviewer/versions
psiViewerPluginVersion=232.2-SNAPSHOT
psiViewerPluginVersion=231-SNAPSHOT
kotlin.stdlib.default.dependency=false
buildNumber=0
1 change: 0 additions & 1 deletion src/main/grammar/FuncLexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ import static org.ton.intellij.func.parser.FuncParserDefinition.*;
%s IN_BLOCK_COMMENT
%s IN_EOL_DOC_COMMENT

%unicode

///////////////////////////////////////////////////////////////////////////////////////////////////
// Whitespaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class FuncReferenceCompletionProvider : CompletionProvider<CompletionParameters>
// println("walking up: ${scope.elementType} | ${scope.text}")
when (scope) {
is FuncBlockStatement -> {
result = TailTypeDecorator.withTail(result, TailType.SEMICOLON)
result = TailTypeDecorator.withTail(result, TailType.createSimpleTailType(';'))
return@treeWalkUp false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class FuncPsiDocumentationTargetProvider : PsiDocumentationTargetProvider {

private const val NBSP = "&nbsp;"

@Suppress("UnstableApiUsage")
class FuncDocumentationTarget(val element: PsiElement, val originalElement: PsiElement?) : DocumentationTarget {
override fun computePresentation(): TargetPresentation =
targetPresentation(element)
Expand Down
35 changes: 15 additions & 20 deletions src/main/kotlin/org/ton/intellij/func/ide/quickdoc/MarkdownNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.intellij.openapi.editor.colors.EditorColorsManager
import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.editor.markup.TextAttributes
import com.intellij.openapi.editor.richcopy.HtmlSyntaxInfoUtil
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiElement
Expand Down Expand Up @@ -121,26 +120,22 @@ class MarkdownNode(
if (linkLabelContent != null) {
val label = linkLabelContent.joinToString(separator = "") { it.text }
val linkText = node.child(MarkdownElementTypes.LINK_TEXT)?.toHtml() ?: label
if (DumbService.isDumb(owner.project)) {
sb.append(linkText)
} else {
if (owner is FuncFunction) {
val resolved = FuncDocumentationProvider.resolve(label, owner)
if (resolved != null) {
println("resolved = $resolved (${resolved.text})")
val hyperlink = buildString {
DocumentationManagerUtil.createHyperlink(
this,
label,
linkText,
false,
true
)
}
sb.append(hyperlink)
} else {
sb.append(node.text)
if (owner is FuncFunction) {
val resolved = FuncDocumentationProvider.resolve(label, owner)
if (resolved != null) {
println("resolved = $resolved (${resolved.text})")
val hyperlink = buildString {
DocumentationManagerUtil.createHyperlink(
this,
label,
linkText,
false,
true
)
}
sb.append(hyperlink)
} else {
sb.append(node.text)
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/ton/intellij/func/psi/FuncTokenType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.ton.intellij.func.parser.FuncParserDefinition.Companion.EOL_COMMENT
import org.ton.intellij.func.parser.FuncParserDefinition.Companion.EOL_DOC_COMMENT
import org.ton.intellij.util.tokenSetOf

open class FuncTokenType(debugName: String) : IElementType(debugName, FuncLanguage)
open class FuncTokenType(val name: String) : IElementType(name, FuncLanguage)

val FUNC_REGULAR_COMMENTS = tokenSetOf(BLOCK_COMMENT, EOL_COMMENT)
val FUNC_DOC_COMMENTS = tokenSetOf(EOL_DOC_COMMENT, BLOCK_DOC_COMMENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,42 @@ package org.ton.intellij.func.refactor

import com.intellij.lang.refactoring.NamesValidator
import com.intellij.openapi.project.Project
import org.ton.intellij.func.psi.FUNC_KEYWORDS

class FuncNamesValidator : NamesValidator {
override fun isKeyword(name: String, project: Project?): Boolean {
if (name.isBlank()) return false
return FUNC_KEYWORDS.types.find {
it.debugName == name
} != null
return when (name) {
"return",
"var",
"repeat",
"do",
"while",
"until",
"try",
"catch",
"if",
"ifnot",
"then",
"else",
"elseif",
"elseifnot",
"type",
"forall",
"extern",
"global",
"const",
"asm",
"impure",
"inline",
"inline_ref",
"method_id",
"infix",
"infixl",
"infixr",
"operator",
"auto_apply" -> true

else -> false
}
}

override fun isIdentifier(name: String, project: Project?): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.ton.intellij.func.stub.type

import com.github.weisj.jsvg.T
import com.intellij.lang.ASTNode
import com.intellij.psi.stubs.IStubElementType
import com.intellij.psi.stubs.IndexSink
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/org/ton/intellij/tlb/TlbFileType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package org.ton.intellij.tlb

import com.intellij.openapi.fileTypes.LanguageFileType
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.annotations.NonNls

object TlbFileType : LanguageFileType(TlbLanguage) {
override fun getName() = "TL-B"
override fun getDescription() = "TL-B Schema file"
override fun getDefaultExtension() = "tlb"
override fun getIcon() = TlbIcons.FILE
override fun getCharset(file: VirtualFile, content: ByteArray?) = Charsets.UTF_8.name()
override fun getCharset(file: VirtualFile, content: ByteArray): @NonNls String? = Charsets.UTF_8.name()
}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<idea-plugin url="https://ton.org" xmlns:xi="http://www.w3.org/2001/XInclude">
<id>org.ton.intellij.plugin</id>
<id>org.ton.intellij-ton</id>
<name>TON</name>
<category>Languages</category>
<vendor url="https://github.com/ton-blockchain/intellij-ton">TON Foundation</vendor>
Expand Down