diff --git a/extensions/intellij/build.gradle.kts b/extensions/intellij/build.gradle.kts index 336b17bf8..4fef352b6 100644 --- a/extensions/intellij/build.gradle.kts +++ b/extensions/intellij/build.gradle.kts @@ -5,13 +5,13 @@ fun properties(key: String) = providers.gradleProperty(key) fun environment(key: String) = providers.environmentVariable(key) plugins { - id("java") // Java support - alias(libs.plugins.kotlin) // Kotlin support - alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin - alias(libs.plugins.changelog) // Gradle Changelog Plugin - alias(libs.plugins.qodana) // Gradle Qodana Plugin - alias(libs.plugins.kover) // Gradle Kover Plugin - kotlin("plugin.serialization") version "1.8.0" + id("java") // Java support + alias(libs.plugins.kotlin) // Kotlin support + alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin + alias(libs.plugins.changelog) // Gradle Changelog Plugin + alias(libs.plugins.qodana) // Gradle Qodana Plugin + alias(libs.plugins.kover) // Gradle Kover Plugin + kotlin("plugin.serialization") version "1.8.0" } group = properties("pluginGroup").get() @@ -24,23 +24,23 @@ repositories { mavenCentral() } // Dependencies are managed with Gradle version catalog - read more: // https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog dependencies { - // implementation(libs.annotations) - implementation("com.squareup.okhttp3:okhttp:4.9.1") { - exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib") - } - implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.32") - implementation("io.ktor:ktor-server-core:2.3.7") { - exclude(group = "org.slf4j", module = "slf4j-api") - } - implementation("io.ktor:ktor-server-netty:2.3.7") { - exclude(group = "org.slf4j", module = "slf4j-api") - } - implementation("io.ktor:ktor-server-cors:2.3.7") { - exclude(group = "org.slf4j", module = "slf4j-api") - } - implementation("com.posthog.java:posthog:1.+") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") - // implementation("com.jetbrains.jsonSchema") + // implementation(libs.annotations) + implementation("com.squareup.okhttp3:okhttp:4.9.1") { + exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib") + } + implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.32") + implementation("io.ktor:ktor-server-core:2.3.7") { + exclude(group = "org.slf4j", module = "slf4j-api") + } + implementation("io.ktor:ktor-server-netty:2.3.7") { + exclude(group = "org.slf4j", module = "slf4j-api") + } + implementation("io.ktor:ktor-server-cors:2.3.7") { + exclude(group = "org.slf4j", module = "slf4j-api") + } + implementation("com.posthog.java:posthog:1.+") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") + // implementation("com.jetbrains.jsonSchema") } // Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for @@ -50,98 +50,100 @@ kotlin { jvmToolchain(17) } // Configure Gradle IntelliJ Plugin - read more: // https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - pluginName = properties("pluginName") - version = properties("platformVersion") - type = properties("platformType") + pluginName = properties("pluginName") + version = properties("platformVersion") + type = properties("platformType") - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins = - properties("platformPlugins").map { - it.split(',').map(String::trim).filter(String::isNotEmpty) - } + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. + plugins = + properties("platformPlugins").map { + it.split(',').map(String::trim).filter(String::isNotEmpty) + } } // Configure Gradle Changelog Plugin - read more: // https://github.com/JetBrains/gradle-changelog-plugin changelog { - groups.empty() - repositoryUrl = properties("pluginRepositoryUrl") + groups.empty() + repositoryUrl = properties("pluginRepositoryUrl") } // Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin qodana { - cachePath = provider { file(".qodana").canonicalPath } - reportPath = provider { file("build/reports/inspections").canonicalPath } - saveReport = true - showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false) + cachePath = provider { file(".qodana").canonicalPath } + reportPath = provider { file("build/reports/inspections").canonicalPath } + saveReport = true + showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false) } // Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration koverReport { defaults { xml { onCheck = true } } } tasks { - prepareSandbox { - from("../../binary/bin") { into("${intellij.pluginName.get()}/core/") } - from("../vscode/node_modules/@vscode/ripgrep") { into("${intellij.pluginName.get()}/ripgrep/") } - } + prepareSandbox { + from("../../binary/bin") { into("${intellij.pluginName.get()}/core/") } + from("../vscode/node_modules/@vscode/ripgrep") { into("${intellij.pluginName.get()}/ripgrep/") } + } - wrapper { gradleVersion = properties("gradleVersion").get() } + wrapper { gradleVersion = properties("gradleVersion").get() } - patchPluginXml { - version = properties("pluginVersion") - sinceBuild = properties("pluginSinceBuild") - untilBuild = properties("pluginUntilBuild") + patchPluginXml { + version = properties("pluginVersion") + sinceBuild = properties("pluginSinceBuild") + untilBuild = properties("pluginUntilBuild") - // Extract the section from README.md and provide for the plugin's - // manifest - pluginDescription = - providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { - val start = "" - val end = "" + // Extract the section from README.md and provide for the plugin's + // manifest + pluginDescription = + providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { + val start = "" + val end = "" - with(it.lines()) { - if (!containsAll(listOf(start, end))) { - throw GradleException( - "Plugin description section not found in README.md:\n$start ... $end") + with(it.lines()) { + if (!containsAll(listOf(start, end))) { + throw GradleException( + "Plugin description section not found in README.md:\n$start ... $end" + ) + } + subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) + } } - subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) - } - } - } + } - // Configure UI tests plugin - // Read more: https://github.com/JetBrains/intellij-ui-test-robot - runIdeForUiTests { - systemProperty("robot-server.port", "8082") - systemProperty("ide.mac.message.dialogs.as.sheets", "false") - systemProperty("jb.privacy.policy.text", "") - systemProperty("jb.consents.confirmation.enabled", "false") - } + // Configure UI tests plugin + // Read more: https://github.com/JetBrains/intellij-ui-test-robot + runIdeForUiTests { + systemProperty("robot-server.port", "8082") + systemProperty("ide.mac.message.dialogs.as.sheets", "false") + systemProperty("jb.privacy.policy.text", "") + systemProperty("jb.consents.confirmation.enabled", "false") + } - signPlugin { - certificateChain = environment("CERTIFICATE_CHAIN") - privateKey = environment("PRIVATE_KEY") - password = environment("PRIVATE_KEY_PASSWORD") - } + signPlugin { + certificateChain = environment("CERTIFICATE_CHAIN") + privateKey = environment("PRIVATE_KEY") + password = environment("PRIVATE_KEY_PASSWORD") + } - publishPlugin { - // dependsOn("patchChangelog") - token = environment("PUBLISH_TOKEN") - // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release - // labels, like 2.1.7-alpha.3 - // Specify pre-release label to publish the plugin in a custom Release Channel automatically. - // Read more: - // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel - channels.set(listOf(environment("RELEASE_CHANNEL").getOrElse("eap"))) + publishPlugin { + // dependsOn("patchChangelog") + token = environment("PUBLISH_TOKEN") + // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release + // labels, like 2.1.7-alpha.3 + // Specify pre-release label to publish the plugin in a custom Release Channel automatically. + // Read more: + // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel + channels.set(listOf(environment("RELEASE_CHANNEL").getOrElse("eap"))) - // We always hide the stable releases until a few days of EAP have proven them stable - // hidden = environment("RELEASE_CHANNEL").map { it == "stable" }.getOrElse(false) - } + // We always hide the stable releases until a few days of EAP have proven them stable + // hidden = environment("RELEASE_CHANNEL").map { it == "stable" }.getOrElse(false) + } - runIde { - // Open the `manual-testing-sandbox` on start - args = - listOf("${rootProject.projectDir.parentFile.parentFile}/manual-testing-sandbox/test.kt") - .map { file(it).absolutePath } - } + runIde { + // Open the `manual-testing-sandbox` directory and the specific file on start + args = listOf( + "${rootProject.projectDir.parentFile.parentFile}/manual-testing-sandbox", + "${rootProject.projectDir.parentFile.parentFile}/manual-testing-sandbox/test.kt" + ).map { file(it).absolutePath } + } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt index 8ca3648dd..61bc2fac5 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt @@ -12,6 +12,7 @@ import com.github.continuedev.continueintellijextension.services.SettingsListene import com.intellij.openapi.Disposable import com.intellij.openapi.actionSystem.KeyboardShortcut import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.application.ApplicationNamesInfo import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.editor.EditorFactory import com.intellij.openapi.fileEditor.FileEditorManager @@ -31,24 +32,36 @@ import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.roots.ModuleRootManager fun showTutorial(project: Project) { - ContinuePluginStartupActivity::class.java.getClassLoader().getResourceAsStream("continue_tutorial.py").use { `is` -> - if (`is` == null) { - throw IOException("Resource not found: continue_tutorial.py") - } - var content = StreamUtil.readText(`is`, StandardCharsets.UTF_8) - if (!System.getProperty("os.name").toLowerCase().contains("mac")) { - content = content.replace("⌘", "⌃") - } - val filepath = Paths.get(getContinueGlobalPath(), "continue_tutorial.py").toString() - File(filepath).writeText(content) - val virtualFile = LocalFileSystem.getInstance().findFileByPath(filepath) + val tutorialFileName = getTutorialFileName() + ContinuePluginStartupActivity::class.java.getClassLoader().getResourceAsStream(tutorialFileName) + .use { `is` -> + if (`is` == null) { + throw IOException("Resource not found: $tutorialFileName") + } + var content = StreamUtil.readText(`is`, StandardCharsets.UTF_8) + if (!System.getProperty("os.name").lowercase().contains("mac")) { + content = content.replace("⌘", "⌃") + } + val filepath = Paths.get(getContinueGlobalPath(), tutorialFileName).toString() + File(filepath).writeText(content) + val virtualFile = LocalFileSystem.getInstance().findFileByPath(filepath) - ApplicationManager.getApplication().invokeLater { - if (virtualFile != null) { - FileEditorManager.getInstance(project).openFile(virtualFile, true) + ApplicationManager.getApplication().invokeLater { + if (virtualFile != null) { + FileEditorManager.getInstance(project).openFile(virtualFile, true) + } } } +} + +private fun getTutorialFileName(): String { + val appName = ApplicationNamesInfo.getInstance().fullProductName.lowercase() + return when { + appName.contains("intellij") -> "continue_tutorial.java" + appName.contains("pycharm") -> "continue_tutorial.py" + appName.contains("webstorm") -> "continue_tutorial.ts" + else -> "continue_tutorial.py" // Default to Python tutorial } } @@ -101,7 +114,7 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { ServiceManager.getService(ContinueExtensionSettings::class.java) if (!settings.continueState.shownWelcomeDialog) { settings.continueState.shownWelcomeDialog = true - // Open continue_tutorial.py + // Open continue_tutorial.java showTutorial(project) } diff --git a/extensions/intellij/src/main/resources/continue_tutorial.java b/extensions/intellij/src/main/resources/continue_tutorial.java new file mode 100644 index 000000000..41ac854c0 --- /dev/null +++ b/extensions/intellij/src/main/resources/continue_tutorial.java @@ -0,0 +1,55 @@ +/* _________ _____ _____ + __ ____/______ _______ __ /____(_)_______ ____ _______ + _ / _ __ \__ __ \_ __/__ / __ __ \_ / / /_ _ \ + / /___ / /_/ /_ / / // /_ _ / _ / / // /_/ / / __/ + \____/ \____/ /_/ /_/ \__/ /_/ /_/ /_/ \__,_/ \___/ + + Chat, Edit, and Autocomplete tutorial +*/ + + +/* ————————————————————————————————————————————————— Chat ————————————————————————————————————————————————— */ + +// Highlight the code below +// Press [Cmd/Ctrl + J] to add to Chat +// Try asking Continue "what sorting algorithm is this?" +public static int[] sortingAlgorithm(int[] x) { + for (int i = 0; i < x.length; i++) { + for (int j = 0; j < x.length - 1; j++) { + if (x[j] > x[j + 1]) { + int temp = x[j]; + x[j] = x[j + 1]; + x[j + 1] = temp; + } + } + } + return x; +} + +/* ————————————————————————————————————————————————— Edit ————————————————————————————————————————————————— */ + +// Highlight the code below +// Press [Cmd/Ctrl + I] to Edit +// Try asking Continue to "make this more readable" +public static int[] sortingAlgorithm2(int[] x) { + for (int i = 0; i < x.length; i++) { + for (int j = 0; j < x.length - 1; j++) { + if (x[j] > x[j + 1]) { + int temp = x[j]; + x[j] = x[j + 1]; + x[j + 1] = temp; + } + } + } + return x; +} + +/* ————————————————————————————————————————————— Autocomplete —————————————————————————————————————————————— */ + +// Place cursor after `sortingAlgorithm...` below and press [Enter] +// Press [Tab] to accept the Autocomplete suggestion + +// Basic assertion for sortingAlgorithm... + + +/* —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— */ diff --git a/extensions/intellij/src/main/resources/continue_tutorial.py b/extensions/intellij/src/main/resources/continue_tutorial.py index e2a4d59e7..16a297c16 100644 --- a/extensions/intellij/src/main/resources/continue_tutorial.py +++ b/extensions/intellij/src/main/resources/continue_tutorial.py @@ -7,8 +7,12 @@ Chat, Edit, and Autocomplete tutorial """ -# ———————————————————— Chat [Cmd/Ctrl + J]: Ask "what sorting algorithm is this?" ———————————————————— +# ————————————————————————————————————————————————— Chat ————————————————————————————————————————————————— # + +## Highlight the code below +## Press [Cmd/Ctrl + J] to add to Chat +## Try asking Continue "what sorting algorithm is this?" def sorting_algorithm(x): for i in range(len(x)): for j in range(len(x) - 1): @@ -16,8 +20,12 @@ def sorting_algorithm(x): x[j], x[j + 1] = x[j + 1], x[j] return x -# —————————————————— Edit [Cmd/Ctrl + I]: Tell Continue to "make this more readable" ————————————————— +# ————————————————————————————————————————————————— Edit ————————————————————————————————————————————————— # + +## Highlight the code below +## Press [Cmd/Ctrl + I] to Edit +## Try asking Continue to "make this more readable" def sorting_algorithm(x): for i in range(len(x)): for j in range(len(x) - 1): @@ -25,9 +33,12 @@ def sorting_algorithm(x): x[j], x[j + 1] = x[j + 1], x[j] return x -# ——————————————— Autocomplete [Tab]: Place cursor after `:` below and press [Enter] ————————————————— +# ————————————————————————————————————————————— Autocomplete —————————————————————————————————————————————— # -# Basic assertion for sorting_algorithm: +## Place cursor after `sorting_algorithm...` below and press [Enter] +## Press [Tab] to accept the Autocomplete suggestion + +# Basic assertion for sorting_algorithm... -"—————————————————— Learn more at https://docs.continue.dev/getting-started/overview ————————————————" \ No newline at end of file +# —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— # diff --git a/extensions/intellij/src/main/resources/continue_tutorial.ts b/extensions/intellij/src/main/resources/continue_tutorial.ts new file mode 100644 index 000000000..301fc248c --- /dev/null +++ b/extensions/intellij/src/main/resources/continue_tutorial.ts @@ -0,0 +1,55 @@ +/* _________ _____ _____ + __ ____/______ _______ __ /____(_)_______ ____ _______ + _ / _ __ \__ __ \_ __/__ / __ __ \_ / / /_ _ \ + / /___ / /_/ /_ / / // /_ _ / _ / / // /_/ / / __/ + \____/ \____/ /_/ /_/ \__/ /_/ /_/ /_/ \__,_/ \___/ + + Chat, Edit, and Autocomplete tutorial +*/ + + +/* ————————————————————————————————————————————————— Chat ————————————————————————————————————————————————— */ + +// Highlight the code below +// Press [Cmd/Ctrl + J] to add to Chat +// Try asking Continue "what sorting algorithm is this?" +function sortingAlgorithm(x: number[]): number[] { + for (let i = 0; i < x.length; i++) { + for (let j = 0; j < x.length - 1; j++) { + if (x[j] > x[j + 1]) { + let temp = x[j]; + x[j] = x[j + 1]; + x[j + 1] = temp; + } + } + } + return x; +} + +/* ————————————————————————————————————————————————— Edit ————————————————————————————————————————————————— */ + +// Highlight the code below +// Press [Cmd/Ctrl + I] to Edit +// Try asking Continue to "make this more readable" +function sortingAlgorithm2(x: number[]): number[] { + for (let i = 0; i < x.length; i++) { + for (let j = 0; j < x.length - 1; j++) { + if (x[j] > x[j + 1]) { + let temp = x[j]; + x[j] = x[j + 1]; + x[j + 1] = temp; + } + } + } + return x; +} + +/* ————————————————————————————————————————————— Autocomplete —————————————————————————————————————————————— */ + +// Place cursor after `sortingAlgorithm...` below and press [Enter] +// Press [Tab] to accept the Autocomplete suggestion + +// Basic assertion for sortingAlgorithm... + + +/* —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— */ diff --git a/extensions/vscode/continue_tutorial.py b/extensions/vscode/continue_tutorial.py index c10e5c209..16a297c16 100644 --- a/extensions/vscode/continue_tutorial.py +++ b/extensions/vscode/continue_tutorial.py @@ -7,8 +7,12 @@ Chat, Edit, and Autocomplete tutorial """ -# ———————————————————— Chat [Cmd/Ctrl + L]: Ask "what sorting algorithm is this?" ———————————————————— +# ————————————————————————————————————————————————— Chat ————————————————————————————————————————————————— # + +## Highlight the code below +## Press [Cmd/Ctrl + J] to add to Chat +## Try asking Continue "what sorting algorithm is this?" def sorting_algorithm(x): for i in range(len(x)): for j in range(len(x) - 1): @@ -16,8 +20,12 @@ def sorting_algorithm(x): x[j], x[j + 1] = x[j + 1], x[j] return x -# —————————————————— Edit [Cmd/Ctrl + I]: Tell Continue to "make this more readable" ————————————————— +# ————————————————————————————————————————————————— Edit ————————————————————————————————————————————————— # + +## Highlight the code below +## Press [Cmd/Ctrl + I] to Edit +## Try asking Continue to "make this more readable" def sorting_algorithm(x): for i in range(len(x)): for j in range(len(x) - 1): @@ -25,9 +33,12 @@ def sorting_algorithm(x): x[j], x[j + 1] = x[j + 1], x[j] return x -# ——————————————— Autocomplete [Tab]: Place cursor after `:` below and press [Enter] ————————————————— +# ————————————————————————————————————————————— Autocomplete —————————————————————————————————————————————— # -# Basic assertion for sorting_algorithm: +## Place cursor after `sorting_algorithm...` below and press [Enter] +## Press [Tab] to accept the Autocomplete suggestion + +# Basic assertion for sorting_algorithm... -"—————————————————— Learn more at https://docs.continue.dev/getting-started/overview ————————————————" \ No newline at end of file +# —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— #