8000 Fixes of 225 228 229 230 231 by koha26 · Pull Request #232 · aemtools/aemtools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixes of 225 228 229 230 231 #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 25, 2022
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object HtlIndexFacade {
return null
}

val normalizedName = normalizeName(name, psiFile)
val normalizedName = normalizeName(name, psiFile) ?: return null

val files = FilenameIndex
.getAllFilesByExt(psiFile.project,
Expand All @@ -62,7 +62,7 @@ object HtlIndexFacade {
return null
}

val normalizedName = normalizeName(name, psiFile)
val normalizedName = normalizeName(name, psiFile) ?: return null

val files = FilenameIndex
.getAllFilesByExt(psiFile.project,
Expand Down Expand Up @@ -146,11 +146,12 @@ object HtlIndexFacade {
* @param psiFile the file in which the file inclusion is present
* @return normalized name
*/
private fun normalizeName(name: String, psiFile: PsiFile): String {
private fun normalizeName(name: String, psiFile: PsiFile): String? {
return if (isAbsolutePath(name)) {
name
} else {
with(psiFile.virtualFile.path) {
val path = psiFile.virtualFile?.path ?: return null
with(path) {
substring(0, lastIndexOf('/')) + "/$name"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.aemtools.index.search

import com.aemtools.common.constant.const
import com.aemtools.common.util.OpenApiUtil.findFileByRelativePath
import com.aemtools.index.HtlTemplateIndex
import com.aemtools.index.model.TemplateDefinition
import com.intellij.openapi.project.Project
Expand Down Expand Up @@ -50,10 +51,14 @@ object HtlTemplateSearch {
it.normalizedPath == name
}
} else {
8000 val path = file.originalFile.containingDirectory.virtualFile.path
val fileName = "$path/$name"
templates.filter {
it.fullName == fileName
val containingDirectoryPath = file.originalFile.containingDirectory?.virtualFile?.path
val filePath = if (containingDirectoryPath != null) {
"$containingDirectoryPath/$name"
} else {
findFileByRelativePath(name, file.project) ?: return listOf()
}
return templates.filter {
it.fullName == filePath
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.intellij.openapi.fileTypes.FileTypeEditorHighlighterProviders
import com.intellij.openapi.fileTypes.LanguageFileType
import com.intellij.openapi.fileTypes.TemplateLanguageFileType
import com.intellij.openapi.fileTypes.ex.FileTypeIdentifiableByVirtualFile
import com.intellij.openapi.project.guessProjectForContentFile
import com.intellij.openapi.project.ProjectLocator
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile
import javax.swing.Icon
Expand All @@ -35,7 +35,7 @@ object HtlFileType
return false
}

val project = guessProjectForContentFile(file)
val project = ProjectLocator.getInstance().guessProjectForFile(file)
val path = file.path

return if (project == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,15 @@ class JcrPropertyInjector : MultiHostInjector {
context: PsiLanguageInjectionHost,
attributeValue: XmlAttributeValue) {
registrar.startInjecting(JcrPropertyLanguage)
val textRange = if (attributeValue.text.length > 2) {
TextRange.create(1, attributeValue.text.length - 1)
} else {
TextRange.create(0, 0)
}
registrar.addPlace(
null, null,
context,
TextRange.create(1, attributeValue.text.length - 1)
textRange
)
registrar.doneInjecting()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class VersionsDiscoveringStartupActivity : StartupActivity {

private fun findPomFiles(project: Project): List<XmlFile> {
val poms = FilenameIndex.getVirtualFilesByName(project, "pom.xml", GlobalSearchScope.projectScope(project))
return poms.map { it.toPsiFile(project) as XmlFile }
return poms.mapNotNull { it.toPsiFile(project) as? XmlFile }
}

private fun setVersionsManuallyNotificationAction(project: Project): NotificationAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import com.intellij.ui.layout.selected
*/
class AemProjectSettingsPanel(private val currentState: AemProjectSettings) {

private val htlVersionsModel = CollectionComboBoxModel(HtlVersion.versions(), currentState.htlVersion.version)
private val aemVersionsModel = buildAemComboboxModel(currentState)
lateinit var isSetHtlVersionManuallyCheckbox: JBCheckBox
lateinit var htlVersionComboBox: ComboBox<String>

val htlVersionsModel = CollectionComboBoxModel(HtlVersion.versions(), currentState.htlVersion.version)
val aemVersionsModel = buildAemComboboxModel(currentState)

var aemVersion: String = currentState.aemVersion.version
var htlVersion: String = currentState.htlVersion.version

private lateinit var isSetHtlVersionManuallyCheckbox: JBCheckBox
private lateinit var htlVersionComboBox: ComboBox<String>

fun getPanel(): DialogPanel = panel {
row("AEM Version:") {
comboBox(aemVersionsModel, ::aemVersion)
Expand All @@ -44,7 +44,7 @@ class AemProjectSettingsPanel(private val currentState: AemProjectSettings) {
}
.addActionListener {
if (isSetHtlVersionManuallyCheckbox.isSelected) {
htlVersionsModel.selectedItem = currentState.htlVersion
htlVersionsModel.selectedItem = currentState.htlVersion.version
}
}
}
Expand All @@ -58,9 +58,13 @@ class AemProjectSettingsPanel(private val currentState: AemProjectSettings) {

fun getPanelState(): AemProjectSettings {
val newState = AemProjectSettings()
newState.aemVersion = aemVersionsModel.selected?.let { AemVersion.fromVersion(it) } ?: currentState.aemVersion
val selectedAemVersion = aemVersionsModel.selected ?: currentState.aemVersion.version
newState.aemVersion = AemVersion.fromVersion(selectedAemVersion) ?: currentState.aemVersion

if (isSetHtlVersionManuallyCheckbox.selected()) {
newState.htlVersion = htlVersionsModel.selected?.let { HtlVersion.fromVersion(it) } ?: currentState.htlVersion
val selectedHtlVersion = htlVersionsModel.selected ?: currentState.htlVersion.version
newState.htlVersion = HtlVersion.fromVersion(selectedHtlVersion) ?: currentState.htlVersion

newState.isManuallyDefinedHtlVersion = true
} else {
newState.htlVersion = currentState.htlVersion
Expand Down
Loading
0