feat: add Xml snippets repository

This commit is contained in:
Akash Yadav
2023-04-07 22:19:08 +05:30
parent 612285215c
commit 6d44ae60c7
3 changed files with 86 additions and 2 deletions
+2 -2
View File
@@ -13,11 +13,11 @@
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="false">
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.auto.service/auto-service/1.0.1/c9779f7372192a96c957a3df1faeeabd07881085/auto-service-1.0.1.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/net.ltgt.gradle.incap/incap-processor/0.2/408ba7e6d0e70fc9f2765809560ea7d4c9ad35cf/incap-processor-0.2.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/net.ltgt.gradle.incap/incap-processor/1.0.0/ddec950483eefb2a5cca0736f5967fccbfdb7d2d/incap-processor-1.0.0.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.auto.service/auto-service-annotations/1.0.1/ac86dacc0eb9285ea9d42eee6aad8629ca3a7432/auto-service-annotations-1.0.1.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.auto/auto-common/1.2/ca270191fd7d2a7297da7c8f29184206df10c67d/auto-common-1.2.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/31.0.1-jre/119ea2b2bc205b138974d351777b20f02b92704b/guava-31.0.1-jre.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/net.ltgt.gradle.incap/incap/0.2/c73e3db9bee414d6ee27995d951fcdbee09acad/incap-0.2.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/net.ltgt.gradle.incap/incap/1.0.0/4d765e5b0e3ee542b57ccffbb9c147c280290207/incap-1.0.0.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.guava/failureaccess/1.0.1/1dcf1de382a0bf95a3d8b0849546c88bac1292c9/failureaccess-1.0.1.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/b421526c5f297295adef1c886e5246c39d4ac629/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.2/25ea2e8b0c338a877313bd4672d3fe056ea78f0d/jsr305-3.0.2.jar" />
@@ -0,0 +1,36 @@
/*
* 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.providers.snippet
import com.itsaky.androidide.lsp.snippets.ISnippet
import com.itsaky.androidide.lsp.snippets.SnippetParser
/**
* Repository for XML snippets.
*
* @author Akash Yadav
*/
object XmlSnippetRepository {
lateinit var snippets: Map<IXmlSnippetScope, List<ISnippet>>
private set
fun init() {
this.snippets = SnippetParser.parse("xml", XML_SNIPPET_SCOPES)
}
}
@@ -0,0 +1,48 @@
/*
* 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.providers.snippet
import com.itsaky.androidide.lsp.snippets.ISnippetScope
val XML_SNIPPET_SCOPES : Array<IXmlSnippetScope> =
arrayOf(
DefaultXmlSnippetScope(XmlResourceType.LAYOUT, XmlScope.TAG),
DefaultXmlSnippetScope(XmlResourceType.LAYOUT, XmlScope.INSIDE),
DefaultXmlSnippetScope(XmlResourceType.MANIFEST, XmlScope.INSIDE)
)
abstract class IXmlSnippetScope : ISnippetScope {
abstract val type: XmlResourceType
abstract val scope: XmlScope
override val filename: String
get() = "${type.name.lowercase()}-${scope.name.lowercase()}"
}
class DefaultXmlSnippetScope(override val type: XmlResourceType, override val scope: XmlScope) :
IXmlSnippetScope()
enum class XmlResourceType {
LAYOUT,
MANIFEST
}
enum class XmlScope {
TAG,
INSIDE
}