Added edit handler for attribute values

This commit is contained in:
Akash Yadav
2022-09-19 21:29:18 +05:30
parent fc86ad5976
commit 1a3a9fb876
2 changed files with 35 additions and 1 deletions
@@ -0,0 +1,32 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.lsp.xml.edits
import com.itsaky.androidide.lsp.edits.DefaultEditHandler
/**
* Handles insertion of attribute values.
*
* @author Akash Yadav
*/
class AttrValueEditHandler : QualifiedValueEditHandler() {
override fun isPartialPart(c: Char): Boolean {
return super.isPartialPart(c) || c in charArrayOf('@', '.', ':', '/')
}
}
@@ -34,6 +34,7 @@ import com.itsaky.androidide.lsp.models.CompletionResult
import com.itsaky.androidide.lsp.models.InsertTextFormat.PLAIN_TEXT
import com.itsaky.androidide.lsp.models.InsertTextFormat.SNIPPET
import com.itsaky.androidide.lsp.models.MatchLevel
import com.itsaky.androidide.lsp.xml.edits.AttrValueEditHandler
import com.itsaky.androidide.lsp.xml.edits.QualifiedValueEditHandler
import com.itsaky.androidide.lsp.xml.edits.TagEditHandler
import com.itsaky.androidide.lsp.xml.utils.XmlUtils.NodeType
@@ -216,7 +217,8 @@ abstract class IXmlCompletionProvider(private val provider: ICompletionProvider)
this.overrideTypeText = type.uppercase()
this.sortText = if (pck == ResourceTableRegistry.PCK_ANDROID) "zzz$text" else text
this.insertText = text
this.editHandler = QualifiedValueEditHandler()
this.insertTextFormat = PLAIN_TEXT
this.editHandler = AttrValueEditHandler()
this.matchLevel = matchLevel
}
}