Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinVaadin committed Dec 16, 2024
1 parent 09c3eae commit cae7472
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class HillaReferenceContributor : PsiReferenceContributor() {

internal class TsxToJavaReferenceProvider : PsiReferenceProvider() {
override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array<PsiReference> {
println(element.toString())
println(element.text)
if (element.parent is JSCallExpression) {
val methodExpression = (element.parent as JSCallExpression).methodExpression
val className = methodExpression?.firstChild?.text
Expand Down Expand Up @@ -54,8 +56,8 @@ class HillaReferenceContributor : PsiReferenceContributor() {
}

override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {

registrar.registerReferenceProvider(
PlatformPatterns.psiElement(JSReferenceExpression::class.java), TsxToJavaReferenceProvider())
PlatformPatterns.psiElement(JSReferenceExpression::class.java),
TsxToJavaReferenceProvider())
}
}
15 changes: 15 additions & 0 deletions src/main/kotlin/com/vaadin/plugin/endpoints/VaadinEndpointGroup.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.vaadin.plugin.endpoints

import com.intellij.microservices.endpoints.ModuleEndpointsFilter
import com.intellij.openapi.project.Project

internal enum class ENDPOINT_GROUP {
HILLA,
FLOW
}

internal class VaadinEndpointGroup(
val project: Project,
val filter: ModuleEndpointsFilter,
val endPointGroup: ENDPOINT_GROUP
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,12 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.ModificationTracker
import com.intellij.psi.PsiElement
import com.intellij.uast.UastModificationTracker
import com.vaadin.plugin.endpoints.VaadinEndpointsProvider.VaadinEndpointGroup
import com.vaadin.plugin.utils.VaadinIcons
import com.vaadin.plugin.utils.hasVaadin

internal class VaadinEndpointsProvider : EndpointsProvider<VaadinEndpointGroup, VaadinRoute> {
override val endpointType: EndpointType = HTTP_SERVER_TYPE

enum class ENDPOINT_GROUP {
HILLA,
FLOW
}

internal class VaadinEndpointGroup(
val project: Project,
val filter: ModuleEndpointsFilter,
val endPointGroup: ENDPOINT_GROUP
)

override val presentation: FrameworkPresentation =
FrameworkPresentation("Vaadin", "Vaadin", VaadinIcons.VAADIN_BLUE)

Expand Down Expand Up @@ -77,7 +65,7 @@ internal class VaadinEndpointsProvider : EndpointsProvider<VaadinEndpointGroup,
val urlString = run {
if (urlMapping.isBlank()) return@run "/"
if (group.endPointGroup == ENDPOINT_GROUP.FLOW && !urlMapping.startsWith("/")) return@run "/$urlMapping"
if (group.endPointGroup == ENDPOINT_GROUP.HILLA) return@run "$urlMapping"
if (group.endPointGroup == ENDPOINT_GROUP.HILLA) return@run urlMapping
return@run urlMapping
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/kotlin/com/vaadin/plugin/endpoints/VaadinModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ internal fun findHillaEndpoints(project: Project, scope: GlobalSearchScope): Col
val className = psiClass.name

if (sourcePsi == null || className == null) return@Processor true
// val uAnnotation = uClass.findAnnotation(HILLA_BROWSER_CALLABLE) ?:
// return@Processor true

endpoints.add(VaadinRoute(className, className, PsiAnchor.create(sourcePsi)))

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
<depends>com.intellij.modules.java</depends>
<depends>org.jetbrains.idea.maven</depends>
<depends>org.jetbrains.plugins.gradle</depends>
<depends>JavaScript</depends>

<!-- Vaadin Endpoints IntelliJ Ultimate dependencies -->
<depends>com.intellij.properties</depends>
<depends optional="true" config-file="vaadin-with-microservices.xml">com.intellij.modules.microservices</depends>
<depends optional="true" config-file="vaadin-with-microservices-jvm.xml">com.intellij.microservices.jvm</depends>
<depends optional="true" config-file="vaadin-with-ultimate.xml">com.intellij.modules.ultimate</depends>
<depends optional="true" config-file="vaadin-with-javascript.xml">JavaScript</depends>

<change-notes>
<![CDATA[
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/META-INF/vaadin-with-javascript.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<idea-plugin>

<extensions defaultExtensionNs="com.intellij">
<psi.referenceContributor language="TypeScript" implementation="com.vaadin.plugin.endpoints.HillaReferenceContributor"/>
</extensions>

</idea-plugin>
1 change: 0 additions & 1 deletion src/main/resources/META-INF/vaadin-with-ultimate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<extensions defaultExtensionNs="com.intellij">
<psi.referenceContributor language="UAST" implementation="com.vaadin.plugin.endpoints.VaadinReferenceContributor"/>
<psi.referenceContributor language="TypeScript" implementation="com.vaadin.plugin.endpoints.HillaReferenceContributor"/>
</extensions>

</idea-plugin>

0 comments on commit cae7472

Please sign in to comment.