Skip to content

Commit

Permalink
Merge pull request #228 from modelix/completion-tree
Browse files Browse the repository at this point in the history
Multiple tokens in completion menu
  • Loading branch information
slisson authored Dec 6, 2024
2 parents 3f6e41e + 6880fb0 commit addae93
Show file tree
Hide file tree
Showing 30 changed files with 432 additions and 126 deletions.
39 changes: 39 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.intellij.tasks.BuildPluginTask
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
Expand Down Expand Up @@ -82,6 +83,19 @@ subprojects {
}
}
}

val gprUser = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR")
val gprToken = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN")
if (gprUser.isNotBlank() && gprToken.isNotBlank()) {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/modelix/modelix.text-editor")
credentials {
username = gprUser
password = gprToken
}
}
}
}
}
}
Expand Down Expand Up @@ -148,3 +162,28 @@ tasks.register("setupNodeEverywhere") {
dependsOn(":projectional-editor-ssr-client-lib:kotlinNodeJsSetup")
dependsOn(":projectional-editor-ssr-common:kotlinNodeJsSetup")
}

val packageAllPlugins by tasks.registering(Zip::class) {
val zipTask = this
archiveBaseName = "all-editor-plugins"
subprojects {
tasks.all {
if (this.name == "buildPlugin") {
val buildPluginTask = this as BuildPluginTask
zipTask.dependsOn(buildPluginTask)
zipTask.from(zipTree(buildPluginTask.archiveFile))
}
}
}
}

publishing {
publications {
create<MavenPublication>("maven") {
artifactId = "all-editor-plugins"
artifact(packageAllPlugins) {
extension = "zip"
}
}
}
}
32 changes: 1 addition & 31 deletions buildSrc/src/main/kotlin/org/modelix/CopyMps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ import org.gradle.api.file.Directory
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.exclude
import org.gradle.kotlin.dsl.support.unzipTo
import org.gradle.kotlin.dsl.support.zipTo
import java.io.File
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import java.util.zip.ZipInputStream

val Project.mpsMajorVersion: String get() {
if (project != rootProject) return rootProject.mpsVersion
if (project != rootProject) return rootProject.mpsMajorVersion
return project.findProperty("mps.version.major")?.toString()?.takeIf { it.isNotEmpty() }
?: project.findProperty("mps.version")?.toString()?.takeIf { it.isNotEmpty() }?.replace(Regex("""(20\d\d\.\d+).*"""), "$1")
?: "2023.2"
Expand Down Expand Up @@ -132,32 +128,6 @@ fun Project.copyMps(): File {
}
}

// Workaround for https://youtrack.jetbrains.com/issue/KT-69541/Kotlin-2.0-compiler-cannot-use-JAR-packaged-as-ZIP64
//
// The issue was first detected with `lib/app.jar` in 2022.2 and 2022.3.
// This JAR is needed since this versions because it contained `com.intellij.openapi.project.ProjectManager`.
// Before that, `lib/platform-api.jar` contained `com.intellij.openapi.project.ProjectManager`.
//
// The workaround is to unzip the JAR with and zip it again.
// Unzipping with Gradle supports ZIP64, but ZIP64 is not used when zipping again.
//
// TODO MODELIX-968 Remove this workaround after it is not needed anymore.
val appJarFile = mpsHomeDir.get().asFile.resolve("lib/app.jar")
if (appJarFile.exists()) {
val appJarContent = mpsHomeDir.get().asFile.resolve("lib/appJarContent")
val appJarFileNotZip64 = mpsHomeDir.get().asFile.resolve("lib/appNotZip64.jar")
println("Unzipping $appJarFile into $appJarContent")
unzipTo(appJarContent, appJarFile)
println("Zipping $appJarContent into $appJarFileNotZip64")
zipTo(appJarFileNotZip64, appJarContent)
println("Deleting $appJarContent")
delete {
this.delete(appJarContent)
}
println("Overriding $appJarFile with $appJarFileNotZip64")
Files.move(appJarFileNotZip64.toPath(), appJarFile.toPath(), StandardCopyOption.REPLACE_EXISTING)
}

// The build number of a local IDE is expected to contain a product code, otherwise an exception is thrown.
val buildTxt = mpsHomeDir.get().asFile.resolve("build.txt")
val buildNumber = buildTxt.readText()
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
[versions]
modelixCore = "9.1.1"
modelixBuildtools="1.7.3"
kotlin = "2.1.0-Beta2"
kotlin = "2.1.0"

[libraries]
modelix-model-api = { group = "org.modelix", name = "model-api", version.ref = "modelixCore" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.modelix.editor.commonAncestor
import org.modelix.editor.descendants
import org.modelix.editor.firstLeaf
import org.modelix.editor.flattenApplicableActions
import org.modelix.editor.getCompletionPattern
import org.modelix.editor.getSubstituteActions
import org.modelix.editor.getVisibleText
import org.modelix.editor.isVisible
Expand Down Expand Up @@ -79,7 +80,7 @@ class CodeCompletionTest {
fun printActions() {
val actions = getSubstituteActions(getNumberLiteralCell())
val parameters = CodeCompletionParameters(editor, "")
actions.forEach { println(it.getMatchingText() + " | " + it.getDescription()) }
actions.forEach { println(it.getCompletionPattern() + " | " + it.getDescription()) }
}

@Test
Expand Down Expand Up @@ -108,8 +109,13 @@ class CodeCompletionTest {
fun noDuplicates() {
val parameters = CodeCompletionParameters(editor, "")
val actions = getSubstituteActions(getNumberLiteralCell())
val knownDuplicates = setOf("none", "[", "it", "|", "ParamRef", "ConvertExpression", "StripUnitExpression", "ValExpression")
val actualDuplicates = actions.groupBy { it.getMatchingText() }.filter { it.value.size > 1 }.map { it.key }
val knownDuplicates = setOf(
"it",
"ParamRef { <shortDescription> <virtualPackage> <param> <smodelAttribute> }",
"StripUnitExpression { <shortDescription> <virtualPackage> <expr> <smodelAttribute> }",
"ValExpression { <shortDescription> <virtualPackage> <smodelAttribute> }"
)
val actualDuplicates = actions.groupBy { it.getCompletionPattern() }.filter { it.value.size > 1 }.map { it.key }
val unexpectedDuplicates = actualDuplicates - knownDuplicates
val missingDuplicates = knownDuplicates - actualDuplicates
assertTrue(unexpectedDuplicates.isEmpty(), "Duplicate entries found: " + unexpectedDuplicates)
Expand All @@ -122,7 +128,7 @@ class CodeCompletionTest {
val parameters = CodeCompletionParameters(editor, "")
return branch.computeRead {
cell.getSubstituteActions().flatMap { it.flattenApplicableActions(parameters) }
.sortedBy { it.getMatchingText() }.toList()
.sortedBy { it.getCompletionPattern() }.toList()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.modelix.editor.JSKeyboardEventType
import org.modelix.editor.KeyLocation
import org.modelix.editor.Modifiers
import org.modelix.editor.flattenApplicableActions
import org.modelix.editor.getCompletionPattern
import org.modelix.editor.getSubstituteActions
import org.modelix.editor.layoutable
import org.modelix.editor.resolvePropertyCell
Expand Down Expand Up @@ -87,7 +88,7 @@ class PropertyChangeTest {
val parameters = CodeCompletionParameters(editor, "")
val cell = editor.resolvePropertyCell(C_NumberLiteral.value, numberLiteral)!!
val actions: List<ICodeCompletionAction> = cell.getSubstituteActions().flatMap { it.flattenApplicableActions(parameters) }.toList()
actions.forEach { println(it.getMatchingText() + " | " + it.getDescription()) }
actions.forEach { println(it.getCompletionPattern() + " | " + it.getDescription()) }
assertTrue(actions.isNotEmpty())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,7 @@
<node concept="3JB3jO" id="4cpiv6orxGs" role="2OY0$2">
<property role="3JB3xJ" value="super" />
</node>
<node concept="1yiDf7" id="23vo47qRLVr" role="2OY0$2" />
<node concept="3JB3jO" id="4cpiv6orxGx" role="2OY0$2">
<property role="3JB3xJ" value="." />
</node>
Expand Down
47 changes: 47 additions & 0 deletions ...s.notation/generator/templates/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,53 @@
<node concept="359W_D" id="2QtC6yZ1W5E" role="37wK5m">
<ref role="359W_E" to="tpee:fz7vLUo" resolve="VariableReference" />
<ref role="359W_F" to="tpee:fzcqZ_w" resolve="variableDeclaration" />
<node concept="1ZhdrF" id="23vo47q_GD7" role="lGtFl">
<property role="2qtEX8" value="linkDeclaration" />
<property role="P3scX" value="7866978e-a0f0-4cc7-81bc-4d213d9375e1/2644386474301421077/2644386474301421079" />
<node concept="3$xsQk" id="23vo47q_GDa" role="3$ytzL">
<node concept="3clFbS" id="23vo47q_GDb" role="2VODD2">
<node concept="3clFbF" id="23vo47q_GDh" role="3cqZAp">
<node concept="2OqwBi" id="23vo47q_JvP" role="3clFbG">
<node concept="2OqwBi" id="23vo47q_GDc" role="2Oq$k0">
<node concept="3TrEf2" id="23vo47q_GDf" role="2OqNvi">
<ref role="3Tt5mk" to="f8gn:ziPuhEA2aC" resolve="link" />
</node>
<node concept="30H73N" id="23vo47q_GDg" role="2Oq$k0" />
</node>
<node concept="2qgKlT" id="23vo47q_Ku9" role="2OqNvi">
<ref role="37wK5l" to="tpcn:hEwIf_V" resolve="getGenuineLink" />
</node>
</node>
</node>
</node>
</node>
</node>
<node concept="1ZhdrF" id="23vo47q_KZD" role="lGtFl">
<property role="2qtEX8" value="conceptDeclaration" />
<property role="P3scX" value="7866978e-a0f0-4cc7-81bc-4d213d9375e1/2644386474301421077/2644386474301421078" />
<node concept="3$xsQk" id="23vo47q_KZE" role="3$ytzL">
<node concept="3clFbS" id="23vo47q_KZF" role="2VODD2">
<node concept="3clFbF" id="23vo47q_M3b" role="3cqZAp">
<node concept="2OqwBi" id="23vo47q_M3c" role="3clFbG">
<node concept="2OqwBi" id="23vo47q_M3d" role="2Oq$k0">
<node concept="2OqwBi" id="23vo47q_M3e" role="2Oq$k0">
<node concept="30H73N" id="23vo47q_M3f" role="2Oq$k0" />
<node concept="3TrEf2" id="23vo47q_M3g" role="2OqNvi">
<ref role="3Tt5mk" to="f8gn:ziPuhEA2aC" resolve="link" />
</node>
</node>
<node concept="2qgKlT" id="23vo47q_M3h" role="2OqNvi">
<ref role="37wK5l" to="tpcn:hEwIf_V" resolve="getGenuineLink" />
</node>
</node>
<node concept="2qgKlT" id="23vo47q_M3i" role="2OqNvi">
<ref role="37wK5l" to="tpcn:7jb4LXpbWaP" resolve="getConceptDeclaration" />
</node>
</node>
</node>
</node>
</node>
</node>
</node>
</node>
</node>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,6 @@
</concept>
<concept id="1225797177491" name="jetbrains.mps.baseLanguage.closures.structure.InvokeFunctionOperation" flags="nn" index="1Bd96e" />
</language>
<language id="c7b55726-1795-47bd-aa21-714ac1e30f21" name="org.modelix.mps.notation">
<concept id="635805674430276261" name="org.modelix.mps.notation.structure.ReferenceCell" flags="ng" index="1yiJt1">
<reference id="635805674430276264" name="link" index="1yiJtc" />
<child id="2346135138154959868" name="renderTarget" index="1KhJq6" />
</concept>
<concept id="8310867745953062360" name="org.modelix.mps.notation.structure.NotationModule" flags="ng" index="3JBFZQ">
<child id="8310867745953085065" name="content" index="3JBHiB" />
</concept>
<concept id="8310867745953086317" name="org.modelix.mps.notation.structure.ConceptNotation" flags="ng" index="3JBH_3">
<reference id="8310867745953086698" name="concept" index="3JBHV5" />
<child id="8310867745953087407" name="cell" index="3JBHQ1" />
</concept>
<concept id="2346135138155555729" name="org.modelix.mps.notation.structure.BL_ReferenceTargetExpression" flags="ng" index="1KnsVF" />
</language>
<language id="3a13115c-633c-4c5c-bbcc-75c4219e9555" name="jetbrains.mps.lang.quotation">
<concept id="5455284157994012186" name="jetbrains.mps.lang.quotation.structure.NodeBuilderInitLink" flags="ng" index="2pIpSj">
<reference id="5455284157994012188" name="link" index="2pIpSl" />
Expand Down Expand Up @@ -3546,20 +3532,5 @@
</node>
</node>
</node>
<node concept="3JBFZQ" id="72hS3ltD5dh">
<property role="TrG5h" value="SpreadsheetsNotation" />
<node concept="3JBH_3" id="72hS3ltD5dk" role="3JBHiB">
<ref role="3JBHV5" to="ur0y:2ti6llKUmc0" resolve="ColumnReference" />
<node concept="1yiJt1" id="72hS3ltFkcB" role="3JBHQ1">
<ref role="1yiJtc" to="ur0y:2ti6llKUmc1" resolve="column" />
<node concept="2OqwBi" id="1edLqv8JwxC" role="1KhJq6">
<node concept="1KnsVF" id="1edLqv8JwqD" role="2Oq$k0" />
<node concept="2qgKlT" id="1edLqv8JylR" role="2OqNvi">
<ref role="37wK5l" to="xmo0:1gyl2moVSFk" resolve="getColumnLabel" />
</node>
</node>
</node>
</node>
</node>
</model>

2 changes: 1 addition & 1 deletion projectional-editor-ssr-mps-languages/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ tasks {

val pluginDir = mpsPluginsDir
if (pluginDir != null) {
create<Sync>("installMpsPlugin") {
register<Sync>("installMpsPlugin") {
dependsOn(prepareSandbox)
from(project.layout.buildDirectory.dir("idea-sandbox/plugins/${project.name}"))
into(pluginDir.resolve(project.name))
Expand Down
Loading

0 comments on commit addae93

Please sign in to comment.