-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b65491
commit 75a2154
Showing
10 changed files
with
271 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
plugins { | ||
kotlin("jvm") | ||
id("maven-publish") | ||
} | ||
|
||
val vertxVersion: String by project | ||
val jupiterVersion: String by project | ||
val guavaVersion: String by project | ||
val projectVersion: String by project | ||
val protocolVersion = project.properties["protocolVersion"] as String? ?: projectVersion | ||
|
||
group = "plus.sourceplus.interface" | ||
version = project.properties["projectVersion"] as String? ?: projectVersion | ||
|
||
intellij { | ||
type.set("IC") | ||
plugins.set(listOf("com.jetbrains.rust:232.20527.212")) | ||
} | ||
|
||
val sourcesJar = tasks.register<Jar>("sourcesJar") { | ||
archiveClassifier.set("sources") | ||
from(project.the<SourceSetContainer>()["main"].allSource) | ||
} | ||
|
||
configure<PublishingExtension> { | ||
repositories { | ||
maven { | ||
name = "GitHubPackages" | ||
url = uri("https://maven.pkg.github.com/sourceplusplus/interface-jetbrains") | ||
credentials { | ||
username = System.getenv("GH_PUBLISH_USERNAME")?.toString() | ||
password = System.getenv("GH_PUBLISH_TOKEN")?.toString() | ||
} | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("maven") { | ||
groupId = project.group.toString() | ||
artifactId = "jetbrains-marker-rs" | ||
version = project.version.toString() | ||
|
||
from(components["kotlin"]) | ||
|
||
// Ship the sources jar | ||
artifact(sourcesJar) | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(projectDependency(":core")) | ||
implementation(projectDependency(":marker")) | ||
implementation("plus.sourceplus:protocol:$protocolVersion") | ||
implementation("io.vertx:vertx-core:$vertxVersion") | ||
implementation("io.vertx:vertx-lang-kotlin-coroutines:$vertxVersion") { | ||
exclude(group = "org.jetbrains.kotlinx") | ||
} | ||
|
||
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") | ||
compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8") | ||
compileOnly("com.google.guava:guava:$guavaVersion") | ||
compileOnly("org.jetbrains:annotations:24.0.1") | ||
|
||
testRuntimeOnly(projectDependency(":marker:ult-marker")) | ||
testImplementation("org.junit.jupiter:junit-jupiter:$jupiterVersion") | ||
} | ||
|
||
fun projectDependency(name: String): ProjectDependency { | ||
return if (rootProject.name.contains("jetbrains")) { | ||
DependencyHandlerScope.of(rootProject.dependencies).project(name) | ||
} else { | ||
DependencyHandlerScope.of(rootProject.dependencies).project(":interfaces:jetbrains$name") | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
marker/rs-marker/src/main/kotlin/spp/jetbrains/marker/rs/RustLanguageProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Source++, the continuous feedback platform for developers. | ||
* Copyright (C) 2022-2024 CodeBrig, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package spp.jetbrains.marker.rs | ||
|
||
import com.intellij.openapi.project.Project | ||
import org.rust.lang.core.psi.RsFile | ||
import spp.jetbrains.artifact.service.ArtifactModelService | ||
import spp.jetbrains.artifact.service.ArtifactTypeService | ||
import spp.jetbrains.marker.LanguageProvider | ||
import spp.jetbrains.marker.rs.service.RustArtifactModelService | ||
import spp.jetbrains.marker.rs.service.RustArtifactTypeService | ||
import spp.jetbrains.marker.source.SourceFileMarker | ||
|
||
/** | ||
* Provides Rust support for the Marker API. | ||
* | ||
* @author [Brandon Fergerson](mailto:[email protected]) | ||
*/ | ||
class RustLanguageProvider : LanguageProvider { | ||
|
||
override fun canSetup() = classExists("org.rust.lang.core.psi.ext.RsElement") | ||
|
||
override fun setup(project: Project, setupDetectors: Boolean) { | ||
SourceFileMarker.SUPPORTED_FILE_TYPES.add(RsFile::class.java) | ||
|
||
ArtifactModelService.addService(RustArtifactModelService(), "Rust") | ||
ArtifactTypeService.addService(RustArtifactTypeService(), "Rust") | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
marker/rs-marker/src/main/kotlin/spp/jetbrains/marker/rs/model/RustIfArtifact.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Source++, the continuous feedback platform for developers. | ||
* Copyright (C) 2022-2024 CodeBrig, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package spp.jetbrains.marker.rs.model | ||
|
||
import org.rust.lang.core.psi.RsIfExpr | ||
import spp.jetbrains.artifact.model.ArtifactElement | ||
import spp.jetbrains.artifact.model.IfArtifact | ||
import spp.jetbrains.artifact.service.toArtifact | ||
|
||
class RustIfArtifact(override val psiElement: RsIfExpr) : IfArtifact(psiElement) { | ||
|
||
override val condition: ArtifactElement? | ||
get() = psiElement.condition.toArtifact() | ||
|
||
override val thenBranch: ArtifactElement? | ||
get() = null | ||
|
||
override val elseBranch: ArtifactElement? | ||
get() = psiElement.elseBranch?.toArtifact() | ||
|
||
override fun clone(): RustIfArtifact { | ||
return RustIfArtifact(psiElement) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
marker/rs-marker/src/main/kotlin/spp/jetbrains/marker/rs/service/RustArtifactModelService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Source++, the continuous feedback platform for developers. | ||
* Copyright (C) 2022-2024 CodeBrig, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package spp.jetbrains.marker.rs.service | ||
|
||
import com.intellij.psi.PsiElement | ||
import org.rust.lang.core.psi.RsIfExpr | ||
import spp.jetbrains.artifact.model.ArtifactElement | ||
import spp.jetbrains.artifact.service.define.IArtifactModelService | ||
import spp.jetbrains.marker.rs.model.RustIfArtifact | ||
|
||
/** | ||
* Provides language-agnostic artifact model service for Rust. | ||
* | ||
* @author [Brandon Fergerson](mailto:[email protected]) | ||
*/ | ||
class RustArtifactModelService : IArtifactModelService { | ||
|
||
override fun toArtifact(element: PsiElement): ArtifactElement? { | ||
return when (element) { | ||
is RsIfExpr -> RustIfArtifact(element) | ||
else -> null | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
marker/rs-marker/src/main/kotlin/spp/jetbrains/marker/rs/service/RustArtifactTypeService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Source++, the continuous feedback platform for developers. | ||
* Copyright (C) 2022-2024 CodeBrig, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package spp.jetbrains.marker.rs.service | ||
|
||
import com.intellij.psi.PsiComment | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.impl.source.tree.LeafPsiElement | ||
import org.rust.lang.core.psi.RsExpr | ||
import org.rust.lang.core.psi.RsFunction | ||
import spp.jetbrains.artifact.service.define.IArtifactTypeService | ||
import spp.protocol.artifact.ArtifactType | ||
|
||
/** | ||
* Used to determine the type of Rust artifacts. | ||
* | ||
* @author [Brandon Fergerson](mailto:[email protected]) | ||
*/ | ||
class RustArtifactTypeService : IArtifactTypeService { | ||
|
||
override fun getAnnotations(element: PsiElement): List<PsiElement> { | ||
return emptyList() //todo: implement | ||
} | ||
|
||
override fun getAnnotationOwnerIfAnnotation(element: PsiElement): PsiElement? { | ||
return null //todo: implement | ||
} | ||
|
||
override fun getAnnotationOwnerIfAnnotation(element: PsiElement, line: Int): PsiElement? { | ||
return null //todo: implement | ||
} | ||
|
||
override fun isComment(element: PsiElement): Boolean { | ||
val comment = element is PsiComment | ||
if (comment) return true | ||
|
||
return if (element is LeafPsiElement) { | ||
isComment(element.parent) | ||
} else false | ||
} | ||
|
||
override fun getType(element: PsiElement): ArtifactType? { | ||
return when (element) { | ||
is RsFunction -> ArtifactType.FUNCTION | ||
is RsExpr -> ArtifactType.EXPRESSION | ||
|
||
else -> null | ||
} | ||
} | ||
|
||
override fun isLiteral(element: PsiElement): Boolean { | ||
return super.isLiteral(element) //todo: implement | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
marker/rs-marker/src/main/resources/META-INF/services/spp.jetbrains.marker.LanguageProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
spp.jetbrains.marker.rs.RustLanguageProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<idea-plugin> | ||
<extensions defaultExtensionNs="com.intellij"> | ||
</extensions> | ||
</idea-plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters