mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 13:11:32 +00:00
idea: significant enhancements to ide experience
This commit is contained in:
@ -70,13 +70,15 @@ class AstPorkIdeaCodegen(pkg: String, outputDirectory: Path, world: AstWorld) :
|
||||
),
|
||||
inherits = mutableListOf("${baseType}(node)"),
|
||||
imports = mutableListOf(
|
||||
"com.intellij.lang.ASTNode"
|
||||
"com.intellij.lang.ASTNode",
|
||||
"gay.pizza.pork.idea.psi.PorkElementHelpers",
|
||||
"javax.swing.Icon",
|
||||
"com.intellij.navigation.ItemPresentation"
|
||||
)
|
||||
)
|
||||
|
||||
if (baseType == "PorkNamedElement") {
|
||||
kotlinClass.imports.add(0, "com.intellij.psi.PsiElement")
|
||||
kotlinClass.imports.add("gay.pizza.pork.idea.psi.PorkElementHelpers")
|
||||
val getNameFunction = KotlinFunction(
|
||||
"getName",
|
||||
overridden = true,
|
||||
@ -111,7 +113,6 @@ class AstPorkIdeaCodegen(pkg: String, outputDirectory: Path, world: AstWorld) :
|
||||
if (type.referencedElementValue != null && type.referencedElementType != null) {
|
||||
kotlinClass.imports.add(0, "com.intellij.psi.PsiReference")
|
||||
kotlinClass.imports.add("gay.pizza.pork.ast.NodeType")
|
||||
kotlinClass.imports.add("gay.pizza.pork.idea.psi.PorkElementHelpers")
|
||||
|
||||
val getReferenceFunction = KotlinFunction(
|
||||
"getReference",
|
||||
@ -123,6 +124,27 @@ class AstPorkIdeaCodegen(pkg: String, outputDirectory: Path, world: AstWorld) :
|
||||
kotlinClass.functions.add(getReferenceFunction)
|
||||
}
|
||||
|
||||
val getIconFunction = KotlinFunction(
|
||||
"getIcon",
|
||||
overridden = true,
|
||||
returnType = "Icon?",
|
||||
parameters = mutableListOf(
|
||||
KotlinParameter("flags", "Int")
|
||||
),
|
||||
isImmediateExpression = true
|
||||
)
|
||||
getIconFunction.body.add("PorkElementHelpers.iconOf(this)")
|
||||
kotlinClass.functions.add(getIconFunction)
|
||||
|
||||
val getPresentationFunction = KotlinFunction(
|
||||
"getPresentation",
|
||||
overridden = true,
|
||||
returnType = "ItemPresentation?",
|
||||
isImmediateExpression = true
|
||||
)
|
||||
getPresentationFunction.body.add("PorkElementHelpers.presentationOf(this)")
|
||||
kotlinClass.functions.add(getPresentationFunction)
|
||||
|
||||
write("${type.name}Element.kt", KotlinWriter(kotlinClass))
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ class KotlinWriter() {
|
||||
appendLine("package $pkg")
|
||||
appendLine()
|
||||
|
||||
for (import in imports) {
|
||||
for (import in imports.toSortedSet()) {
|
||||
appendLine("import $import")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user