Skip to content

Commit e63105a

Browse files
committed
- fix: completion did not provide all possibilities (when using with ember-hbs-imports)
- fix: tag completions & references did not work in some cases
1 parent c5e1031 commit e63105a

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Changelog
44
===============================================================================
5+
## 2022.1.1
6+
- fix: completion did not provide all possibilities (when using with ember-hbs-imports)
7+
- fix: tag completions & references did not work in some cases
8+
59
## 2022.1.0
610
- upgrade to 2022.1.0
711

src/main/kotlin/com/emberjs/EmberTagNameProvider.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ class EmberTagNameProvider : XmlTagNameProvider {
125125
val regex = Regex("\\|.*\\|")
126126
val txt = element.name.replace("IntellijIdeaRulezzz", "").split(".").first()
127127
// find all |blocks| from mustache
128-
val blocks = PsiTreeUtil.collectElements(element.containingFile) { it is HbBlockWrapperImpl }
128+
val hbsView = element.containingFile.viewProvider.getPsi(Language.findLanguageByID("Handlebars")!!)
129+
val blocks = PsiTreeUtil.collectElements(hbsView) { it is HbBlockWrapperImpl }
129130
.filter { it.children[0].text.contains(regex) }
130131
.filter { it.textRange.contains(element.textRange) }
131132

@@ -266,8 +267,8 @@ fun toLookupElement(name: EmberName, useImports: Boolean, priority: Double = 90.
266267
tagName = name.tagName
267268
}
268269
val lookupElement = LookupElementBuilder
269-
.create(tagName)
270-
.withTailText(" from ${name.importPath.split("/").first()}")
270+
.create(name, tagName)
271+
.withTailText(" from ${name.importPath}")
271272
.withTypeText("component")
272273
.withIcon(EmberIconProvider.getIcon("component"))
273274
.withCaseSensitivity(true)

src/main/kotlin/com/emberjs/hbs/HbsLocalReference.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ class HbsLocalReference(private val leaf: PsiElement, val target: PsiElement?) :
272272
fun referenceBlocks(element: PsiElement, name: String): PsiReference? {
273273
// any |block param|
274274
// as mustache
275-
val hbblockRefs = PsiTreeUtil.collectElements(element.containingFile, { it is HbOpenBlockMustacheImpl })
275+
val hbsView = element.containingFile.viewProvider.getPsi(Language.findLanguageByID("Handlebars")!!)
276+
val hbblockRefs = PsiTreeUtil.collectElements(hbsView, { it is HbOpenBlockMustacheImpl })
276277
.filter {
277278
PsiTreeUtil.collectElements(PsiTreeUtil.getNextSiblingOfType(it, HbStatementsImpl::class.java), { it == element }).isNotEmpty()
278279
}

src/main/kotlin/com/emberjs/lookup/EmberLookupElementBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder
1010
object EmberLookupElementBuilder {
1111
fun create(it: EmberName, dots: Boolean = true): LookupElement {
1212
val element = LookupElementBuilder
13-
.create(if (dots) it.name.replace("/", ".") else it.name)
13+
.create(it, if (dots) it.name.replace("/", ".") else it.name)
1414
.withTypeText(it.type)
15-
.withTailText(" from ${it.importPath.split("/").first()}")
15+
.withTailText(" from ${it.importPath}")
1616
.withIcon(EmberIconProvider.getIcon(it.type) ?: EmberIcons.EMPTY_16)
1717
.withCaseSensitivity(true)
1818
.withInsertHandler(HbsInsertHandler())

src/main/kotlin/com/emberjs/resolver/EmberName.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ data class EmberName(val type: String, val path: String, val fullImportPath: Str
5353
val angleBracketsName by lazy {
5454
assert(type == "component" || isComponentTemplate)
5555

56-
val baseName = if (isComponentTemplate) name.removePrefix("components/") else name
56+
var baseName = if (isComponentTemplate) name.removePrefix("components/") else name
57+
baseName = baseName.first().uppercase() + baseName.subSequence(1, baseName.lastIndex)
5758

5859
baseName.replace(SIMPLE_DASHERIZE_REGEXP) {
5960
assert(it.range.first - it.range.last == 0)

0 commit comments

Comments
 (0)