Skip to content

Commit

Permalink
Merge branch 'release/2.6.0' into feat/preview_panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Aug 28, 2024
2 parents 7c58e39 + 646db56 commit ad1fa05
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 8 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ version = "2.6.0+jre17"
repositories {
mavenCentral()
intellijPlatform {
jetbrainsRuntime()
defaultRepositories()

jetbrainsRuntime()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ abstract class PsiFileXPath<AsyncAPISpecification: PsiFile> {
*/
fun compileXPath(specificationReference: String): String {
return specificationReference
.removePrefix("\"")
.removePrefix("\"") // double quoted "some text"
.removeSuffix("\"")
.removePrefix("\'") // single quoted 'some text'
.removeSuffix("\'")
.replace("#/", "")
.split("/")
.joinToString(".", "$.", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ object YamlFileXPath: PsiFileXPath<YAMLFile>() {

override fun findText(asyncAPISpecification: YAMLFile?, psiXPath: String, partialMatch: Boolean): List<String> {
return findPsi(asyncAPISpecification, psiXPath, partialMatch).map {
it.text.removePrefix("\"").removeSuffix("\"")
it.text
.removePrefix("\"") // double quoted "some text"
.removeSuffix("\"")
.removePrefix("\'") // single quoted 'some text'
.removeSuffix("\'")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,23 @@ class AsyncAPIFileReference(
}

private fun extractFileLocation(fileReference: String): String? {
return fileReference.removePrefix("\"").removeSuffix("\"").split("#/").firstOrNull()
return fileReference
.removePrefix("\"") // double quoted 'some text'
.removeSuffix("\"")
.removePrefix("\'") // single quoted 'some text'
.removeSuffix("\'")
.split("#/")
.firstOrNull()
}

private fun extractLocalReference(fileReference: String): String? {
return fileReference.removePrefix("\"").removeSuffix("\"").split("#/").getOrNull(1)
return fileReference
.removePrefix("\"") // double quoted 'some text'
.removeSuffix("\"")
.removePrefix("\'") // single quoted 'some text'
.removeSuffix("\'")
.split("#/")
.getOrNull(1)
}

private fun findFile(fileLocation: String): PsiFile? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class AsyncAPISpecificationReferenceContributor: PsiReferenceContributor() {
return expectedChild.withParent(expectedParent)
}

private fun fileReferencePattern(): PsiElementPattern.Capture<YAMLValue> {
val expectedChild = PlatformPatterns.psiElement(YAMLValue::class.java)
private fun fileReferencePattern(): PsiElementPattern.Capture<YAMLQuotedText> {
val expectedChild = PlatformPatterns.psiElement(YAMLQuotedText::class.java)
.withText(StandardPatterns.string().contains(".yaml"))

val expectedParent = PlatformPatterns.psiElement(YAMLKeyValue::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class AsyncAPIFileReferenceProvider: PsiReferenceProvider() {

override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array<PsiReference> {
/* experimental */
val value = element.text.removePrefix("\"").removeSuffix("\"")
val value = element.text.removePrefix("\"") // Double quoted "some text"
.removeSuffix("\"")
.removePrefix("\'") // Single quoted 'some text'
.removePrefix("\'")
val textRange = TextRange(1, value.length + 1)
/* experimental */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class AsyncAPILocalReferenceProvider: PsiReferenceProvider() {

override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array<PsiReference> {
/* experimental */
val value = element.text.removePrefix("\"").removeSuffix("\"")
val value = element.text.removePrefix("\"") // Double quoted "some text"
.removeSuffix("\"")
.removePrefix("\'") // Single quoted 'some text'
.removeSuffix("\'")
val textRange = TextRange(1, value.length + 1)
/* experimental */

Expand Down

0 comments on commit ad1fa05

Please sign in to comment.