Skip to content

Commit

Permalink
Fix top-level constant reference highlighting (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-vinted authored Aug 10, 2023
1 parent f8d64a4 commit 98dcadb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Top-level constant references are now highlighted correctly (#18)

## [0.0.5] - 2023-08-01

### Added
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.vinted.packwerkintellij
pluginName = packwerk-intellij
pluginRepositoryUrl = https://github.com/vinted/packwerk-intellij
# SemVer format -> https://semver.org
pluginVersion = 0.0.5
pluginVersion = 0.0.6

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 223
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.intellij.psi.PsiFile
import com.vinted.packwerkintellij.PackwerkSettingsState
import org.intellij.markdown.lexer.push
import org.jetbrains.plugins.ruby.ruby.lang.psi.references.RColonReference
import org.jetbrains.plugins.ruby.ruby.lang.psi.references.RTopConstReference
import org.jetbrains.plugins.ruby.ruby.lang.psi.variables.RConstant
import java.nio.charset.Charset
import java.util.*
Expand Down Expand Up @@ -144,7 +145,10 @@ internal class PackwerkAnnotator : ExternalAnnotator<PackwerkAnnotator.State, Pa
var el = file.findElementAt(offset)

// Expand compound constants (e.g. Foo::Bar)
while (el != null && (el.parent is RConstant || el.parent is RColonReference)) {
while (
el != null &&
(el.parent is RConstant || el.parent is RColonReference || el.parent is RTopConstReference)
) {
el = el.parent
}

Expand Down

0 comments on commit 98dcadb

Please sign in to comment.