Skip to content

Commit

Permalink
refactor: rename AsyncAPISchemaIndex to AsyncAPISpecificationIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Dec 10, 2023
1 parent 46e1bb3 commit c5cd3c2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class AsyncAPISchemaIndexer: DataIndexer<String, Set<String>, FileContent> {
}
asyncapiSchema ?: return index

index[AsyncAPISchemaIndex.asyncapi] = setOf(inputData.file.path)
index[AsyncAPISpecificationIndex.asyncapi] = setOf(inputData.file.path)
var foundReferences = emptySet<String>()
AsyncAPISpecificationReferencesCollector(asyncapiSchema, inputData.file.parent).collectFiles().forEach { (referenceType, references) ->
index[referenceType] = references

foundReferences = foundReferences.plus(references)
index[AsyncAPISchemaIndex.references] = foundReferences
index[AsyncAPISpecificationIndex.references] = foundReferences
}

return index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.io.DataOutput
* I use [Set] because of cases when schema has multiple references to schemas.
* @author Pavel Bodiachevskii
*/
class AsyncAPISchemaIndex: FileBasedIndexExtension<String, Set<String>>() {
class AsyncAPISpecificationIndex: FileBasedIndexExtension<String, Set<String>>() {

override fun getName(): ID<String, Set<String>> = asyncapiIndexId

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ class AsyncAPISpecificationReferencesCollector(

companion object {
val possibleReferencesLocation = mapOf(
AsyncAPISchemaIndex.channels to setOf("\$.channels.*.\$ref"),
AsyncAPISchemaIndex.parameters to setOf(
AsyncAPISpecificationIndex.channels to setOf("\$.channels.*.\$ref"),
AsyncAPISpecificationIndex.parameters to setOf(
"\$.channels.*.parameters.*.\$ref",
"\$.components.parameters.*.\$ref"
),
AsyncAPISchemaIndex.traits to setOf(
AsyncAPISpecificationIndex.traits to setOf(
"\$.channels.*.subscribe.traits.*.\$ref",
"\$.channels.*.publish.traits.*.\$ref",
"\$.components.messages.*.traits.*.\$ref"
),
AsyncAPISchemaIndex.messages to setOf(
AsyncAPISpecificationIndex.messages to setOf(
"\$.channels.*.subscribe.message.\$ref",
"\$.channels.*.publish.message.\$ref",
"\$.components.messages.*.\$ref"
),
AsyncAPISchemaIndex.schemas to setOf("\$.components.schemas.*.\$ref"),
AsyncAPISchemaIndex.securitySchemes to setOf("\$.components.securitySchemes.*.\$ref"),
AsyncAPISchemaIndex.correlationIds to setOf(
AsyncAPISpecificationIndex.schemas to setOf("\$.components.schemas.*.\$ref"),
AsyncAPISpecificationIndex.securitySchemes to setOf("\$.components.securitySchemes.*.\$ref"),
AsyncAPISpecificationIndex.correlationIds to setOf(
"\$.components.messages.*.correlationId.\$ref",
"\$.components.messages.*.traits.*.correlationId.\$ref"
),
AsyncAPISchemaIndex.headers to setOf(
AsyncAPISpecificationIndex.headers to setOf(
"\$.components.messages.*.headers.\$ref",
"\$.components.messages.*.traits.*.headers.\$ref"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asyncapi.plugin.idea.extensions.inspection

import com.asyncapi.plugin.idea.extensions.index.AsyncAPISchemaIndex
import com.asyncapi.plugin.idea.extensions.index.AsyncAPISpecificationIndex
import com.intellij.json.psi.JsonFile
import com.intellij.psi.PsiFile
import com.intellij.psi.search.GlobalSearchScope
Expand Down Expand Up @@ -68,16 +68,16 @@ class AsyncAPISchemaDetector {

private fun indexedAsyncAPISchemas(asyncapiSchema: PsiFile): List<String> {
return FileBasedIndex.getInstance().getValues(
AsyncAPISchemaIndex.asyncapiIndexId,
AsyncAPISchemaIndex.asyncapi,
AsyncAPISpecificationIndex.asyncapiIndexId,
AsyncAPISpecificationIndex.asyncapi,
GlobalSearchScope.allScope(asyncapiSchema.project)
).flatten()
}

private fun indexedReferencedAsyncAPISchemas(asyncapiSchema: PsiFile): List<String> {
return FileBasedIndex.getInstance().getValues(
AsyncAPISchemaIndex.asyncapiIndexId,
AsyncAPISchemaIndex.references,
AsyncAPISpecificationIndex.asyncapiIndexId,
AsyncAPISpecificationIndex.references,
GlobalSearchScope.allScope(asyncapiSchema.project)
).flatten()
}
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 @@ -45,7 +45,7 @@
<localInspection language="JSON" displayName="AsyncAPI schema inspection (json)" groupName="AsyncAPI schema inspections" enabledByDefault="true" level="ERROR" implementationClass="com.asyncapi.plugin.idea.extensions.inspection.AsyncAPIJsonSchemaInspection"/>

<!-- AsyncAPI schema indexing -->
<fileBasedIndex implementation="com.asyncapi.plugin.idea.extensions.index.AsyncAPISchemaIndex"/>
<fileBasedIndex implementation="com.asyncapi.plugin.idea.extensions.index.AsyncAPISpecificationIndex"/>

<!-- AsyncAPI references -->
<psi.referenceContributor language="JSON" implementation="com.asyncapi.plugin.idea.extensions.psi.reference.contributor.json.AsyncAPISpecificationReferenceContributor"/>
Expand Down

0 comments on commit c5cd3c2

Please sign in to comment.