-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/include-indexing
- Loading branch information
Showing
11 changed files
with
115 additions
and
40 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
44 changes: 44 additions & 0 deletions
44
src/main/kotlin/com/vaadin/plugin/endpoints/VaadinFlowEndpointsProvider.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,44 @@ | ||
package com.vaadin.plugin.endpoints | ||
|
||
import com.intellij.microservices.endpoints.EndpointsFilter | ||
import com.intellij.microservices.endpoints.FrameworkPresentation | ||
import com.intellij.microservices.endpoints.ModuleEndpointsFilter | ||
import com.intellij.microservices.endpoints.presentation.HttpUrlPresentation | ||
import com.intellij.microservices.url.UrlPath | ||
import com.intellij.navigation.ItemPresentation | ||
import com.intellij.openapi.project.Project | ||
import com.vaadin.plugin.utils.VaadinIcons | ||
import com.vaadin.plugin.utils.hasVaadin | ||
|
||
internal class VaadinFlowEndpointsProvider : VaadinEndpointsProvider() { | ||
|
||
override val presentation: FrameworkPresentation = | ||
FrameworkPresentation("Vaadin-Flow", "Vaadin Flow", VaadinIcons.VAADIN_BLUE) | ||
|
||
override fun getEndpointGroups(project: Project, filter: EndpointsFilter): Iterable<VaadinRoute> { | ||
if (filter !is ModuleEndpointsFilter) return emptyList() | ||
if (!hasVaadin(filter.module)) return emptyList() | ||
|
||
return findFlowRoutes(project, filter.transitiveSearchScope) | ||
} | ||
|
||
override fun getEndpointPresentation(group: VaadinRoute, endpoint: VaadinRoute): ItemPresentation { | ||
return HttpUrlPresentation(normalizeUrl(group.urlMapping), group.locationString, VaadinIcons.VAADIN_BLUE) | ||
} | ||
|
||
private fun normalizeUrl(urlMapping: String): String { | ||
val urlString = run { | ||
if (urlMapping.isBlank()) return@run "/" | ||
if (!urlMapping.startsWith("/")) return@run "/$urlMapping" | ||
return@run urlMapping | ||
} | ||
|
||
return parseVaadinUrlMapping(urlString).getPresentation(VaadinUrlRenderer) | ||
} | ||
|
||
private object VaadinUrlRenderer : UrlPath.PathSegmentRenderer { | ||
override fun visitVariable(variable: UrlPath.PathSegment.Variable): String { | ||
return "{${variable.variableName}}" | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/com/vaadin/plugin/endpoints/VaadinHillaEndpointsProvider.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,27 @@ | ||
package com.vaadin.plugin.endpoints | ||
|
||
import com.intellij.microservices.endpoints.EndpointsFilter | ||
import com.intellij.microservices.endpoints.FrameworkPresentation | ||
import com.intellij.microservices.endpoints.ModuleEndpointsFilter | ||
import com.intellij.microservices.endpoints.presentation.HttpUrlPresentation | ||
import com.intellij.navigation.ItemPresentation | ||
import com.intellij.openapi.project.Project | ||
import com.vaadin.plugin.utils.VaadinIcons | ||
import com.vaadin.plugin.utils.hasVaadin | ||
|
||
internal class VaadinHillaEndpointsProvider : VaadinEndpointsProvider() { | ||
|
||
override val presentation: FrameworkPresentation = | ||
FrameworkPresentation("Vaadin-Hilla", "Vaadin Hilla", VaadinIcons.HILLA) | ||
|
||
override fun getEndpointGroups(project: Project, filter: EndpointsFilter): Iterable<VaadinRoute> { | ||
if (filter !is ModuleEndpointsFilter) return emptyList() | ||
if (!hasVaadin(filter.module)) return emptyList() | ||
|
||
return findHillaEndpoints(project, filter.transitiveSearchScope) | ||
} | ||
|
||
override fun getEndpointPresentation(group: VaadinRoute, endpoint: VaadinRoute): ItemPresentation { | ||
return HttpUrlPresentation(group.urlMapping, group.locationString, VaadinIcons.HILLA) | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
<idea-plugin> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<psi.referenceContributor language="UAST" implementation="com.vaadin.plugin.endpoints.VaadinReferenceContributor"/> | ||
</extensions> | ||
|
||
</idea-plugin> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.