Skip to content

Commit d7636d7

Browse files
artemmukhinavrong
authored andcommitted
Add js module for Rust <-> JavaScript interop
1 parent 953cd3d commit d7636d7

File tree

7 files changed

+68
-1
lines changed

7 files changed

+68
-1
lines changed

build.gradle.kts

+17-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ project(":plugin") {
171171
project(":intellij-toml"),
172172
"IntelliLang",
173173
graziePlugin,
174-
psiViewerPlugin
174+
psiViewerPlugin,
175+
"JavaScriptLanguage"
175176
)
176177
if (baseIDE == "idea") {
177178
plugins += listOf(
@@ -194,6 +195,7 @@ project(":plugin") {
194195
implementation(project(":intelliLang"))
195196
implementation(project(":duplicates"))
196197
implementation(project(":grazie"))
198+
implementation(project(":js"))
197199
}
198200

199201
tasks {
@@ -314,6 +316,7 @@ project(":idea") {
314316
project(":clion") {
315317
intellij {
316318
version = clionVersion
319+
setPlugins("JavaScriptLanguage")
317320
}
318321
dependencies {
319322
implementation(project(":"))
@@ -407,6 +410,19 @@ project(":grazie") {
407410
}
408411
}
409412

413+
project(":js") {
414+
intellij {
415+
version = ideaVersion
416+
setPlugins("JavaScriptLanguage")
417+
}
418+
dependencies {
419+
implementation(project(":"))
420+
implementation(project(":common"))
421+
testImplementation(project(":", "testOutput"))
422+
testImplementation(project(":common", "testOutput"))
423+
}
424+
}
425+
410426
project(":intellij-toml") {
411427
version = "0.2.$patchVersion.${prop("buildNumber")}$versionSuffix"
412428

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Use of this source code is governed by the MIT license that can be
3+
* found in the LICENSE file.
4+
*/
5+
6+
package org.rust.js
7+
8+
import com.intellij.patterns.PlatformPatterns
9+
import com.intellij.psi.*
10+
import com.intellij.util.ProcessingContext
11+
import org.rust.lang.core.psi.RsElementTypes
12+
13+
class MyReferenceContributor : PsiReferenceContributor() {
14+
override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {
15+
registrar.registerReferenceProvider(
16+
PlatformPatterns.psiElement(RsElementTypes.IDENTIFIER),
17+
MyReferenceProvider()
18+
)
19+
}
20+
}
21+
22+
class MyReferenceProvider : PsiReferenceProvider() {
23+
override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array<PsiReference> {
24+
return emptyArray()
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<idea-plugin>
2+
<extensions defaultExtensionNs="com.intellij">
3+
<psi.referenceContributor language="JSON" implementation="org.rust.js.MyReferenceContributor"/>
4+
</extensions>
5+
</idea-plugin>
6+
7+
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Use of this source code is governed by the MIT license that can be
3+
* found in the LICENSE file.
4+
*/
5+
6+
package org.rust.js
7+
8+
class MyReferenceContributorTest {
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude" allow-bundled-update="true">
2+
<id>org.rust.js</id>
3+
<xi:include href="/META-INF/rust-core.xml" xpointer="xpointer(/idea-plugin/*)"/>
4+
<depends optional="true" config-file="js-only.xml">JavaScript</depends>
5+
</idea-plugin>

plugin/src/main/resources/META-INF/plugin.xml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<depends optional="true" config-file="duplicates-only.xml">com.intellij.modules.duplicatesDetector</depends>
2828
<depends optional="true" config-file="coverage-only.xml">com.intellij.modules.coverage</depends>
2929
<depends optional="true" config-file="grazie-only.xml">tanvd.grazi</depends>
30+
<depends optional="true" config-file="js-only.xml">JavaScript</depends>
3031

3132
<extensions defaultExtensionNs="com.intellij">
3233
<!-- although Rust module type is only created by IDEA, we need it in other IDEs as well

settings.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ include(
1212
"intelliLang",
1313
"duplicates",
1414
"grazie",
15+
"js",
1516
"intellij-toml"
1617
)

0 commit comments

Comments
 (0)