diff --git a/build.gradle.kts b/build.gradle.kts index 100617d..3d41d6a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,6 +13,7 @@ version = "2.6.0+jre17" repositories { mavenCentral() intellijPlatform { + jetbrainsRuntime() defaultRepositories() jetbrainsRuntime() diff --git a/src/main/kotlin/com/asyncapi/plugin/idea/_core/xpath/PsiFileXPath.kt b/src/main/kotlin/com/asyncapi/plugin/idea/_core/xpath/PsiFileXPath.kt index b711988..4b9ae7b 100644 --- a/src/main/kotlin/com/asyncapi/plugin/idea/_core/xpath/PsiFileXPath.kt +++ b/src/main/kotlin/com/asyncapi/plugin/idea/_core/xpath/PsiFileXPath.kt @@ -18,8 +18,10 @@ abstract class PsiFileXPath { */ fun compileXPath(specificationReference: String): String { return specificationReference - .removePrefix("\"") + .removePrefix("\"") // double quoted "some text" .removeSuffix("\"") + .removePrefix("\'") // single quoted 'some text' + .removeSuffix("\'") .replace("#/", "") .split("/") .joinToString(".", "$.", "") diff --git a/src/main/kotlin/com/asyncapi/plugin/idea/_core/xpath/YamlFileXPath.kt b/src/main/kotlin/com/asyncapi/plugin/idea/_core/xpath/YamlFileXPath.kt index 8ba412d..9643e33 100644 --- a/src/main/kotlin/com/asyncapi/plugin/idea/_core/xpath/YamlFileXPath.kt +++ b/src/main/kotlin/com/asyncapi/plugin/idea/_core/xpath/YamlFileXPath.kt @@ -14,7 +14,11 @@ object YamlFileXPath: PsiFileXPath() { override fun findText(asyncAPISpecification: YAMLFile?, psiXPath: String, partialMatch: Boolean): List { return findPsi(asyncAPISpecification, psiXPath, partialMatch).map { - it.text.removePrefix("\"").removeSuffix("\"") + it.text + .removePrefix("\"") // double quoted "some text" + .removeSuffix("\"") + .removePrefix("\'") // single quoted 'some text' + .removeSuffix("\'") } } diff --git a/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/AsyncAPIFileReference.kt b/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/AsyncAPIFileReference.kt index ce440ca..5409007 100644 --- a/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/AsyncAPIFileReference.kt +++ b/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/AsyncAPIFileReference.kt @@ -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? { diff --git a/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/contributor/yaml/AsyncAPISpecificationReferenceContributor.kt b/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/contributor/yaml/AsyncAPISpecificationReferenceContributor.kt index 41e5f36..25a59f9 100644 --- a/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/contributor/yaml/AsyncAPISpecificationReferenceContributor.kt +++ b/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/contributor/yaml/AsyncAPISpecificationReferenceContributor.kt @@ -33,8 +33,8 @@ class AsyncAPISpecificationReferenceContributor: PsiReferenceContributor() { return expectedChild.withParent(expectedParent) } - private fun fileReferencePattern(): PsiElementPattern.Capture { - val expectedChild = PlatformPatterns.psiElement(YAMLValue::class.java) + private fun fileReferencePattern(): PsiElementPattern.Capture { + val expectedChild = PlatformPatterns.psiElement(YAMLQuotedText::class.java) .withText(StandardPatterns.string().contains(".yaml")) val expectedParent = PlatformPatterns.psiElement(YAMLKeyValue::class.java) diff --git a/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/provider/yaml/AsyncAPIFileReferenceProvider.kt b/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/provider/yaml/AsyncAPIFileReferenceProvider.kt index f3d21b2..eccee6f 100644 --- a/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/provider/yaml/AsyncAPIFileReferenceProvider.kt +++ b/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/provider/yaml/AsyncAPIFileReferenceProvider.kt @@ -14,7 +14,10 @@ class AsyncAPIFileReferenceProvider: PsiReferenceProvider() { override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array { /* 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 */ diff --git a/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/provider/yaml/AsyncAPILocalReferenceProvider.kt b/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/provider/yaml/AsyncAPILocalReferenceProvider.kt index 0bd4834..21566a6 100644 --- a/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/provider/yaml/AsyncAPILocalReferenceProvider.kt +++ b/src/main/kotlin/com/asyncapi/plugin/idea/extensions/psi/reference/provider/yaml/AsyncAPILocalReferenceProvider.kt @@ -14,7 +14,10 @@ class AsyncAPILocalReferenceProvider: PsiReferenceProvider() { override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array { /* 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 */