initial commit
This commit is contained in:
@@ -6,7 +6,6 @@ import com.intellij.psi.PsiElement
|
|||||||
import com.intellij.util.IncorrectOperationException
|
import com.intellij.util.IncorrectOperationException
|
||||||
import me.zhouxi.slint.lang.createIdentifier
|
import me.zhouxi.slint.lang.createIdentifier
|
||||||
import me.zhouxi.slint.lang.psi.SlintNamed
|
import me.zhouxi.slint.lang.psi.SlintNamed
|
||||||
import me.zhouxi.slint.lang.psi.SlintPsiElementImpl
|
|
||||||
import me.zhouxi.slint.lang.psi.SlintPsiNamedElement
|
import me.zhouxi.slint.lang.psi.SlintPsiNamedElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
9
src/main/kotlin/me/zhouxi/slint/stubs/SlintPsiStub.kt
Normal file
9
src/main/kotlin/me/zhouxi/slint/stubs/SlintPsiStub.kt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package me.zhouxi.slint.stubs
|
||||||
|
|
||||||
|
import com.intellij.psi.stubs.StubElement
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintPsiNamedElement
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhouxi 2024/5/23
|
||||||
|
*/
|
||||||
|
interface SlintPsiStub<T : SlintPsiNamedElement?> : StubElement<T>
|
||||||
10
src/main/kotlin/me/zhouxi/slint/stubs/SlintStubTypes.kt
Normal file
10
src/main/kotlin/me/zhouxi/slint/stubs/SlintStubTypes.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package me.zhouxi.slint.stubs
|
||||||
|
|
||||||
|
import me.zhouxi.slint.stubs.types.SlintComponentStubType
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhouxi 2024/5/23
|
||||||
|
*/
|
||||||
|
object SlintStubTypes {
|
||||||
|
val ComponentType = SlintComponentStubType()
|
||||||
|
}
|
||||||
14
src/main/kotlin/me/zhouxi/slint/stubs/StubKeys.java
Normal file
14
src/main/kotlin/me/zhouxi/slint/stubs/StubKeys.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package me.zhouxi.slint.stubs;
|
||||||
|
|
||||||
|
import com.intellij.psi.stubs.StubIndexKey;
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintComponentName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhouxi 2024/5/23
|
||||||
|
*/
|
||||||
|
public class StubKeys {
|
||||||
|
|
||||||
|
public static final StubIndexKey<String, SlintComponentName> COMPONENT = StubIndexKey.createIndexKey("slint.component");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package me.zhouxi.slint.stubs.impl
|
||||||
|
|
||||||
|
import com.intellij.psi.stubs.IStubElementType
|
||||||
|
import com.intellij.psi.stubs.StubBase
|
||||||
|
import com.intellij.psi.stubs.StubElement
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintComponent
|
||||||
|
import me.zhouxi.slint.stubs.stub.SlintComponentStub
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhouxi 2024/5/23
|
||||||
|
*/
|
||||||
|
|
||||||
|
class SlintComponentStubImpl(
|
||||||
|
parent: StubElement<*>?,
|
||||||
|
elementType: IStubElementType<out StubElement<*>, *>,
|
||||||
|
override val exported: Boolean,
|
||||||
|
override val identifier: String,
|
||||||
|
) :
|
||||||
|
StubBase<SlintComponent>(parent, elementType), SlintComponentStub {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package me.zhouxi.slint.stubs.impl
|
||||||
|
|
||||||
|
import com.intellij.psi.stubs.PsiFileStubImpl
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintFile
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhouxi 2024/5/23
|
||||||
|
*/
|
||||||
|
class SlintFileStub(file: SlintFile) : PsiFileStubImpl<SlintFile>(file)
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package me.zhouxi.slint.stubs.stub
|
||||||
|
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintComponent
|
||||||
|
import me.zhouxi.slint.stubs.SlintPsiStub
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhouxi 2024/5/23
|
||||||
|
*/
|
||||||
|
interface SlintComponentStub : SlintPsiStub<SlintComponent> {
|
||||||
|
val exported: Boolean
|
||||||
|
|
||||||
|
val identifier: String
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package me.zhouxi.slint.stubs.types
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.stubs.*
|
||||||
|
import com.intellij.psi.util.parentOfType
|
||||||
|
import me.zhouxi.slint.lang.SlintLanguage
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintComponent
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintExport
|
||||||
|
import me.zhouxi.slint.lang.psi.impl.SlintComponentImpl
|
||||||
|
import me.zhouxi.slint.stubs.StubKeys
|
||||||
|
import me.zhouxi.slint.stubs.impl.SlintComponentStubImpl
|
||||||
|
import me.zhouxi.slint.stubs.stub.SlintComponentStub
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhouxi 2024/5/23
|
||||||
|
*/
|
||||||
|
class SlintComponentStubType :
|
||||||
|
IStubElementType<SlintComponentStub, SlintComponent>("SlintComponentStub", SlintLanguage.INSTANCE) {
|
||||||
|
override fun createPsi(stub: SlintComponentStub): SlintComponent {
|
||||||
|
return SlintComponentImpl(stub, this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createStub(psi: SlintComponent, parentStub: StubElement<out PsiElement?>): SlintComponentStub {
|
||||||
|
return SlintComponentStubImpl(
|
||||||
|
parentStub,
|
||||||
|
this,
|
||||||
|
psi.parentOfType<SlintExport>() != null,
|
||||||
|
psi.componentName!!.text
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getExternalId(): String {
|
||||||
|
return "slint.component"
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(IOException::class)
|
||||||
|
override fun serialize(stub: SlintComponentStub, dataStream: StubOutputStream) {
|
||||||
|
dataStream.writeBoolean(stub.exported)
|
||||||
|
dataStream.writeName(stub.identifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(IOException::class)
|
||||||
|
override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>): SlintComponentStub {
|
||||||
|
val exported = dataStream.readBoolean()
|
||||||
|
val identifier = dataStream.readNameString()
|
||||||
|
return SlintComponentStubImpl(parentStub, this, exported, identifier!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun indexStub(stub: SlintComponentStub, sink: IndexSink) {
|
||||||
|
sink.occurrence(StubKeys.COMPONENT, stub.identifier)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,6 +47,8 @@
|
|||||||
<runLineMarkerContributor implementationClass="me.zhouxi.slint.preview.PreviewRunLineMarkerContributor"
|
<runLineMarkerContributor implementationClass="me.zhouxi.slint.preview.PreviewRunLineMarkerContributor"
|
||||||
language="Slint"/>
|
language="Slint"/>
|
||||||
|
|
||||||
|
<stubElementTypeHolder class="me.zhouxi.slint.stubs.SlintStubTypes" externalIdPrefix="slint."/>
|
||||||
|
|
||||||
</extensions>
|
</extensions>
|
||||||
<actions>
|
<actions>
|
||||||
<action id="slint.preview" class="me.zhouxi.slint.preview.PreviewAction"
|
<action id="slint.preview" class="me.zhouxi.slint.preview.PreviewAction"
|
||||||
|
|||||||
Reference in New Issue
Block a user