修改bnf
This commit is contained in:
@@ -36,7 +36,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
intellij {
|
intellij {
|
||||||
version.set("IC-2023.2.5")
|
version.set("IU-2023.2.5")
|
||||||
sandboxDir.set("idea-sandbox")
|
sandboxDir.set("idea-sandbox")
|
||||||
plugins.set(listOf("java"))
|
plugins.set(listOf("java"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,11 +66,11 @@
|
|||||||
//
|
//
|
||||||
Document ::= DocumentElement*
|
Document ::= DocumentElement*
|
||||||
private recoverTopElement ::= !('component' | 'struct' | 'enum' | 'global'| 'export'|'import' )
|
private recoverTopElement ::= !('component' | 'struct' | 'enum' | 'global'| 'export'|'import' )
|
||||||
private DocumentElement ::= Import | Struct |Export | Enum | GlobalSingleton | Component {
|
private DocumentElement ::= Import | Struct | Enum | GlobalSingleton | Component | Export {
|
||||||
recoverWhile=recoverTopElement
|
recoverWhile=recoverTopElement
|
||||||
}
|
}
|
||||||
GlobalSingleton ::= GlobalKeyword ComponentName ComponentBody {
|
GlobalSingleton ::= ExportKeyword? GlobalKeyword ComponentName ComponentBody {
|
||||||
pin=1
|
pin=2
|
||||||
implements=["me.zhouxi.slint.lang.psi.SlintPsiNamedElement"]
|
implements=["me.zhouxi.slint.lang.psi.SlintPsiNamedElement"]
|
||||||
mixin="me.zhouxi.slint.lang.psi.impl.SlintPsiNamedElementMixinImpl"
|
mixin="me.zhouxi.slint.lang.psi.impl.SlintPsiNamedElementMixinImpl"
|
||||||
}
|
}
|
||||||
@@ -79,30 +79,32 @@ Import ::= ImportKeyword ImportElement? ModuleLocation';'{
|
|||||||
pin=1
|
pin=1
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImportElement ::= '{' ImportedIdentifier (',' ImportedIdentifier)* ','? '}' FromKeyword {
|
private ImportElement ::= '{' ImportedSpecifier (',' ImportedSpecifier)* ','? '}' FromKeyword {
|
||||||
pin=1
|
pin=1
|
||||||
}
|
}
|
||||||
|
|
||||||
// ABc as Def
|
// ABc as Def
|
||||||
ImportedIdentifier ::= ReferenceIdentifier ImportAlias?{
|
ImportedSpecifier ::= ReferenceIdentifier ImportAlias?{
|
||||||
pin=1
|
pin=1
|
||||||
recoverWhile=AliasNameRecover
|
recoverWhile=AliasNameRecover
|
||||||
}
|
}
|
||||||
private AliasNameRecover::=!(','|'}'|';')
|
private AliasNameRecover::=!(','|'}'|';')
|
||||||
|
|
||||||
private ImportAlias ::= AsKeyword InternalName {
|
ImportAlias ::= AsKeyword InternalName {
|
||||||
pin=1
|
pin=1
|
||||||
|
implements=["me.zhouxi.slint.lang.psi.SlintPsiNamedElement"]
|
||||||
|
mixin="me.zhouxi.slint.lang.psi.impl.SlintPsiNamedElementMixinImpl"
|
||||||
}
|
}
|
||||||
//Struct 定义
|
//Struct 定义
|
||||||
Struct ::= StructKeyword TypeName (':=')? StructBody {
|
Struct ::= ExportKeyword? StructKeyword TypeName (':=')? StructBody {
|
||||||
pin=1
|
pin=2
|
||||||
}
|
}
|
||||||
private StructBody ::= '{' FieldDeclarations? '}'{
|
private StructBody ::= '{' FieldDeclarations? '}'{
|
||||||
pin=1
|
pin=1
|
||||||
}
|
}
|
||||||
//EnumDeclaration
|
//EnumDeclaration
|
||||||
Enum ::= EnumKeyword EnumName '{' (EnumValue (','EnumValue)*','? )? '}'{
|
Enum ::= ExportKeyword? EnumKeyword EnumName '{' (EnumValue (','EnumValue)*','? )? '}'{
|
||||||
pin=1
|
pin=2
|
||||||
implements=["me.zhouxi.slint.lang.psi.SlintPsiNamedElement"]
|
implements=["me.zhouxi.slint.lang.psi.SlintPsiNamedElement"]
|
||||||
mixin="me.zhouxi.slint.lang.psi.impl.SlintPsiNamedElementMixinImpl"
|
mixin="me.zhouxi.slint.lang.psi.impl.SlintPsiNamedElementMixinImpl"
|
||||||
}
|
}
|
||||||
@@ -111,15 +113,17 @@ Enum ::= EnumKeyword EnumName '{' (EnumValue (','EnumValue)*','? )? '}'{
|
|||||||
Export ::= ExportKeyword ExportElement {
|
Export ::= ExportKeyword ExportElement {
|
||||||
pin=1
|
pin=1
|
||||||
}
|
}
|
||||||
private ExportElement ::= ExportType | Struct| Component | ExportModule | GlobalSingleton|Enum
|
private ExportElement ::= ExportType | ExportModule
|
||||||
|
|
||||||
ExportType ::= '{' ExportIdentifier (','ExportIdentifier)* ','? '}'{
|
ExportType ::= '{' ExportSpecifier (','ExportSpecifier)* ','? '}'{
|
||||||
pin=1
|
pin=1
|
||||||
}
|
}
|
||||||
ExportIdentifier ::= ReferenceIdentifier ExportAlias?{
|
ExportSpecifier::= ReferenceIdentifier ExportAlias?{
|
||||||
|
recoverWhile=AliasNameRecover
|
||||||
|
implements=["me.zhouxi.slint.lang.psi.SlintPsiNamedElement"]
|
||||||
|
mixin="me.zhouxi.slint.lang.psi.impl.SlintPsiNamedElementMixinImpl"
|
||||||
}
|
}
|
||||||
private ExportAlias ::= AsKeyword ExternalName{
|
ExportAlias ::= AsKeyword ExternalName{
|
||||||
pin=1
|
pin=1
|
||||||
}
|
}
|
||||||
ExportModule ::= '*' FromKeyword ModuleLocation ';'{
|
ExportModule ::= '*' FromKeyword ModuleLocation ';'{
|
||||||
@@ -131,8 +135,8 @@ ExportModule ::= '*' FromKeyword ModuleLocation ';'{
|
|||||||
//Old syntax
|
//Old syntax
|
||||||
//private LegacyComponent ::=(GlobalKeyword ComponentName ':=' ComponentName? ComponentBody)| ('global'? SubComponent)
|
//private LegacyComponent ::=(GlobalKeyword ComponentName ':=' ComponentName? ComponentBody)| ('global'? SubComponent)
|
||||||
|
|
||||||
Component ::= ComponentKeyword ComponentName InheritDeclaration? ComponentBody {
|
Component ::= ExportKeyword? ComponentKeyword ComponentName InheritDeclaration? ComponentBody {
|
||||||
pin=1
|
pin=2
|
||||||
implements=[
|
implements=[
|
||||||
"me.zhouxi.slint.lang.psi.SlintPsiNamedElement"
|
"me.zhouxi.slint.lang.psi.SlintPsiNamedElement"
|
||||||
"com.intellij.psi.StubBasedPsiElement<me.zhouxi.slint.stubs.stub.SlintComponentStub>"
|
"com.intellij.psi.StubBasedPsiElement<me.zhouxi.slint.stubs.stub.SlintComponentStub>"
|
||||||
@@ -517,10 +521,7 @@ FunctionName ::= GenericIdentifier
|
|||||||
|
|
||||||
ComponentName ::=GenericIdentifier
|
ComponentName ::=GenericIdentifier
|
||||||
|
|
||||||
InternalName ::= GenericIdentifier{
|
InternalName ::= GenericIdentifier
|
||||||
mixin="me.zhouxi.slint.lang.psi.impl.SlintPsiNamedElementMixinImpl"
|
|
||||||
implements=["me.zhouxi.slint.lang.psi.SlintPsiNamedElement"]
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyName ::= GenericIdentifier
|
PropertyName ::= GenericIdentifier
|
||||||
|
|
||||||
@@ -530,10 +531,7 @@ EnumName ::= GenericIdentifier
|
|||||||
|
|
||||||
EnumValue ::=GenericIdentifier
|
EnumValue ::=GenericIdentifier
|
||||||
|
|
||||||
ExternalName ::=GenericIdentifier{
|
ExternalName ::=GenericIdentifier
|
||||||
mixin="me.zhouxi.slint.lang.psi.impl.SlintPsiNamedElementMixinImpl"
|
|
||||||
implements=["me.zhouxi.slint.lang.psi.SlintPsiNamedElement"]
|
|
||||||
}
|
|
||||||
|
|
||||||
ReferenceIdentifier::=GenericIdentifier{
|
ReferenceIdentifier::=GenericIdentifier{
|
||||||
mixin="me.zhouxi.slint.lang.psi.impl.SlintReferencedIdentifierMixinImpl"
|
mixin="me.zhouxi.slint.lang.psi.impl.SlintReferencedIdentifierMixinImpl"
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import com.intellij.codeInsight.completion.*
|
|||||||
import com.intellij.codeInsight.lookup.LookupElementBuilder
|
import com.intellij.codeInsight.lookup.LookupElementBuilder
|
||||||
import com.intellij.icons.AllIcons
|
import com.intellij.icons.AllIcons
|
||||||
import com.intellij.patterns.PlatformPatterns
|
import com.intellij.patterns.PlatformPatterns
|
||||||
|
import com.intellij.psi.PsiClass
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
|
import com.intellij.psi.stubs.StubIndex
|
||||||
import com.intellij.psi.util.childrenOfType
|
import com.intellij.psi.util.childrenOfType
|
||||||
import com.intellij.psi.util.parentOfType
|
import com.intellij.psi.util.parentOfType
|
||||||
import com.intellij.util.ProcessingContext
|
import com.intellij.util.ProcessingContext
|
||||||
@@ -15,6 +18,7 @@ import me.zhouxi.slint.lang.psi.SlintPsiUtils.InternalTypes
|
|||||||
import me.zhouxi.slint.lang.psi.SlintTypes
|
import me.zhouxi.slint.lang.psi.SlintTypes
|
||||||
import me.zhouxi.slint.lang.psi.utils.exportedElements
|
import me.zhouxi.slint.lang.psi.utils.exportedElements
|
||||||
import me.zhouxi.slint.lang.psi.utils.inheritDeclaredElements
|
import me.zhouxi.slint.lang.psi.utils.inheritDeclaredElements
|
||||||
|
import me.zhouxi.slint.stubs.StubKeys
|
||||||
import me.zhouxi.slint.stubs.types.SlintFileElementType
|
import me.zhouxi.slint.stubs.types.SlintFileElementType
|
||||||
|
|
||||||
class SlintCompletionContributor : CompletionContributor() {
|
class SlintCompletionContributor : CompletionContributor() {
|
||||||
@@ -57,19 +61,17 @@ class SlintCompletionContributor : CompletionContributor() {
|
|||||||
context: ProcessingContext,
|
context: ProcessingContext,
|
||||||
result: CompletionResultSet
|
result: CompletionResultSet
|
||||||
) {
|
) {
|
||||||
|
val project = parameters.position.project
|
||||||
|
val components = StubIndex.getInstance().getAllKeys(StubKeys.Component, project).map {
|
||||||
|
LookupElementBuilder.create(it).withIcon(AllIcons.Nodes.Class)
|
||||||
|
}
|
||||||
|
result.addAllElements(components)
|
||||||
result.addAllElements(ElementKeywords)
|
result.addAllElements(ElementKeywords)
|
||||||
val component = parameters.position.parentOfType<SlintComponent>() ?: return
|
val currentComponent = parameters.position.parentOfType<SlintComponent>() ?: return
|
||||||
val elements = component.inheritDeclaredElements()
|
val elements = currentComponent.inheritDeclaredElements().map {
|
||||||
for (element in elements) {
|
LookupElementBuilder.create(it).withIcon(AllIcons.Nodes.Property)
|
||||||
result.addElement(LookupElementBuilder.create(element).withIcon(AllIcons.Nodes.Property))
|
|
||||||
}
|
|
||||||
val file = component.containingFile as SlintFile
|
|
||||||
val array = file.childrenOfType<SlintImport>()
|
|
||||||
.mapNotNull { it.moduleLocation?.reference?.resolve() as SlintFile? }
|
|
||||||
.flatMap { it.exportedElements() }
|
|
||||||
for (element in array) {
|
|
||||||
result.addElement(LookupElementBuilder.create(element).withIcon(AllIcons.Nodes.Class))
|
|
||||||
}
|
}
|
||||||
|
result.addAllElements(elements)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import me.zhouxi.slint.lang.psi.SlintPsiNamedElement
|
|||||||
abstract class SlintPsiNamedElementMixinImpl(node: ASTNode) : SlintPsiElementImpl(node),
|
abstract class SlintPsiNamedElementMixinImpl(node: ASTNode) : SlintPsiElementImpl(node),
|
||||||
SlintPsiNamedElement {
|
SlintPsiNamedElement {
|
||||||
override fun getNameIdentifier(): PsiElement? {
|
override fun getNameIdentifier(): PsiElement? {
|
||||||
return findChildByClass(SlintNamed::class.java)
|
return findChildByClass(SlintNamed::class.java) ?: this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getName(): String? {
|
override fun getName(): String? {
|
||||||
@@ -26,7 +26,12 @@ abstract class SlintPsiNamedElementMixinImpl(node: ASTNode) : SlintPsiElementImp
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getTextOffset(): Int {
|
override fun getTextOffset(): Int {
|
||||||
return nameIdentifier?.textOffset ?: super.getTextOffset()
|
val identifier = nameIdentifier
|
||||||
|
return if (identifier == this) {
|
||||||
|
return super.getTextOffset()
|
||||||
|
} else {
|
||||||
|
identifier!!.textOffset
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(IncorrectOperationException::class)
|
@Throws(IncorrectOperationException::class)
|
||||||
|
|||||||
@@ -7,29 +7,29 @@ import me.zhouxi.slint.lang.psi.*
|
|||||||
|
|
||||||
fun SlintExport.exportedElements(): List<SlintPsiNamedElement> {
|
fun SlintExport.exportedElements(): List<SlintPsiNamedElement> {
|
||||||
val list = mutableListOf<SlintPsiNamedElement>()
|
val list = mutableListOf<SlintPsiNamedElement>()
|
||||||
this.exportType?.exportIdentifierList?.forEach {
|
// this.exportType?.exportIdentifierList?.forEach {
|
||||||
if (it.externalName == null) {
|
// if (it.externalName == null) {
|
||||||
val component = it.referenceIdentifier.reference?.resolve() as SlintComponent?
|
// val component = it.referenceIdentifier.reference?.resolve() as SlintComponent?
|
||||||
component?.let { list.add(component) }
|
// component?.let { list.add(component) }
|
||||||
} else {
|
// } else {
|
||||||
list.add(it.externalName!!)
|
// list.add(it.externalName!!)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.component?.let { list.add(it) }
|
// this.component?.let { list.add(it) }
|
||||||
this.globalSingleton?.let { list.add(it) }
|
// this.globalSingleton?.let { list.add(it) }
|
||||||
val file = this.exportModule?.moduleLocation?.reference?.resolve() as SlintFile? ?: return list
|
// val file = this.exportModule?.moduleLocation?.reference?.resolve() as SlintFile? ?: return list
|
||||||
val exports = file.childrenOfType<SlintExport>()
|
// val exports = file.childrenOfType<SlintExport>()
|
||||||
//TODO recursion error
|
// //TODO recursion error
|
||||||
exports.forEach { list.addAll(it.exportedElements()) }
|
// exports.forEach { list.addAll(it.exportedElements()) }
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SlintImport.importedElements(): List<PsiElement> {
|
fun SlintImport.importedElements(): List<PsiElement> {
|
||||||
val list = mutableListOf<PsiElement>()
|
val list = mutableListOf<PsiElement>()
|
||||||
this.importedIdentifierList.forEach { identifier ->
|
// this.importedIdentifierList.forEach { identifier ->
|
||||||
list.add(identifier.referenceIdentifier)
|
// list.add(identifier.referenceIdentifier)
|
||||||
identifier.internalName?.let { list.add(it) }
|
// identifier.internalName?.let { list.add(it) }
|
||||||
}
|
// }
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ class SlintReferenceContributor : PsiReferenceContributor() {
|
|||||||
psiElement(SubComponent),
|
psiElement(SubComponent),
|
||||||
psiElement(Component),
|
psiElement(Component),
|
||||||
psiElement(InheritDeclaration),
|
psiElement(InheritDeclaration),
|
||||||
psiElement(ImportedIdentifier),
|
// psiElement(ImportedIdentifier),
|
||||||
psiElement(ExportIdentifier)
|
// psiElement(ExportIdentifier)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
ComponentReferenceProvider()
|
ComponentReferenceProvider()
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ class ComponentReferenceProvider : PsiReferenceProvider() {
|
|||||||
if (component != null) {
|
if (component != null) {
|
||||||
return component
|
return component
|
||||||
}
|
}
|
||||||
// TODO psiTreeUtils
|
|
||||||
//然后是导出的组件 maybe component or externalName
|
|
||||||
val externalElement = file.exportedElements().firstOrNull { it.textMatches(element) }
|
|
||||||
if (externalElement != null) {
|
|
||||||
return externalElement
|
|
||||||
}
|
|
||||||
//maybe internalName or referencedIdentifier;
|
//maybe internalName or referencedIdentifier;
|
||||||
val element = file.importedElements().firstOrNull { it.textMatches(element) } ?: return null
|
val element = file.importedElements().firstOrNull { it.textMatches(element) } ?: return null
|
||||||
if (element is SlintPsiReferencedIdentifier) {
|
if (element is SlintPsiReferencedIdentifier) {
|
||||||
@@ -44,13 +38,5 @@ class ComponentReferenceProvider : PsiReferenceProvider() {
|
|||||||
}
|
}
|
||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getVariants(): Array<Any> {
|
|
||||||
val file = element.containingFile as SlintFile
|
|
||||||
val array: Array<Any> = file.childrenOfType<SlintImport>()
|
|
||||||
.mapNotNull { it.moduleLocation?.reference?.resolve() as SlintFile? }
|
|
||||||
.flatMap { it.exportedElements() }.toTypedArray()
|
|
||||||
return array
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package me.zhouxi.slint.reference.provider
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import com.intellij.psi.PsiReference
|
|
||||||
import com.intellij.psi.PsiReferenceBase
|
|
||||||
import com.intellij.psi.PsiReferenceProvider
|
|
||||||
import com.intellij.psi.util.parentOfType
|
|
||||||
import com.intellij.util.ProcessingContext
|
|
||||||
import me.zhouxi.slint.lang.psi.SlintFile
|
|
||||||
import me.zhouxi.slint.lang.psi.SlintImport
|
|
||||||
import me.zhouxi.slint.lang.psi.SlintInternalName
|
|
||||||
import me.zhouxi.slint.lang.psi.utils.exportedElements
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author zhouxi 2024/5/17
|
|
||||||
*/
|
|
||||||
class InternalNameReferenceProvider : PsiReferenceProvider() {
|
|
||||||
override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array<PsiReference> {
|
|
||||||
return arrayOf(InternalNameReference(element as SlintInternalName))
|
|
||||||
}
|
|
||||||
|
|
||||||
class InternalNameReference(element: SlintInternalName) : PsiReferenceBase<SlintInternalName?>(element) {
|
|
||||||
override fun resolve(): PsiElement? {
|
|
||||||
val slintImport = element.parentOfType<SlintImport>() ?: return null
|
|
||||||
val slintFile = slintImport.moduleLocation?.reference?.resolve() as? SlintFile ?: return null
|
|
||||||
return slintFile.exportedElements().firstOrNull { it.textMatches(element) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,16 +2,18 @@ package me.zhouxi.slint.stubs.impl
|
|||||||
|
|
||||||
import com.intellij.psi.stubs.PsiFileStubImpl
|
import com.intellij.psi.stubs.PsiFileStubImpl
|
||||||
import com.intellij.psi.tree.IStubFileElementType
|
import com.intellij.psi.tree.IStubFileElementType
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintComponent
|
||||||
import me.zhouxi.slint.lang.psi.SlintFile
|
import me.zhouxi.slint.lang.psi.SlintFile
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintTypes
|
||||||
import me.zhouxi.slint.stubs.stub.SlintFileStub
|
import me.zhouxi.slint.stubs.stub.SlintFileStub
|
||||||
|
import me.zhouxi.slint.stubs.types.SlintComponentStubType
|
||||||
import me.zhouxi.slint.stubs.types.SlintFileElementType
|
import me.zhouxi.slint.stubs.types.SlintFileElementType
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhouxi 2024/5/23
|
* @author zhouxi 2024/5/23
|
||||||
*/
|
*/
|
||||||
class SlintFileStubImpl(file: SlintFile) : PsiFileStubImpl<SlintFile>(file), SlintFileStub {
|
class SlintFileStubImpl(file: SlintFile?) : PsiFileStubImpl<SlintFile>(file), SlintFileStub {
|
||||||
|
|
||||||
|
override fun getType() = SlintFileElementType
|
||||||
|
|
||||||
override fun getType(): IStubFileElementType<*> {
|
|
||||||
return SlintFileElementType
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,5 @@ import me.zhouxi.slint.lang.psi.SlintComponent
|
|||||||
import me.zhouxi.slint.stubs.StubKeys
|
import me.zhouxi.slint.stubs.StubKeys
|
||||||
|
|
||||||
class ComponentNameIndex : StringStubIndexExtension<SlintComponent>() {
|
class ComponentNameIndex : StringStubIndexExtension<SlintComponent>() {
|
||||||
override fun getKey(): StubIndexKey<String, SlintComponent> {
|
override fun getKey() = StubKeys.Component
|
||||||
return StubKeys.Component
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
package me.zhouxi.slint.stubs.stub;
|
package me.zhouxi.slint.stubs.stub
|
||||||
|
|
||||||
import com.intellij.psi.stubs.PsiFileStub;
|
import com.intellij.psi.stubs.PsiFileStub
|
||||||
import me.zhouxi.slint.lang.psi.SlintFile;
|
import me.zhouxi.slint.lang.psi.SlintComponent
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintFile
|
||||||
|
import me.zhouxi.slint.lang.psi.SlintTypes
|
||||||
|
import me.zhouxi.slint.stubs.types.SlintFileElementType
|
||||||
|
|
||||||
public interface SlintFileStub extends PsiFileStub<SlintFile> {
|
interface SlintFileStub : PsiFileStub<SlintFile> {
|
||||||
|
|
||||||
|
val components: Array<SlintComponent>
|
||||||
|
get() = getChildrenByType(SlintTypes.Component) {
|
||||||
|
arrayOfNulls<SlintComponent>(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ import com.intellij.lang.ASTNode
|
|||||||
import com.intellij.lang.LighterAST
|
import com.intellij.lang.LighterAST
|
||||||
import com.intellij.lang.LighterASTNode
|
import com.intellij.lang.LighterASTNode
|
||||||
import com.intellij.lang.LighterASTTokenNode
|
import com.intellij.lang.LighterASTTokenNode
|
||||||
import com.intellij.lang.TreeBackedLighterAST
|
import com.intellij.psi.PsiClass
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.impl.search.JavaSourceFilterScope
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import com.intellij.psi.stubs.*
|
import com.intellij.psi.stubs.*
|
||||||
import com.intellij.psi.util.parentOfType
|
import com.intellij.psi.util.parentOfType
|
||||||
import me.zhouxi.slint.lang.SlintLanguage
|
import me.zhouxi.slint.lang.SlintLanguage
|
||||||
import me.zhouxi.slint.lang.psi.SlintComponent
|
import me.zhouxi.slint.lang.psi.SlintComponent
|
||||||
import me.zhouxi.slint.lang.psi.SlintExport
|
import me.zhouxi.slint.lang.psi.SlintExport
|
||||||
import me.zhouxi.slint.lang.psi.SlintTypes.ComponentName
|
import me.zhouxi.slint.lang.psi.SlintTypes.*
|
||||||
import me.zhouxi.slint.lang.psi.SlintTypes.Export
|
|
||||||
import me.zhouxi.slint.lang.psi.impl.SlintComponentImpl
|
import me.zhouxi.slint.lang.psi.impl.SlintComponentImpl
|
||||||
import me.zhouxi.slint.stubs.StubKeys
|
import me.zhouxi.slint.stubs.StubKeys
|
||||||
import me.zhouxi.slint.stubs.impl.SlintComponentStubImpl
|
import me.zhouxi.slint.stubs.impl.SlintComponentStubImpl
|
||||||
import me.zhouxi.slint.stubs.stub.SlintComponentStub
|
import me.zhouxi.slint.stubs.stub.SlintComponentStub
|
||||||
import org.mozilla.javascript.ast.AstNode
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +37,7 @@ class SlintComponentStubType(debugName: String) :
|
|||||||
return SlintComponentStubImpl(
|
return SlintComponentStubImpl(
|
||||||
parentStub,
|
parentStub,
|
||||||
this,
|
this,
|
||||||
psi.parentOfType<SlintExport>() != null,
|
psi.exportKeyword != null,
|
||||||
psi.componentName!!.text
|
psi.componentName!!.text
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -60,15 +60,7 @@ class SlintComponentStubType(debugName: String) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createStub(tree: LighterAST, node: LighterASTNode, parentStub: StubElement<*>): SlintComponentStub {
|
override fun createStub(tree: LighterAST, node: LighterASTNode, parentStub: StubElement<*>): SlintComponentStub {
|
||||||
var exported = false
|
val exported = tree.getChildren(node).any { it.tokenType == ExportKeyword }
|
||||||
var parent = tree.getParent(node)
|
|
||||||
while (parent != null) {
|
|
||||||
if (parent.tokenType == Export) {
|
|
||||||
exported = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
parent = tree.getParent(parent)
|
|
||||||
}
|
|
||||||
val identifier = tree.getChildren(node).first { it.tokenType == ComponentName }
|
val identifier = tree.getChildren(node).first { it.tokenType == ComponentName }
|
||||||
val token = tree.getChildren(identifier)[0] as LighterASTTokenNode
|
val token = tree.getChildren(identifier)[0] as LighterASTTokenNode
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
package me.zhouxi.slint.stubs.types
|
package me.zhouxi.slint.stubs.types
|
||||||
|
|
||||||
|
import com.intellij.psi.stubs.StubElement
|
||||||
|
import com.intellij.psi.stubs.StubInputStream
|
||||||
import com.intellij.psi.tree.ILightStubFileElementType
|
import com.intellij.psi.tree.ILightStubFileElementType
|
||||||
import me.zhouxi.slint.lang.SlintLanguage
|
import me.zhouxi.slint.lang.SlintLanguage
|
||||||
import me.zhouxi.slint.stubs.impl.SlintFileStubImpl
|
import me.zhouxi.slint.stubs.impl.SlintFileStubImpl
|
||||||
|
import me.zhouxi.slint.stubs.stub.SlintFileStub
|
||||||
|
|
||||||
object SlintFileElementType : ILightStubFileElementType<SlintFileStubImpl?>("SlintFile", SlintLanguage.INSTANCE) {
|
object SlintFileElementType : ILightStubFileElementType<SlintFileStub>("SlintFile", SlintLanguage.INSTANCE) {
|
||||||
|
|
||||||
override fun getStubVersion(): Int {
|
override fun getStubVersion(): Int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>?): SlintFileStub {
|
||||||
|
return SlintFileStubImpl(null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user